engine
engine copied to clipboard
Add/remove mesh instance
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.
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.
We need this!