We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 4d22d1a commit 09c7b05Copy full SHA for 09c7b05
.changeset/public-bananas-add.md
@@ -0,0 +1,5 @@
1
+---
2
+"@jolly-pixel/voxel.renderer": patch
3
4
+
5
+Remove chunk before rebuilding it
packages/voxel-renderer/src/VoxelRenderer.ts
@@ -782,6 +782,11 @@ export class VoxelRenderer extends ActorComponent {
782
`Rebuilding chunk '${chunkKeyBase}' with layer name '${layer.name}'`
783
);
784
785
+ // Remove any existing meshes for this chunk before adding new ones.
786
+ // This prevents orphaned Three.js objects when a chunk is rebuilt multiple
787
+ // times (e.g. load() followed by awake()).
788
+ this.#removeChunk(layer, chunk);
789
790
const geometries = this.#meshBuilder.buildChunkGeometries(chunk, layer);
791
if (!geometries) {
792
return;
0 commit comments