function casteljauPoint(curve, t) {
    const THREE = require('three');
    // Step 1
    const Ax = ((1 - t) * curve.start[0]) + (t * (curve.start[0] + curve.startControl[0]));
    const Ay = ((1 - t) * curve.start[1]) + (t * (curve.start[1] + curve.startControl[1]));
    const Az = ((1 - t) * curve.start[2]) + (t * (curve.start[2] + curve.startControl[2]));
    const Bx = ((1 - t) * (curve.start[0] + curve.startControl[0])) + (t * (curve.end[0] + curve.endControl[0]));
    const By = ((1 - t) * (curve.start[1] + curve.startControl[1])) + (t * (curve.end[1] + curve.endControl[1]));
    const Bz = ((1 - t) * (curve.start[2] + curve.startControl[2])) + (t * (curve.end[2] + curve.endControl[2]));
    const Cx = ((1 - t) * (curve.end[0] + curve.endControl[0])) + (t * curve.end[0]);
    const Cy = ((1 - t) * (curve.end[1] + curve.endControl[1])) + (t * curve.end[1]);
    const Cz = ((1 - t) * (curve.end[2] + curve.endControl[2])) + (t * curve.end[2]);

    // Step 2
    const Dx = ((1 - t) * Ax) + (t * Bx);
    const Dy = ((1 - t) * Ay) + (t * By);
    const Dz = ((1 - t) * Az) + (t * Bz);
    const Ex = ((1 - t) * Bx) + (t * Cx);
    const Ey = ((1 - t) * By) + (t * Cy);
    const Ez = ((1 - t) * Bz) + (t * Cz);

    // Step 3
    const Px = ((1 - t) * Dx) + (t * Ex);
    const Py = ((1 - t) * Dy) + (t * Ey);
    const Pz = ((1 - t) * Dz) + (t * Ez);
    return new THREE.Vector3(Px, Py, Pz);
}
// Takes a curve and a percent along the curve and returns the 3d coordinates of that point in a vector3
Takes a curve and a percent along the curve and returns the 3d coordinates of that point in a vector3
Takes a curve and a percent along the curve and returns the 3d coordinates of that point in a vector3
function casteljauPoint(curve, t) {
    const THREE = require('three');
    const Ax = ((1 - t) * curve.start[0]) + (t * (curve.start[0] + curve.startControl[0]));
    const Ay = ((1 - t) * curve.start[1]) + (t * (curve.start[1] + curve.startControl[1]));
    const Az = ((1 - t) * curve.start[2]) + (t * (curve.start[2] + curve.startControl[2]));
    const Bx = ((1 - t) * (curve.start[0] + curve.startControl[0])) + (t * (curve.end[0] + curve.endControl[0]));
    const By = ((1 - t) * (curve.start[1] + curve.startControl[1])) + (t * (curve.end[1] + curve.endControl[1]));
    const Bz = ((1 - t) * (curve.start[2] + curve.startControl[2])) + (t * (curve.end[2] + curve.endControl[2]));
    const Cx = ((1 - t) * (curve.end[0] + curve.endControl[0])) + (t * curve.end[0]);
    const Cy = ((1 - t) * (curve.end[1] + curve.endControl[1])) + (t * curve.end[1]);
    const Cz = ((1 - t) * (curve.end[2] + curve.endControl[2])) + (t * curve.end[2]);
    const Dx = ((1 - t) * Ax) + (t * Bx);
    const Dy = ((1 - t) * Ay) + (t * By);
    const Dz = ((1 - t) * Az) + (t * Bz);
    const Ex = ((1 - t) * Bx) + (t * Cx);
    const Ey = ((1 - t) * By) + (t * Cy);
    const Ez = ((1 - t) * Bz) + (t * Cz);
    const Px = ((1 - t) * Dx) + (t * Ex);
    const Py = ((1 - t) * Dy) + (t * Ey);
    const Pz = ((1 - t) * Dz) + (t * Ez);
    return new THREE.Vector3(Px, Py, Pz);
}
function casteljauPoint ( curve , t ) { const THREE = require ( 'three' ) ; const Ax = ( ( 1 - t ) * curve . start [ 0 ] ) + ( t * ( curve . start [ 0 ] + curve . startControl [ 0 ] ) ) ; const Ay = ( ( 1 - t ) * curve . start [ 1 ] ) + ( t * ( curve . start [ 1 ] + curve . startControl [ 1 ] ) ) ; const Az = ( ( 1 - t ) * curve . start [ 2 ] ) + ( t * ( curve . start [ 2 ] + curve . startControl [ 2 ] ) ) ; const Bx = ( ( 1 - t ) * ( curve . start [ 0 ] + curve . startControl [ 0 ] ) ) + ( t * ( curve . end [ 0 ] + curve . endControl [ 0 ] ) ) ; const By = ( ( 1 - t ) * ( curve . start [ 1 ] + curve . startControl [ 1 ] ) ) + ( t * ( curve . end [ 1 ] + curve . endControl [ 1 ] ) ) ; const Bz = ( ( 1 - t ) * ( curve . start [ 2 ] + curve . startControl [ 2 ] ) ) + ( t * ( curve . end [ 2 ] + curve . endControl [ 2 ] ) ) ; const Cx = ( ( 1 - t ) * ( curve . end [ 0 ] + curve . endControl [ 0 ] ) ) + ( t * curve . end [ 0 ] ) ; const Cy = ( ( 1 - t ) * ( curve . end [ 1 ] + curve . endControl [ 1 ] ) ) + ( t * curve . end [ 1 ] ) ; const Cz = ( ( 1 - t ) * ( curve . end [ 2 ] + curve . endControl [ 2 ] ) ) + ( t * curve . end [ 2 ] ) ; const Dx = ( ( 1 - t ) * Ax ) + ( t * Bx ) ; const Dy = ( ( 1 - t ) * Ay ) + ( t * By ) ; const Dz = ( ( 1 - t ) * Az ) + ( t * Bz ) ; const Ex = ( ( 1 - t ) * Bx ) + ( t * Cx ) ; const Ey = ( ( 1 - t ) * By ) + ( t * Cy ) ; const Ez = ( ( 1 - t ) * Bz ) + ( t * Cz ) ; const Px = ( ( 1 - t ) * Dx ) + ( t * Ex ) ; const Py = ( ( 1 - t ) * Dy ) + ( t * Ey ) ; const Pz = ( ( 1 - t ) * Dz ) + ( t * Ez ) ; return new THREE . Vector3 ( Px , Py , Pz ) ; }
Takes a curve and a percent along the curve and returns the 3d coordinates of that point in a vector3
Takes a curve and a percent along the curve and returns the 3d coordinates of that point in a vector3
// Step 1 // Step 2 // Step 3