Skip to content

Commit

Permalink
Fixed instance id null checks
Browse files Browse the repository at this point in the history
  • Loading branch information
dgreenheck committed May 26, 2024
1 parent 68ec66f commit 1cdb5e6
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions scripts/worldChunk.js
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
Expand All @@ -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);
Expand Down Expand Up @@ -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);
}

/**
Expand Down

0 comments on commit 1cdb5e6

Please sign in to comment.