Shape
Base type for Nape Shape's
Static Members
@private
Instance Members
@private
Type of shape.
Body this Shape is assigned to.
This value can be set to add Shape to the given Body, and set to null
to remove it from its present Body.
@default null
Faster equivalent to casting this to Circle type
Faster equivalent to casting this to Polygon type
World space centre of mass of this Shape.
This value can be accessed even if Shape is not in a Body, but
attempting to query the values of it will return an error in debug
builds unless the Shape is in a Body.
This Vec2 is immutable.
Local space centre of mass of this Shape.
This Vec2 can be set and is equivalent to performing the necessary
translation of the Shape in local coordinates, and also equivalent
to this.localCOM.set(value)
.
Setting this value whilst this shape is part of a static Body that
is part of a Space is not permitted.
Area of the Hhape.
Non-mass weighted moment of inertia for Shape.
Coeffecient of angular fluid drag for this Shape.
Material used by this shape.
@default new Material()
InteractionFilter used by this shape.
@default new InteractionFilter()
FluidProperties used by this shape.
This object provides information for buoyancy and fluid drag computations
when this shape is interacting as a fluid.
@default new FluidProperties();
Whether this shape is able to interact as a fluid.
Unless this field is true, this Shape can never interact as a fluid.
Just because this field is true however, does not mean this shape will always
interact as a fluid, the final result is down to the combination of
InteractionFilters on the pairing of shapes and sensory interaction
takes higher priority.
@default false
Whether this shape is able to interact as sensor.
Unless this field is true, this Shape can never interact as a sensor.
Just because this field is true however, does not mean this shape will always
interact as a sensor, the final result is down to the combination of
InteractionFilters on the pairing of shapes. Sensor interaction has highest priority.
@default false
World space bounding box for this shape.
This value can be accessed even if the Shape is not part of a Body,
however attempting to query its values would result in an error in
debug builds.
This AABB is immutable.
Faster equivalent to type == ShapeType.CIRCLE
Returns | Description |
---|---|
Bool | True if shape is a Circle type. |
Faster equivalent to type == ShapeType.POLYGON
Returns | Description |
---|---|
Bool | True if shape is a Polygon type. |
Translate this shape in its local coordinate system.
This is equivalent to: shape.localCOM.addeq(displacement)
Name | Type | Description |
---|---|---|
translation |
nape.geom.Vec2 | The local translation to apply to Shape. |
Returns | Description |
---|---|
Shape | A reference to 'this' Shape. |
Scale this shape in its local coordinate system.
For Circle shapes, scalex and scaley must be exactly equal.
Name | Type | Description |
---|---|---|
scalex |
Float | The x-coordinate scaling to apply to Shape. |
scaley |
Float | The y-coordinate scaling to apply to Shape. |
Returns | Description |
---|---|
Shape | A reference to 'this' Shape. |
Rotate this shape in its local coordinate system.
Name | Type | Description |
---|---|---|
angle |
Float | The number of radians to rotate this Shape by in a clockwise direction. |
Returns | Description |
---|---|
Shape | A reference to 'this' Shape. |
Apply local transformation matrix to Shape.
For Circle shapes, the matrix must be equiorthogonal.
Name | Type | Description |
---|---|---|
matrix |
nape.geom.Mat23 | The matrix to transform Shape by. |
Returns | Description |
---|---|
Shape | A reference to 'this' Shape. |
Test containment of world-space coordinate in Shape.
This Shape must be part of a Body so that world coordinates are
defined.
Name | Type | Description |
---|---|---|
point |
nape.geom.Vec2 | The point to check for containment. |
Returns | Description |
---|---|
Bool | True if point is contained within the Shape. |
Produce an exact copy of this Shape.
The copied shape will be identical with the copied Shape's userData
object being assigned the same fields as 'this' Shape with the same
values copied over by reference for object types.
Returns | Description |
---|---|
Shape | A copy of this shape. |
@private
Returns |
---|
String |