10 KiB
Planck.js API Doc › Globals › EdgeShape
Class: EdgeShape
A line segment (edge) shape. These can be connected in chains or loops to other edge shapes. The connectivity information is used to ensure correct contact normals.
Hierarchy
-
↳ EdgeShape
Index
Constructors
Properties
Methods
- _set
- computeAABB
- computeDistanceProxy
- computeMass
- getChildCount
- getNextVertex
- getPrevVertex
- getRadius
- getType
- rayCast
- setNextVertex
- setPrevVertex
- testPoint
- isValid
Constructors
constructor
+ new EdgeShape(v1?: Vec2, v2?: Vec2): EdgeShape
Defined in src/collision/shape/EdgeShape.ts:51
Parameters:
| Name | Type |
|---|---|
v1? |
Vec2 |
v2? |
Vec2 |
Returns: EdgeShape
Properties
m_hasVertex0
• m_hasVertex0: boolean
Defined in src/collision/shape/EdgeShape.ts:50
m_hasVertex3
• m_hasVertex3: boolean
Defined in src/collision/shape/EdgeShape.ts:51
m_radius
• m_radius: number
Defined in src/collision/Shape.ts:39
m_type
• m_type: ShapeType
Defined in src/collision/Shape.ts:38
m_vertex0
• m_vertex0: Vec2
Defined in src/collision/shape/EdgeShape.ts:48
m_vertex1
• m_vertex1: Vec2
Defined in src/collision/shape/EdgeShape.ts:43
m_vertex2
• m_vertex2: Vec2
Defined in src/collision/shape/EdgeShape.ts:44
m_vertex3
• m_vertex3: Vec2
Defined in src/collision/shape/EdgeShape.ts:49
Static TYPE
▪ TYPE: "edge" = 'edge' as 'edge'
Defined in src/collision/shape/EdgeShape.ts:40
Methods
_set
▸ _set(v1: Vec2, v2: Vec2): EdgeShape
Defined in src/collision/shape/EdgeShape.ts:157
Set this as an isolated edge.
Parameters:
| Name | Type |
|---|---|
v1 |
Vec2 |
v2 |
Vec2 |
Returns: EdgeShape
computeAABB
▸ computeAABB(aabb: AABB, xf: Transform, childIndex: number): void
Overrides Shape.computeAABB
Defined in src/collision/shape/EdgeShape.ts:276
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
Overrides Shape.computeDistanceProxy
Defined in src/collision/shape/EdgeShape.ts:297
Parameters:
| Name | Type |
|---|---|
proxy |
DistanceProxy |
Returns: void
computeMass
▸ computeMass(massData: MassData, density?: number): void
Overrides Shape.computeMass
Defined in src/collision/shape/EdgeShape.ts:291
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
Overrides Shape.getChildCount
Defined in src/collision/shape/EdgeShape.ts:187
Get the number of child primitives.
Returns: 1
getNextVertex
▸ getNextVertex(): Vec2
Defined in src/collision/shape/EdgeShape.ts:124
Optional next vertex, used for smooth collision.
Returns: Vec2
getPrevVertex
▸ getPrevVertex(): Vec2
Defined in src/collision/shape/EdgeShape.ts:150
Optional prev vertex, used for smooth collision.
Returns: Vec2
getRadius
▸ getRadius(): number
Inherited from Shape.getRadius
Defined in src/collision/Shape.ts:62
Returns: number
getType
▸ getType(): ShapeType
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.
rayCast
▸ rayCast(output: RayCastOutput, input: RayCastInput, xf: Transform, childIndex: number): boolean
Defined in src/collision/shape/EdgeShape.ts:210
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
setNextVertex
▸ setNextVertex(v?: Vec2): EdgeShape
Defined in src/collision/shape/EdgeShape.ts:110
Optional next vertex, used for smooth collision.
Parameters:
| Name | Type |
|---|---|
v? |
Vec2 |
Returns: EdgeShape
setPrevVertex
▸ setPrevVertex(v?: Vec2): EdgeShape
Defined in src/collision/shape/EdgeShape.ts:136
Optional prev vertex, used for smooth collision.
Parameters:
| Name | Type |
|---|---|
v? |
Vec2 |
Returns: EdgeShape
testPoint
▸ testPoint(xf: Transform, p: Vec2): false
Defined in src/collision/shape/EdgeShape.ts:198
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: false
Static isValid
▸ isValid(shape: Shape | null | undefined): shape is Shape
Defined in src/collision/Shape.ts:58
Parameters:
| Name | Type |
|---|---|
shape |
Shape | null | undefined |
Returns: shape is Shape