Capítulo 367 de 859

Chapter 367: SplineCurve

Core Idea

A curve representing a 2D spline curve.

Key Concepts

  • isSplineCurve : boolean (readonly): This flag can be used for type testing.
  • points : Array.<Vector2>: An array of 2D points defining the curve.

Code Examples

// Create a sine-like wave
const curve = new THREE.SplineCurve( [
	new THREE.Vector2( -10, 0 ),
	new THREE.Vector2( -5, 5 ),
	new THREE.Vector2( 0, 0 ),
	new THREE.Vector2( 5, -5 ),
	new THREE.Vector2( 10, 0 )
] );
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 splineObject = new THREE.Line( geometry, material );
  • What it demonstrates: Typical usage of SplineCurve.

Reference Tables

Constructor

Signature
new SplineCurve( points : Array.<Vector2> )

Properties

PropertyDescription
.isSplineCurve : boolean (readonly)This flag can be used for type testing.
.points : Array.<Vector2>An array of 2D points defining the curve.

Methods

MethodDescription
.getPoint( t : number, optionalTarget : Vector2 ) : Vector2Returns a point on the curve.

Key Takeaways

  1. SplineCurve extends: Curve
  2. Most relevant properties: isSplineCurve, points.
  3. Key methods: getPoint.

Connects To