Repository navigation
Conversation
This enables rendering thousands of identical objects (e.g., robot trajectories)
with a single draw call using Three.js InstancedMesh.
Features:
- New InstancedMesh class in geometry.py for creating instanced objects
- set_instance_matrices() for efficient batch transform updates
- set_instance_colors() for per-instance coloring
- Full JavaScript viewer support with dynamic buffer updates
Performance: ~100x faster than individual objects for 1000+ instances
Example usage:
```python
from meshcat.geometry import InstancedMesh, Box, MeshPhongMaterial
# Create 1000 instances
instanced = InstancedMesh(Box([0.1, 0.1, 0.1]), MeshPhongMaterial(), count=1000)
for i in range(1000):
instanced.set_matrix_at(i, translation_matrix)
vis["robots"].set_object(instanced)
# Efficient updates (only sends transforms, not geometry)
vis["robots"].set_instance_matrices(new_matrices)
```
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Changes
Python (
meshcat-python):geometry.py: NewInstancedMeshclass withset_matrix_at(),set_matrices(),set_color_at(),set_colors()methodscommands.py: NewSetInstanceMatricesandSetInstanceColorscommands for efficient updatesvisualizer.py: Newset_instance_matrices()andset_instance_colors()methodszmqserver.py: Added new command typesJavaScript (
meshcatviewer):index.js: Handler for_InstancedMeshobject type andset_instance_matrices/set_instance_colorscommandsUsage Example
Test plan
examples/instanced_mesh_simple.py- basic grid animationexamples/instanced_mesh_demo.py- full feature demo with performance comparison🤖 Generated with Claude Code