minerender 2.1.0-beta.7 → 2.1.0-beta.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -1
- package/dist/browser/esm/armor/Armor.mjs +84 -0
- package/dist/browser/esm/armor/Armor.mjs.map +1 -0
- package/dist/browser/esm/armor/index.mjs +3 -0
- package/dist/browser/esm/armor/index.mjs.map +1 -0
- package/dist/browser/esm/assets/BlockEntities.mjs +2 -0
- package/dist/browser/esm/assets/BlockEntities.mjs.map +1 -1
- package/dist/browser/esm/assets/Entities.mjs +39 -11
- package/dist/browser/esm/assets/Entities.mjs.map +1 -1
- package/dist/browser/esm/assets/MineRenderData.mjs +8 -17
- package/dist/browser/esm/assets/MineRenderData.mjs.map +1 -1
- package/dist/browser/esm/assets/ModelTextures.mjs +13 -7
- package/dist/browser/esm/assets/ModelTextures.mjs.map +1 -1
- package/dist/browser/esm/assets/_versions/DatasetVersions.mjs +22 -0
- package/dist/browser/esm/assets/_versions/DatasetVersions.mjs.map +1 -0
- package/dist/browser/esm/cache/Caching.mjs +8 -0
- package/dist/browser/esm/cache/Caching.mjs.map +1 -1
- package/dist/browser/esm/entity/scene/EntityObject.mjs +31 -5
- package/dist/browser/esm/entity/scene/EntityObject.mjs.map +1 -1
- package/dist/browser/esm/env/browser/BrowserEnv.mjs +11 -4
- package/dist/browser/esm/env/browser/BrowserEnv.mjs.map +1 -1
- package/dist/browser/esm/index.browser.d.mts +129 -13
- package/dist/browser/esm/index.browser.mjs.map +1 -1
- package/dist/browser/esm/index.mjs +1 -0
- package/dist/browser/esm/index.mjs.map +1 -1
- package/dist/browser/esm/model/ItemGlint.mjs +7 -6
- package/dist/browser/esm/model/ItemGlint.mjs.map +1 -1
- package/dist/browser/esm/model/block/scene/BlockObject.mjs +16 -5
- package/dist/browser/esm/model/block/scene/BlockObject.mjs.map +1 -1
- package/dist/browser/esm/scene/SceneDocument.mjs +35 -5
- package/dist/browser/esm/scene/SceneDocument.mjs.map +1 -1
- package/dist/browser/esm/scene/SceneDocumentLoader.mjs +14 -3
- package/dist/browser/esm/scene/SceneDocumentLoader.mjs.map +1 -1
- package/dist/browser/esm/skin/SkinGeometries.mjs +4 -1
- package/dist/browser/esm/skin/SkinGeometries.mjs.map +1 -1
- package/dist/browser/esm/skin/SkinPart.mjs +2 -0
- package/dist/browser/esm/skin/SkinPart.mjs.map +1 -1
- package/dist/browser/esm/skin/SkinTextureCoordinates.mjs +11 -1
- package/dist/browser/esm/skin/SkinTextureCoordinates.mjs.map +1 -1
- package/dist/browser/esm/skin/SkinTextures.mjs +1 -1
- package/dist/browser/esm/skin/SkinTextures.mjs.map +1 -1
- package/dist/browser/esm/skin/scene/SkinObject.mjs +119 -7
- package/dist/browser/esm/skin/scene/SkinObject.mjs.map +1 -1
- package/dist/browser/esm/texture/PalettedTextures.mjs +46 -0
- package/dist/browser/esm/texture/PalettedTextures.mjs.map +1 -0
- package/dist/browser/esm/texture/index.mjs +1 -0
- package/dist/browser/esm/texture/index.mjs.map +1 -1
- package/dist/browser/esm/util/util.mjs +0 -2
- package/dist/browser/esm/util/util.mjs.map +1 -1
- package/dist/browser/esm/world/Chunk.mjs +62 -33
- package/dist/browser/esm/world/Chunk.mjs.map +1 -1
- package/dist/browser/esm/world/MineRenderWorld.mjs +98 -13
- package/dist/browser/esm/world/MineRenderWorld.mjs.map +1 -1
- package/dist/browser/esm/world/SectionMesh.mjs +65 -9
- package/dist/browser/esm/world/SectionMesh.mjs.map +1 -1
- package/dist/browser/esm/world/SectionModels.mjs +21 -15
- package/dist/browser/esm/world/SectionModels.mjs.map +1 -1
- package/dist/browser/esm/world/SectionWorker.mjs +8 -2
- package/dist/browser/esm/world/SectionWorker.mjs.map +1 -1
- package/dist/browser/esm/world/WorldStreamer.mjs +109 -15
- package/dist/browser/esm/world/WorldStreamer.mjs.map +1 -1
- package/dist/browser/index.d.ts +129 -13
- package/dist/browser/index.js +1592 -894
- package/dist/browser/index.js.map +1 -1
- package/dist/bundle.js +1330 -619
- package/dist/bundle.js.map +1 -1
- package/dist/node/index.d.mts +117 -12
- package/dist/node/index.d.ts +117 -12
- package/dist/node/index.js +1505 -793
- package/dist/node/index.js.map +1 -1
- package/dist/node/index.mjs +1303 -593
- package/dist/node/index.mjs.map +1 -1
- package/package.json +2 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// src/world/Chunk.ts
|
|
2
|
+
import { BlockObject } from "../model/block/scene/BlockObject.mjs";
|
|
2
3
|
import { Color, Vector3 } from "three";
|
|
3
4
|
import { ChunkData } from "./ChunkData.mjs";
|
|
4
5
|
import { BlockStates } from "../assets/BlockStates.mjs";
|
|
@@ -269,8 +270,10 @@ var Chunk = class _Chunk {
|
|
|
269
270
|
if (rejected?.status === "rejected") throw rejected.reason;
|
|
270
271
|
}
|
|
271
272
|
const positions = [];
|
|
272
|
-
|
|
273
|
-
|
|
273
|
+
const jobs = /* @__PURE__ */ new Map();
|
|
274
|
+
let failureOrder = Infinity, failure;
|
|
275
|
+
for (const [order, { index, key, block }] of placements.entries()) {
|
|
276
|
+
jobs.delete(index);
|
|
274
277
|
this.hiddenBlocks.delete(index);
|
|
275
278
|
this.data.assign(index, this.data.intern(block), block?.nbt);
|
|
276
279
|
const readBlock = this.data.snapshot(index);
|
|
@@ -286,7 +289,6 @@ var Chunk = class _Chunk {
|
|
|
286
289
|
this.z * 16 + Math.floor(index / 16) % 16
|
|
287
290
|
);
|
|
288
291
|
positions.push(worldPos);
|
|
289
|
-
let object;
|
|
290
292
|
try {
|
|
291
293
|
if (!readBlock) continue;
|
|
292
294
|
const resolved = resolutions.get(key);
|
|
@@ -308,7 +310,7 @@ var Chunk = class _Chunk {
|
|
|
308
310
|
this.sectionBlocks.set(index, templates.map((template) => ({ index, template, cullMask: 0, biomeTint: context?.tint })));
|
|
309
311
|
this.meshDirty = true;
|
|
310
312
|
} else {
|
|
311
|
-
|
|
313
|
+
jobs.set(index, { order, readBlock, blockState, position: MineRenderWorld.worldToScenePosition(worldPos), options: {
|
|
312
314
|
mergeMeshes: true,
|
|
313
315
|
instanceMeshes: true,
|
|
314
316
|
maxInstanceCount: 2e3,
|
|
@@ -316,13 +318,12 @@ var Chunk = class _Chunk {
|
|
|
316
318
|
variantPosition,
|
|
317
319
|
biome: context?.biome,
|
|
318
320
|
biomePosition: this.biomePosition(index, blockState, stored)
|
|
319
|
-
});
|
|
320
|
-
|
|
321
|
+
} });
|
|
322
|
+
continue;
|
|
321
323
|
}
|
|
322
324
|
this.renderedBlocks.set(index, { get block() {
|
|
323
325
|
return readBlock();
|
|
324
|
-
}, object });
|
|
325
|
-
if (object) this.objectBlocks.add(index);
|
|
326
|
+
}, object: void 0 });
|
|
326
327
|
} catch (error) {
|
|
327
328
|
if (preserveDataOnFailure && readBlock) {
|
|
328
329
|
this.renderedBlocks.set(index, { get block() {
|
|
@@ -330,12 +331,35 @@ var Chunk = class _Chunk {
|
|
|
330
331
|
}, object: void 0 });
|
|
331
332
|
} else this.data.assign(index, 0);
|
|
332
333
|
this.fluidCells[index] = 0;
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
334
|
+
if (order < failureOrder) {
|
|
335
|
+
failureOrder = order;
|
|
336
|
+
failure = error;
|
|
337
|
+
}
|
|
336
338
|
}
|
|
337
339
|
}
|
|
338
|
-
|
|
340
|
+
const pending = [...jobs];
|
|
341
|
+
const objects = await Promise.allSettled(pending.map(([, job]) => this.createBlockObject(job.blockState, job.position, job.options)));
|
|
342
|
+
for (const [i, [index, { order, readBlock }]] of pending.entries()) {
|
|
343
|
+
const result = objects[i];
|
|
344
|
+
if (result.status === "fulfilled") {
|
|
345
|
+
this.renderedBlocks.set(index, { get block() {
|
|
346
|
+
return readBlock();
|
|
347
|
+
}, object: result.value });
|
|
348
|
+
this.objectBlocks.add(index);
|
|
349
|
+
} else {
|
|
350
|
+
if (preserveDataOnFailure) {
|
|
351
|
+
this.renderedBlocks.set(index, { get block() {
|
|
352
|
+
return readBlock();
|
|
353
|
+
}, object: void 0 });
|
|
354
|
+
} else this.data.assign(index, 0);
|
|
355
|
+
this.fluidCells[index] = 0;
|
|
356
|
+
if (order < failureOrder) {
|
|
357
|
+
failureOrder = order;
|
|
358
|
+
failure = result.reason;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
if (failureOrder < Infinity) throw failure;
|
|
339
363
|
return positions;
|
|
340
364
|
}
|
|
341
365
|
/** Replaces every cell from parsed section data. The caller refreshes neighbor culling. */
|
|
@@ -406,37 +430,42 @@ var Chunk = class _Chunk {
|
|
|
406
430
|
failed = true;
|
|
407
431
|
}
|
|
408
432
|
}
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
)
|
|
426
|
-
this.renderedBlocks.get(index).object = object;
|
|
433
|
+
const objects = await Promise.allSettled(perBlocks.map(({ index, blockState, biome }) => this.createBlockObject(blockState, new Vector3(
|
|
434
|
+
this.x * 256 + index % 16 * 16,
|
|
435
|
+
this.y * 256 + Math.floor(index / 256) * 16,
|
|
436
|
+
this.z * 256 + Math.floor(index / 16) % 16 * 16
|
|
437
|
+
), {
|
|
438
|
+
mergeMeshes: true,
|
|
439
|
+
instanceMeshes: true,
|
|
440
|
+
maxInstanceCount: 2e3,
|
|
441
|
+
initialState: this.data.stateAt(this.data.idAt(index)).properties,
|
|
442
|
+
variantPosition: this.positionAt(index),
|
|
443
|
+
biome,
|
|
444
|
+
biomePosition: this.biomePosition(index, blockState, this.data.stateAt(this.data.idAt(index)))
|
|
445
|
+
})));
|
|
446
|
+
for (const [i, { index }] of perBlocks.entries()) {
|
|
447
|
+
const result = objects[i];
|
|
448
|
+
if (result.status === "fulfilled") {
|
|
449
|
+
this.renderedBlocks.get(index).object = result.value;
|
|
427
450
|
this.objectBlocks.add(index);
|
|
428
|
-
}
|
|
451
|
+
} else {
|
|
429
452
|
this.data.assign(index, 0);
|
|
430
453
|
this.fluidCells[index] = 0;
|
|
431
454
|
this.renderedBlocks.delete(index);
|
|
432
455
|
this.objectBlocks.delete(index);
|
|
433
|
-
|
|
434
|
-
if (!failed) failure = error;
|
|
456
|
+
if (!failed) failure = result.reason;
|
|
435
457
|
failed = true;
|
|
436
458
|
}
|
|
437
459
|
}
|
|
438
460
|
if (failed) throw failure;
|
|
439
461
|
}
|
|
462
|
+
createBlockObject(blockState, position, options) {
|
|
463
|
+
return this.scene.addSceneObject(blockState, () => {
|
|
464
|
+
const object = new BlockObject(blockState, options);
|
|
465
|
+
object.position.copy(position);
|
|
466
|
+
return object;
|
|
467
|
+
}, options);
|
|
468
|
+
}
|
|
440
469
|
positionAt(index) {
|
|
441
470
|
return [this.x * 16 + index % 16, this.y * 16 + Math.floor(index / 256), this.z * 16 + Math.floor(index / 16) % 16];
|
|
442
471
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/world/Chunk.ts"],"sourcesContent":["import { Block } from \"../model/block/Block\";\nimport { BlockObject } from \"../model/block/scene/BlockObject\";\nimport { Color, Mesh, Object3D, Raycaster, Vector3 } from \"three\";\nimport { Maybe } from \"../util/util\";\nimport { BlockInfo } from \"./BlockInfo\";\nimport { ChunkData } from \"./ChunkData\";\nimport { MineRenderScene } from \"../renderer/MineRenderScene\";\nimport { BlockStates } from \"../assets/BlockStates\";\nimport { AssetKey } from \"../assets/AssetKey\";\nimport { MineRenderWorld } from \"./MineRenderWorld\";\nimport { isTripleArray, TripleArray } from \"../model/Model\";\nimport { SectionModels } from \"./SectionModels\";\nimport { BlockEntities } from \"../assets/BlockEntities\";\nimport { SectionFluids, SectionMesh, SectionMeshEntry } from \"./SectionMesh\";\nimport { FluidKind, getBlockFluidState } from \"../model/fluid/FluidGeometry\";\nimport { fluidKindOf } from \"../model/fluid/FluidQuads\";\nimport { BlockState } from \"../model/block/BlockState\";\nimport { CUBE_FACE_OFFSETS } from \"../CubeFace\";\nimport { BlockTints } from \"../model/block/BlockTints\";\nimport { Biomes, BiomeColorKind } from \"../assets/Biomes\";\nimport { BiomeBlend } from \"./_biomes/BiomeBlend\";\nimport { isInstanceReference } from \"../instance/InstanceReference\";\nimport type { InstanceReference } from \"../instance/InstanceReference\";\nimport type { ModelObject } from \"../model/scene/ModelObject\";\nimport type { WorldBlockIntersection } from \"./WorldBlockIntersection\";\nimport { hitNormal, pickableMeshes, visibleHits } from \"./_picking/Picking\";\nimport { BlockCullingData, BlockCullingRule, blockCullingRule, skipsBlockFace } from \"./_culling/BlockCulling\";\n\nconst WATER_TINT = new Color(0x3f76e4).toArray() as TripleArray;\n\n/**\n * A 16×16×16 block section and its render objects.\n * Constructor coordinates identify the section. Block accessors use world block coordinates\n * unless their name explicitly refers to positions within the chunk.\n */\nexport class Chunk<SectionMeshing extends boolean = false> {\n\n public readonly scene: MineRenderScene; //TODO: should probably be the world\n\n public readonly x: number;\n public readonly y: number;\n public readonly z: number;\n\n private readonly data = new ChunkData();\n private readonly renderedBlocks = new Map<number, BlockInfo<SectionMeshing>>();\n private readonly objectBlocks = new Set<number>();\n private readonly sectionBlocks = new Map<number, SectionMeshEntry[]>();\n private readonly hiddenBlocks = new Set<number>();\n private readonly fluidCells = new Uint8Array(4096);\n private readonly blockPosition = new Vector3();\n private waterTints?: Float32Array;\n private biomes?: readonly string[];\n private sectionMesh?: SectionMesh;\n private meshDirty = false;\n private meshGeneration = 0;\n private ambientOcclusionCells?: Uint8Array;\n private readonly blockChanges = new Set<Promise<unknown>>();\n private biomeChange?: Promise<unknown>;\n\n constructor(scene: MineRenderScene, x: number, y: number, z: number,\n private readonly onBlocksChanged?: (positions: Vector3[], deferCulling?: boolean) => Promise<void>,\n private readonly sectionModels?: SectionModels,\n private readonly neighborCell?: (x: number, y: number, z: number) => number,\n private readonly biomeAt?: (x: number, y: number, z: number) => Maybe<string>,\n private readonly onBiomesChanged?: (biomes?: readonly string[]) => Promise<void>,\n private readonly lightAt?: (x: number, y: number, z: number) => number,\n private readonly onLightCleared?: () => Promise<void>,\n private readonly ambientLight = 0,\n private readonly biomeBlend?: () => BiomeBlend | undefined) {\n this.scene = scene;\n this.x = x;\n this.y = y;\n this.z = z;\n }\n\n /** Finds the nearest owned block hit across sections, testing each shared mesh once. */\n public static raycast<SectionMeshing extends boolean>(chunks: Iterable<Chunk<SectionMeshing>>, raycaster: Raycaster): WorldBlockIntersection | undefined {\n type Owner = { chunk: Chunk<SectionMeshing>; index: number };\n const roots = new Map<Object3D, Mesh[]>();\n const targets = new Map<Mesh, {\n owners: Map<number | undefined, Owner>;\n section?: { chunk: Chunk<SectionMeshing>; mesh: SectionMesh };\n }>();\n const meshes = (root: Object3D, scene: MineRenderScene): Mesh[] => {\n const cached = roots.get(root);\n if (cached) return cached;\n const result = pickableMeshes(root, scene, raycaster);\n roots.set(root, result);\n return result;\n };\n const add = (root: Object3D, owner: Owner, reference?: InstanceReference<ModelObject>) => {\n for (const mesh of meshes(root, owner.chunk.scene)) {\n if (reference && reference.instanceable.getInstanceReference(mesh, reference.index) !== reference) continue;\n let entry = targets.get(mesh);\n if (!entry) targets.set(mesh, entry = { owners: new Map() });\n entry.owners.set(reference?.index, owner);\n }\n };\n for (const chunk of chunks) {\n for (const index of chunk.objectBlocks) {\n const block = chunk.renderedBlocks.get(index)!.object;\n if (!block || !block.visible || chunk.hiddenBlocks.has(index)) continue;\n const owner = { chunk, index };\n for (const model of block.models) {\n if (isInstanceReference(model)) {\n if (model.instanceable.isInstanceActive(model.index, model)) add(model.instanceable, owner, model);\n } else {\n add(model, owner);\n }\n }\n for (const entity of block.blockEntities) add(entity, owner);\n }\n if (chunk.sectionMesh) {\n for (const mesh of meshes(chunk.sectionMesh, chunk.scene)) {\n targets.set(mesh, { owners: new Map(), section: { chunk, mesh: chunk.sectionMesh } });\n }\n }\n }\n for (const hit of visibleHits(raycaster, [...targets.keys()])) {\n const mesh = hit.object as Mesh;\n const entry = targets.get(mesh)!;\n let owner = entry.owners.get(hit.instanceId) ?? entry.owners.get(undefined);\n if (entry.section) {\n const index = entry.section.mesh.getBlockIndex(hit);\n if (index !== undefined) owner = { chunk: entry.section.chunk, index };\n }\n if (!owner || owner.chunk.hiddenBlocks.has(owner.index)) continue;\n const info = owner.chunk.renderedBlocks.get(owner.index);\n if (!info) continue;\n return {\n position: new Vector3(owner.chunk.x * 16 + owner.index % 16,\n owner.chunk.y * 16 + Math.floor(owner.index / 256), owner.chunk.z * 16 + Math.floor(owner.index / 16) % 16),\n block: info.block,\n point: hit.point.clone(),\n normal: hitNormal(hit),\n distance: hit.distance\n };\n }\n return undefined;\n }\n\n public getBlockAt(x: number, y: number, z: number): Maybe<BlockInfo<SectionMeshing>>;\n public getBlockAt(pos: Vector3): Maybe<BlockInfo<SectionMeshing>>;\n public getBlockAt(pos: TripleArray): Maybe<BlockInfo<SectionMeshing>>;\n public getBlockAt(posOrX: number | Vector3 | TripleArray, y?: number, z?: number): Maybe<BlockInfo<SectionMeshing>> {\n if (typeof posOrX == \"number\") {\n return this.getBlockAt(new Vector3(posOrX, y, z));\n }\n if (isTripleArray(posOrX)) {\n return this.getBlockAt(new Vector3(posOrX[0], posOrX[1], posOrX[2]))\n }\n const pos = this.blockPosition.set(posOrX.x - this.x * 16, posOrX.y - this.y * 16, posOrX.z - this.z * 16);\n const index = Chunk.chunkPosToBlockIndex(pos);\n return this.renderedBlocks.get(index);\n }\n\n /** Returns the saved 4-block biome sample at integer world block coordinates, or `undefined` if absent. */\n public getBiomeAt(x: number, y: number, z: number): Maybe<string>;\n public getBiomeAt(pos: Vector3): Maybe<string>;\n public getBiomeAt(pos: TripleArray): Maybe<string>;\n public getBiomeAt(posOrX: number | Vector3 | TripleArray, y?: number, z?: number): Maybe<string> {\n if (typeof posOrX === \"number\") return this.getBiomeAt(new Vector3(posOrX, y, z));\n if (isTripleArray(posOrX)) return this.getBiomeAt(new Vector3(...posOrX));\n const pos = this.worldPosToChunkPos(posOrX);\n Chunk.chunkPosToBlockIndex(pos);\n return this.biomeAt ? this.biomeAt(posOrX.x, posOrX.y, posOrX.z)\n : this.biomes?.[Math.floor(pos.x / 4) + Math.floor(pos.z / 4) * 4 + Math.floor(pos.y / 4) * 16];\n }\n\n /** Copies 64 biome IDs in x + z * 4 + y * 16 order and refreshes placed blocks. Omit the array to clear biome data. */\n public setBiomes(biomes?: readonly string[]): Promise<void> {\n const copy = biomes ? [...biomes] : undefined;\n if (copy && (copy.length !== 64 || !copy.every(id => typeof id === \"string\" && id.length > 0))) {\n throw new RangeError(\"Section biomes must contain 64 nonempty biome IDs\");\n }\n if (this.onBiomesChanged) return this.onBiomesChanged(copy);\n this.biomes = copy;\n return this.refreshBiomes();\n }\n\n /**\n * Rebuilds biome-tinted blocks while preserving hidden blocks and unrelated render objects.\n * The owning world can defer neighbor culling until all affected chunks are refreshed.\n */\n public refreshBiomes(columns?: readonly { x: number; z: number }[], deferCulling = false): Promise<void> {\n return this.changeBlocks(() => this.refreshBiomeBlocks(columns, deferCulling), true);\n }\n\n private async refreshBiomeBlocks(columns?: readonly { x: number; z: number }[], deferCulling = false): Promise<void> {\n const blend = columns && this.biomeBlend?.();\n // Individual objects keep their own biome's unblended color, so only a change to their own column affects them.\n const ownColumn = columns?.some(column => column.x === this.x && column.z === this.z);\n const affected = new Map<string, Promise<boolean>>();\n const blocks: { index: number; block: Block }[] = [];\n for (const index of this.renderedBlocks.keys()) {\n if (blend) {\n if (this.objectBlocks.has(index) && !ownColumn) continue;\n const [x, , z] = this.positionAt(index), radius = blend.radius;\n if (!columns!.some(column => x >= column.x * 16 - radius && x <= column.x * 16 + 15 + radius\n && z >= column.z * 16 - radius && z <= column.z * 16 + 15 + radius)) continue;\n }\n const block = this.data.get(index)!;\n const stateKey = ChunkData.paletteKey(block);\n let matches = affected.get(stateKey);\n if (!matches) {\n const key = AssetKey.parse(\"blockstates\", block.type);\n matches = BlockStates.get(key).then(async state => {\n const origin = state?.key ?? key;\n const [source, fluid] = await Promise.all([BlockTints.biomeSource(origin), getBlockFluidState(origin, block.properties)]);\n return !!source || fluid?.kind === \"water\";\n });\n affected.set(stateKey, matches);\n }\n if (await matches) blocks.push({ index, block });\n }\n if (blend) {\n const groups = new Map<string, typeof blocks>();\n for (const entry of blocks) {\n const key = ChunkData.paletteKey(entry.block);\n let group = groups.get(key);\n if (!group) groups.set(key, group = []);\n group.push(entry);\n }\n blocks.length = 0;\n const biomes = new Map<string, Promise<boolean>>();\n for (const group of groups.values()) {\n const { contexts, fluid } = await this.resolveState(group[0].block, group.map(entry => entry.index), biomes);\n for (const entry of group) {\n const context = contexts.get(entry.index);\n const current = this.sectionBlocks.get(entry.index)?.[0]?.biomeTint;\n const tint = context?.tint;\n const tintChanged = !!current !== !!tint || tint?.some((value, channel) => value !== current?.[channel]);\n const waterChanged = fluid?.kind === \"water\" && (context?.waterTint ?? WATER_TINT).some((value, channel) =>\n Math.fround(value) !== (this.waterTints?.[entry.index * 3 + channel] ?? Math.fround(WATER_TINT[channel])));\n if (this.objectBlocks.has(entry.index) || tintChanged || waterChanged) blocks.push(entry);\n }\n }\n }\n if (!blocks.length) return;\n const hidden = new Set(this.hiddenBlocks);\n try {\n await this.replaceBlocks(blocks, true);\n } finally {\n for (const index of hidden) {\n this.hiddenBlocks.add(index);\n this.renderedBlocks.get(index)?.object?.setVisible(false);\n }\n const positions = blocks.map(({ index }) => new Vector3(...this.positionAt(index)));\n if (this.onBlocksChanged) await this.onBlocksChanged(positions, deferCulling);\n else await this.rebuildSectionMesh();\n }\n }\n\n /**\n * Places a block at integer world block coordinates. Pass `undefined` to remove it.\n */\n public async setBlockAt(x: number, y: number, z: number, block: Maybe<Block>): Promise<Maybe<BlockInfo<SectionMeshing>>>;\n public async setBlockAt(pos: Vector3, block: Maybe<Block>): Promise<Maybe<BlockInfo<SectionMeshing>>>;\n public async setBlockAt(pos: TripleArray, block: Maybe<Block>): Promise<Maybe<BlockInfo<SectionMeshing>>>;\n public async setBlockAt(posOrX: number | Vector3 | TripleArray, yOrBlock?: number | Block, z?: number, block?: Block): Promise<Maybe<BlockInfo<SectionMeshing>>> {\n if (typeof posOrX == \"number\") {\n return this.setBlockAt(new Vector3(posOrX, yOrBlock as number, z), block as Block);\n }\n if (isTripleArray(posOrX)) {\n return this.setBlockAt(new Vector3(posOrX[0], posOrX[1], posOrX[2]), yOrBlock as Block);\n }\n const worldPos: Vector3 = posOrX;\n const pos: Vector3 = this.worldPosToChunkPos(worldPos);\n block = yOrBlock as Block;\n\n return this.setBlockInChunkAt(pos, block, worldPos);\n }\n\n /**\n * Places a block at integer chunk-local coordinates from 0 to 15.\n */\n public async setBlockInChunkAt(pos: Vector3, block?: Block, worldPos?: Vector3,\n onBlocksChanged = this.onBlocksChanged): Promise<Maybe<BlockInfo<SectionMeshing>>> {\n if (typeof worldPos === \"undefined\") {\n worldPos = this.chunkPosToWorldPos(pos);\n }\n\n const index = Chunk.chunkPosToBlockIndex(pos);\n try {\n await this.placeBlocks([{ index, block }]);\n return this.renderedBlocks.get(index);\n } finally {\n await onBlocksChanged?.([worldPos]);\n }\n }\n\n /** Places cells in input order and returns changed world positions without refreshing neighbors. */\n public async placeBlocks(blocks: readonly { index: number; block: Maybe<Block> }[]): Promise<Vector3[]> {\n return this.changeBlocks(() => this.replaceBlocks(blocks));\n }\n\n private changeBlocks<T>(change: () => Promise<T>, refreshBiomes = false): Promise<T> {\n // Color refreshes snapshot existing blocks; edits on either side of that snapshot must retain their order.\n const before = refreshBiomes ? Promise.allSettled(this.blockChanges) : this.biomeChange;\n const result = before ? before.catch(() => undefined).then(change) : change();\n const pending = result.finally(() => {\n this.blockChanges.delete(pending);\n if (this.biomeChange === pending) this.biomeChange = undefined;\n });\n this.blockChanges.add(pending);\n if (refreshBiomes) this.biomeChange = pending;\n return pending;\n }\n\n private async replaceBlocks(blocks: readonly { index: number; block: Maybe<Block> }[], preserveDataOnFailure = false): Promise<Vector3[]> {\n const placements = blocks.map(({ index, block }) => ({\n index,\n key: block && !ChunkData.isAir(block) ? ChunkData.paletteKey(block) : undefined,\n block: block ? {\n type: block.type,\n properties: block.properties ? { ...block.properties } : undefined,\n nbt: block.nbt === undefined ? undefined : structuredClone(block.nbt)\n } : undefined\n }));\n const states = new Map<string, { stored: Block; indices: number[] }>();\n for (const { index, key, block } of placements) {\n if (key === undefined) continue;\n let state = states.get(key);\n if (!state) states.set(key, state = { stored: block!, indices: [] });\n state.indices.push(index);\n }\n const biomes = new Map<string, Promise<boolean>>();\n const settled = await Promise.allSettled([...states.values()].map(({ stored, indices }) =>\n this.resolveState(stored, indices, biomes)));\n const resolutions = new Map([...states.keys()].map((key, i) => [key, settled[i]]));\n if (preserveDataOnFailure) {\n const rejected = settled.find(result => result.status === \"rejected\");\n if (rejected?.status === \"rejected\") throw rejected.reason;\n }\n const positions: Vector3[] = [];\n let failed = false, failure: unknown;\n for (const { index, key, block } of placements) {\n this.hiddenBlocks.delete(index);\n this.data.assign(index, this.data.intern(block), block?.nbt);\n const readBlock = this.data.snapshot(index);\n this.renderedBlocks.get(index)?.object?.removeFromScene();\n if (this.sectionBlocks.delete(index)) this.meshDirty = true;\n if (this.fluidCells[index]) this.meshDirty = true;\n this.fluidCells[index] = 0;\n this.renderedBlocks.delete(index);\n this.objectBlocks.delete(index);\n const worldPos = new Vector3(this.x * 16 + index % 16, this.y * 16 + Math.floor(index / 256),\n this.z * 16 + Math.floor(index / 16) % 16);\n positions.push(worldPos);\n let object: BlockObject | undefined;\n try {\n if (!readBlock) continue;\n const resolved = resolutions.get(key!)!;\n if (resolved.status === \"rejected\") throw resolved.reason;\n const { blockState, perBlock, fluid, prepared, contexts, stored } = resolved.value;\n const context = contexts.get(index);\n if (!blockState) {\n this.data.assign(index, 0);\n continue;\n }\n const variantPosition = worldPos.toArray();\n if (fluid) {\n this.fluidCells[index] = (fluid.kind === \"water\" ? 16 : 32) | Math.min(fluid.level, 8);\n if (fluid.kind === \"water\") this.setWaterTint(index, context?.waterTint);\n this.meshDirty = true;\n }\n const templates = perBlock ? undefined : fluid?.renderModel === false ? [] : (context?.prepared ?? prepared)?.pick(variantPosition);\n if (templates) {\n this.sectionBlocks.set(index, templates.map(template => ({ index, template, cullMask: 0, biomeTint: context?.tint })));\n this.meshDirty = true;\n } else {\n object = await this.scene.addBlock(blockState, {\n mergeMeshes: true,\n instanceMeshes: true,\n maxInstanceCount: 2000,\n initialState: stored.properties,\n variantPosition, biome: context?.biome,\n biomePosition: this.biomePosition(index, blockState, stored)\n }) as BlockObject;\n object.setPosition(MineRenderWorld.worldToScenePosition(worldPos));\n }\n this.renderedBlocks.set(index, { get block() { return readBlock(); }, object } as BlockInfo<SectionMeshing>);\n if (object) this.objectBlocks.add(index);\n } catch (error) {\n if (preserveDataOnFailure && readBlock) {\n // Keep saved block data available for a failed color refresh to retry.\n this.renderedBlocks.set(index, { get block() { return readBlock(); }, object: undefined } as BlockInfo<SectionMeshing>);\n } else this.data.assign(index, 0);\n this.fluidCells[index] = 0;\n object?.removeFromScene();\n if (!failed) failure = error;\n failed = true;\n }\n }\n if (failed) throw failure;\n return positions;\n }\n\n /** Replaces every cell from parsed section data. The caller refreshes neighbor culling. */\n public placeSection(data: ChunkData): Promise<void> {\n return this.changeBlocks(() => this.replaceSection(data));\n }\n\n private async replaceSection(data: ChunkData): Promise<void> {\n for (const info of this.renderedBlocks.values()) info.object?.removeFromScene();\n this.sectionBlocks.clear();\n this.fluidCells.fill(0);\n this.waterTints = undefined;\n this.renderedBlocks.clear();\n this.objectBlocks.clear();\n this.hiddenBlocks.clear();\n this.meshDirty = true;\n this.data.copyFrom(data);\n\n const ids = new Map<number, number[]>();\n for (let index = 0; index < 4096; index++) {\n const id = this.data.idAt(index);\n if (!id) continue;\n let indices = ids.get(id);\n if (!indices) ids.set(id, indices = []);\n indices.push(index);\n }\n const palette = [...ids.keys()], biomes = new Map<string, Promise<boolean>>();\n const settled = await Promise.allSettled(palette.map(id =>\n this.resolveState(this.data.stateAt(id)!, ids.get(id)!, biomes)));\n const resolutions = new Map(palette.map((id, i) => [id, settled[i]]));\n const perBlocks: { index: number; blockState: BlockState; biome?: string }[] = [];\n let failed = false, failure: unknown;\n for (let index = 0; index < 4096; index++) {\n const id = this.data.idAt(index);\n if (!id) continue;\n try {\n const resolved = resolutions.get(id)!;\n if (resolved.status === \"rejected\") throw resolved.reason;\n const { blockState, perBlock, fluid, prepared, contexts } = resolved.value;\n const context = contexts.get(index);\n if (!blockState) {\n this.data.assign(index, 0);\n this.fluidCells[index] = 0;\n continue;\n }\n if (fluid) {\n this.fluidCells[index] = (fluid.kind === \"water\" ? 16 : 32) | Math.min(fluid.level, 8);\n if (fluid.kind === \"water\") this.setWaterTint(index, context?.waterTint);\n }\n const variantPosition: TripleArray = [this.x * 16 + index % 16,\n this.y * 16 + Math.floor(index / 256), this.z * 16 + Math.floor(index / 16) % 16];\n const templates = perBlock ? undefined : fluid?.renderModel === false ? [] : (context?.prepared ?? prepared)?.pick(variantPosition);\n if (templates) {\n this.sectionBlocks.set(index, templates.map(template => ({ index, template, cullMask: 0, biomeTint: context?.tint })));\n this.meshDirty = true;\n } else {\n perBlocks.push({ index, blockState, biome: context?.biome });\n }\n const readBlock = this.data.snapshot(index)!;\n this.renderedBlocks.set(index, { get block() { return readBlock(); }, object: undefined } as BlockInfo<SectionMeshing>);\n this.objectBlocks.delete(index);\n } catch (error) {\n this.data.assign(index, 0);\n this.fluidCells[index] = 0;\n if (!failed) failure = error;\n failed = true;\n }\n }\n for (const { index, blockState, biome } of perBlocks) {\n let object: BlockObject | undefined;\n try {\n object = await this.scene.addBlock(blockState, {\n mergeMeshes: true,\n instanceMeshes: true,\n maxInstanceCount: 2000,\n initialState: this.data.stateAt(this.data.idAt(index))!.properties,\n variantPosition: this.positionAt(index), biome,\n biomePosition: this.biomePosition(index, blockState, this.data.stateAt(this.data.idAt(index))!)\n }) as BlockObject;\n object.setPosition(new Vector3(this.x * 256 + index % 16 * 16,\n this.y * 256 + Math.floor(index / 256) * 16, this.z * 256 + Math.floor(index / 16) % 16 * 16));\n this.renderedBlocks.get(index)!.object = object;\n this.objectBlocks.add(index);\n } catch (error) {\n this.data.assign(index, 0);\n this.fluidCells[index] = 0;\n this.renderedBlocks.delete(index);\n this.objectBlocks.delete(index);\n object?.removeFromScene();\n if (!failed) failure = error;\n failed = true;\n }\n }\n if (failed) throw failure;\n }\n\n private positionAt(index: number): TripleArray {\n return [this.x * 16 + index % 16, this.y * 16 + Math.floor(index / 256), this.z * 16 + Math.floor(index / 16) % 16];\n }\n\n /** Refreshes saved lighting after adjacent columns load or unload, including columns with only light data. */\n public async refreshLight(indices?: Iterable<number>): Promise<void> {\n if (!this.lightAt) return;\n for (const index of indices ?? this.renderedBlocks.keys()) {\n if (this.renderedBlocks.has(index)) this.meshDirty = true;\n }\n }\n\n /** Refreshes baked corner shading after edits or a world setting change. Disabled chunks keep no AO neighborhood. */\n public refreshAmbientOcclusion(enabled: boolean): void {\n if (!enabled && !this.ambientOcclusionCells) return;\n const cells = enabled ? this.buildAmbientOcclusionCells() : undefined;\n if (cells?.some((value, index) => value !== this.ambientOcclusionCells?.[index])\n || !!cells !== !!this.ambientOcclusionCells) this.meshDirty = true;\n this.ambientOcclusionCells = cells;\n }\n\n private buildAmbientOcclusionCells(): Uint8Array {\n const cells = new Uint8Array(18 * 18 * 18);\n for (let y = -1; y <= 16; y++) {\n for (let z = -1; z <= 16; z++) {\n for (let x = -1; x <= 16; x++) {\n const inner = x >= 0 && x < 16 && y >= 0 && y < 16 && z >= 0 && z < 16;\n cells[(y + 1) * 324 + (z + 1) * 18 + x + 1] = inner\n ? Number(this.isOccludingIndex(y * 256 + z * 16 + x))\n : Number(!!((this.neighborCell?.(this.x * 16 + x, this.y * 16 + y, this.z * 16 + z) ?? 0) & 64));\n }\n }\n }\n return cells;\n }\n\n private biomePosition(index: number, blockState: BlockState, stored: Block): TripleArray {\n const position = this.positionAt(index), name = blockState.key?.toNamespacedString();\n if (stored.properties?.half === \"upper\" && (name === \"minecraft:tall_grass\" || name === \"minecraft:large_fern\")) position[1]--;\n return position;\n }\n\n private async resolveState(stored: Block, indices: readonly number[], biomes: Map<string, Promise<boolean>>) {\n const blockState = await BlockStates.get(AssetKey.parse(\"blockstates\", stored.type));\n let perBlock = !blockState || !this.sectionModels\n || !!(blockState.key && BlockEntities.entry(await BlockEntities.getIndex(blockState.key.root), blockState.key.toNamespacedString()));\n const fluid = await getBlockFluidState(blockState?.key, stored.properties);\n const hasBiomes = this.getBiomeAt(this.x * 16, this.y * 16, this.z * 16) !== undefined\n || this.biomeAt?.(this.x * 16, this.y * 16 - 1, this.z * 16) !== undefined;\n const source = hasBiomes && blockState ? await BlockTints.biomeSource(blockState.key) : undefined;\n const prepare = (color?: () => Promise<number | undefined>) => perBlock || fluid?.renderModel === false ? undefined\n : this.sectionModels!.prepareState(blockState!, stored.properties, color);\n type Context = {\n biome?: string;\n prepared?: Awaited<ReturnType<SectionModels[\"prepareState\"]>>;\n tint?: TripleArray;\n waterTint?: TripleArray;\n };\n const contexts = new Map<number, Context>();\n const blend = this.biomeBlend?.();\n if (blend && !perBlock && blockState && (source || fluid?.kind === \"water\")) {\n const prepared = fluid?.renderModel === false ? undefined\n : await this.sectionModels!.prepareState(blockState, stored.properties, undefined, true);\n if (!prepared && fluid?.renderModel !== false) {\n // A model that cannot join the section mesh becomes an individual object with its own biome's color.\n perBlock = true;\n } else {\n await Promise.all(indices.map(async index => {\n const position = this.biomePosition(index, blockState, stored);\n const biomeColor = (kind: BiomeColorKind) => blend.getColor(kind, blockState.key, position);\n const context: Context = {};\n if (source && prepared?.biomeTint) {\n const color = await biomeColor(source);\n if (color !== undefined) context.tint = new Color(color).toArray() as TripleArray;\n }\n if (fluid?.kind === \"water\") {\n const color = await biomeColor(\"water\");\n if (color !== undefined && color !== 0x3f76e4) context.waterTint = new Color(color).toArray() as TripleArray;\n }\n contexts.set(index, context);\n }));\n return { blockState, perBlock, fluid, prepared, contexts, stored };\n }\n }\n const groups = new Map<string, { biome: string; position: TripleArray; indices: number[] }>();\n if (blockState && (source || fluid?.kind === \"water\")) {\n for (const index of indices) {\n const position = this.biomePosition(index, blockState, stored);\n const biome = this.biomeAt ? this.biomeAt(...position)\n : position[1] >= this.y * 16 ? this.getBiomeAt(position) : undefined;\n if (!biome) continue;\n const key = JSON.stringify(source === \"grass\" ? [biome, position[0], position[2]] : [biome]);\n let group = groups.get(key);\n if (!group) groups.set(key, group = { biome, position, indices: [] });\n group.indices.push(index);\n }\n }\n const groupedCount = [...groups.values()].reduce((sum, group) => sum + group.indices.length, 0);\n const prepared = groupedCount < indices.length ? await prepare() : undefined;\n await Promise.all([...groups.values()].map(async ({ biome, position, indices }) => {\n const available = () => {\n const key = JSON.stringify([biome, blockState?.key?.root]);\n let found = biomes.get(key);\n if (!found) {\n found = Biomes.get(biome, blockState?.key).then(value => value !== undefined);\n biomes.set(key, found);\n }\n return found;\n };\n const context: Context = { biome };\n if (perBlock) {\n if (!await available()) context.biome = undefined;\n } else {\n context.prepared = await prepare(async () => await available()\n ? BlockTints.getBiomeColor(blockState?.key, biome, position) : undefined);\n if (fluid?.kind === \"water\" && await available()) {\n const color = await Biomes.getColor(biome, \"water\", blockState?.key);\n if (color !== undefined && color !== 0x3f76e4) context.waterTint = new Color(color).toArray() as TripleArray;\n }\n }\n for (const index of indices) contexts.set(index, context);\n }));\n return { blockState, perBlock, fluid, prepared, contexts, stored };\n }\n\n private setWaterTint(index: number, tint?: TripleArray): void {\n if (!this.sectionModels || (!this.waterTints && tint === undefined)) return;\n if (!this.waterTints) {\n this.waterTints = new Float32Array(4096 * 3);\n for (let cell = 0; cell < 4096; cell++) this.waterTints.set(WATER_TINT, cell * 3);\n }\n this.waterTints.set(tint ?? WATER_TINT, index * 3);\n }\n\n /** Changes visibility at world block coordinates while preserving the block's data. */\n public setBlockVisibleAt(pos: Vector3, visible: boolean): Promise<void> {\n const position = pos.clone();\n return this.changeBlocks(() => this.setBlockVisibility(position, visible));\n }\n\n private async setBlockVisibility(pos: Vector3, visible: boolean): Promise<void> {\n const index = Chunk.chunkPosToBlockIndex(this.worldPosToChunkPos(pos));\n const block = this.renderedBlocks.get(index);\n if (!block || visible === !this.hiddenBlocks.has(index)) {\n return;\n }\n if (visible) {\n this.hiddenBlocks.delete(index);\n } else {\n this.hiddenBlocks.add(index);\n }\n block.object?.setVisible(visible);\n if (this.sectionBlocks.has(index) || this.fluidCells[index]) {\n this.meshDirty = true;\n }\n this.scene.dirty = true;\n await this.onBlocksChanged?.([pos]);\n }\n\n public isBlockVisibleAt(pos: Vector3): boolean {\n return this.isBlockVisibleIndex(Chunk.chunkPosToBlockIndex(this.worldPosToChunkPos(pos)));\n }\n\n /** Reports whether a cell has a visible render object or section entry. */\n public isBlockVisibleIndex(index: number): boolean {\n return this.renderedBlocks.has(index) && !this.hiddenBlocks.has(index);\n }\n\n /** Stored state of a rendered, visible cell, or `undefined`. */\n public visibleBlockIndex(index: number): Maybe<Pick<Block, \"type\" | \"properties\">> {\n return this.isBlockVisibleIndex(index) ? this.data.stateAt(this.data.idAt(index)) : undefined;\n }\n\n /** Fluid kind bits and level of a cell, or 0. Hidden cells report 0. */\n public fluidByteIndex(index: number): number {\n return this.hiddenBlocks.has(index) ? 0 : this.fluidCells[index];\n }\n\n /** Whether the cell holds a fluid, merged or per-block. */\n public isFluidIndex(index: number): boolean {\n return this.fluidCells[index] !== 0;\n }\n\n public isOccludingAt(pos: Vector3): boolean {\n return this.isOccludingIndex(Chunk.chunkPosToBlockIndex(this.worldPosToChunkPos(pos)));\n }\n\n /** Reports whether a visible cell hides neighboring cube faces. */\n public isOccludingIndex(index: number): boolean {\n return !this.hiddenBlocks.has(index)\n && (this.sectionBlocks.get(index)?.some(entry => entry.template.occludes)\n ?? this.renderedBlocks.get(index)?.object?.isOccluding ?? false);\n }\n\n public async setCullMaskAt(pos: Vector3, mask: number): Promise<void> {\n await this.setCullMaskIndex(Chunk.chunkPosToBlockIndex(this.worldPosToChunkPos(pos)), mask);\n }\n\n /**\n * Recomputes section masks and returns changed per-block masks. Omit indices to visit every cell.\n * `culling` supplies neighbor face rules; `blockAt` supplies visible states outside this chunk.\n */\n public updateCullMasks(indices: Iterable<number> | undefined, occludes: (x: number, y: number, z: number) => boolean,\n culling?: BlockCullingData, blockAt?: (x: number, y: number, z: number) => Maybe<Pick<Block, \"type\" | \"properties\">>): [number, number][] {\n const changed: [number, number][] = [];\n const rules: (BlockCullingRule | null | undefined)[] = [];\n for (const index of indices ?? this.fluidCells.keys()) {\n if (!this.isBlockVisibleIndex(index)) continue;\n const x = index % 16, y = Math.floor(index / 256), z = Math.floor(index / 16) % 16;\n const id = this.data.idAt(index);\n let rule = rules[id];\n if (culling && rule === undefined) rules[id] = rule = blockCullingRule(culling, this.data.stateAt(id)!.type) ?? null;\n const block = rule ? this.data.stateAt(id)! : undefined;\n let mask = 0;\n for (let face = 0; face < CUBE_FACE_OFFSETS.length; face++) {\n const [dx, dy, dz] = CUBE_FACE_OFFSETS[face];\n const nx = x + dx, ny = y + dy, nz = z + dz;\n const inner = nx >= 0 && nx < 16 && ny >= 0 && ny < 16 && nz >= 0 && nz < 16;\n if (inner ? this.isOccludingIndex(ny * 256 + nz * 16 + nx)\n : occludes(this.x * 16 + nx, this.y * 16 + ny, this.z * 16 + nz)) mask |= 1 << face;\n else if (rule) {\n const neighbor = inner ? this.visibleBlockIndex(ny * 256 + nz * 16 + nx)\n : blockAt?.(this.x * 16 + nx, this.y * 16 + ny, this.z * 16 + nz);\n if (neighbor && skipsBlockFace(culling!, rule, block!, neighbor, face)) mask |= 1 << face;\n }\n }\n if (this.fluidCells[index]) this.meshDirty = true;\n const entries = this.sectionBlocks.get(index);\n if (entries) {\n for (const entry of entries) {\n if (entry.cullMask !== mask) {\n entry.cullMask = mask;\n this.meshDirty = true;\n }\n }\n } else {\n const object = this.renderedBlocks.get(index)?.object;\n if (object && object.cullMask !== mask) changed.push([index, mask]);\n }\n }\n return changed;\n }\n\n /** Updates hidden faces for a cell's section entry or individual render object. */\n public async setCullMaskIndex(index: number, mask: number): Promise<void> {\n if (this.fluidCells[index]) this.meshDirty = true;\n const entries = this.sectionBlocks.get(index);\n if (entries) {\n for (const entry of entries) {\n if (entry.cullMask !== mask) {\n entry.cullMask = mask;\n this.meshDirty = true;\n }\n }\n } else {\n await this.renderedBlocks.get(index)?.object?.setCullMask(mask);\n }\n }\n\n /** Rebuilds visible section geometry and discards results superseded by another rebuild or clear. */\n public async rebuildSectionMesh(): Promise<void> {\n if (!this.sectionModels || !this.meshDirty) return;\n this.meshDirty = false;\n const generation = ++this.meshGeneration;\n const entries = [...this.sectionBlocks.entries()].flatMap(([index, entries]) => this.hiddenBlocks.has(index) ? [] : entries);\n let fluids: SectionFluids | undefined;\n const origins = new Map<FluidKind, string>();\n for (let index = 0; index < this.fluidCells.length; index++) {\n const kind = fluidKindOf(this.fluidCells[index]);\n if (!kind || origins.has(kind) || this.hiddenBlocks.has(index)) continue;\n const block = this.renderedBlocks.get(index);\n if (block && !block.object) origins.set(kind, block.block.type);\n }\n if (origins.size) {\n fluids = { cells: new Uint8Array(18 * 18 * 18), waterTints: this.waterTints?.slice() };\n for (let y = -1; y <= 16; y++) {\n for (let z = -1; z <= 16; z++) {\n for (let x = -1; x <= 16; x++) {\n const index = y * 256 + z * 16 + x;\n const inner = x >= 0 && x < 16 && y >= 0 && y < 16 && z >= 0 && z < 16;\n fluids.cells[(y + 1) * 324 + (z + 1) * 18 + x + 1] = inner\n ? this.fluidByteIndex(index) | (this.renderedBlocks.get(index)?.object ? 128 : 0)\n | (this.isOccludingIndex(index) ? 64 : 0)\n : this.neighborCell?.(this.x * 16 + x, this.y * 16 + y, this.z * 16 + z) ?? 0;\n }\n }\n }\n for (const [kind, type] of origins) {\n const state = await BlockStates.get(AssetKey.parse(\"blockstates\", type));\n fluids[kind] = await this.sectionModels.fluidAtlas(kind, state?.key?.root);\n }\n }\n let light: Uint8Array | undefined;\n if (this.lightAt) {\n light = new Uint8Array(18 * 18 * 18);\n for (let y = -1; y <= 16; y++) {\n for (let z = -1; z <= 16; z++) {\n for (let x = -1; x <= 16; x++) {\n light[(y + 1) * 324 + (z + 1) * 18 + x + 1] = this.lightAt(this.x * 16 + x, this.y * 16 + y, this.z * 16 + z);\n }\n }\n }\n }\n let next: SectionMesh | undefined;\n try {\n next = entries.length || fluids ? await SectionMesh.buildAsync(entries, this.sectionModels.maxAtlasSize, fluids,\n { light, ambientLight: this.ambientLight, ambientOcclusion: this.ambientOcclusionCells }) : undefined;\n } catch (error) {\n if (generation === this.meshGeneration) this.meshDirty = true;\n throw error;\n }\n if (generation !== this.meshGeneration) {\n next?.dispose();\n return;\n }\n this.sectionMesh?.dispose();\n this.sectionMesh = next;\n if (next) {\n next.position.set(this.x * 256, this.y * 256, this.z * 256);\n this.scene.add(next);\n }\n this.scene.dirty = true;\n }\n\n /** Removes stored blocks and render objects. Set `notify` to false to skip the owning world's update. */\n public async clear(notify = true): Promise<void> {\n if (this.blockChanges.size) await Promise.allSettled(this.blockChanges);\n const positions = notify && this.onBlocksChanged ? [...this.renderedBlocks.keys()].map(index => this.chunkPosToWorldPos(\n new Vector3(index % 16, Math.floor(index / 256), Math.floor(index / 16) % 16)\n )) : [];\n for (const info of this.renderedBlocks.values()) info.object?.removeFromScene();\n this.sectionBlocks.clear();\n this.meshGeneration++;\n this.sectionMesh?.dispose();\n this.sectionMesh = undefined;\n this.meshDirty = false;\n this.renderedBlocks.clear();\n this.objectBlocks.clear();\n this.hiddenBlocks.clear();\n this.fluidCells.fill(0);\n this.waterTints = undefined;\n this.ambientOcclusionCells = undefined;\n this.data.clear();\n this.biomes = undefined;\n if (notify) {\n await this.onBiomesChanged?.(undefined);\n await this.onLightCleared?.();\n await this.onBlocksChanged?.(positions);\n }\n }\n\n public async dispose(): Promise<void> {\n await this.clear();\n }\n\n static isAir(block: Maybe<Block>): boolean {\n return ChunkData.isAir(block);\n }\n\n /** Maps chunk-local coordinates from 0 to 15 to a storage index, with x varying fastest, then z, then y. */\n static chunkPosToBlockIndex(pos: Vector3): number {\n if ([pos.x, pos.y, pos.z].some(value => !Number.isInteger(value) || value < 0 || value >= 16)) {\n throw new RangeError(\"Block coordinates must be integers from 0 to 15 within a chunk\");\n }\n return (pos.y * 16 * 16) + (pos.z * 16) + pos.x;\n }\n\n worldPosToChunkPos(pos: Vector3): Vector3 {\n return new Vector3(\n pos.x - (this.x * 16),\n pos.y - (this.y * 16),\n pos.z - (this.z * 16)\n )\n }\n\n chunkPosToWorldPos(pos: Vector3): Vector3 {\n return new Vector3(\n (this.x * 16) + pos.x,\n (this.y * 16) + pos.y,\n (this.z * 16) + pos.z\n );\n }\n\n}\n"],"mappings":";AAEA,SAAS,OAAkC,eAAe;AAG1D,SAAS,iBAAiB;AAE1B,SAAS,mBAAmB;AAC5B,SAAS,gBAAgB;AACzB,SAAS,uBAAuB;AAChC,SAAS,qBAAkC;AAE3C,SAAS,qBAAqB;AAC9B,SAAwB,mBAAqC;AAC7D,SAAoB,0BAA0B;AAC9C,SAAS,mBAAmB;AAE5B,SAAS,yBAAyB;AAClC,SAAS,kBAAkB;AAC3B,SAAS,cAA8B;AAEvC,SAAS,2BAA2B;AAIpC,SAAS,WAAW,gBAAgB,mBAAmB;AACvD,SAA6C,kBAAkB,sBAAsB;AAErF,IAAM,aAAa,IAAI,MAAM,OAAQ,EAAE,QAAQ;AAOxC,IAAM,QAAN,MAAM,OAA8C;AAAA,EAwBvD,YAAY,OAAwB,GAAW,GAAW,GAC7B,iBACA,eACA,cACA,SACA,iBACA,SACA,gBACA,eAAe,GACf,YAA2C;AAR3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAzB7B,SAAiB,OAAO,IAAI,UAAU;AACtC,SAAiB,iBAAiB,oBAAI,IAAuC;AAC7E,SAAiB,eAAe,oBAAI,IAAY;AAChD,SAAiB,gBAAgB,oBAAI,IAAgC;AACrE,SAAiB,eAAe,oBAAI,IAAY;AAChD,SAAiB,aAAa,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AAK,KAAK,MAAM;AAChB,SAAK,SAAS;AACd,QAAI,QAAQ;AACR,YAAM,KAAK,kBAAkB,MAAS;AACtC,YAAM,KAAK,iBAAiB;AAC5B,YAAM,KAAK,kBAAkB,SAAS;AAAA,IAC1C;AAAA,EACJ;AAAA,EAEA,MAAa,UAAyB;AAClC,UAAM,KAAK,MAAM;AAAA,EACrB;AAAA,EAEA,OAAO,MAAM,OAA8B;AACvC,WAAO,UAAU,MAAM,KAAK;AAAA,EAChC;AAAA;AAAA,EAGA,OAAO,qBAAqB,KAAsB;AAC9C,QAAI,CAAC,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC,EAAE,KAAK,WAAS,CAAC,OAAO,UAAU,KAAK,KAAK,QAAQ,KAAK,SAAS,EAAE,GAAG;AAC3F,YAAM,IAAI,WAAW,gEAAgE;AAAA,IACzF;AACA,WAAQ,IAAI,IAAI,KAAK,KAAO,IAAI,IAAI,KAAM,IAAI;AAAA,EAClD;AAAA,EAEA,mBAAmB,KAAuB;AACtC,WAAO,IAAI;AAAA,MACP,IAAI,IAAK,KAAK,IAAI;AAAA,MAClB,IAAI,IAAK,KAAK,IAAI;AAAA,MAClB,IAAI,IAAK,KAAK,IAAI;AAAA,IACtB;AAAA,EACJ;AAAA,EAEA,mBAAmB,KAAuB;AACtC,WAAO,IAAI;AAAA,MACN,KAAK,IAAI,KAAM,IAAI;AAAA,MACnB,KAAK,IAAI,KAAM,IAAI;AAAA,MACnB,KAAK,IAAI,KAAM,IAAI;AAAA,IACxB;AAAA,EACJ;AAEJ;","names":["prepared","indices","entries"]}
|
|
1
|
+
{"version":3,"sources":["../../../../src/world/Chunk.ts"],"sourcesContent":["import { Block } from \"../model/block/Block\";\nimport { BlockObject, BlockObjectOptions } from \"../model/block/scene/BlockObject\";\nimport { Color, Mesh, Object3D, Raycaster, Vector3 } from \"three\";\nimport { Maybe } from \"../util/util\";\nimport { BlockInfo } from \"./BlockInfo\";\nimport { ChunkData } from \"./ChunkData\";\nimport { MineRenderScene } from \"../renderer/MineRenderScene\";\nimport { BlockStates } from \"../assets/BlockStates\";\nimport { AssetKey } from \"../assets/AssetKey\";\nimport { MineRenderWorld } from \"./MineRenderWorld\";\nimport { isTripleArray, TripleArray } from \"../model/Model\";\nimport { SectionModels } from \"./SectionModels\";\nimport { BlockEntities } from \"../assets/BlockEntities\";\nimport { SectionFluids, SectionMesh, SectionMeshEntry } from \"./SectionMesh\";\nimport { FluidKind, getBlockFluidState } from \"../model/fluid/FluidGeometry\";\nimport { fluidKindOf } from \"../model/fluid/FluidQuads\";\nimport { BlockState } from \"../model/block/BlockState\";\nimport { CUBE_FACE_OFFSETS } from \"../CubeFace\";\nimport { BlockTints } from \"../model/block/BlockTints\";\nimport { Biomes, BiomeColorKind } from \"../assets/Biomes\";\nimport { BiomeBlend } from \"./_biomes/BiomeBlend\";\nimport { isInstanceReference } from \"../instance/InstanceReference\";\nimport type { InstanceReference } from \"../instance/InstanceReference\";\nimport type { ModelObject } from \"../model/scene/ModelObject\";\nimport type { WorldBlockIntersection } from \"./WorldBlockIntersection\";\nimport { hitNormal, pickableMeshes, visibleHits } from \"./_picking/Picking\";\nimport { BlockCullingData, BlockCullingRule, blockCullingRule, skipsBlockFace } from \"./_culling/BlockCulling\";\n\nconst WATER_TINT = new Color(0x3f76e4).toArray() as TripleArray;\n\n/**\n * A 16×16×16 block section and its render objects.\n * Constructor coordinates identify the section. Block accessors use world block coordinates\n * unless their name explicitly refers to positions within the chunk.\n */\nexport class Chunk<SectionMeshing extends boolean = false> {\n\n public readonly scene: MineRenderScene; //TODO: should probably be the world\n\n public readonly x: number;\n public readonly y: number;\n public readonly z: number;\n\n private readonly data = new ChunkData();\n private readonly renderedBlocks = new Map<number, BlockInfo<SectionMeshing>>();\n private readonly objectBlocks = new Set<number>();\n private readonly sectionBlocks = new Map<number, SectionMeshEntry[]>();\n private readonly hiddenBlocks = new Set<number>();\n private readonly fluidCells = new Uint8Array(4096);\n private readonly blockPosition = new Vector3();\n private waterTints?: Float32Array;\n private biomes?: readonly string[];\n private sectionMesh?: SectionMesh;\n private meshDirty = false;\n private meshGeneration = 0;\n private ambientOcclusionCells?: Uint8Array;\n private readonly blockChanges = new Set<Promise<unknown>>();\n private biomeChange?: Promise<unknown>;\n\n constructor(scene: MineRenderScene, x: number, y: number, z: number,\n private readonly onBlocksChanged?: (positions: Vector3[], deferCulling?: boolean) => Promise<void>,\n private readonly sectionModels?: SectionModels,\n private readonly neighborCell?: (x: number, y: number, z: number) => number,\n private readonly biomeAt?: (x: number, y: number, z: number) => Maybe<string>,\n private readonly onBiomesChanged?: (biomes?: readonly string[]) => Promise<void>,\n private readonly lightAt?: (x: number, y: number, z: number) => number,\n private readonly onLightCleared?: () => Promise<void>,\n private readonly ambientLight = 0,\n private readonly biomeBlend?: () => BiomeBlend | undefined) {\n this.scene = scene;\n this.x = x;\n this.y = y;\n this.z = z;\n }\n\n /** Finds the nearest owned block hit across sections, testing each shared mesh once. */\n public static raycast<SectionMeshing extends boolean>(chunks: Iterable<Chunk<SectionMeshing>>, raycaster: Raycaster): WorldBlockIntersection | undefined {\n type Owner = { chunk: Chunk<SectionMeshing>; index: number };\n const roots = new Map<Object3D, Mesh[]>();\n const targets = new Map<Mesh, {\n owners: Map<number | undefined, Owner>;\n section?: { chunk: Chunk<SectionMeshing>; mesh: SectionMesh };\n }>();\n const meshes = (root: Object3D, scene: MineRenderScene): Mesh[] => {\n const cached = roots.get(root);\n if (cached) return cached;\n const result = pickableMeshes(root, scene, raycaster);\n roots.set(root, result);\n return result;\n };\n const add = (root: Object3D, owner: Owner, reference?: InstanceReference<ModelObject>) => {\n for (const mesh of meshes(root, owner.chunk.scene)) {\n if (reference && reference.instanceable.getInstanceReference(mesh, reference.index) !== reference) continue;\n let entry = targets.get(mesh);\n if (!entry) targets.set(mesh, entry = { owners: new Map() });\n entry.owners.set(reference?.index, owner);\n }\n };\n for (const chunk of chunks) {\n for (const index of chunk.objectBlocks) {\n const block = chunk.renderedBlocks.get(index)!.object;\n if (!block || !block.visible || chunk.hiddenBlocks.has(index)) continue;\n const owner = { chunk, index };\n for (const model of block.models) {\n if (isInstanceReference(model)) {\n if (model.instanceable.isInstanceActive(model.index, model)) add(model.instanceable, owner, model);\n } else {\n add(model, owner);\n }\n }\n for (const entity of block.blockEntities) add(entity, owner);\n }\n if (chunk.sectionMesh) {\n for (const mesh of meshes(chunk.sectionMesh, chunk.scene)) {\n targets.set(mesh, { owners: new Map(), section: { chunk, mesh: chunk.sectionMesh } });\n }\n }\n }\n for (const hit of visibleHits(raycaster, [...targets.keys()])) {\n const mesh = hit.object as Mesh;\n const entry = targets.get(mesh)!;\n let owner = entry.owners.get(hit.instanceId) ?? entry.owners.get(undefined);\n if (entry.section) {\n const index = entry.section.mesh.getBlockIndex(hit);\n if (index !== undefined) owner = { chunk: entry.section.chunk, index };\n }\n if (!owner || owner.chunk.hiddenBlocks.has(owner.index)) continue;\n const info = owner.chunk.renderedBlocks.get(owner.index);\n if (!info) continue;\n return {\n position: new Vector3(owner.chunk.x * 16 + owner.index % 16,\n owner.chunk.y * 16 + Math.floor(owner.index / 256), owner.chunk.z * 16 + Math.floor(owner.index / 16) % 16),\n block: info.block,\n point: hit.point.clone(),\n normal: hitNormal(hit),\n distance: hit.distance\n };\n }\n return undefined;\n }\n\n public getBlockAt(x: number, y: number, z: number): Maybe<BlockInfo<SectionMeshing>>;\n public getBlockAt(pos: Vector3): Maybe<BlockInfo<SectionMeshing>>;\n public getBlockAt(pos: TripleArray): Maybe<BlockInfo<SectionMeshing>>;\n public getBlockAt(posOrX: number | Vector3 | TripleArray, y?: number, z?: number): Maybe<BlockInfo<SectionMeshing>> {\n if (typeof posOrX == \"number\") {\n return this.getBlockAt(new Vector3(posOrX, y, z));\n }\n if (isTripleArray(posOrX)) {\n return this.getBlockAt(new Vector3(posOrX[0], posOrX[1], posOrX[2]))\n }\n const pos = this.blockPosition.set(posOrX.x - this.x * 16, posOrX.y - this.y * 16, posOrX.z - this.z * 16);\n const index = Chunk.chunkPosToBlockIndex(pos);\n return this.renderedBlocks.get(index);\n }\n\n /** Returns the saved 4-block biome sample at integer world block coordinates, or `undefined` if absent. */\n public getBiomeAt(x: number, y: number, z: number): Maybe<string>;\n public getBiomeAt(pos: Vector3): Maybe<string>;\n public getBiomeAt(pos: TripleArray): Maybe<string>;\n public getBiomeAt(posOrX: number | Vector3 | TripleArray, y?: number, z?: number): Maybe<string> {\n if (typeof posOrX === \"number\") return this.getBiomeAt(new Vector3(posOrX, y, z));\n if (isTripleArray(posOrX)) return this.getBiomeAt(new Vector3(...posOrX));\n const pos = this.worldPosToChunkPos(posOrX);\n Chunk.chunkPosToBlockIndex(pos);\n return this.biomeAt ? this.biomeAt(posOrX.x, posOrX.y, posOrX.z)\n : this.biomes?.[Math.floor(pos.x / 4) + Math.floor(pos.z / 4) * 4 + Math.floor(pos.y / 4) * 16];\n }\n\n /** Copies 64 biome IDs in x + z * 4 + y * 16 order and refreshes placed blocks. Omit the array to clear biome data. */\n public setBiomes(biomes?: readonly string[]): Promise<void> {\n const copy = biomes ? [...biomes] : undefined;\n if (copy && (copy.length !== 64 || !copy.every(id => typeof id === \"string\" && id.length > 0))) {\n throw new RangeError(\"Section biomes must contain 64 nonempty biome IDs\");\n }\n if (this.onBiomesChanged) return this.onBiomesChanged(copy);\n this.biomes = copy;\n return this.refreshBiomes();\n }\n\n /**\n * Rebuilds biome-tinted blocks while preserving hidden blocks and unrelated render objects.\n * The owning world can defer neighbor culling until all affected chunks are refreshed.\n */\n public refreshBiomes(columns?: readonly { x: number; z: number }[], deferCulling = false): Promise<void> {\n return this.changeBlocks(() => this.refreshBiomeBlocks(columns, deferCulling), true);\n }\n\n private async refreshBiomeBlocks(columns?: readonly { x: number; z: number }[], deferCulling = false): Promise<void> {\n const blend = columns && this.biomeBlend?.();\n // Individual objects keep their own biome's unblended color, so only a change to their own column affects them.\n const ownColumn = columns?.some(column => column.x === this.x && column.z === this.z);\n const affected = new Map<string, Promise<boolean>>();\n const blocks: { index: number; block: Block }[] = [];\n for (const index of this.renderedBlocks.keys()) {\n if (blend) {\n if (this.objectBlocks.has(index) && !ownColumn) continue;\n const [x, , z] = this.positionAt(index), radius = blend.radius;\n if (!columns!.some(column => x >= column.x * 16 - radius && x <= column.x * 16 + 15 + radius\n && z >= column.z * 16 - radius && z <= column.z * 16 + 15 + radius)) continue;\n }\n const block = this.data.get(index)!;\n const stateKey = ChunkData.paletteKey(block);\n let matches = affected.get(stateKey);\n if (!matches) {\n const key = AssetKey.parse(\"blockstates\", block.type);\n matches = BlockStates.get(key).then(async state => {\n const origin = state?.key ?? key;\n const [source, fluid] = await Promise.all([BlockTints.biomeSource(origin), getBlockFluidState(origin, block.properties)]);\n return !!source || fluid?.kind === \"water\";\n });\n affected.set(stateKey, matches);\n }\n if (await matches) blocks.push({ index, block });\n }\n if (blend) {\n const groups = new Map<string, typeof blocks>();\n for (const entry of blocks) {\n const key = ChunkData.paletteKey(entry.block);\n let group = groups.get(key);\n if (!group) groups.set(key, group = []);\n group.push(entry);\n }\n blocks.length = 0;\n const biomes = new Map<string, Promise<boolean>>();\n for (const group of groups.values()) {\n const { contexts, fluid } = await this.resolveState(group[0].block, group.map(entry => entry.index), biomes);\n for (const entry of group) {\n const context = contexts.get(entry.index);\n const current = this.sectionBlocks.get(entry.index)?.[0]?.biomeTint;\n const tint = context?.tint;\n const tintChanged = !!current !== !!tint || tint?.some((value, channel) => value !== current?.[channel]);\n const waterChanged = fluid?.kind === \"water\" && (context?.waterTint ?? WATER_TINT).some((value, channel) =>\n Math.fround(value) !== (this.waterTints?.[entry.index * 3 + channel] ?? Math.fround(WATER_TINT[channel])));\n if (this.objectBlocks.has(entry.index) || tintChanged || waterChanged) blocks.push(entry);\n }\n }\n }\n if (!blocks.length) return;\n const hidden = new Set(this.hiddenBlocks);\n try {\n await this.replaceBlocks(blocks, true);\n } finally {\n for (const index of hidden) {\n this.hiddenBlocks.add(index);\n this.renderedBlocks.get(index)?.object?.setVisible(false);\n }\n const positions = blocks.map(({ index }) => new Vector3(...this.positionAt(index)));\n if (this.onBlocksChanged) await this.onBlocksChanged(positions, deferCulling);\n else await this.rebuildSectionMesh();\n }\n }\n\n /**\n * Places a block at integer world block coordinates. Pass `undefined` to remove it.\n */\n public async setBlockAt(x: number, y: number, z: number, block: Maybe<Block>): Promise<Maybe<BlockInfo<SectionMeshing>>>;\n public async setBlockAt(pos: Vector3, block: Maybe<Block>): Promise<Maybe<BlockInfo<SectionMeshing>>>;\n public async setBlockAt(pos: TripleArray, block: Maybe<Block>): Promise<Maybe<BlockInfo<SectionMeshing>>>;\n public async setBlockAt(posOrX: number | Vector3 | TripleArray, yOrBlock?: number | Block, z?: number, block?: Block): Promise<Maybe<BlockInfo<SectionMeshing>>> {\n if (typeof posOrX == \"number\") {\n return this.setBlockAt(new Vector3(posOrX, yOrBlock as number, z), block as Block);\n }\n if (isTripleArray(posOrX)) {\n return this.setBlockAt(new Vector3(posOrX[0], posOrX[1], posOrX[2]), yOrBlock as Block);\n }\n const worldPos: Vector3 = posOrX;\n const pos: Vector3 = this.worldPosToChunkPos(worldPos);\n block = yOrBlock as Block;\n\n return this.setBlockInChunkAt(pos, block, worldPos);\n }\n\n /**\n * Places a block at integer chunk-local coordinates from 0 to 15.\n */\n public async setBlockInChunkAt(pos: Vector3, block?: Block, worldPos?: Vector3,\n onBlocksChanged = this.onBlocksChanged): Promise<Maybe<BlockInfo<SectionMeshing>>> {\n if (typeof worldPos === \"undefined\") {\n worldPos = this.chunkPosToWorldPos(pos);\n }\n\n const index = Chunk.chunkPosToBlockIndex(pos);\n try {\n await this.placeBlocks([{ index, block }]);\n return this.renderedBlocks.get(index);\n } finally {\n await onBlocksChanged?.([worldPos]);\n }\n }\n\n /** Places cells in input order and returns changed world positions without refreshing neighbors. */\n public async placeBlocks(blocks: readonly { index: number; block: Maybe<Block> }[]): Promise<Vector3[]> {\n return this.changeBlocks(() => this.replaceBlocks(blocks));\n }\n\n private changeBlocks<T>(change: () => Promise<T>, refreshBiomes = false): Promise<T> {\n // Color refreshes snapshot existing blocks; edits on either side of that snapshot must retain their order.\n const before = refreshBiomes ? Promise.allSettled(this.blockChanges) : this.biomeChange;\n const result = before ? before.catch(() => undefined).then(change) : change();\n const pending = result.finally(() => {\n this.blockChanges.delete(pending);\n if (this.biomeChange === pending) this.biomeChange = undefined;\n });\n this.blockChanges.add(pending);\n if (refreshBiomes) this.biomeChange = pending;\n return pending;\n }\n\n private async replaceBlocks(blocks: readonly { index: number; block: Maybe<Block> }[], preserveDataOnFailure = false): Promise<Vector3[]> {\n const placements = blocks.map(({ index, block }) => ({\n index,\n key: block && !ChunkData.isAir(block) ? ChunkData.paletteKey(block) : undefined,\n block: block ? {\n type: block.type,\n properties: block.properties ? { ...block.properties } : undefined,\n nbt: block.nbt === undefined ? undefined : structuredClone(block.nbt)\n } : undefined\n }));\n const states = new Map<string, { stored: Block; indices: number[] }>();\n for (const { index, key, block } of placements) {\n if (key === undefined) continue;\n let state = states.get(key);\n if (!state) states.set(key, state = { stored: block!, indices: [] });\n state.indices.push(index);\n }\n const biomes = new Map<string, Promise<boolean>>();\n const settled = await Promise.allSettled([...states.values()].map(({ stored, indices }) =>\n this.resolveState(stored, indices, biomes)));\n const resolutions = new Map([...states.keys()].map((key, i) => [key, settled[i]]));\n if (preserveDataOnFailure) {\n const rejected = settled.find(result => result.status === \"rejected\");\n if (rejected?.status === \"rejected\") throw rejected.reason;\n }\n const positions: Vector3[] = [];\n const jobs = new Map<number, { order: number; readBlock: () => Block; blockState: BlockState;\n position: Vector3; options: Partial<BlockObjectOptions> }>();\n let failureOrder = Infinity, failure: unknown;\n for (const [order, { index, key, block }] of placements.entries()) {\n jobs.delete(index);\n this.hiddenBlocks.delete(index);\n this.data.assign(index, this.data.intern(block), block?.nbt);\n const readBlock = this.data.snapshot(index);\n this.renderedBlocks.get(index)?.object?.removeFromScene();\n if (this.sectionBlocks.delete(index)) this.meshDirty = true;\n if (this.fluidCells[index]) this.meshDirty = true;\n this.fluidCells[index] = 0;\n this.renderedBlocks.delete(index);\n this.objectBlocks.delete(index);\n const worldPos = new Vector3(this.x * 16 + index % 16, this.y * 16 + Math.floor(index / 256),\n this.z * 16 + Math.floor(index / 16) % 16);\n positions.push(worldPos);\n try {\n if (!readBlock) continue;\n const resolved = resolutions.get(key!)!;\n if (resolved.status === \"rejected\") throw resolved.reason;\n const { blockState, perBlock, fluid, prepared, contexts, stored } = resolved.value;\n const context = contexts.get(index);\n if (!blockState) {\n this.data.assign(index, 0);\n continue;\n }\n const variantPosition = worldPos.toArray();\n if (fluid) {\n this.fluidCells[index] = (fluid.kind === \"water\" ? 16 : 32) | Math.min(fluid.level, 8);\n if (fluid.kind === \"water\") this.setWaterTint(index, context?.waterTint);\n this.meshDirty = true;\n }\n const templates = perBlock ? undefined : fluid?.renderModel === false ? [] : (context?.prepared ?? prepared)?.pick(variantPosition);\n if (templates) {\n this.sectionBlocks.set(index, templates.map(template => ({ index, template, cullMask: 0, biomeTint: context?.tint })));\n this.meshDirty = true;\n } else {\n jobs.set(index, { order, readBlock, blockState, position: MineRenderWorld.worldToScenePosition(worldPos), options: {\n mergeMeshes: true,\n instanceMeshes: true,\n maxInstanceCount: 2000,\n initialState: stored.properties,\n variantPosition, biome: context?.biome,\n biomePosition: this.biomePosition(index, blockState, stored)\n } });\n continue;\n }\n this.renderedBlocks.set(index, { get block() { return readBlock(); }, object: undefined } as BlockInfo<SectionMeshing>);\n } catch (error) {\n if (preserveDataOnFailure && readBlock) {\n // Keep saved block data available for a failed color refresh to retry.\n this.renderedBlocks.set(index, { get block() { return readBlock(); }, object: undefined } as BlockInfo<SectionMeshing>);\n } else this.data.assign(index, 0);\n this.fluidCells[index] = 0;\n if (order < failureOrder) { failureOrder = order; failure = error; }\n }\n }\n const pending = [...jobs];\n const objects = await Promise.allSettled(pending.map(([, job]) =>\n this.createBlockObject(job.blockState, job.position, job.options)));\n for (const [i, [index, { order, readBlock }]] of pending.entries()) {\n const result = objects[i];\n if (result.status === \"fulfilled\") {\n this.renderedBlocks.set(index, { get block() { return readBlock(); }, object: result.value } as BlockInfo<SectionMeshing>);\n this.objectBlocks.add(index);\n } else {\n if (preserveDataOnFailure) {\n // Keep saved block data available for a failed color refresh to retry.\n this.renderedBlocks.set(index, { get block() { return readBlock(); }, object: undefined } as BlockInfo<SectionMeshing>);\n } else this.data.assign(index, 0);\n this.fluidCells[index] = 0;\n if (order < failureOrder) { failureOrder = order; failure = result.reason; }\n }\n }\n if (failureOrder < Infinity) throw failure;\n return positions;\n }\n\n /** Replaces every cell from parsed section data. The caller refreshes neighbor culling. */\n public placeSection(data: ChunkData): Promise<void> {\n return this.changeBlocks(() => this.replaceSection(data));\n }\n\n private async replaceSection(data: ChunkData): Promise<void> {\n for (const info of this.renderedBlocks.values()) info.object?.removeFromScene();\n this.sectionBlocks.clear();\n this.fluidCells.fill(0);\n this.waterTints = undefined;\n this.renderedBlocks.clear();\n this.objectBlocks.clear();\n this.hiddenBlocks.clear();\n this.meshDirty = true;\n this.data.copyFrom(data);\n\n const ids = new Map<number, number[]>();\n for (let index = 0; index < 4096; index++) {\n const id = this.data.idAt(index);\n if (!id) continue;\n let indices = ids.get(id);\n if (!indices) ids.set(id, indices = []);\n indices.push(index);\n }\n const palette = [...ids.keys()], biomes = new Map<string, Promise<boolean>>();\n const settled = await Promise.allSettled(palette.map(id =>\n this.resolveState(this.data.stateAt(id)!, ids.get(id)!, biomes)));\n const resolutions = new Map(palette.map((id, i) => [id, settled[i]]));\n const perBlocks: { index: number; blockState: BlockState; biome?: string }[] = [];\n let failed = false, failure: unknown;\n for (let index = 0; index < 4096; index++) {\n const id = this.data.idAt(index);\n if (!id) continue;\n try {\n const resolved = resolutions.get(id)!;\n if (resolved.status === \"rejected\") throw resolved.reason;\n const { blockState, perBlock, fluid, prepared, contexts } = resolved.value;\n const context = contexts.get(index);\n if (!blockState) {\n this.data.assign(index, 0);\n this.fluidCells[index] = 0;\n continue;\n }\n if (fluid) {\n this.fluidCells[index] = (fluid.kind === \"water\" ? 16 : 32) | Math.min(fluid.level, 8);\n if (fluid.kind === \"water\") this.setWaterTint(index, context?.waterTint);\n }\n const variantPosition: TripleArray = [this.x * 16 + index % 16,\n this.y * 16 + Math.floor(index / 256), this.z * 16 + Math.floor(index / 16) % 16];\n const templates = perBlock ? undefined : fluid?.renderModel === false ? [] : (context?.prepared ?? prepared)?.pick(variantPosition);\n if (templates) {\n this.sectionBlocks.set(index, templates.map(template => ({ index, template, cullMask: 0, biomeTint: context?.tint })));\n this.meshDirty = true;\n } else {\n perBlocks.push({ index, blockState, biome: context?.biome });\n }\n const readBlock = this.data.snapshot(index)!;\n this.renderedBlocks.set(index, { get block() { return readBlock(); }, object: undefined } as BlockInfo<SectionMeshing>);\n this.objectBlocks.delete(index);\n } catch (error) {\n this.data.assign(index, 0);\n this.fluidCells[index] = 0;\n if (!failed) failure = error;\n failed = true;\n }\n }\n const objects = await Promise.allSettled(perBlocks.map(({ index, blockState, biome }) =>\n this.createBlockObject(blockState, new Vector3(this.x * 256 + index % 16 * 16,\n this.y * 256 + Math.floor(index / 256) * 16, this.z * 256 + Math.floor(index / 16) % 16 * 16), {\n mergeMeshes: true,\n instanceMeshes: true,\n maxInstanceCount: 2000,\n initialState: this.data.stateAt(this.data.idAt(index))!.properties,\n variantPosition: this.positionAt(index), biome,\n biomePosition: this.biomePosition(index, blockState, this.data.stateAt(this.data.idAt(index))!)\n })));\n for (const [i, { index }] of perBlocks.entries()) {\n const result = objects[i];\n if (result.status === \"fulfilled\") {\n this.renderedBlocks.get(index)!.object = result.value;\n this.objectBlocks.add(index);\n } else {\n this.data.assign(index, 0);\n this.fluidCells[index] = 0;\n this.renderedBlocks.delete(index);\n this.objectBlocks.delete(index);\n if (!failed) failure = result.reason;\n failed = true;\n }\n }\n if (failed) throw failure;\n }\n\n private createBlockObject(blockState: BlockState, position: Vector3, options: Partial<BlockObjectOptions>): Promise<BlockObject> {\n return this.scene.addSceneObject(blockState, () => {\n const object = new BlockObject(blockState, options);\n // Init places models, the fluid surface, and block entities here so they never draw at the origin.\n object.position.copy(position);\n return object;\n }, options) as Promise<BlockObject>;\n }\n\n private positionAt(index: number): TripleArray {\n return [this.x * 16 + index % 16, this.y * 16 + Math.floor(index / 256), this.z * 16 + Math.floor(index / 16) % 16];\n }\n\n /** Refreshes saved lighting after adjacent columns load or unload, including columns with only light data. */\n public async refreshLight(indices?: Iterable<number>): Promise<void> {\n if (!this.lightAt) return;\n for (const index of indices ?? this.renderedBlocks.keys()) {\n if (this.renderedBlocks.has(index)) this.meshDirty = true;\n }\n }\n\n /** Refreshes baked corner shading after edits or a world setting change. Disabled chunks keep no AO neighborhood. */\n public refreshAmbientOcclusion(enabled: boolean): void {\n if (!enabled && !this.ambientOcclusionCells) return;\n const cells = enabled ? this.buildAmbientOcclusionCells() : undefined;\n if (cells?.some((value, index) => value !== this.ambientOcclusionCells?.[index])\n || !!cells !== !!this.ambientOcclusionCells) this.meshDirty = true;\n this.ambientOcclusionCells = cells;\n }\n\n private buildAmbientOcclusionCells(): Uint8Array {\n const cells = new Uint8Array(18 * 18 * 18);\n for (let y = -1; y <= 16; y++) {\n for (let z = -1; z <= 16; z++) {\n for (let x = -1; x <= 16; x++) {\n const inner = x >= 0 && x < 16 && y >= 0 && y < 16 && z >= 0 && z < 16;\n cells[(y + 1) * 324 + (z + 1) * 18 + x + 1] = inner\n ? Number(this.isOccludingIndex(y * 256 + z * 16 + x))\n : Number(!!((this.neighborCell?.(this.x * 16 + x, this.y * 16 + y, this.z * 16 + z) ?? 0) & 64));\n }\n }\n }\n return cells;\n }\n\n private biomePosition(index: number, blockState: BlockState, stored: Block): TripleArray {\n const position = this.positionAt(index), name = blockState.key?.toNamespacedString();\n if (stored.properties?.half === \"upper\" && (name === \"minecraft:tall_grass\" || name === \"minecraft:large_fern\")) position[1]--;\n return position;\n }\n\n private async resolveState(stored: Block, indices: readonly number[], biomes: Map<string, Promise<boolean>>) {\n const blockState = await BlockStates.get(AssetKey.parse(\"blockstates\", stored.type));\n let perBlock = !blockState || !this.sectionModels\n || !!(blockState.key && BlockEntities.entry(await BlockEntities.getIndex(blockState.key.root), blockState.key.toNamespacedString()));\n const fluid = await getBlockFluidState(blockState?.key, stored.properties);\n const hasBiomes = this.getBiomeAt(this.x * 16, this.y * 16, this.z * 16) !== undefined\n || this.biomeAt?.(this.x * 16, this.y * 16 - 1, this.z * 16) !== undefined;\n const source = hasBiomes && blockState ? await BlockTints.biomeSource(blockState.key) : undefined;\n const prepare = (color?: () => Promise<number | undefined>) => perBlock || fluid?.renderModel === false ? undefined\n : this.sectionModels!.prepareState(blockState!, stored.properties, color);\n type Context = {\n biome?: string;\n prepared?: Awaited<ReturnType<SectionModels[\"prepareState\"]>>;\n tint?: TripleArray;\n waterTint?: TripleArray;\n };\n const contexts = new Map<number, Context>();\n const blend = this.biomeBlend?.();\n if (blend && !perBlock && blockState && (source || fluid?.kind === \"water\")) {\n const prepared = fluid?.renderModel === false ? undefined\n : await this.sectionModels!.prepareState(blockState, stored.properties, undefined, true);\n if (!prepared && fluid?.renderModel !== false) {\n // A model that cannot join the section mesh becomes an individual object with its own biome's color.\n perBlock = true;\n } else {\n await Promise.all(indices.map(async index => {\n const position = this.biomePosition(index, blockState, stored);\n const biomeColor = (kind: BiomeColorKind) => blend.getColor(kind, blockState.key, position);\n const context: Context = {};\n if (source && prepared?.biomeTint) {\n const color = await biomeColor(source);\n if (color !== undefined) context.tint = new Color(color).toArray() as TripleArray;\n }\n if (fluid?.kind === \"water\") {\n const color = await biomeColor(\"water\");\n if (color !== undefined && color !== 0x3f76e4) context.waterTint = new Color(color).toArray() as TripleArray;\n }\n contexts.set(index, context);\n }));\n return { blockState, perBlock, fluid, prepared, contexts, stored };\n }\n }\n const groups = new Map<string, { biome: string; position: TripleArray; indices: number[] }>();\n if (blockState && (source || fluid?.kind === \"water\")) {\n for (const index of indices) {\n const position = this.biomePosition(index, blockState, stored);\n const biome = this.biomeAt ? this.biomeAt(...position)\n : position[1] >= this.y * 16 ? this.getBiomeAt(position) : undefined;\n if (!biome) continue;\n const key = JSON.stringify(source === \"grass\" ? [biome, position[0], position[2]] : [biome]);\n let group = groups.get(key);\n if (!group) groups.set(key, group = { biome, position, indices: [] });\n group.indices.push(index);\n }\n }\n const groupedCount = [...groups.values()].reduce((sum, group) => sum + group.indices.length, 0);\n const prepared = groupedCount < indices.length ? await prepare() : undefined;\n await Promise.all([...groups.values()].map(async ({ biome, position, indices }) => {\n const available = () => {\n const key = JSON.stringify([biome, blockState?.key?.root]);\n let found = biomes.get(key);\n if (!found) {\n found = Biomes.get(biome, blockState?.key).then(value => value !== undefined);\n biomes.set(key, found);\n }\n return found;\n };\n const context: Context = { biome };\n if (perBlock) {\n if (!await available()) context.biome = undefined;\n } else {\n context.prepared = await prepare(async () => await available()\n ? BlockTints.getBiomeColor(blockState?.key, biome, position) : undefined);\n if (fluid?.kind === \"water\" && await available()) {\n const color = await Biomes.getColor(biome, \"water\", blockState?.key);\n if (color !== undefined && color !== 0x3f76e4) context.waterTint = new Color(color).toArray() as TripleArray;\n }\n }\n for (const index of indices) contexts.set(index, context);\n }));\n return { blockState, perBlock, fluid, prepared, contexts, stored };\n }\n\n private setWaterTint(index: number, tint?: TripleArray): void {\n if (!this.sectionModels || (!this.waterTints && tint === undefined)) return;\n if (!this.waterTints) {\n this.waterTints = new Float32Array(4096 * 3);\n for (let cell = 0; cell < 4096; cell++) this.waterTints.set(WATER_TINT, cell * 3);\n }\n this.waterTints.set(tint ?? WATER_TINT, index * 3);\n }\n\n /** Changes visibility at world block coordinates while preserving the block's data. */\n public setBlockVisibleAt(pos: Vector3, visible: boolean): Promise<void> {\n const position = pos.clone();\n return this.changeBlocks(() => this.setBlockVisibility(position, visible));\n }\n\n private async setBlockVisibility(pos: Vector3, visible: boolean): Promise<void> {\n const index = Chunk.chunkPosToBlockIndex(this.worldPosToChunkPos(pos));\n const block = this.renderedBlocks.get(index);\n if (!block || visible === !this.hiddenBlocks.has(index)) {\n return;\n }\n if (visible) {\n this.hiddenBlocks.delete(index);\n } else {\n this.hiddenBlocks.add(index);\n }\n block.object?.setVisible(visible);\n if (this.sectionBlocks.has(index) || this.fluidCells[index]) {\n this.meshDirty = true;\n }\n this.scene.dirty = true;\n await this.onBlocksChanged?.([pos]);\n }\n\n public isBlockVisibleAt(pos: Vector3): boolean {\n return this.isBlockVisibleIndex(Chunk.chunkPosToBlockIndex(this.worldPosToChunkPos(pos)));\n }\n\n /** Reports whether a cell has a visible render object or section entry. */\n public isBlockVisibleIndex(index: number): boolean {\n return this.renderedBlocks.has(index) && !this.hiddenBlocks.has(index);\n }\n\n /** Stored state of a rendered, visible cell, or `undefined`. */\n public visibleBlockIndex(index: number): Maybe<Pick<Block, \"type\" | \"properties\">> {\n return this.isBlockVisibleIndex(index) ? this.data.stateAt(this.data.idAt(index)) : undefined;\n }\n\n /** Fluid kind bits and level of a cell, or 0. Hidden cells report 0. */\n public fluidByteIndex(index: number): number {\n return this.hiddenBlocks.has(index) ? 0 : this.fluidCells[index];\n }\n\n /** Whether the cell holds a fluid, merged or per-block. */\n public isFluidIndex(index: number): boolean {\n return this.fluidCells[index] !== 0;\n }\n\n public isOccludingAt(pos: Vector3): boolean {\n return this.isOccludingIndex(Chunk.chunkPosToBlockIndex(this.worldPosToChunkPos(pos)));\n }\n\n /** Reports whether a visible cell hides neighboring cube faces. */\n public isOccludingIndex(index: number): boolean {\n return !this.hiddenBlocks.has(index)\n && (this.sectionBlocks.get(index)?.some(entry => entry.template.occludes)\n ?? this.renderedBlocks.get(index)?.object?.isOccluding ?? false);\n }\n\n public async setCullMaskAt(pos: Vector3, mask: number): Promise<void> {\n await this.setCullMaskIndex(Chunk.chunkPosToBlockIndex(this.worldPosToChunkPos(pos)), mask);\n }\n\n /**\n * Recomputes section masks and returns changed per-block masks. Omit indices to visit every cell.\n * `culling` supplies neighbor face rules; `blockAt` supplies visible states outside this chunk.\n */\n public updateCullMasks(indices: Iterable<number> | undefined, occludes: (x: number, y: number, z: number) => boolean,\n culling?: BlockCullingData, blockAt?: (x: number, y: number, z: number) => Maybe<Pick<Block, \"type\" | \"properties\">>): [number, number][] {\n const changed: [number, number][] = [];\n const rules: (BlockCullingRule | null | undefined)[] = [];\n for (const index of indices ?? this.fluidCells.keys()) {\n if (!this.isBlockVisibleIndex(index)) continue;\n const x = index % 16, y = Math.floor(index / 256), z = Math.floor(index / 16) % 16;\n const id = this.data.idAt(index);\n let rule = rules[id];\n if (culling && rule === undefined) rules[id] = rule = blockCullingRule(culling, this.data.stateAt(id)!.type) ?? null;\n const block = rule ? this.data.stateAt(id)! : undefined;\n let mask = 0;\n for (let face = 0; face < CUBE_FACE_OFFSETS.length; face++) {\n const [dx, dy, dz] = CUBE_FACE_OFFSETS[face];\n const nx = x + dx, ny = y + dy, nz = z + dz;\n const inner = nx >= 0 && nx < 16 && ny >= 0 && ny < 16 && nz >= 0 && nz < 16;\n if (inner ? this.isOccludingIndex(ny * 256 + nz * 16 + nx)\n : occludes(this.x * 16 + nx, this.y * 16 + ny, this.z * 16 + nz)) mask |= 1 << face;\n else if (rule) {\n const neighbor = inner ? this.visibleBlockIndex(ny * 256 + nz * 16 + nx)\n : blockAt?.(this.x * 16 + nx, this.y * 16 + ny, this.z * 16 + nz);\n if (neighbor && skipsBlockFace(culling!, rule, block!, neighbor, face)) mask |= 1 << face;\n }\n }\n if (this.fluidCells[index]) this.meshDirty = true;\n const entries = this.sectionBlocks.get(index);\n if (entries) {\n for (const entry of entries) {\n if (entry.cullMask !== mask) {\n entry.cullMask = mask;\n this.meshDirty = true;\n }\n }\n } else {\n const object = this.renderedBlocks.get(index)?.object;\n if (object && object.cullMask !== mask) changed.push([index, mask]);\n }\n }\n return changed;\n }\n\n /** Updates hidden faces for a cell's section entry or individual render object. */\n public async setCullMaskIndex(index: number, mask: number): Promise<void> {\n if (this.fluidCells[index]) this.meshDirty = true;\n const entries = this.sectionBlocks.get(index);\n if (entries) {\n for (const entry of entries) {\n if (entry.cullMask !== mask) {\n entry.cullMask = mask;\n this.meshDirty = true;\n }\n }\n } else {\n await this.renderedBlocks.get(index)?.object?.setCullMask(mask);\n }\n }\n\n /** Rebuilds visible section geometry and discards results superseded by another rebuild or clear. */\n public async rebuildSectionMesh(): Promise<void> {\n if (!this.sectionModels || !this.meshDirty) return;\n this.meshDirty = false;\n const generation = ++this.meshGeneration;\n const entries = [...this.sectionBlocks.entries()].flatMap(([index, entries]) => this.hiddenBlocks.has(index) ? [] : entries);\n let fluids: SectionFluids | undefined;\n const origins = new Map<FluidKind, string>();\n for (let index = 0; index < this.fluidCells.length; index++) {\n const kind = fluidKindOf(this.fluidCells[index]);\n if (!kind || origins.has(kind) || this.hiddenBlocks.has(index)) continue;\n const block = this.renderedBlocks.get(index);\n if (block && !block.object) origins.set(kind, block.block.type);\n }\n if (origins.size) {\n fluids = { cells: new Uint8Array(18 * 18 * 18), waterTints: this.waterTints?.slice() };\n for (let y = -1; y <= 16; y++) {\n for (let z = -1; z <= 16; z++) {\n for (let x = -1; x <= 16; x++) {\n const index = y * 256 + z * 16 + x;\n const inner = x >= 0 && x < 16 && y >= 0 && y < 16 && z >= 0 && z < 16;\n fluids.cells[(y + 1) * 324 + (z + 1) * 18 + x + 1] = inner\n ? this.fluidByteIndex(index) | (this.renderedBlocks.get(index)?.object ? 128 : 0)\n | (this.isOccludingIndex(index) ? 64 : 0)\n : this.neighborCell?.(this.x * 16 + x, this.y * 16 + y, this.z * 16 + z) ?? 0;\n }\n }\n }\n for (const [kind, type] of origins) {\n const state = await BlockStates.get(AssetKey.parse(\"blockstates\", type));\n fluids[kind] = await this.sectionModels.fluidAtlas(kind, state?.key?.root);\n }\n }\n let light: Uint8Array | undefined;\n if (this.lightAt) {\n light = new Uint8Array(18 * 18 * 18);\n for (let y = -1; y <= 16; y++) {\n for (let z = -1; z <= 16; z++) {\n for (let x = -1; x <= 16; x++) {\n light[(y + 1) * 324 + (z + 1) * 18 + x + 1] = this.lightAt(this.x * 16 + x, this.y * 16 + y, this.z * 16 + z);\n }\n }\n }\n }\n let next: SectionMesh | undefined;\n try {\n next = entries.length || fluids ? await SectionMesh.buildAsync(entries, this.sectionModels.maxAtlasSize, fluids,\n { light, ambientLight: this.ambientLight, ambientOcclusion: this.ambientOcclusionCells }) : undefined;\n } catch (error) {\n if (generation === this.meshGeneration) this.meshDirty = true;\n throw error;\n }\n if (generation !== this.meshGeneration) {\n next?.dispose();\n return;\n }\n this.sectionMesh?.dispose();\n this.sectionMesh = next;\n if (next) {\n next.position.set(this.x * 256, this.y * 256, this.z * 256);\n this.scene.add(next);\n }\n this.scene.dirty = true;\n }\n\n /** Removes stored blocks and render objects. Set `notify` to false to skip the owning world's update. */\n public async clear(notify = true): Promise<void> {\n if (this.blockChanges.size) await Promise.allSettled(this.blockChanges);\n const positions = notify && this.onBlocksChanged ? [...this.renderedBlocks.keys()].map(index => this.chunkPosToWorldPos(\n new Vector3(index % 16, Math.floor(index / 256), Math.floor(index / 16) % 16)\n )) : [];\n for (const info of this.renderedBlocks.values()) info.object?.removeFromScene();\n this.sectionBlocks.clear();\n this.meshGeneration++;\n this.sectionMesh?.dispose();\n this.sectionMesh = undefined;\n this.meshDirty = false;\n this.renderedBlocks.clear();\n this.objectBlocks.clear();\n this.hiddenBlocks.clear();\n this.fluidCells.fill(0);\n this.waterTints = undefined;\n this.ambientOcclusionCells = undefined;\n this.data.clear();\n this.biomes = undefined;\n if (notify) {\n await this.onBiomesChanged?.(undefined);\n await this.onLightCleared?.();\n await this.onBlocksChanged?.(positions);\n }\n }\n\n public async dispose(): Promise<void> {\n await this.clear();\n }\n\n static isAir(block: Maybe<Block>): boolean {\n return ChunkData.isAir(block);\n }\n\n /** Maps chunk-local coordinates from 0 to 15 to a storage index, with x varying fastest, then z, then y. */\n static chunkPosToBlockIndex(pos: Vector3): number {\n if ([pos.x, pos.y, pos.z].some(value => !Number.isInteger(value) || value < 0 || value >= 16)) {\n throw new RangeError(\"Block coordinates must be integers from 0 to 15 within a chunk\");\n }\n return (pos.y * 16 * 16) + (pos.z * 16) + pos.x;\n }\n\n worldPosToChunkPos(pos: Vector3): Vector3 {\n return new Vector3(\n pos.x - (this.x * 16),\n pos.y - (this.y * 16),\n pos.z - (this.z * 16)\n )\n }\n\n chunkPosToWorldPos(pos: Vector3): Vector3 {\n return new Vector3(\n (this.x * 16) + pos.x,\n (this.y * 16) + pos.y,\n (this.z * 16) + pos.z\n );\n }\n\n}\n"],"mappings":";AACA,SAAS,mBAAuC;AAChD,SAAS,OAAkC,eAAe;AAG1D,SAAS,iBAAiB;AAE1B,SAAS,mBAAmB;AAC5B,SAAS,gBAAgB;AACzB,SAAS,uBAAuB;AAChC,SAAS,qBAAkC;AAE3C,SAAS,qBAAqB;AAC9B,SAAwB,mBAAqC;AAC7D,SAAoB,0BAA0B;AAC9C,SAAS,mBAAmB;AAE5B,SAAS,yBAAyB;AAClC,SAAS,kBAAkB;AAC3B,SAAS,cAA8B;AAEvC,SAAS,2BAA2B;AAIpC,SAAS,WAAW,gBAAgB,mBAAmB;AACvD,SAA6C,kBAAkB,sBAAsB;AAErF,IAAM,aAAa,IAAI,MAAM,OAAQ,EAAE,QAAQ;AAOxC,IAAM,QAAN,MAAM,OAA8C;AAAA,EAwBvD,YAAY,OAAwB,GAAW,GAAW,GAC7B,iBACA,eACA,cACA,SACA,iBACA,SACA,gBACA,eAAe,GACf,YAA2C;AAR3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAzB7B,SAAiB,OAAO,IAAI,UAAU;AACtC,SAAiB,iBAAiB,oBAAI,IAAuC;AAC7E,SAAiB,eAAe,oBAAI,IAAY;AAChD,SAAiB,gBAAgB,oBAAI,IAAgC;AACrE,SAAiB,eAAe,oBAAI,IAAY;AAChD,SAAiB,aAAa,IAAI,WAAW,IAAI;AACjD,SAAiB,gBAAgB,IAAI,QAAQ;AAI7C,SAAQ,YAAY;AACpB,SAAQ,iBAAiB;AAEzB,SAAiB,eAAe,oBAAI,IAAsB;AAatD,SAAK,QAAQ;AACb,SAAK,IAAI;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