-
-
Notifications
You must be signed in to change notification settings - Fork 35.5k
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
BatchedMesh setGeometryIdAt getGeometryIdAt #29343
Conversation
📦 Bundle sizeFull ESM build, minified and gzipped.
🌳 Bundle size after tree-shakingMinimal build including a renderer, camera, empty scene, and dependencies.
|
Think this could warrant an example, or perhaps an option for displaying this dynamic switching in one of the existing batch examples. |
@cmhhelgeson Example patched 👍 |
I'm testing the branch using this link: https://raw.githack.com/Makio64/three.js-BatchedMesh-geometryIdAt/dev/examples/webgpu_mesh_batch.html I'm receiving the error below upon clicking Randomize Geometry: |
Testing these kinds of live links will not work without updated three.js build files. |
@cmhhelgeson @gkjohnson Its my first PR since long time on threejs, should I add the new build to my PR for testing purpose ? |
No adding the build files will often result in merge conflicts. I just intended to say that if you want to test the PR then you need to pull and run the branch locally. |
@gkjohnson @cmhhelgeson It should be good to go now. Let me know if you feel it needs other changes. |
This PR add the possibility to switch the geometryId of an instance with setGeometryIdAt and to get the geometryId of an instance with getGeometryIdAt.
This PR implement this feature in the same way than set/get of matrix/color/visibility.
Before the PR
batchedMesh._drawInfo[instanceId].geometryIndex = geometryId
X
After the PR
batchedMesh.setGeometryIdAt(instanceId, geometryId)
batchedMesh.getGeometryIdAt(instanceId)
Why ?
Currently we can replace a geometry by another but we cant change the geometry use by an instance.
For example in game, while the player explore the level sometimes I needs more instance with rocks geometry and less with trees geometry and sometimes the opposite. In this case with this feature we can re-use the instance in a clever way updating only their geometryId.