const layers = defineCollisionLayers({ player: ['enemy'], enemy: ['player'] });
const ecs = ECSpresso
.create()
.withPlugin(createTransform3DPlugin())
.withPlugin(createCollision3DPlugin({ layers }))
.build();
ecs.eventBus.subscribe('collision3D', (data) => {
console.log(data.entityA, data.entityB, data.normalZ);
});
Create a 3D collision plugin for ECSpresso.
Provides layer-based collision detection between entities with 3D colliders, publishing
collision3Devents on contact. Supports AABB3D-AABB3D, sphere-sphere, and AABB3D-sphere tests. Automatically uses thespatialIndex3Dresource for broadphase when present.