From 1cdb5e65bb840352385b622080b067213630d16d Mon Sep 17 00:00:00 2001 From: Daniel Greenheck Date: Fri, 23 Feb 2024 22:51:28 -0500 Subject: [PATCH] Fixed instance id null checks --- scripts/worldChunk.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/worldChunk.js b/scripts/worldChunk.js index e057a3bd..2ce316af 100644 --- a/scripts/worldChunk.js +++ b/scripts/worldChunk.js @@ -337,7 +337,7 @@ export class WorldChunk extends THREE.Group { const block = this.getBlock(x, y, z); // If this block is non-empty and does not already have an instance, create a new one - if (block && block.id !== blocks.empty.id && !block.instanceId) { + if (block && block.id !== blocks.empty.id && block.instanceId === null) { // Append a new instance to the end of our InstancedMesh const mesh = this.children.find((instanceMesh) => instanceMesh.name === block.id); const instanceId = mesh.count++; @@ -364,7 +364,7 @@ export class WorldChunk extends THREE.Group { deleteBlockInstance(x, y, z) { const block = this.getBlock(x, y, z); - if (block.id === blocks.empty.id || !block.instanceId) return; + if (block.id === blocks.empty.id || block.instanceId === null) return; // Get the mesh and instance id of the block const mesh = this.children.find((instanceMesh) => instanceMesh.name === block.id); @@ -394,7 +394,7 @@ export class WorldChunk extends THREE.Group { mesh.instanceMatrix.needsUpdate = true; mesh.computeBoundingSphere(); - this.setBlockInstanceId(x, y, z, undefined); + this.setBlockInstanceId(x, y, z, null); } /**