2021-05-11 18:30:36 -07:00

9.5 KiB
Raw Permalink Blame History

Planck.js API Doc › Globals › BoxShape

Class: BoxShape

A rectangle polygon which extend PolygonShape.

Hierarchy

↳ PolygonShape

↳ BoxShape

Index

Constructors

Properties

Methods

Constructors

constructor

+ new BoxShape(hx: number, hy: number, center?: Vec2, angle?: number): BoxShape

Overrides PolygonShape.constructor

Defined in src/collision/shape/BoxShape.ts:32

Parameters:

Name Type
hx number
hy number
center? Vec2
angle? number

Returns: BoxShape

Properties

m_centroid

• m_centroid: Vec2

Inherited from PolygonShape.m_centroid

Defined in src/collision/shape/PolygonShape.ts:49


m_count

• m_count: number

Inherited from PolygonShape.m_count

Defined in src/collision/shape/PolygonShape.ts:52


m_normals

• m_normals: Vec2[]

Inherited from PolygonShape.m_normals

Defined in src/collision/shape/PolygonShape.ts:51


m_radius

• m_radius: number

Inherited from Shape.m_radius

Defined in src/collision/Shape.ts:39


m_type

• m_type: ShapeType

Inherited from Shape.m_type

Defined in src/collision/Shape.ts:38


m_vertices

• m_vertices: Vec2[]

Inherited from PolygonShape.m_vertices

Defined in src/collision/shape/PolygonShape.ts:50


Static TYPE

▪ TYPE: "polygon" = 'polygon' as 'polygon'

Overrides PolygonShape.TYPE

Defined in src/collision/shape/BoxShape.ts:32

Methods

computeAABB

▸ computeAABB(aabb: AABB, xf: Transform, childIndex: number): void

Inherited from PolygonShape.computeAABB

Overrides Shape.computeAABB

Defined in src/collision/shape/PolygonShape.ts:388

Given a transform, compute the associated axis aligned bounding box for a child shape.

Parameters:

Name Type Description
aabb AABB Returns the axis aligned box.
xf Transform The world transform of the shape.
childIndex number The child shape

Returns: void


computeDistanceProxy

▸ computeDistanceProxy(proxy: DistanceProxy): void

Inherited from PolygonShape.computeDistanceProxy

Overrides Shape.computeDistanceProxy

Defined in src/collision/shape/PolygonShape.ts:522

Parameters:

Name Type
proxy DistanceProxy

Returns: void


computeMass

▸ computeMass(massData: MassData, density: number): void

Inherited from PolygonShape.computeMass

Overrides Shape.computeMass

Defined in src/collision/shape/PolygonShape.ts:413

Compute the mass properties of this shape using its dimensions and density. The inertia tensor is computed about the local origin.

Parameters:

Name Type Description
massData MassData Returns the mass data for this shape.
density number The density in kilograms per meter squared.

Returns: void


getChildCount

▸ getChildCount(): 1

Inherited from PolygonShape.getChildCount

Overrides Shape.getChildCount

Defined in src/collision/shape/PolygonShape.ts:127

Get the number of child primitives.

Returns: 1


getRadius

▸ getRadius(): number

Inherited from Shape.getRadius

Defined in src/collision/Shape.ts:62

Returns: number


getType

▸ getType(): ShapeType

Inherited from Shape.getType

Defined in src/collision/Shape.ts:72

Get the type of this shape. You can use this to down cast to the concrete shape.

Returns: ShapeType

the shape type.


getVertex

▸ getVertex(index: number): Vec2

Inherited from PolygonShape.getVertex

Defined in src/collision/shape/PolygonShape.ts:98

Parameters:

Name Type
index number

Returns: Vec2


rayCast

▸ rayCast(output: RayCastOutput, input: RayCastInput, xf: Transform, childIndex: number): boolean

Inherited from PolygonShape.rayCast

Overrides Shape.rayCast

Defined in src/collision/shape/PolygonShape.ts:320

Cast a ray against a child shape.

Parameters:

Name Type Description
output RayCastOutput The ray-cast results.
input RayCastInput The ray-cast input parameters.
xf Transform The transform to be applied to the shape.
childIndex number The child shape index

Returns: boolean


testPoint

▸ testPoint(xf: Transform, p: Vec2): boolean

Inherited from PolygonShape.testPoint

Overrides Shape.testPoint

Defined in src/collision/shape/PolygonShape.ts:299

Test a point for containment in this shape. This only works for convex shapes.

Parameters:

Name Type Description
xf Transform The shape world transform.
p Vec2 A point in world coordinates.

Returns: boolean


validate

▸ validate(): boolean

Inherited from PolygonShape.validate

Defined in src/collision/shape/PolygonShape.ts:499

Validate convexity. This is a very time consuming operation.

Returns: boolean

true if valid


Static isValid

▸ isValid(shape: Shape | null | undefined): shape is Shape

Inherited from Shape.isValid

Defined in src/collision/Shape.ts:58

Parameters:

Name Type
shape Shape | null | undefined

Returns: shape is Shape