fromPath static method

ParametricTubeGeometry fromPath(
  1. Curve path, [
  2. int segments = 64,
  3. double radius = 1,
  4. int segmentsRadius = 8,
  5. bool closed = false,
])

Implementation

static ParametricTubeGeometry fromPath(Curve path, [int segments = 64, double radius = 1, int segmentsRadius = 8, bool closed = false ]) {
	final numpoints = segments + 1;

	final frames = path.computeFrenetFrames( segments, closed ),
		//tangents = frames.tangents,
		normals = frames.normals,
		binormals = frames.binormals;

	final position = new Vector3();

	parametricTube(double u, double v, Vector3 target ) {
		v *= 2 * math.pi;

		final i = ( u * ( numpoints - 1 ) ).floor();

		path.getPointAt( u, position );

		final normal = normals![ i ];
		final binormal = binormals![ i ];

		final cx = - radius * math.cos( v ); // TODO: Hack: Negating it so it faces outside.
		final cy = radius * math.sin( v );

		position.x += cx * normal.x + cy * binormal.x;
		position.y += cx * normal.y + cy * binormal.y;
		position.z += cx * normal.z + cy * binormal.z;

		target.setFrom( position );
	}

	return ParametricTubeGeometry.init( parametricTube, segments, segmentsRadius );

	// proxy internals

	// this.tangents = tangents;
	// this.normals = normals;
	// this.binormals = binormals;
}