engine icon indicating copy to clipboard operation
engine copied to clipboard

Add/remove mesh instance

Open LeXXik opened this issue 5 months ago • 2 comments

Fixes #6680

Adds new API:

const mesh = Mesh.fromGeometry(app.graphicsDevice, new BoxGeometry());
const instance = new MeshInstance(mesh, new StandardMaterial());

entity.render.addMeshInstance(instance);
entity.render.removeMeshInstance(instance);

Tests included.

I confirm I have read the contributing guidelines and signed the Contributor License Agreement.

LeXXik avatar Jul 21 '25 11:07 LeXXik

This is very useful! We had cases where we needed to do that, we had to slice the meshInstances array, then modify it and assign again, but that leads to unnecessary re-initializations and layers stuff, is just not efficient to do at runtime as it could be. In this PR there is no unnecessary work, which is great.

Maksims avatar Jul 21 '25 12:07 Maksims

We need this!

Maksims avatar Sep 03 '25 12:09 Maksims