Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface CubicBezierCurve

Create a smooth 2d cubic bezier curve, defined by a start point, endpoint and two control points.

Code Example

const curve = new THREE.CubicBezierCurve(
new THREE.Vector2( -10, 0 ),
new THREE.Vector2( -5, 15 ),
new THREE.Vector2( 20, 15 ),
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 curveObject = new THREE.Line( geometry, material );

Hierarchy

Index

Constructors

constructor

Properties

arcLengthDivisions

arcLengthDivisions: number

This value 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 is 200.

default

200

type

type: string
default

'CubicBezierCurve'

v0

The starting point.

default

new THREE.Vector2()

v1

The first control point.

default

new THREE.Vector2()

v2

The second control point.

default

new THREE.Vector2()

v3

The ending point.

default

new THREE.Vector2()

Methods

clone

computeFrenetFrames

copy

fromJSON

getLength

  • getLength(): number

getLengths

  • getLengths(divisions?: number): number[]

getPoint

getPointAt

  • Parameters

    • u: number

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

    • Optional optionalTarget: I3JS.Vector2

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

    Returns I3JS.Vector2

    Returns a vector for a given position on the curve according to the arc length.

getPoints

getSpacedPoints

getTangent

  • Parameters

    • t: number

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

    • Optional optionalTarget: I3JS.Vector2

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

    Returns I3JS.Vector2

    Returns a unit vector tangent at t. If the derived curve does not implement its tangent derivation, two points a small delta apart will be used to find its gradient which seems to give a reasonable approximation.

getTangentAt

  • Parameters

    • u: number

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

    • Optional optionalTarget: I3JS.Vector2

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

    Returns I3JS.Vector2

    Returns tangent at a point which is equidistant to the ends of the curve from the point given in .getTangent.

getUtoTmapping

  • getUtoTmapping(u: number, distance: number): number
  • Given u in the range ( 0 .. 1 ), returns t also in the range ( 0 .. 1 ). u and t can then be used to give you points which are equidistant from the ends of the curve, using .getPoint.

    Parameters

    • u: number
    • distance: number

    Returns number

toJSON

  • toJSON(): object

updateArcLengths

  • updateArcLengths(): void

Generated using TypeDoc