Shape class

Defines an arbitrary 2d shape plane using paths with optional holes. It can be used with ExtrudeGeometry, ShapeGeometry, to get points, or to get triangulated faces.

final heartShape = Shape();
heartShape.moveTo( 25, 25 );
heartShape.bezierCurveTo( 25, 25, 20, 0, 0, 0 );
heartShape.bezierCurveTo( - 30, 0, - 30, 35, - 30, 35 );
heartShape.bezierCurveTo( - 30, 55, - 10, 77, 25, 95 );
heartShape.bezierCurveTo( 60, 77, 80, 55, 80, 35 );
heartShape.bezierCurveTo( 80, 35, 80, 0, 50, 0 );
heartShape.bezierCurveTo( 35, 0, 25, 25, 25, 25 );

final extrudeSettings = { 
  'depth': 8, 
  'bevelEnabled': true, 
  'bevelSegments': 2, 
  'steps': 2, 
  'bevelSize': 1, 
  'bevelThickness': 1 
};

final geometry = ExtrudeGeometry( heartShape, extrudeSettings );

final mesh = Mesh( geometry, MeshPhongMaterial() );
Inheritance

Constructors

Shape([List<Vector2>? points])
points -- (optional) array of Vector2.
Shape.fromJson(Map<String, dynamic> json)

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
currentPoint ↔ Vector2
getter/setter pairinherited
curves List<Curve>
getter/setter pairinherited
hashCode int
The hash code for this object.
no setterinherited
holes List<Path>
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
userData Map<String, dynamic>
getter/setter pairinherited
uuid String
getter/setter pair
v0 ↔ Vector
getter/setter pairinherited
v1 ↔ Vector
getter/setter pairinherited
v2 ↔ Vector
getter/setter pairinherited

Methods

absarc(double aX, double aY, double aRadius, double aStartAngle, double aEndAngle, [bool? aClockwise]) Shape
aX, aY -- The absolute center of the arc.
override
absellipse(double aX, double aY, double xRadius, double yRadius, double aStartAngle, double aEndAngle, [bool? aClockwise, double? aRotation]) Shape
aX, aY -- The absolute center of the ellipse.
override
add(Curve curve) → void
inherited
arc(double aX, double aY, double aRadius, double aStartAngle, double aEndAngle, [bool? aClockwise]) Shape
aX, aY -- The center of the arc offset from the last call.
override
bezierCurveTo(double aCP1x, double aCP1y, double aCP2x, double aCP2y, double aX, double aY) Shape
This creates a bezier curve from currentPoint with (cp1X, cp1Y) and (cp2X, cp2Y) as control points and updates currentPoint to x and y.
override
clone() Curve
Creates a clone of this instance.
inherited
closePath() → void
Adds a lineCurve to close the path.
inherited
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) Shape
Copies another name object to this instance.
override
ellipse(double aX, double aY, double xRadius, double yRadius, double aStartAngle, double aEndAngle, [bool? aClockwise, double? aRotation]) Shape
aX, aY -- The center of the ellipse offset from the last call.
override
extractPoints(dynamic divisions) Map<String, dynamic>
divisions -- The fineness of the result.
fromJson(Map<String, dynamic> json) Shape
Copies the data from the given JSON object to this instance.
override
getCurveLengths() List<double>
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]) → Vector?
inherited
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 = 12]) List<Vector?>
divisions -- number of pieces to divide the curve into. Default is 12.
inherited
getPointsHoles(int divisions) List<List<Vector?>?>
divisions -- The fineness of the result.
getSpacedPoints([num divisions = 40, num offset = 0.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
lineTo(double x, double y) Shape
Connects a LineCurve from currentPoint to x, y onto the path.
override
moveTo(double x, double y) Shape
Move the currentPoint to x, y.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
quadraticCurveTo(double aCPx, double aCPy, double aX, double aY) Shape
Creates a quadratic curve from currentPoint with cpX and cpY as control point and updates currentPoint to x and y.
override
setFromPoints(List<Vector2> points) Path
points -- array of Vector2.
inherited
splineThru(List<Vector2> pts) Shape
points - An array of Vector2
override
toJson() Map<String, dynamic>
Returns a JSON object representation of this instance.
override
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