Skip to content
On this page

Class: CollisionListener ​

WebSG.CollisionListener

A Collision Listener provides an interface for listening to collisions events between nodes with colliders. Collision events are recorded for both the start and end of a collision. .collisions() should be called each frame to iterate through the collisions that occurred since the last call to .collisions(). Failing to regularly call .collisions() will result in a memory leak. If you are done listening to collisions, you should call .dispose() to free up the memory used by the collision listener and stop listening to collisions.

Table of contents ​

Constructors ​

Methods ​

Constructors ​

constructor ​

• new CollisionListener()

Methods ​

collisions ​

▸ collisions(): CollisionIterator

Returns an iterator for the collisions that occurred since the last call to .collisions().

Returns ​

CollisionIterator

Defined in ​

websg.d.ts:969


dispose ​

▸ dispose(): void

Disposes of the collision listener and stops listening to collisions.

Returns ​

void

Defined in ​

websg.d.ts:973