Capítulo 338 de 859

Chapter 338: CatmullRomCurve3

Core Idea

A curve representing a Catmull-Rom spline.

Key Concepts

  • closed : boolean: Whether the curve is closed or not.
  • curveType : 'centripetal' | 'chordal' | 'catmullrom': The curve type.
  • isCatmullRomCurve3 : boolean (readonly): This flag can be used for type testing.
  • points : Array.<Vector3>: An array of 3D points defining the curve.
  • tension : number: Tension of the curve.

Code Examples

//Create a closed wavey loop
const curve = new THREE.CatmullRomCurve3( [
	new THREE.Vector3( -10, 0, 10 ),
	new THREE.Vector3( -5, 5, 5 ),
	new THREE.Vector3( 0, 0, 0 ),
	new THREE.Vector3( 5, -5, 5 ),
	new THREE.Vector3( 10, 0, 10 )
] );
const points = curve.getPoints( 50 );
const geometry = new THREE.BufferGeometry().setFromPoints( points );
const material = new THREE.LineBasicMaterial( { color: 0xff0000 } );
// Create the final object to add to the scene
const curveObject = new THREE.Line( geometry, material );
  • What it demonstrates: Typical usage of CatmullRomCurve3.

Reference Tables

Constructor

Signature
`new CatmullRomCurve3( points : Array.<Vector3>, closed : boolean, curveType : 'centripetal'

Properties

PropertyDescription
.closed : booleanWhether the curve is closed or not.
`.curveType : 'centripetal''chordal'
.isCatmullRomCurve3 : boolean (readonly)This flag can be used for type testing.
.points : Array.<Vector3>An array of 3D points defining the curve.
.tension : numberTension of the curve.

Methods

MethodDescription
.getPoint( t : number, optionalTarget : Vector3 ) : Vector3Returns a point on the curve.

Key Takeaways

  1. CatmullRomCurve3 extends: Curve
  2. Most relevant properties: closed, curveType, isCatmullRomCurve3, points.
  3. Key methods: getPoint.

Connects To