2020-07-28 20:21:55 -07:00
|
|
|
|
[Planck.js API Doc](../README.md) › [Globals](../globals.md) › [Shape](shape.md)
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
2020-07-28 20:21:55 -07:00
|
|
|
|
# Class: Shape
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
## Hierarchy
|
|
|
|
|
|
|
|
|
|
|
|
* **Shape**
|
|
|
|
|
|
|
|
|
|
|
|
## Index
|
|
|
|
|
|
|
|
|
|
|
|
### Methods
|
|
|
|
|
|
|
|
|
|
|
|
* [computeAABB](shape.md#computeaabb)
|
|
|
|
|
|
* [computeDistanceProxy](shape.md#computedistanceproxy)
|
|
|
|
|
|
* [computeMass](shape.md#computemass)
|
|
|
|
|
|
* [getChildCount](shape.md#getchildcount)
|
|
|
|
|
|
* [getRadius](shape.md#getradius)
|
|
|
|
|
|
* [getType](shape.md#gettype)
|
|
|
|
|
|
* [isValid](shape.md#isvalid)
|
|
|
|
|
|
* [rayCast](shape.md#raycast)
|
|
|
|
|
|
* [testPoint](shape.md#testpoint)
|
|
|
|
|
|
|
|
|
|
|
|
## Methods
|
|
|
|
|
|
|
|
|
|
|
|
### computeAABB
|
|
|
|
|
|
|
|
|
|
|
|
▸ **computeAABB**(`aabb`: [AABB](aabb.md), `xf`: [Transform](transform.md), `childIndex?`: number): *void*
|
|
|
|
|
|
|
2020-08-03 20:19:01 -07:00
|
|
|
|
*Defined in [shape/index.d.ts:18](https://github.com/shakiba/planck.js/blob/038d425/lib/shape/index.d.ts#L18)*
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Parameters:**
|
|
|
|
|
|
|
|
|
|
|
|
Name | Type |
|
|
|
|
|
|
------ | ------ |
|
|
|
|
|
|
`aabb` | [AABB](aabb.md) |
|
|
|
|
|
|
`xf` | [Transform](transform.md) |
|
|
|
|
|
|
`childIndex?` | number |
|
|
|
|
|
|
|
|
|
|
|
|
**Returns:** *void*
|
|
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### computeDistanceProxy
|
|
|
|
|
|
|
|
|
|
|
|
▸ **computeDistanceProxy**(`proxy`: [DistanceProxy](distanceproxy.md)): *void*
|
|
|
|
|
|
|
2020-08-03 20:19:01 -07:00
|
|
|
|
*Defined in [shape/index.d.ts:20](https://github.com/shakiba/planck.js/blob/038d425/lib/shape/index.d.ts#L20)*
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Parameters:**
|
|
|
|
|
|
|
|
|
|
|
|
Name | Type |
|
|
|
|
|
|
------ | ------ |
|
|
|
|
|
|
`proxy` | [DistanceProxy](distanceproxy.md) |
|
|
|
|
|
|
|
|
|
|
|
|
**Returns:** *void*
|
|
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### computeMass
|
|
|
|
|
|
|
2020-07-28 20:21:55 -07:00
|
|
|
|
▸ **computeMass**(`massData`: [MassData](../interfaces/massdata.md), `density?`: number): *void*
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
2020-08-03 20:19:01 -07:00
|
|
|
|
*Defined in [shape/index.d.ts:19](https://github.com/shakiba/planck.js/blob/038d425/lib/shape/index.d.ts#L19)*
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Parameters:**
|
|
|
|
|
|
|
|
|
|
|
|
Name | Type |
|
|
|
|
|
|
------ | ------ |
|
2020-07-28 20:21:55 -07:00
|
|
|
|
`massData` | [MassData](../interfaces/massdata.md) |
|
2020-07-27 00:12:01 -07:00
|
|
|
|
`density?` | number |
|
|
|
|
|
|
|
|
|
|
|
|
**Returns:** *void*
|
|
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### getChildCount
|
|
|
|
|
|
|
|
|
|
|
|
▸ **getChildCount**(): *number*
|
|
|
|
|
|
|
2020-08-03 20:19:01 -07:00
|
|
|
|
*Defined in [shape/index.d.ts:15](https://github.com/shakiba/planck.js/blob/038d425/lib/shape/index.d.ts#L15)*
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Returns:** *number*
|
|
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### getRadius
|
|
|
|
|
|
|
|
|
|
|
|
▸ **getRadius**(): *number*
|
|
|
|
|
|
|
2020-08-03 20:19:01 -07:00
|
|
|
|
*Defined in [shape/index.d.ts:13](https://github.com/shakiba/planck.js/blob/038d425/lib/shape/index.d.ts#L13)*
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Returns:** *number*
|
|
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### getType
|
|
|
|
|
|
|
2020-07-28 20:21:55 -07:00
|
|
|
|
▸ **getType**(): *[ShapeType](../globals.md#shapetype)*
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
2020-08-03 20:19:01 -07:00
|
|
|
|
*Defined in [shape/index.d.ts:14](https://github.com/shakiba/planck.js/blob/038d425/lib/shape/index.d.ts#L14)*
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
2020-07-28 20:21:55 -07:00
|
|
|
|
**Returns:** *[ShapeType](../globals.md#shapetype)*
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### isValid
|
|
|
|
|
|
|
|
|
|
|
|
▸ **isValid**(`shape`: any): *boolean*
|
|
|
|
|
|
|
2020-08-03 20:19:01 -07:00
|
|
|
|
*Defined in [shape/index.d.ts:12](https://github.com/shakiba/planck.js/blob/038d425/lib/shape/index.d.ts#L12)*
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Parameters:**
|
|
|
|
|
|
|
|
|
|
|
|
Name | Type |
|
|
|
|
|
|
------ | ------ |
|
|
|
|
|
|
`shape` | any |
|
|
|
|
|
|
|
|
|
|
|
|
**Returns:** *boolean*
|
|
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### rayCast
|
|
|
|
|
|
|
2020-07-28 20:21:55 -07:00
|
|
|
|
▸ **rayCast**(`output`: [RayCastOutput](../interfaces/raycastoutput.md), `input`: [RayCastInput](../interfaces/raycastinput.md), `xf`: [Transform](transform.md), `childIndex?`: number): *boolean*
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
2020-08-03 20:19:01 -07:00
|
|
|
|
*Defined in [shape/index.d.ts:17](https://github.com/shakiba/planck.js/blob/038d425/lib/shape/index.d.ts#L17)*
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Parameters:**
|
|
|
|
|
|
|
|
|
|
|
|
Name | Type |
|
|
|
|
|
|
------ | ------ |
|
2020-07-28 20:21:55 -07:00
|
|
|
|
`output` | [RayCastOutput](../interfaces/raycastoutput.md) |
|
|
|
|
|
|
`input` | [RayCastInput](../interfaces/raycastinput.md) |
|
2020-07-27 00:12:01 -07:00
|
|
|
|
`xf` | [Transform](transform.md) |
|
|
|
|
|
|
`childIndex?` | number |
|
|
|
|
|
|
|
|
|
|
|
|
**Returns:** *boolean*
|
|
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### testPoint
|
|
|
|
|
|
|
|
|
|
|
|
▸ **testPoint**(`xf`: [Transform](transform.md), `p`: [Vec2](vec2.md)): *false*
|
|
|
|
|
|
|
2020-08-03 20:19:01 -07:00
|
|
|
|
*Defined in [shape/index.d.ts:16](https://github.com/shakiba/planck.js/blob/038d425/lib/shape/index.d.ts#L16)*
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Parameters:**
|
|
|
|
|
|
|
|
|
|
|
|
Name | Type |
|
|
|
|
|
|
------ | ------ |
|
|
|
|
|
|
`xf` | [Transform](transform.md) |
|
|
|
|
|
|
`p` | [Vec2](vec2.md) |
|
|
|
|
|
|
|
|
|
|
|
|
**Returns:** *false*
|