Skip to content

Conversation

andreas-hilti
Copy link
Contributor

@andreas-hilti andreas-hilti commented Jul 20, 2025

Fixed #31457

Description

setInstanceCount tries to shrink availableInstanceIds as much as it can, by trying to remove ids at the end.
However, the condition was wrong, given that the largest id is instanceInfo.length - 1, not instanceInfo.length.

Copy link

github-actions bot commented Jul 20, 2025

📦 Bundle size

Full ESM build, minified and gzipped.

Before After Diff
WebGL 338.04
78.86
338.04
78.86
+0 B
+0 B
WebGPU 559.11
154.78
559.11
154.78
+0 B
+0 B
WebGPU Nodes 558.03
154.56
558.03
154.56
+0 B
+0 B

🌳 Bundle size after tree-shaking

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

Before After Diff
WebGL 469.29
113.56
469.29
113.56
+0 B
+0 B
WebGPU 634.4
171.81
634.4
171.81
+0 B
+0 B
WebGPU Nodes 589.53
161.13
589.53
161.13
+0 B
+0 B

@andreas-hilti andreas-hilti deleted the fix/setInstanceCount branch July 20, 2025 22:04
@andreas-hilti andreas-hilti restored the fix/setInstanceCount branch July 20, 2025 22:05
@andreas-hilti andreas-hilti reopened this Jul 20, 2025
@gkjohnson gkjohnson added this to the r179 milestone Jul 20, 2025
@gkjohnson
Copy link
Collaborator

Nice find! Thank you for the change. I see the PR is marked as draft. Are there any further changes you plan to make?

@andreas-hilti andreas-hilti marked this pull request as ready for review July 21, 2025 04:30
@andreas-hilti
Copy link
Contributor Author

Nice find! Thank you for the change. I see the PR is marked as draft. Are there any further changes you plan to make?

Thanks. No, but the tests were not yet clean.

@Mugen87 Mugen87 changed the title Fix BatchedMesh.setInstanceCount BatchedMesh: Fix setInstanceCount(). Jul 21, 2025
@Mugen87 Mugen87 merged commit 6a0dab0 into mrdoob:dev Jul 21, 2025
13 of 14 checks passed
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.

BatchedMesh: setInstanceCount can't shrink available instances
3 participants