playcanvas / playcanvas/engine

RenderComponent - ability to dynamically add/remove MeshInstance.

Open
#6,680 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

area: graphics enhancement
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.