Skip to main content

Many Colliders

This example demonstrates the performance of the engine when using many colliders.

info

Some recent changes in the engine have resulted in a performance regression when creating a large number of meshes.

This is a known issue and will be fixed in a future release.

const boxMesh = createBoxMesh(1, 1, 1);
for (let level = 0; level < 6; level++) {
for (let row = 0; row < 10; row++) {
for (let col = 0; col < 10; col++) {
const x = -9 + (18 / 10) * col;
const y = 0.5 + 3 * level;
const z = -9 + (18 / 10) * row;
const entity = this.world.createEntity();
this.world.addComponents(entity, [
new TTransformComponent(new TTransform(vec3.fromValues(x, y, z))),
),
new TMeshComponent({ source: 'inline', geometry: boxMesh.geometry }),
new TMaterialComponent(boxMesh.material),
new TRigidBodyComponent({ mass: 1 }, createBoxCollider(1, 1, 1)),
]);
}
}
}