import * as THREE from 'three'
import { GUI } from 'three/addons/libs/lil-gui.module.min.js'
// scene stuff
const renderer = new THREE.WebGLRenderer({ antialias: true }) // create a renderer
renderer.setSize(window.innerWidth, window.innerHeight)
document.body.appendChild(renderer.domElement)
const camera = new THREE.PerspectiveCamera(30, window.innerWidth / window.innerHeight, 0.1, 1000) // create a camera
camera.position.z = 4
camera.position.y = -0.03
const scene = new THREE.Scene() // create a scene
scene.background = new THREE.Color(0xffffff) // set white background color
// plane stuff
const size = 2 // plane size
const segments = 40 // plane segments
const geometry = new THREE.PlaneGeometry(size, size, segments, segments) // create a plane geometry
const material = new THREE.MeshNormalMaterial() // assign it a material
const mesh = new THREE.Mesh(geometry, material) // create mesh
scene.add(mesh) // and add it to the scene
const positionAttribute = mesh.geometry.attributes.position // position attribute
const verticesCount = positionAttribute.array.length / 3 // vertices count
mesh.rotateX(-Math.PI / 3) // rotate the plane for visualization purposes
mesh.rotateZ(-Math.PI / 4)
// original plane stuff
const originalGeometry = new THREE.PlaneGeometry(size, size, segments, segments) // create a plane geometry
const originalMesh = new THREE.Mesh(originalGeometry) // create mesh
// proportional editing stuff
const range = 0.25 // initial range
const intensity = 0.5 // initial intensity
const originalVertexPosition = new THREE.Vector3() // current editing vertex position of the original mesh
const displacement = new THREE.Vector3(0, 0, 1) // main displacement direction
const gaussianDisplacement = new THREE.Vector3() // and scale it with the gaussian value
const middleIndex = Math.ceil(verticesCount / 2) - 1 // middle vertex index of the mesh
const centerPosition = new THREE.Vector3() // vertex position for gaussian bell...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Fiddle Pages
Your fiddles accessible under a custom domain and a vanity path - the simplest hosting for your personal project.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Get Fiddle Pages with PRO
Your fiddles accessible under a custom domain and a vanity path - the simplest hosting for your personal project.