-
-
Save xyztlp/6fa7903fab54fc3d75da1d43ee48bb2c to your computer and use it in GitHub Desktop.
Bend Three JS Plane Geometry With Bezier Curve
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Bend Three JS plane geometry with bezier curve | |
| //Curved plane generation, bezier curve plane, | |
| function bendPlaneGeometry(planeGeometry, centerBendZ) | |
| { | |
| var curve = new THREE.CubicBezierCurve3( | |
| planeGeometry.vertices[0], | |
| new THREE.Vector3(planeGeometry.parameters.width/2, 0, centerBendZ ), | |
| new THREE.Vector3(planeGeometry.parameters.width/2, 0, centerBendZ ), | |
| planeGeometry.vertices[(planeGeometry.vertices.length/2) - 1] | |
| ); | |
| var planePoints = curve.getPoints(Math.abs(planeGeometry.vertices.length/2)-1); | |
| for(var edgeI = 1; edgeI < 3; edgeI++){ | |
| for(var pointI = 0; pointI < planePoints.length; pointI++){ | |
| planeGeometry.vertices[(edgeI === 2) ? planePoints.length + pointI : pointI].z = planePoints[pointI].z; | |
| } | |
| } | |
| planeGeometry.computeFaceNormals(); | |
| planeGeometry.computeVertexNormals(); | |
| return planeGeometry; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment