playcanvas / playcanvas/engine
RenderComponent - ability to dynamically add/remove MeshInstance.
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 16.8k
- Forks
- 2k
- Avg merge
- 4h 32m
- Merged PRs (30d)
- 222
Description
When creating procedural meshes, sometimes it is beneficial to add them to a single render component. Currently, if you set a new array of mesh instances, previous ones will be destroyed - which is not always desirable. So adding mesh instances not in one go is not convenient atm.
I wrote a quick workaround for this:
// add MeshInstance to RenderComponent
const meshInstances = entity.render.meshInstances.slice(0);
entity.render._meshInstances = [];
meshInstances.push(this.meshInstance);
entity.render.meshInstances = meshInstances;
Of course this is not great, so it would be good to have a public API for it, something like:
entity.render.addMeshInstance(meshInstasnce);
entity.render.removeMeshInstance(meshInstance);
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the RenderComponent implementation and the meshInstances property setter, then inspect related tests if present. Determine how mesh instances are currently stored and destroyed before defining the add and remove behavior. Done means a public API supports incremental changes without unexpectedly destroying existing mesh instances, with coverage for both operations.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- computer-graphics, game-dev
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100