2020-07-28 20:21:55 -07:00
|
|
|
|
[Planck.js API Doc](../README.md) › [Globals](../globals.md) › [DistanceProxy](distanceproxy.md)
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
2020-07-28 20:21:55 -07:00
|
|
|
|
# Class: DistanceProxy
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
2021-04-16 17:10:15 +02:00
|
|
|
|
A distance proxy is used by the GJK algorithm. It encapsulates any shape.
|
|
|
|
|
|
|
2020-07-27 00:12:01 -07:00
|
|
|
|
## Hierarchy
|
|
|
|
|
|
|
|
|
|
|
|
* **DistanceProxy**
|
|
|
|
|
|
|
|
|
|
|
|
## Index
|
|
|
|
|
|
|
2020-07-28 20:21:55 -07:00
|
|
|
|
### Constructors
|
|
|
|
|
|
|
|
|
|
|
|
* [constructor](distanceproxy.md#constructor)
|
|
|
|
|
|
|
2020-07-27 00:12:01 -07:00
|
|
|
|
### Properties
|
|
|
|
|
|
|
|
|
|
|
|
* [m_buffer](distanceproxy.md#m_buffer)
|
|
|
|
|
|
* [m_count](distanceproxy.md#m_count)
|
|
|
|
|
|
* [m_radius](distanceproxy.md#m_radius)
|
|
|
|
|
|
* [m_vertices](distanceproxy.md#m_vertices)
|
|
|
|
|
|
|
|
|
|
|
|
### Methods
|
|
|
|
|
|
|
|
|
|
|
|
* [getSupport](distanceproxy.md#getsupport)
|
|
|
|
|
|
* [getSupportVertex](distanceproxy.md#getsupportvertex)
|
|
|
|
|
|
* [getVertex](distanceproxy.md#getvertex)
|
|
|
|
|
|
* [getVertexCount](distanceproxy.md#getvertexcount)
|
|
|
|
|
|
* [set](distanceproxy.md#set)
|
|
|
|
|
|
|
2020-07-28 20:21:55 -07:00
|
|
|
|
## Constructors
|
|
|
|
|
|
|
|
|
|
|
|
### constructor
|
|
|
|
|
|
|
|
|
|
|
|
\+ **new DistanceProxy**(): *[DistanceProxy](distanceproxy.md)*
|
|
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/collision/Distance.ts:235](https://github.com/shakiba/planck.js/blob/acc3bd8/src/collision/Distance.ts#L235)*
|
2020-07-28 20:21:55 -07:00
|
|
|
|
|
|
|
|
|
|
**Returns:** *[DistanceProxy](distanceproxy.md)*
|
|
|
|
|
|
|
2020-07-27 00:12:01 -07:00
|
|
|
|
## Properties
|
|
|
|
|
|
|
|
|
|
|
|
### m_buffer
|
|
|
|
|
|
|
2021-05-02 17:18:33 -07:00
|
|
|
|
• **m_buffer**: *[Vec2](vec2.md)[]*
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/collision/Distance.ts:232](https://github.com/shakiba/planck.js/blob/acc3bd8/src/collision/Distance.ts#L232)*
|
2020-08-03 20:19:01 -07:00
|
|
|
|
|
|
|
|
|
|
internal
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### m_count
|
|
|
|
|
|
|
|
|
|
|
|
• **m_count**: *number*
|
|
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/collision/Distance.ts:234](https://github.com/shakiba/planck.js/blob/acc3bd8/src/collision/Distance.ts#L234)*
|
2020-08-03 20:19:01 -07:00
|
|
|
|
|
|
|
|
|
|
internal
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### m_radius
|
|
|
|
|
|
|
|
|
|
|
|
• **m_radius**: *number*
|
|
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/collision/Distance.ts:235](https://github.com/shakiba/planck.js/blob/acc3bd8/src/collision/Distance.ts#L235)*
|
2020-08-03 20:19:01 -07:00
|
|
|
|
|
|
|
|
|
|
internal
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### m_vertices
|
|
|
|
|
|
|
2021-05-02 17:18:33 -07:00
|
|
|
|
• **m_vertices**: *[Vec2](vec2.md)[]*
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/collision/Distance.ts:233](https://github.com/shakiba/planck.js/blob/acc3bd8/src/collision/Distance.ts#L233)*
|
2020-08-03 20:19:01 -07:00
|
|
|
|
|
|
|
|
|
|
internal
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
## Methods
|
|
|
|
|
|
|
|
|
|
|
|
### getSupport
|
|
|
|
|
|
|
|
|
|
|
|
▸ **getSupport**(`d`: [Vec2](vec2.md)): *number*
|
|
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/collision/Distance.ts:263](https://github.com/shakiba/planck.js/blob/acc3bd8/src/collision/Distance.ts#L263)*
|
2021-04-16 17:10:15 +02:00
|
|
|
|
|
|
|
|
|
|
Get the supporting vertex index in the given direction.
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Parameters:**
|
|
|
|
|
|
|
|
|
|
|
|
Name | Type |
|
|
|
|
|
|
------ | ------ |
|
|
|
|
|
|
`d` | [Vec2](vec2.md) |
|
|
|
|
|
|
|
|
|
|
|
|
**Returns:** *number*
|
|
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### getSupportVertex
|
|
|
|
|
|
|
|
|
|
|
|
▸ **getSupportVertex**(`d`: [Vec2](vec2.md)): *[Vec2](vec2.md)*
|
|
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/collision/Distance.ts:279](https://github.com/shakiba/planck.js/blob/acc3bd8/src/collision/Distance.ts#L279)*
|
2021-04-16 17:10:15 +02:00
|
|
|
|
|
|
|
|
|
|
Get the supporting vertex in the given direction.
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Parameters:**
|
|
|
|
|
|
|
|
|
|
|
|
Name | Type |
|
|
|
|
|
|
------ | ------ |
|
|
|
|
|
|
`d` | [Vec2](vec2.md) |
|
|
|
|
|
|
|
|
|
|
|
|
**Returns:** *[Vec2](vec2.md)*
|
|
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### getVertex
|
|
|
|
|
|
|
|
|
|
|
|
▸ **getVertex**(`index`: number): *[Vec2](vec2.md)*
|
|
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/collision/Distance.ts:255](https://github.com/shakiba/planck.js/blob/acc3bd8/src/collision/Distance.ts#L255)*
|
2021-04-16 17:10:15 +02:00
|
|
|
|
|
|
|
|
|
|
Get a vertex by index. Used by Distance.
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Parameters:**
|
|
|
|
|
|
|
|
|
|
|
|
Name | Type |
|
|
|
|
|
|
------ | ------ |
|
|
|
|
|
|
`index` | number |
|
|
|
|
|
|
|
|
|
|
|
|
**Returns:** *[Vec2](vec2.md)*
|
|
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### getVertexCount
|
|
|
|
|
|
|
|
|
|
|
|
▸ **getVertexCount**(): *number*
|
|
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/collision/Distance.ts:248](https://github.com/shakiba/planck.js/blob/acc3bd8/src/collision/Distance.ts#L248)*
|
2021-04-16 17:10:15 +02:00
|
|
|
|
|
|
|
|
|
|
Get the vertex count.
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Returns:** *number*
|
|
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### set
|
|
|
|
|
|
|
|
|
|
|
|
▸ **set**(`shape`: [Shape](shape.md), `index`: number): *void*
|
|
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/collision/Distance.ts:287](https://github.com/shakiba/planck.js/blob/acc3bd8/src/collision/Distance.ts#L287)*
|
2021-04-16 17:10:15 +02:00
|
|
|
|
|
|
|
|
|
|
Initialize the proxy using the given shape. The shape must remain in scope
|
|
|
|
|
|
while the proxy is in use.
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Parameters:**
|
|
|
|
|
|
|
|
|
|
|
|
Name | Type |
|
|
|
|
|
|
------ | ------ |
|
|
|
|
|
|
`shape` | [Shape](shape.md) |
|
|
|
|
|
|
`index` | number |
|
|
|
|
|
|
|
|
|
|
|
|
**Returns:** *void*
|