Shape

nape.phys.Interactornape.shape.Shape (Class) → Circle, Polygon

Base type for Nape Shape's

Static Members

nape
zpp_internalAlloc: Bool

@private

Instance Members

@private


nape
type: ShapeType

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


nape
castCircle: Null<Circle>

Faster equivalent to casting this to Circle type


nape
castPolygon: Null<Polygon>

Faster equivalent to casting this to Polygon type


nape
worldCOM: nape.geom.Vec2

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.


nape
localCOM: nape.geom.Vec2

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.


nape
area: Float

Area of the Hhape.


nape
inertia: Float

Non-mass weighted moment of inertia for Shape.


nape
angDrag: Float

Coeffecient of angular fluid drag for this Shape.


nape
material: nape.phys.Material

Material used by this shape.

@default new Material()


InteractionFilter used by this shape.

@default new InteractionFilter()


nape
fluidProperties: nape.phys.FluidProperties

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();


nape
fluidEnabled: Bool

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


nape
sensorEnabled: Bool

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


nape
bounds: nape.geom.AABB

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.


nape
isCircle(): Bool

Faster equivalent to type == ShapeType.CIRCLE

Returns Description
Bool True if shape is a Circle type.

nape
isPolygon(): Bool

Faster equivalent to type == ShapeType.POLYGON

Returns Description
Bool True if shape is a Polygon type.

nape
translate(translation: nape.geom.Vec2): Shape

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.

nape
scale(scalex: Float, scaley: Float): 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.

nape
rotate(angle: Float): 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.

nape
transform(matrix: nape.geom.Mat23): 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.

nape
contains(point: nape.geom.Vec2): Bool

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.

nape
copy(): 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.

nape
toString(): String

@private

Returns
String

Private Members

nape
new(): Void