#Cannot make tubeGeometry with curve

6 messages · Page 1 of 1 (latest)

jagged elk
#

Take simple code:

const sine = sinCurve(1)
const tube = new THREE.Mesh(
    new THREE.TubeGeometry(sine, 20, 2, 8, false),
    new THREE.MeshBasicMaterial({ color: 0xffffff })
)
function sinCurve(amplitude) {
    // Make simple SIN points -^_-
    const points = [];
    for (let i = 0; i < 5; i++) {
        const x = ((2 * Math.PI) / 4) * i ;
        const y = amplitude * Math.sin( x );
        points.push(new THREE.Vector3(x, y,0));
    }
    
    const curve = new THREE.SplineCurve(points);
    return curve;
}

Curve appears valid and works with methods like getPoints() as expected. The resultant tube-geometry has all NAN position/normal attribute values though

jagged elk
unique folio
#

Have you tried walking through the code on Three's side?

jagged elk
#

A little bit, first step of tube geometry is curve.computeFrenetFrames() and that fails with all NAN

jagged elk
#

SplineCurve can be defined with and retains 3D points however still acts like a 2D curve and is subsequently incompatible with TubeGeometry 🥲

idle stirrup
#

use SplineCurve3 for 3D curves (THREE.SplineCurve3)
and add a z