CatmullRomCurve3 class

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

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

final points = curve.getPoints( 50 );
final geometry = BufferGeometry().setFromPoints( points );

final material = LineBasicMaterial( { color: 0xff0000 } );

// Create the final object to add to the scene
Inheritance

Constructors

CatmullRomCurve3({List<Vector>? points, bool closed = false, String curveType = 'centripetal', num tension = 0.5})
points – An array of Vector3 points

Properties

arcLengthDivisions int
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.
getter/setter pairinherited
autoClose bool
getter/setter pairinherited
cacheArcLengths List<double>?
getter/setter pairinherited
cacheLengths List<double>?
getter/setter pairinherited
closed bool
getter/setter pair
currentPoint ↔ Vector2
getter/setter pairinherited
curves List<Curve>
getter/setter pairinherited
curveType String
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
isCatmullRomCurve3 bool
getter/setter pair
isCubicBezierCurve bool
getter/setter pairinherited
isEllipseCurve bool
getter/setter pairinherited
isLineCurve bool
getter/setter pairinherited
isLineCurve3 bool
getter/setter pairinherited
isQuadraticBezierCurve bool
getter/setter pairinherited
isSplineCurve bool
getter/setter pairinherited
needsUpdate bool
getter/setter pairinherited
points List<Vector>
getter/setter pairinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
tension num
getter/setter pair
userData Map<String, dynamic>
getter/setter pairinherited
v0 ↔ Vector
getter/setter pairinherited
v1 ↔ Vector
getter/setter pairinherited
v2 ↔ Vector
getter/setter pairinherited

Methods

clone() CatmullRomCurve3
Creates a clone of this instance.
override
computeFrenetFrames(int segments, bool closed) FrenetFrames
Generates the Frenet Frames. Requires a curve definition in 3D space. Used in geometries like TubeGeometry or ExtrudeGeometry.
inherited
copy(Curve source) CatmullRomCurve3
Copies another name object to this instance.
override
fromJson(Map<String, dynamic> json) Curve
Copies the data from the given JSON object to this instance.
inherited
getLength() double
Get total curve arc length
inherited
getLengths(int? divisions) List<double>
Get list of cumulative segment lengths
inherited
getPoint(double t, [Vector? optionalTarget]) → Vector3?
override
getPointAt(double u, [Vector? optionalTarget]) → Vector?
u - A position on the curve according to the arc length. Must be in the range 0, 1 .
inherited
getPoints([int divisions = 5]) List<Vector?>
divisions -- number of pieces to divide the curve into. Default is 5.
inherited
getSpacedPoints([int divisions = 5, int offset = 0]) List<Vector?>
divisions -- number of pieces to divide the curve into. Default is 5.
inherited
getTangent(double t, [Vector? optionalTarget]) → Vector
t - A position on the curve. Must be in the range 0, 1 .
inherited
getTangentAt(double u, [Vector? optionalTarget]) → Vector
u - A position on the curve according to the arc length. Must be in the range 0, 1 .
inherited
getUtoTmapping(double u, [double? distance]) double
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.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toJson() Map<String, dynamic>
Returns a JSON object representation of this instance.
inherited
toString() String
A string representation of this object.
inherited
updateArcLengths() → void
Update the cumulative segment distance cache. The method must be called every time curve parameters are changed. If an updated curve is part of a composed curve like CurvePath, updateArcLengths must be called on the composed curve, too.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited