Skip to content
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: add support for resizing instance count, geometry size #29577

Merged
merged 8 commits into from
Oct 8, 2024

Conversation

gkjohnson
Copy link
Collaborator

Related issue: #29464

Description

Adds support for Batched setGeometrySize and setInstanceCount. If adequate extents of the necessary geometry and instance buffers remain unused then the buffers can be shrunk, as well. However due to buffer fragmentation after adding / removing geometry and instances to and from the BatchedMesh it may not be possible to shrink the buffer - eg if 1000 instances are added and then the first 999 are removed. We could handle this case if we were to re-map ids so the data in this buffers could be rearranged without breaking references but we've decided not to do that for complexity reasons, which I think is okay.

To help with that issue the add geometry and instance functions have been adjusted to use earlier ids.

Tested by resizing geometry and instance buffers in the batched mesh demo and ensuring that there were no visual changes.

@gkjohnson gkjohnson added this to the r170 milestone Oct 7, 2024
@gkjohnson gkjohnson marked this pull request as ready for review October 7, 2024 13:39
Copy link

github-actions bot commented Oct 7, 2024

📦 Bundle size

Full ESM build, minified and gzipped.

Before After Diff
WebGL 688.12
170.5
689.82
170.9
+1.71 kB
+403 B
WebGPU 808.01
217.65
809.73
218.11
+1.72 kB
+462 B
WebGPU Nodes 807.52
217.52
809.24
217.98
+1.72 kB
+462 B

🌳 Bundle size after tree-shaking

Minimal build including a renderer, camera, empty scene, and dependencies.

Before After Diff
WebGL 462.84
111.78
462.84
111.78
+0 B
+0 B
WebGPU 535.76
144.59
535.76
144.59
+0 B
+0 B
WebGPU Nodes 491.87
134.33
491.87
134.33
+0 B
+0 B

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants