Created
January 6, 2017 18:00
-
-
Save dImrich/39988ff5078800f4f1c6eec85223cacc to your computer and use it in GitHub Desktop.
Bend Three JS Plane Geometry With Bezier Curve
This file contains 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