Class CatmullRomCurve3

A smooth 3d spline curve from a series of points using the Catmull-Rom algorithm.

References: https://en.wikipedia.org/wiki/Centripetal_Catmull%E2%80%93Rom_spline

http://www.cemyuksel.com/research/catmullrom_param/

Example

//Create a closed wavey loop
const curve = new CatmullRomCurve3( [
new Vector3( -10, 0, 10 ),
new Vector3( -5, 5, 5 ),
new Vector3( 0, 0, 0 ),
new Vector3( 5, -5, 5 ),
new Vector3( 10, 0, 10 )
] );

const points = curve.getPoints( 50 );

Hierarchy

  • Curve<Vector3>
    • CatmullRomCurve3

Constructors

Properties

arcLengthDivisions: number

Determines the amount of divisions when calculating the cumulative segment lengths of a curve via .getLengths. To ensure precision when using methods like .getSpacedPoints, it is recommended to increase .arcLengthDivisions if the curve is very large.

Default

200

closed: boolean

The curve will loop back onto itself when this is true.

When curveType is catmullrom, defines catmullrom's tension.

isArcCurve: boolean

subclass should override

Default Value

false

isCatmullRomCurve3: boolean

Default Value

true

isCubicBezierCurve: boolean

subclass should override

Default Value

false

isCubicBezierCurve3: boolean

subclass should override

Default Value

false

isEllipseCurve: boolean

subclass should override

Default Value

false

isLineCurve: boolean

subclass should override

Default Value

false

isLineCurve3: boolean

subclass should override

Default Value

false

isQuadraticBezierCurve: boolean

subclass should override

Default Value

false

isQuadraticBezierCurve3: boolean

subclass should override

Default Value

false

isSplineCurve: boolean

subclass should override

Default Value

false

points: Vector3[]

The array of Vector3 points that define the curve. It needs at least two entries.

Default Value

[]

tension: number

When curveType is catmullrom, defines catmullrom's tension.

type: string

Default Value

'CatmullRomCurve3'

Methods

  • Creates a new instance with same property values as this curve.

    Returns

    A new Curve instance exactly like this curve.

    Returns Curve<Vector3>

  • Generates the Frenet frames. Learn more at http://www.cs.indiana.edu/pub/techreports/TR425.pdf

    Returns

    An object with shape: { tangents: Vector3[]; normals: Vector3[]; binormals: Vector3[]; }

    Parameters

    • segments: number

      Number of segments

    • Optional closed: boolean

      True if this curve is closed.

    Returns { binormals: Vector3[]; normals: Vector3[]; tangents: Vector3[] }

    • binormals: Vector3[]
    • normals: Vector3[]
    • tangents: Vector3[]
  • Get list of cumulative segment lengths.

    Returns

    Array of points

    Parameters

    • Optional divisions: number

    Returns number[]

  • Find the point (vector) for point t of the curve where t is between 0 and 1.

    Returns

    The point.

    Parameters

    • t: number

      A position on the curve. Must be in the range [ 0, 1 ].

    • Optional optionalTarget: Vector3

      (optional) If specified, the result will be copied into this Vector, otherwise a new Vector will be created.

    Returns Vector3

  • Find a vector for point at relative position in curve according to arc length

    Returns

    The point.

    Parameters

    • u: number

      A position on the curve according to the arc length. Must be in the range [ 0, 1 ].

    • Optional optionalTarget: Vector3

      (optional) If specified, the result will be copied into this Vector, otherwise a new Vector will be created.

    Returns Vector3

  • Compute a set of divisions + 1 points using getPoint( t ).

    Returns

    Array of point vectors.

    Parameters

    • Optional divisions: number

      number of pieces to divide the curve into. Default is 5.

    Returns Vector3[]

  • Compute a set of divisions + 1 equi-spaced points using getPointAt( u ).

    Returns

    Array of point vectors.

    Parameters

    • Optional divisions: number

      number of pieces to divide the curve into. Default is 5.

    Returns Vector3[]

  • Compute a unit vector tangent at t. If the subclassed curve do not implement its tangent derivation, 2 points a small delta apart will be used to find its gradient which seems to give a reasonable approximation getTangent(t: number, optionalTarget?: T): T;

    Returns

    A vector tangent to t.

    Parameters

    • t: number

      A position on the curve. Must be in the range [ 0, 1 ].

    • Optional optionalTarget: Vector3

      — (optional) If specified, the result will be copied into this Vector, otherwise a new Vector will be created.

    Returns Vector3

  • Compute the tangent at a point which is equidistant to the ends of the curve from the point given in getTangent().

    Returns

    a vector tangent to u.

    Parameters

    • u: number

      A position on the curve according to the arc length. Must be in the range [ 0, 1 ].

    • Optional optionalTarget: Vector3

      (optional) If specified, the result will be copied into this Vector, otherwise a new Vector will be created.

    Returns Vector3

  • Given u ( 0 .. 1 ), get a t to find p. This gives you points which are equi distance

    Parameters

    • u: number
    • distance: number

    Returns number

  • Create a JSON object representation of this instance.

    Returns

    A JSON object

    Returns object