Scene rendering performance optimization plugin based on instance object

1 | Babylon.js Playground (
This is an instance object-based performance optimization plugin that organizes all grids using the same geometry and materials and turns them into instance objects for rendering.
It has all the disadvantages of the instance object, but you can still manipulate the source grid of the instance object map, and the plug-in will update automatically.
When using rays to get to the generated instance object, you can get the mapping source grid via getSourceMesh.
You can also get its instance objects directly using the source grid’s getInstanceInfo.
In some cases, such as the model in this case, the number of render calls can be drastically reduced to improve rendering performance.
It should be noted that if there is skeleton skin or animation in the model, it may cause problems. For unnecessary models, it can be excluded by addExcludedMesh.


Very neat, thanks for sharing! :smiley:

1 Like

Fixed instance objects not updating properly when the source grid scale was changed to 0.
1 | Babylon.js Playground (

Note: If the isVisible of the source grid is changed in the animation, there will be a problem. Because the two isVisible are not the same, simple proxy mapping cannot be done, such as highlighting with HighlightLayer if a single grid needs to be selected, because instance object constraints require that the source grid isVisible be set to true in order to render the correct HighlightLayer.

1 | Babylon.js Playground (
This is the proxy scheme using Object.defineProperty, modifying isVisible of the source grid will be proxyed to isVisible of the instance Object, and you need to modify _isVisible to manipulate the source grid if instance objects exist.