working light system

This commit is contained in:
LabyStudio
2022-02-02 15:18:45 +01:00
parent 1fc627b501
commit 010d883273
6 changed files with 28 additions and 46 deletions
@@ -20,7 +20,7 @@ window.ChunkSection = class {
this.group = new THREE.Object3D();
this.group.matrixAutoUpdate = false;
this.queuedForRebuild = true;
this.isModified = false;
this.blocks = [];
this.blockLight = [];
@@ -44,7 +44,7 @@ window.ChunkSection = class {
}
rebuild(renderer) {
this.queuedForRebuild = false;
this.isModified = false;
this.group.clear();
// Start drawing chunk section
@@ -80,6 +80,8 @@ window.ChunkSection = class {
setBlockAt(x, y, z, typeId) {
let index = y << 8 | z << 4 | x;
this.blocks[index] = typeId;
this.isModified = true;
}
setLightAt(sourceType, x, y, z, lightLevel) {
@@ -91,6 +93,8 @@ window.ChunkSection = class {
if (sourceType === EnumSkyBlock.BLOCK) {
this.blockLight[index] = lightLevel;
}
this.isModified = true;
}
getTotalLightAt(x, y, z) {
@@ -127,12 +131,4 @@ window.ChunkSection = class {
}
return true;
}
queueForRebuild() {
this.queuedForRebuild = true;
}
isQueuedForRebuild() {
return this.queuedForRebuild;
}
}