Capítulo 57 de 859

Chapter 57: TubeGeometry

Core Idea

Creates a tube that extrudes along a 3D curve.

Key Concepts

  • parameters : Object: Holds the constructor parameters that have been used to generate the geometry. Any modification after instantiation does not change the geo…

Code Examples

class CustomSinCurve extends THREE.Curve {
	getPoint( t, optionalTarget = new THREE.Vector3() ) {
		const tx = t * 3 - 1.5;
		const ty = Math.sin( 2 * Math.PI * t );
		const tz = 0;
		return optionalTarget.set( tx, ty, tz );
	}
}
const path = new CustomSinCurve( 10 );
const geometry = new THREE.TubeGeometry( path, 20, 2, 8, false );
const material = new THREE.MeshBasicMaterial( { color: 0x00ff00 } );
const mesh = new THREE.Mesh( geometry, material );
scene.add( mesh );
  • What it demonstrates: Typical usage of TubeGeometry.

Reference Tables

Constructor

Signature
new TubeGeometry( path : Curve, tubularSegments : number, radius : number, radialSegments : number, closed : boolean )

Properties

PropertyDescription
.parameters : ObjectHolds the constructor parameters that have been used to generate the geometry. Any modification after instantiation does not change the geometry.

Key Takeaways

  1. TubeGeometry extends: EventDispatcher → BufferGeometry
  2. Most relevant properties: parameters.

Connects To