Created
July 6, 2020 11:46
-
-
Save fforw/eabd04441f1b75781662b901687b113f to your computer and use it in GitHub Desktop.
Three.js Bezier unrolled
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
| const bzv0 = new Vector3(); | |
| const bzv1 = new Vector3(); | |
| function quadraticBezier( v0, v1, v2, t, out) | |
| { | |
| bzv0.x = v0.x + (v1.x - v0.x) * t; | |
| bzv0.y = v0.y + (v1.y - v0.y) * t; | |
| bzv0.z = v0.z + (v1.z - v0.z) * t; | |
| bzv1.x = v1.x + (v2.x - v1.x) * t; | |
| bzv1.y = v1.y + (v2.y - v1.y) * t; | |
| bzv1.z = v1.z + (v2.z - v1.z) * t; | |
| out.x = bzv0.x + (bzv1.x - bzv0.x) * t; | |
| out.y = bzv0.y + (bzv1.y - bzv0.y) * t; | |
| out.z = bzv0.z + (bzv1.z - bzv0.z) * t; | |
| return out; | |
| } |
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
| /* | |
| v0 = (0,0,0) | |
| v1 = (0,x,0) | |
| v2 = (x,x,x) | |
| */ | |
| function quadraticBezier( v0, v1, v2, t, out) | |
| { | |
| bzv0.x = /*v0.x +*/ (v1.x /*- v0.x*/) * t; | |
| bzv0.y = /*v0.y +*/ (v1.y /*- v0.y*/) * t; | |
| bzv0.z = /*v0.z +*/ (v1.z /*- v0.z*/) * t; | |
| bzv1.x = /*v1.x +*/ (v2.x /*- v1.x*/) * t; | |
| bzv1.y = v1.y + (v2.y - v1.y) * t; | |
| bzv1.z = /*v1.z +*/ (v2.z /*- v1.z*/) * t; | |
| out.x = bzv0.x + (bzv1.x - bzv0.x) * t; | |
| out.y = bzv0.y + (bzv1.y - bzv0.y) * t; | |
| out.z = bzv0.z + (bzv1.z - bzv0.z) * t; | |
| return out; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment