huge performance improvements

This commit is contained in:
ForestOfLight
2025-04-18 19:16:34 -07:00
Unverified
parent 80aed5f349
commit 79f4605943
11 changed files with 104 additions and 48 deletions
+23 -2
View File
@@ -39,10 +39,10 @@ export class Structure {
}
}
*getLayerBlocks(y) {
*getLayerBlocks(layer) {
for (let x = 0; x < this.#structure.size.x; x++) {
for (let z = 0; z < this.#structure.size.z; z++) {
yield this.getBlock({ x, y, z });
yield this.getBlock({ x, y: layer, z });
}
}
}
@@ -52,5 +52,26 @@ export class Structure {
yield * this.getLayerBlocks(y);
}
}
getLayerLocations(layer) {
const locations = new Set();
for (let x = 0; x < this.#structure.size.x; x++) {
for (let z = 0; z < this.#structure.size.z; z++) {
locations.add(new Vector(x, layer, z));
}
}
return locations;
}
getAllLocations() {
const locations = new Set();
for (let y = 0; y < this.#structure.size.y; y++) {
const layerLocations = this.getLayerLocations(y);
for (const location of layerLocations) {
locations.add(location);
}
}
return locations;
}
}