Class: MapIndexedColliderCollection
Defined in: src/sdk/components/map/colliders/MapIndexedColliderCollection.ts:108
A spatially indexed collection of MapIndexedCollider objects. This collection supports collision (intersection) testing against simple shapes on all members of the collection at once, allowing you to enumerate all members that collide with a given shape.
Members are stored in a spatial index tree. The tree divides the area contained in the collection's
bounds in half at each depth level, alternating between the x (horizontal) and y (vertical) axes
at each successive level. Each division forms a cell (node) in the tree. When a collider is added to the collection,
it is sorted into those cells that intersect its axis-aligned bounding box. This partitioning scheme results in an
expected O(n / 2^d + d) time complexity for intersection tests against the collection, where n is the number of
colliders in the collection and d is the depth of the tree. This assumes colliders are at least roughly uniformly
distributed in position and most colliders are sorted into only one leaf cell.
Constructors
Constructor
new MapIndexedColliderCollection(
options?):MapIndexedColliderCollection
Defined in: src/sdk/components/map/colliders/MapIndexedColliderCollection.ts:129
Creates a new instance of MapIndexedColliderCollection. The collection is created with initial bounds of size zero.
Parameters
| Parameter | Type | Description |
|---|---|---|
options? | Readonly<MapIndexedColliderCollectionOptions> | Options with which to configure the collection. |
Returns
MapIndexedColliderCollection
Methods
deregister()
deregister(
collider):void
Defined in: src/sdk/components/map/colliders/MapIndexedColliderCollection.ts:467
Deregisters a collider with this collection.
Parameters
| Parameter | Type | Description |
|---|---|---|
collider | MapIndexedCollider | The collider to deregister. |
Returns
void
Throws
Error if this collection has been destroyed.
destroy()
destroy():
void
Defined in: src/sdk/components/map/colliders/MapIndexedColliderCollection.ts:780
Destroys this collection.
Returns
void
getBounds()
getBounds():
ReadonlyFloat64Array
Defined in: src/sdk/components/map/colliders/MapIndexedColliderCollection.ts:156
Gets the bounds of this collection, as [minX, minY, maxX, maxY] in pixels. Intersection tests against this
collection that fall outside the bounds will always fail to return any intersections.
Returns
The bounds of this collection, as [minX, minY, maxX, maxY] in pixels.
Throws
Error if this collection has been destroyed.
See
getDepth()
getDepth():
number
Defined in: src/sdk/components/map/colliders/MapIndexedColliderCollection.ts:172
Gets the depth of this collection's spatial index tree. A depth of zero effectively disables spatial indexing. Each increase of one in depth halves the area of the cells (buckets) into which the collection's colliders are sorted.
Returns
number
The depth of this collection's spatial index tree.
Throws
Error if this collection has been destroyed.
See
getFirstSplitAxis()
getFirstSplitAxis():
"x"|"y"|"auto"
Defined in: src/sdk/components/map/colliders/MapIndexedColliderCollection.ts:191
Gets the axis along which the collection's spatial index tree first splits its cells. At each successive level of
the tree, the axis along with the cells are split alternates between x (horizontal) and y (vertical). The 'x'
option indicates the tree is split along the x axis at level 1, then the y axis at level 2, then the x axis at
level 3, etc. The 'y' option indicates the tree is split along the y axis at level 1, then the x axis at level
2, then the y axis at level 3, etc. The 'auto' option indicates the tree automatically selects the first-split
axis to be the one along which the collection's bounds is longest.
Returns
"x" | "y" | "auto"
The axis along which the collection's spatial index tree first splits its cells.
Throws
Error if this collection has been destroyed.
See
intersectBox()
intersectBox(
cx,cy,axisX,axisY,halfWidth,halfHeight,mapProjection,out):MapIndexedCollider[]
Defined in: src/sdk/components/map/colliders/MapIndexedColliderCollection.ts:508
Finds all colliders in this collection that intersect an oriented rectangular box. If the specified box lies outside this collection's bounds, then the test is guaranteed to return zero colliders.
Parameters
| Parameter | Type | Description |
|---|---|---|
cx | number | The x coordinate of the center of the box. |
cy | number | The y coordinate of the center of the box. |
axisX | number | The x component of the unit vector parallel to the axis that defines the box's width. |
axisY | number | The y component of the unit vector parallel to the axis that defines the box's width. |
halfWidth | number | The half width of the box. |
halfHeight | number | The half height of the box. |
mapProjection | MapProjection | The map projection. |
out | unknown[] | The array to which to write the results. |
Returns
All colliders in this collection that intersect the specified oriented rectangular box, in order of decreasing priority.
Throws
Error if this collection has been destroyed.
intersectCircle()
intersectCircle(
cx,cy,radius,mapProjection,out):MapIndexedCollider[]
Defined in: src/sdk/components/map/colliders/MapIndexedColliderCollection.ts:633
Finds all colliders in this collection that intersect a circle. If the specified circle lies outside this collection's bounds, then the test is guaranteed to return zero colliders.
Parameters
| Parameter | Type | Description |
|---|---|---|
cx | number | The x coordinate of the center of the circle. |
cy | number | The y coordinate of the center of the circle. |
radius | number | The radius of the circle. |
mapProjection | MapProjection | The map projection. |
out | unknown[] | The array to which to write the results. |
Returns
All colliders in this collection that intersect the specified circle, in order of decreasing priority.
Throws
Error if this collection has been destroyed.
register()
register(
collider):void
Defined in: src/sdk/components/map/colliders/MapIndexedColliderCollection.ts:443
Registers a collider with this collection.
Parameters
| Parameter | Type | Description |
|---|---|---|
collider | MapIndexedCollider | The collider to register. |
Returns
void
Throws
Error if this collection has been destroyed.
setBounds()
setBounds(
bounds):void
Defined in: src/sdk/components/map/colliders/MapIndexedColliderCollection.ts:207
Sets the bounds of this collection. Intersection tests against this collection that fall outside the bounds will always fail to return any intersections.
Parameters
| Parameter | Type | Description |
|---|---|---|
bounds | ReadonlyFloat64Array | The bounds to set, as [minX, minY, maxX, maxY] in pixels. |
Returns
void
Throws
Error if this collection has been destroyed.
See
setDepth()
setDepth(
depth):void
Defined in: src/sdk/components/map/colliders/MapIndexedColliderCollection.ts:225
Sets the depth of this collection's spatial index tree. A depth of zero effectively disables spatial indexing. Each increase of one in depth halves the area of the cells (buckets) into which the collection's colliders are sorted. Larger depths potentially increase the performance of intersection queries on the collection, but also increase the overhead needed to maintain the spatial index.
Parameters
| Parameter | Type | Description |
|---|---|---|
depth | number | The depth to set. |
Returns
void
Throws
Error if this collection has been destroyed.
See
setFirstSplitAxis()
setFirstSplitAxis(
axis):void
Defined in: src/sdk/components/map/colliders/MapIndexedColliderCollection.ts:245
Sets the axis along which the collection's spatial index tree first splits its cells. At each successive level of
the tree, the axis along with the cells are split alternates between x (horizontal) and y (vertical). The 'x'
option will cause the tree to split along the x axis at level 1, then the y axis at level 2, then the x axis at
level 3, etc. The 'y' option will cause the tree to split along the y axis at level 1, then the x axis at level
2, then the y axis at level 3, etc. The 'auto' option will cause the tree to select the first-split axis to be
the one along which the collection's bounds is longest.
Parameters
| Parameter | Type | Description |
|---|---|---|
axis | "x" | "y" | "auto" | The axis to set. |
Returns
void
Throws
Error if this collection has been destroyed.
See
setParams()
setParams(
bounds?,depth?,firstSplitAxis?):void
Defined in: src/sdk/components/map/colliders/MapIndexedColliderCollection.ts:265
Sets various parameters of this collection. Calling this method when changing multiple parameters is more efficient than calling the methods to set the individual parameters separately.
Parameters
| Parameter | Type | Description |
|---|---|---|
bounds? | Readonly<Omit<Float64Array<ArrayBufferLike>, "set" | "sort" | "copyWithin">> | The bounds of this collection to set, as [minX, minY, maxX, maxY] in pixels. If not defined, then the bounds will not be changed. See setBounds() for more information on setting bounds. |
depth? | number | The depth of this collection's spatial index tree to set. If not defined, then the depth will not be changed. See setDepth() on setting depth. |
firstSplitAxis? | "x" | "y" | "auto" | The axis along which the collection's spatial index tree first splits its cells. If not defined, then the first-split axis will not be changed. See setFirstSplitAxis() for more information on setting the first-split axis. |
Returns
void
Throws
Error if this collection has been destroyed.