minerender 2.1.0-alpha.36 → 2.1.0-alpha.37

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.
@@ -1679,7 +1679,8 @@ declare function toTrianglesDrawMode(geometry: BufferGeometry, drawMode: Triangl
1679
1679
  declare function computeMorphedAttributes(object: Mesh | Line | Points): object;
1680
1680
 
1681
1681
  interface BlockInfo {
1682
- block: Block;
1682
+ /** Detached block data; use world or chunk setters to update stored blocks. */
1683
+ readonly block: Block;
1683
1684
  object: BlockObject;
1684
1685
  }
1685
1686
 
@@ -1688,7 +1689,8 @@ declare class Chunk {
1688
1689
  readonly x: number;
1689
1690
  readonly y: number;
1690
1691
  readonly z: number;
1691
- private readonly _blocks;
1692
+ private readonly data;
1693
+ private readonly renderedBlocks;
1692
1694
  constructor(scene: MineRenderScene, x: number, y: number, z: number);
1693
1695
  getBlockAt(x: number, y: number, z: number): Maybe<BlockInfo>;
1694
1696
  getBlockAt(pos: Vector3): Maybe<BlockInfo>;
@@ -1711,6 +1713,21 @@ declare class Chunk {
1711
1713
  chunkPosToWorldPos(pos: Vector3): Vector3;
1712
1714
  }
1713
1715
 
1716
+ declare class ChunkData {
1717
+ private readonly indices;
1718
+ private readonly palette;
1719
+ private readonly paletteIds;
1720
+ private readonly freeIds;
1721
+ private readonly nbt;
1722
+ get(index: number): Maybe<Block>;
1723
+ snapshot(index: number): Maybe<() => Block>;
1724
+ set(index: number, block?: Block): void;
1725
+ clear(): void;
1726
+ static isAir(block: Maybe<Block>): boolean;
1727
+ private static copyBlock;
1728
+ private static validateIndex;
1729
+ }
1730
+
1714
1731
  declare class MineRenderWorld {
1715
1732
  readonly scene: MineRenderScene;
1716
1733
  private readonly _chunks;
@@ -1767,4 +1784,4 @@ declare class BrowserCache extends PersistentCache<LocalForage> {
1767
1784
  */
1768
1785
  declare function probeImageSize(data: Uint8Array): ImageSizeInfo;
1769
1786
 
1770
- export { AXES, type AnimationFrame, type AnimationMeta, type AnimatorFunction, ArchiveAssetSource, type ArchiveEntry, type ArchiveProxy, AssetKey, AssetLoadError, AssetLoader, AssetParser, AssetSource, type AssetType, Assets, Axis, BUILTIN_ENTITY, BUILTIN_GENERATED, BasicAssetKey, type BasicMinecraftAsset, BatchedExecutor, type BedrockBone, type BedrockCube, type BedrockEntityDescription, type BedrockEntityFile, type BedrockGeometry, type BedrockGeometryFile, type Block, type BlockInfo, type BlockModel, type BlockModelTextures, BlockObject, type BlockObjectOptions, type BlockState, type BlockStateMultipart, type BlockStateProperties, type BlockStateProperty, type BlockStatePropertyDefaults, type BlockStatePropertyValue, type BlockStateVariant, type BlockStateVariants, BlockStates, BlockTints, type BoxGeometryKey, BrowserArchiveProxy, BrowserCache, BrowserEnv, CUBE_FACES, type CacheKey, Caching, type CameraOptions, CanvasImage, type CapeLayout, Chunk, type CompatCanvas, type CompatImage, type ComposerOptions, type ControlsOptions, CubeFace, CubeFaceIndex, DEFAULT_ELEMENTS, DEFAULT_NAMESPACE, DEFAULT_ROOT, DEFAULT_UV, DISPLAY_POSITIONS, type DebugOptions, type DeepPartial, DefaultBlockStates, DisplayPosition, DisplayTransforms, type Disposable, type DoubleArray, type ElementFace, type ElementRotation, Entities, type EntityLayer, type EntityModel, type EntityModelCube, type EntityModelFile, type EntityModelLayer, type EntityModelOptions, type EntityModelPart, EntityObject, type EntityObjectOptions, Env, type EnvProvider, type ExtractableImageData, type FromTo, Geometries, GuiLight, GuiObject, type GuiObjectOptions, HostedAssetSource, type IModelTextures, ITEM_GENERATED, type ImageInfo, ImageLoader, type ImageSizeInfo, InstanceManager, InstanceReference, type Instanceable, type ItemModel, type ItemModelTextures, type ListAsset, MapControls, type MaterialKey, Materials, type Maybe, type MeshKey, Meshes, MineRenderError, MineRenderScene, type MineRenderSceneOptions, MineRenderWorld, type MinecraftAsset, MinecraftCubeTexture, MinecraftFaceUV, type MinecraftTextureMeta, type Model, type ModelDisplay, type ModelElement, type ModelFaces, ModelGenerator, ModelMerger, ModelObject, type ModelObjectOptions, ModelTextures, Models, type MultiBlockBlock, type MultiBlockStructure, type MultipartCondition, type NBTAsset, NBTHelper, OrbitControls, PersistentCache, type QuadArray, type RawImageKey, type RenderOptions, Renderer, type RendererOptions, type RequestConfig, RequestError, type RequestResponse, Requests, type ResponseParser, SKIN_PARTS, SceneInspector, SceneObject, type SceneObjectOptions, SceneStats, SceneStatsDisplay, SchematicParser, type Serializable, type SkinGeometries, SkinImage, SkinObject, type SkinObjectOptions, SkinPart, type SkinTexture, type SkinTextureCoordinates, SkinTextures, Skins, type StructureNBT, StructureParser, type TextureAsset, TextureAtlas, type TextureKey, TextureLoader, Textures, Ticker, type TickerFunction, TintColors, type Transformable, type TripleArray, UVMapper, WrappedImage, addBox3WireframeToObject, addWireframeToMesh, addWireframeToObject, applyElementRotation, applyGenericRotation, axisToVec3, base64decode, base64encode, capeTextureSizes, captureException, changeEvent, clampRotationDegrees, classicSkinGeometries, classicSkinTextureCoordinates, computeMorphedAttributes, createCanvas, createImage, estimateBytesUsed, interleaveAttributes, isAssetKey, isBasicAssetKey, isBlockObject, isDisposable, isDoubleArray, isEntityObject, isInstanceManager, isInstanceReference, isInstanceable, isInstancedMesh, isMesh, isMineRenderScene, isModelObject, isObject3D, isOrthographicCamera, isPerspectiveCamera, isQuadArray, isSceneObject, isTransformable, isTripleArray, isVector3, md5, mergeBufferAttributes, mergeBufferGeometries, mergeVertices, prefix, probeImageSize, registerBrowserEnv, serializeBoxGeometryKey, serializeImageKey, serializeMaterialKey, serializeMeshKey, serializeTextureKey, sha1, sha256, sha512, shutdown, sleep, slimSkinGeometries, slimSkinTextureCoordinates, timingEnd, timingStart, toDegrees, toRadians, toTrianglesDrawMode };
1787
+ export { AXES, type AnimationFrame, type AnimationMeta, type AnimatorFunction, ArchiveAssetSource, type ArchiveEntry, type ArchiveProxy, AssetKey, AssetLoadError, AssetLoader, AssetParser, AssetSource, type AssetType, Assets, Axis, BUILTIN_ENTITY, BUILTIN_GENERATED, BasicAssetKey, type BasicMinecraftAsset, BatchedExecutor, type BedrockBone, type BedrockCube, type BedrockEntityDescription, type BedrockEntityFile, type BedrockGeometry, type BedrockGeometryFile, type Block, type BlockInfo, type BlockModel, type BlockModelTextures, BlockObject, type BlockObjectOptions, type BlockState, type BlockStateMultipart, type BlockStateProperties, type BlockStateProperty, type BlockStatePropertyDefaults, type BlockStatePropertyValue, type BlockStateVariant, type BlockStateVariants, BlockStates, BlockTints, type BoxGeometryKey, BrowserArchiveProxy, BrowserCache, BrowserEnv, CUBE_FACES, type CacheKey, Caching, type CameraOptions, CanvasImage, type CapeLayout, Chunk, ChunkData, type CompatCanvas, type CompatImage, type ComposerOptions, type ControlsOptions, CubeFace, CubeFaceIndex, DEFAULT_ELEMENTS, DEFAULT_NAMESPACE, DEFAULT_ROOT, DEFAULT_UV, DISPLAY_POSITIONS, type DebugOptions, type DeepPartial, DefaultBlockStates, DisplayPosition, DisplayTransforms, type Disposable, type DoubleArray, type ElementFace, type ElementRotation, Entities, type EntityLayer, type EntityModel, type EntityModelCube, type EntityModelFile, type EntityModelLayer, type EntityModelOptions, type EntityModelPart, EntityObject, type EntityObjectOptions, Env, type EnvProvider, type ExtractableImageData, type FromTo, Geometries, GuiLight, GuiObject, type GuiObjectOptions, HostedAssetSource, type IModelTextures, ITEM_GENERATED, type ImageInfo, ImageLoader, type ImageSizeInfo, InstanceManager, InstanceReference, type Instanceable, type ItemModel, type ItemModelTextures, type ListAsset, MapControls, type MaterialKey, Materials, type Maybe, type MeshKey, Meshes, MineRenderError, MineRenderScene, type MineRenderSceneOptions, MineRenderWorld, type MinecraftAsset, MinecraftCubeTexture, MinecraftFaceUV, type MinecraftTextureMeta, type Model, type ModelDisplay, type ModelElement, type ModelFaces, ModelGenerator, ModelMerger, ModelObject, type ModelObjectOptions, ModelTextures, Models, type MultiBlockBlock, type MultiBlockStructure, type MultipartCondition, type NBTAsset, NBTHelper, OrbitControls, PersistentCache, type QuadArray, type RawImageKey, type RenderOptions, Renderer, type RendererOptions, type RequestConfig, RequestError, type RequestResponse, Requests, type ResponseParser, SKIN_PARTS, SceneInspector, SceneObject, type SceneObjectOptions, SceneStats, SceneStatsDisplay, SchematicParser, type Serializable, type SkinGeometries, SkinImage, SkinObject, type SkinObjectOptions, SkinPart, type SkinTexture, type SkinTextureCoordinates, SkinTextures, Skins, type StructureNBT, StructureParser, type TextureAsset, TextureAtlas, type TextureKey, TextureLoader, Textures, Ticker, type TickerFunction, TintColors, type Transformable, type TripleArray, UVMapper, WrappedImage, addBox3WireframeToObject, addWireframeToMesh, addWireframeToObject, applyElementRotation, applyGenericRotation, axisToVec3, base64decode, base64encode, capeTextureSizes, captureException, changeEvent, clampRotationDegrees, classicSkinGeometries, classicSkinTextureCoordinates, computeMorphedAttributes, createCanvas, createImage, estimateBytesUsed, interleaveAttributes, isAssetKey, isBasicAssetKey, isBlockObject, isDisposable, isDoubleArray, isEntityObject, isInstanceManager, isInstanceReference, isInstanceable, isInstancedMesh, isMesh, isMineRenderScene, isModelObject, isObject3D, isOrthographicCamera, isPerspectiveCamera, isQuadArray, isSceneObject, isTransformable, isTripleArray, isVector3, md5, mergeBufferAttributes, mergeBufferGeometries, mergeVertices, prefix, probeImageSize, registerBrowserEnv, serializeBoxGeometryKey, serializeImageKey, serializeMaterialKey, serializeMeshKey, serializeTextureKey, sha1, sha256, sha512, shutdown, sleep, slimSkinGeometries, slimSkinTextureCoordinates, timingEnd, timingStart, toDegrees, toRadians, toTrianglesDrawMode };
@@ -1679,7 +1679,8 @@ declare function toTrianglesDrawMode(geometry: BufferGeometry, drawMode: Triangl
1679
1679
  declare function computeMorphedAttributes(object: Mesh | Line | Points): object;
1680
1680
 
1681
1681
  interface BlockInfo {
1682
- block: Block;
1682
+ /** Detached block data; use world or chunk setters to update stored blocks. */
1683
+ readonly block: Block;
1683
1684
  object: BlockObject;
1684
1685
  }
1685
1686
 
@@ -1688,7 +1689,8 @@ declare class Chunk {
1688
1689
  readonly x: number;
1689
1690
  readonly y: number;
1690
1691
  readonly z: number;
1691
- private readonly _blocks;
1692
+ private readonly data;
1693
+ private readonly renderedBlocks;
1692
1694
  constructor(scene: MineRenderScene, x: number, y: number, z: number);
1693
1695
  getBlockAt(x: number, y: number, z: number): Maybe<BlockInfo>;
1694
1696
  getBlockAt(pos: Vector3): Maybe<BlockInfo>;
@@ -1711,6 +1713,21 @@ declare class Chunk {
1711
1713
  chunkPosToWorldPos(pos: Vector3): Vector3;
1712
1714
  }
1713
1715
 
1716
+ declare class ChunkData {
1717
+ private readonly indices;
1718
+ private readonly palette;
1719
+ private readonly paletteIds;
1720
+ private readonly freeIds;
1721
+ private readonly nbt;
1722
+ get(index: number): Maybe<Block>;
1723
+ snapshot(index: number): Maybe<() => Block>;
1724
+ set(index: number, block?: Block): void;
1725
+ clear(): void;
1726
+ static isAir(block: Maybe<Block>): boolean;
1727
+ private static copyBlock;
1728
+ private static validateIndex;
1729
+ }
1730
+
1714
1731
  declare class MineRenderWorld {
1715
1732
  readonly scene: MineRenderScene;
1716
1733
  private readonly _chunks;
@@ -1767,4 +1784,4 @@ declare class BrowserCache extends PersistentCache<LocalForage> {
1767
1784
  */
1768
1785
  declare function probeImageSize(data: Uint8Array): ImageSizeInfo;
1769
1786
 
1770
- export { AXES, type AnimationFrame, type AnimationMeta, type AnimatorFunction, ArchiveAssetSource, type ArchiveEntry, type ArchiveProxy, AssetKey, AssetLoadError, AssetLoader, AssetParser, AssetSource, type AssetType, Assets, Axis, BUILTIN_ENTITY, BUILTIN_GENERATED, BasicAssetKey, type BasicMinecraftAsset, BatchedExecutor, type BedrockBone, type BedrockCube, type BedrockEntityDescription, type BedrockEntityFile, type BedrockGeometry, type BedrockGeometryFile, type Block, type BlockInfo, type BlockModel, type BlockModelTextures, BlockObject, type BlockObjectOptions, type BlockState, type BlockStateMultipart, type BlockStateProperties, type BlockStateProperty, type BlockStatePropertyDefaults, type BlockStatePropertyValue, type BlockStateVariant, type BlockStateVariants, BlockStates, BlockTints, type BoxGeometryKey, BrowserArchiveProxy, BrowserCache, BrowserEnv, CUBE_FACES, type CacheKey, Caching, type CameraOptions, CanvasImage, type CapeLayout, Chunk, type CompatCanvas, type CompatImage, type ComposerOptions, type ControlsOptions, CubeFace, CubeFaceIndex, DEFAULT_ELEMENTS, DEFAULT_NAMESPACE, DEFAULT_ROOT, DEFAULT_UV, DISPLAY_POSITIONS, type DebugOptions, type DeepPartial, DefaultBlockStates, DisplayPosition, DisplayTransforms, type Disposable, type DoubleArray, type ElementFace, type ElementRotation, Entities, type EntityLayer, type EntityModel, type EntityModelCube, type EntityModelFile, type EntityModelLayer, type EntityModelOptions, type EntityModelPart, EntityObject, type EntityObjectOptions, Env, type EnvProvider, type ExtractableImageData, type FromTo, Geometries, GuiLight, GuiObject, type GuiObjectOptions, HostedAssetSource, type IModelTextures, ITEM_GENERATED, type ImageInfo, ImageLoader, type ImageSizeInfo, InstanceManager, InstanceReference, type Instanceable, type ItemModel, type ItemModelTextures, type ListAsset, MapControls, type MaterialKey, Materials, type Maybe, type MeshKey, Meshes, MineRenderError, MineRenderScene, type MineRenderSceneOptions, MineRenderWorld, type MinecraftAsset, MinecraftCubeTexture, MinecraftFaceUV, type MinecraftTextureMeta, type Model, type ModelDisplay, type ModelElement, type ModelFaces, ModelGenerator, ModelMerger, ModelObject, type ModelObjectOptions, ModelTextures, Models, type MultiBlockBlock, type MultiBlockStructure, type MultipartCondition, type NBTAsset, NBTHelper, OrbitControls, PersistentCache, type QuadArray, type RawImageKey, type RenderOptions, Renderer, type RendererOptions, type RequestConfig, RequestError, type RequestResponse, Requests, type ResponseParser, SKIN_PARTS, SceneInspector, SceneObject, type SceneObjectOptions, SceneStats, SceneStatsDisplay, SchematicParser, type Serializable, type SkinGeometries, SkinImage, SkinObject, type SkinObjectOptions, SkinPart, type SkinTexture, type SkinTextureCoordinates, SkinTextures, Skins, type StructureNBT, StructureParser, type TextureAsset, TextureAtlas, type TextureKey, TextureLoader, Textures, Ticker, type TickerFunction, TintColors, type Transformable, type TripleArray, UVMapper, WrappedImage, addBox3WireframeToObject, addWireframeToMesh, addWireframeToObject, applyElementRotation, applyGenericRotation, axisToVec3, base64decode, base64encode, capeTextureSizes, captureException, changeEvent, clampRotationDegrees, classicSkinGeometries, classicSkinTextureCoordinates, computeMorphedAttributes, createCanvas, createImage, estimateBytesUsed, interleaveAttributes, isAssetKey, isBasicAssetKey, isBlockObject, isDisposable, isDoubleArray, isEntityObject, isInstanceManager, isInstanceReference, isInstanceable, isInstancedMesh, isMesh, isMineRenderScene, isModelObject, isObject3D, isOrthographicCamera, isPerspectiveCamera, isQuadArray, isSceneObject, isTransformable, isTripleArray, isVector3, md5, mergeBufferAttributes, mergeBufferGeometries, mergeVertices, prefix, probeImageSize, registerBrowserEnv, serializeBoxGeometryKey, serializeImageKey, serializeMaterialKey, serializeMeshKey, serializeTextureKey, sha1, sha256, sha512, shutdown, sleep, slimSkinGeometries, slimSkinTextureCoordinates, timingEnd, timingStart, toDegrees, toRadians, toTrianglesDrawMode };
1787
+ export { AXES, type AnimationFrame, type AnimationMeta, type AnimatorFunction, ArchiveAssetSource, type ArchiveEntry, type ArchiveProxy, AssetKey, AssetLoadError, AssetLoader, AssetParser, AssetSource, type AssetType, Assets, Axis, BUILTIN_ENTITY, BUILTIN_GENERATED, BasicAssetKey, type BasicMinecraftAsset, BatchedExecutor, type BedrockBone, type BedrockCube, type BedrockEntityDescription, type BedrockEntityFile, type BedrockGeometry, type BedrockGeometryFile, type Block, type BlockInfo, type BlockModel, type BlockModelTextures, BlockObject, type BlockObjectOptions, type BlockState, type BlockStateMultipart, type BlockStateProperties, type BlockStateProperty, type BlockStatePropertyDefaults, type BlockStatePropertyValue, type BlockStateVariant, type BlockStateVariants, BlockStates, BlockTints, type BoxGeometryKey, BrowserArchiveProxy, BrowserCache, BrowserEnv, CUBE_FACES, type CacheKey, Caching, type CameraOptions, CanvasImage, type CapeLayout, Chunk, ChunkData, type CompatCanvas, type CompatImage, type ComposerOptions, type ControlsOptions, CubeFace, CubeFaceIndex, DEFAULT_ELEMENTS, DEFAULT_NAMESPACE, DEFAULT_ROOT, DEFAULT_UV, DISPLAY_POSITIONS, type DebugOptions, type DeepPartial, DefaultBlockStates, DisplayPosition, DisplayTransforms, type Disposable, type DoubleArray, type ElementFace, type ElementRotation, Entities, type EntityLayer, type EntityModel, type EntityModelCube, type EntityModelFile, type EntityModelLayer, type EntityModelOptions, type EntityModelPart, EntityObject, type EntityObjectOptions, Env, type EnvProvider, type ExtractableImageData, type FromTo, Geometries, GuiLight, GuiObject, type GuiObjectOptions, HostedAssetSource, type IModelTextures, ITEM_GENERATED, type ImageInfo, ImageLoader, type ImageSizeInfo, InstanceManager, InstanceReference, type Instanceable, type ItemModel, type ItemModelTextures, type ListAsset, MapControls, type MaterialKey, Materials, type Maybe, type MeshKey, Meshes, MineRenderError, MineRenderScene, type MineRenderSceneOptions, MineRenderWorld, type MinecraftAsset, MinecraftCubeTexture, MinecraftFaceUV, type MinecraftTextureMeta, type Model, type ModelDisplay, type ModelElement, type ModelFaces, ModelGenerator, ModelMerger, ModelObject, type ModelObjectOptions, ModelTextures, Models, type MultiBlockBlock, type MultiBlockStructure, type MultipartCondition, type NBTAsset, NBTHelper, OrbitControls, PersistentCache, type QuadArray, type RawImageKey, type RenderOptions, Renderer, type RendererOptions, type RequestConfig, RequestError, type RequestResponse, Requests, type ResponseParser, SKIN_PARTS, SceneInspector, SceneObject, type SceneObjectOptions, SceneStats, SceneStatsDisplay, SchematicParser, type Serializable, type SkinGeometries, SkinImage, SkinObject, type SkinObjectOptions, SkinPart, type SkinTexture, type SkinTextureCoordinates, SkinTextures, Skins, type StructureNBT, StructureParser, type TextureAsset, TextureAtlas, type TextureKey, TextureLoader, Textures, Ticker, type TickerFunction, TintColors, type Transformable, type TripleArray, UVMapper, WrappedImage, addBox3WireframeToObject, addWireframeToMesh, addWireframeToObject, applyElementRotation, applyGenericRotation, axisToVec3, base64decode, base64encode, capeTextureSizes, captureException, changeEvent, clampRotationDegrees, classicSkinGeometries, classicSkinTextureCoordinates, computeMorphedAttributes, createCanvas, createImage, estimateBytesUsed, interleaveAttributes, isAssetKey, isBasicAssetKey, isBlockObject, isDisposable, isDoubleArray, isEntityObject, isInstanceManager, isInstanceReference, isInstanceable, isInstancedMesh, isMesh, isMineRenderScene, isModelObject, isObject3D, isOrthographicCamera, isPerspectiveCamera, isQuadArray, isSceneObject, isTransformable, isTripleArray, isVector3, md5, mergeBufferAttributes, mergeBufferGeometries, mergeVertices, prefix, probeImageSize, registerBrowserEnv, serializeBoxGeometryKey, serializeImageKey, serializeMaterialKey, serializeMeshKey, serializeTextureKey, sha1, sha256, sha512, shutdown, sleep, slimSkinGeometries, slimSkinTextureCoordinates, timingEnd, timingStart, toDegrees, toRadians, toTrianglesDrawMode };
@@ -37,8 +37,8 @@ var require_dist = __commonJS({
37
37
  __assign = Object.assign || function(t) {
38
38
  for (var s, i = 1, n = arguments.length; i < n; i++) {
39
39
  s = arguments[i];
40
- for (var p12 in s) if (Object.prototype.hasOwnProperty.call(s, p12))
41
- t[p12] = s[p12];
40
+ for (var p11 in s) if (Object.prototype.hasOwnProperty.call(s, p11))
41
+ t[p11] = s[p11];
42
42
  }
43
43
  return t;
44
44
  };
@@ -147,6 +147,7 @@ __export(index_browser_exports, {
147
147
  Caching: () => Caching,
148
148
  CanvasImage: () => CanvasImage,
149
149
  Chunk: () => Chunk,
150
+ ChunkData: () => ChunkData,
150
151
  CubeFace: () => CubeFace,
151
152
  CubeFaceIndex: () => CubeFaceIndex,
152
153
  DEFAULT_ELEMENTS: () => DEFAULT_ELEMENTS,
@@ -1323,12 +1324,12 @@ var AssetKey = class _AssetKey extends BasicAssetKey {
1323
1324
  return a.join("/");
1324
1325
  }
1325
1326
  getFullPath() {
1326
- let p12 = [];
1327
+ let p11 = [];
1327
1328
  if (this.type) {
1328
- p12.push(this.type);
1329
+ p11.push(this.type);
1329
1330
  }
1330
- p12.push(this.path);
1331
- return p12.join("/");
1331
+ p11.push(this.path);
1332
+ return p11.join("/");
1332
1333
  }
1333
1334
  toNamespacedString() {
1334
1335
  return this.namespace + ":" + this.getFullPath();
@@ -1415,7 +1416,7 @@ var ModelMerger = class {
1415
1416
  merged.display = { ...inheritedDisplay, ...DisplayTransforms.withHandFallbacks(source.display) };
1416
1417
  }
1417
1418
  }
1418
- merged.hierarchy = models.map((m) => m.parent).filter((p12) => `${p12}`);
1419
+ merged.hierarchy = models.map((m) => m.parent).filter((p11) => `${p11}`);
1419
1420
  merged.hierarchy.push(`${merged.parent}`);
1420
1421
  return merged;
1421
1422
  }
@@ -7331,6 +7332,87 @@ var Skins = class {
7331
7332
  // src/world/Chunk.ts
7332
7333
  var import_three25 = require("three");
7333
7334
 
7335
+ // src/world/ChunkData.ts
7336
+ var ChunkData = class _ChunkData {
7337
+ constructor() {
7338
+ this.indices = new Uint16Array(4096);
7339
+ this.palette = [void 0];
7340
+ this.paletteIds = /* @__PURE__ */ new Map();
7341
+ this.freeIds = [];
7342
+ this.nbt = /* @__PURE__ */ new Map();
7343
+ }
7344
+ get(index) {
7345
+ _ChunkData.validateIndex(index);
7346
+ const entry = this.palette[this.indices[index]];
7347
+ return entry ? _ChunkData.copyBlock(entry.state, this.nbt.get(index)) : void 0;
7348
+ }
7349
+ snapshot(index) {
7350
+ _ChunkData.validateIndex(index);
7351
+ const entry = this.palette[this.indices[index]];
7352
+ return entry ? _ChunkData.copyBlock.bind(void 0, entry.state, this.nbt.get(index)) : void 0;
7353
+ }
7354
+ set(index, block) {
7355
+ _ChunkData.validateIndex(index);
7356
+ let state;
7357
+ let key;
7358
+ let nbt;
7359
+ if (block && !_ChunkData.isAir(block)) {
7360
+ const type = AssetKey.parse("blockstates", block.type).toNamespacedString();
7361
+ const properties = Object.fromEntries(Object.keys(block.properties ?? {}).sort().map((name) => [name, block.properties[name]]));
7362
+ state = Object.freeze(Object.keys(properties).length ? { type, properties: Object.freeze(properties) } : { type });
7363
+ key = JSON.stringify([type, properties]);
7364
+ if (block.nbt !== void 0) nbt = structuredClone(block.nbt);
7365
+ }
7366
+ const previousId = this.indices[index];
7367
+ if (previousId !== 0) {
7368
+ const previous = this.palette[previousId];
7369
+ if (--previous.references === 0) {
7370
+ this.paletteIds.delete(previous.key);
7371
+ this.palette[previousId] = void 0;
7372
+ this.freeIds.push(previousId);
7373
+ }
7374
+ }
7375
+ let id = 0;
7376
+ if (state && key !== void 0) {
7377
+ const existingId = this.paletteIds.get(key);
7378
+ if (existingId !== void 0) {
7379
+ id = existingId;
7380
+ this.palette[id].references++;
7381
+ } else {
7382
+ id = this.freeIds.pop() ?? this.palette.length;
7383
+ this.palette[id] = { key, state, references: 1 };
7384
+ this.paletteIds.set(key, id);
7385
+ }
7386
+ }
7387
+ this.indices[index] = id;
7388
+ if (nbt !== void 0) this.nbt.set(index, nbt);
7389
+ else this.nbt.delete(index);
7390
+ }
7391
+ clear() {
7392
+ this.indices.fill(0);
7393
+ this.palette.length = 1;
7394
+ this.paletteIds.clear();
7395
+ this.freeIds.length = 0;
7396
+ this.nbt.clear();
7397
+ }
7398
+ static isAir(block) {
7399
+ if (typeof block === "undefined" || typeof block.type === "undefined") return true;
7400
+ const key = AssetKey.parse("blockstates", block.type);
7401
+ return key.namespace === "minecraft" && !key.type && ["air", "cave_air", "void_air"].includes(key.path);
7402
+ }
7403
+ static copyBlock(state, nbt) {
7404
+ const block = { type: state.type };
7405
+ if (state.properties) block.properties = { ...state.properties };
7406
+ if (nbt !== void 0) block.nbt = structuredClone(nbt);
7407
+ return block;
7408
+ }
7409
+ static validateIndex(index) {
7410
+ if (!Number.isInteger(index) || index < 0 || index >= 4096) {
7411
+ throw new RangeError("Block index must be an integer from 0 to 4095");
7412
+ }
7413
+ }
7414
+ };
7415
+
7334
7416
  // src/world/MineRenderWorld.ts
7335
7417
  var import_three24 = require("three");
7336
7418
  var MineRenderWorld = class {
@@ -7441,10 +7523,10 @@ var MineRenderWorld = class {
7441
7523
  };
7442
7524
 
7443
7525
  // src/world/Chunk.ts
7444
- var p11 = prefix("Chunk");
7445
7526
  var Chunk = class _Chunk {
7446
7527
  constructor(scene, x, y, z) {
7447
- this._blocks = [];
7528
+ this.data = new ChunkData();
7529
+ this.renderedBlocks = /* @__PURE__ */ new Map();
7448
7530
  this.scene = scene;
7449
7531
  this.x = x;
7450
7532
  this.y = y;
@@ -7459,7 +7541,7 @@ var Chunk = class _Chunk {
7459
7541
  }
7460
7542
  const pos = this.worldPosToChunkPos(posOrX);
7461
7543
  const index = _Chunk.chunkPosToBlockIndex(pos);
7462
- return this._blocks[index];
7544
+ return this.renderedBlocks.get(index);
7463
7545
  }
7464
7546
  async setBlockAt(posOrX, yOrBlock, z, block) {
7465
7547
  if (typeof posOrX == "number") {
@@ -7481,44 +7563,47 @@ var Chunk = class _Chunk {
7481
7563
  worldPos = this.chunkPosToWorldPos(pos);
7482
7564
  }
7483
7565
  const index = _Chunk.chunkPosToBlockIndex(pos);
7484
- const current = this._blocks[index];
7485
- if (typeof current !== "undefined") {
7486
- console.debug(p11, "deleting existing block at", pos, worldPos, index);
7487
- current.object.removeFromScene();
7488
- delete this._blocks[index];
7489
- }
7490
- if (!block || _Chunk.isAir(block)) return void 0;
7491
- const blockState = await BlockStates.get(AssetKey.parse("blockstates", block.type));
7492
- if (blockState) {
7493
- const blockObject = await this.scene.addBlock(blockState, {
7566
+ this.data.set(index, block);
7567
+ const readBlock = this.data.snapshot(index);
7568
+ this.renderedBlocks.get(index)?.object.removeFromScene();
7569
+ this.renderedBlocks.delete(index);
7570
+ if (!readBlock) return void 0;
7571
+ const stored = readBlock();
7572
+ let object;
7573
+ try {
7574
+ const blockState = await BlockStates.get(AssetKey.parse("blockstates", stored.type));
7575
+ if (!blockState) {
7576
+ this.data.set(index, void 0);
7577
+ return void 0;
7578
+ }
7579
+ object = await this.scene.addBlock(blockState, {
7494
7580
  mergeMeshes: true,
7495
7581
  instanceMeshes: true,
7496
7582
  maxInstanceCount: 2e3
7497
7583
  });
7498
- if (block.properties) {
7499
- await blockObject.setState(block.properties);
7500
- }
7501
- const scenePos = MineRenderWorld.worldToScenePosition(worldPos);
7502
- blockObject.setPosition(scenePos);
7503
- this._blocks[index] = {
7504
- block,
7505
- object: blockObject
7506
- };
7507
- return this._blocks[index];
7584
+ if (stored.properties) await object.setState(stored.properties);
7585
+ object.setPosition(MineRenderWorld.worldToScenePosition(worldPos));
7586
+ const info = { get block() {
7587
+ return readBlock();
7588
+ }, object };
7589
+ this.renderedBlocks.set(index, info);
7590
+ return info;
7591
+ } catch (error) {
7592
+ this.data.set(index, void 0);
7593
+ object?.removeFromScene();
7594
+ throw error;
7508
7595
  }
7509
- return void 0;
7510
7596
  }
7511
7597
  async clear() {
7512
- this._blocks.forEach((block) => block.object.removeFromScene());
7513
- this._blocks.length = 0;
7598
+ for (const info of this.renderedBlocks.values()) info.object.removeFromScene();
7599
+ this.renderedBlocks.clear();
7600
+ this.data.clear();
7514
7601
  }
7515
7602
  async dispose() {
7516
7603
  await this.clear();
7517
7604
  }
7518
7605
  static isAir(block) {
7519
- if (typeof block === "undefined" || typeof block.type === "undefined") return true;
7520
- const key = AssetKey.parse("blockstates", block.type);
7521
- return key.namespace === "minecraft" && !key.type && ["air", "cave_air", "void_air"].includes(key.path);
7606
+ return ChunkData.isAir(block);
7522
7607
  }
7523
7608
  static chunkPosToBlockIndex(pos) {
7524
7609
  if ([pos.x, pos.y, pos.z].some((value) => !Number.isInteger(value) || value < 0 || value >= 16)) {