Skip to content

Add/remove mesh instance #7844

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

LeXXik
Copy link
Contributor

@LeXXik LeXXik commented Jul 21, 2025

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 LeXXik marked this pull request as ready for review July 21, 2025 11:32
@Maksims
Copy link
Collaborator

Maksims commented Jul 21, 2025

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RenderComponent - ability to dynamically add/remove MeshInstance.
2 participants