minerender 2.1.0-alpha.37 → 2.1.0-alpha.39

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.
@@ -2,8 +2,8 @@ import * as three from 'three';
2
2
  import { Vector3, PixelFormat, BoxGeometry, Material, Mesh, Euler, Vector2, BufferAttribute, Float32BufferAttribute, BufferGeometry, Object3D, Box3, InstancedMesh, PerspectiveCamera, OrthographicCamera, Matrix4, Scene, Object3DEventMap, Texture, Camera, MOUSE, TOUCH, WebGLRenderer, EventDispatcher, Raycaster, Intersection, MeshBasicMaterial, CanvasTexture, InterleavedBufferAttribute, TrianglesDrawModes, Line, Points } from 'three';
3
3
  import * as nodeCanvas from 'canvas';
4
4
  import { ImageData as ImageData$1, CanvasRenderingContext2D } from 'canvas';
5
- import { Buffer as Buffer$1 } from 'buffer';
6
- import { NBT } from 'prismarine-nbt';
5
+ import { Buffer } from 'buffer';
6
+ import { NBT, NBTFormat, Metadata } from 'prismarine-nbt';
7
7
  import { ZipReader } from '@zip.js/zip.js';
8
8
  import { AsyncLoadingCache, SimpleCache } from '@inventivetalent/loading-cache';
9
9
  import Stats from 'stats.js';
@@ -38,6 +38,7 @@ declare enum CubeFaceIndex {
38
38
  NORTH = 5
39
39
  }
40
40
  declare const CUBE_FACES: CubeFace[];
41
+ declare const CUBE_FACE_OFFSETS: readonly [readonly [1, 0, 0], readonly [-1, 0, 0], readonly [0, 1, 0], readonly [0, -1, 0], readonly [0, 0, 1], readonly [0, 0, -1]];
41
42
 
42
43
  interface Disposable {
43
44
  dispose(): void;
@@ -319,7 +320,7 @@ interface ImageInfo {
319
320
  width: number;
320
321
  height: number;
321
322
  type?: string;
322
- data: Buffer$1;
323
+ data: Buffer;
323
324
  }
324
325
  declare class ImageLoader {
325
326
  protected static _createImage(): CompatImage;
@@ -804,6 +805,11 @@ declare class DisplayTransforms {
804
805
  static apply(geometry: BufferGeometry, matrix: Matrix4): void;
805
806
  }
806
807
 
808
+ declare class ModelCulling {
809
+ static toLocalMask(worldMask: number, rotation: Euler): number;
810
+ static isOpaqueFullCube(atlas: Maybe<TextureAtlas>): boolean;
811
+ }
812
+
807
813
  declare class ModelGenerator {
808
814
  static readonly ITEM_LAYERS: string[];
809
815
  static generateItemModel(imageData: ImageData$1, layer: string): ModelElement[];
@@ -881,6 +887,7 @@ declare class ModelObject extends SceneObject {
881
887
  constructor(originalModel: Model, options?: Partial<ModelObjectOptions>);
882
888
  init(): Promise<void>;
883
889
  get textureAtlas(): Maybe<TextureAtlas>;
890
+ get isOpaqueFullCube(): boolean;
884
891
  protected loadTextures(): Promise<void>;
885
892
  protected createMeshes(force?: boolean): void;
886
893
  protected applyTextures(): void;
@@ -892,6 +899,8 @@ interface ModelObjectOptions extends SceneObjectOptions {
892
899
  uvLockRotation?: TripleArray;
893
900
  /** sRGB 0xRRGGBB colors by face tint index; omitted indices stay white. */
894
901
  tints?: Record<number, number>;
902
+ /** Hidden neighbor directions in CUBE_FACES order, before the model's block rotation. */
903
+ cullMask?: number;
895
904
  }
896
905
  declare function isModelObject(obj: any): obj is ModelObject;
897
906
 
@@ -1095,11 +1104,17 @@ declare class BlockObject extends SceneObject {
1095
1104
  private _instanceModel;
1096
1105
  private _variants;
1097
1106
  private _models;
1107
+ private _cullMask;
1098
1108
  constructor(blockState: BlockState, options?: Partial<BlockObjectOptions>);
1099
1109
  init(): Promise<void>;
1100
1110
  dispose(): void;
1101
1111
  removeFromScene(): void;
1102
1112
  private clearModels;
1113
+ private removeModels;
1114
+ get isOccluding(): boolean;
1115
+ private getModelMatrix;
1116
+ private getModelCullMask;
1117
+ setCullMask(worldMask: number): Promise<void>;
1103
1118
  get state(): {
1104
1119
  [key: string]: string;
1105
1120
  };
@@ -1127,20 +1142,27 @@ declare function isBlockObject(obj: any): obj is BlockObject;
1127
1142
  interface MultiBlockStructure {
1128
1143
  readonly size: TripleArray;
1129
1144
  readonly blocks: MultiBlockBlock[];
1145
+ readonly dataVersion?: number;
1146
+ readonly entities?: MultiBlockEntity[];
1147
+ }
1148
+ interface MultiBlockEntity {
1149
+ position: TripleArray;
1150
+ blockPosition?: TripleArray;
1151
+ nbt: unknown;
1130
1152
  }
1131
1153
  interface MultiBlockBlock extends Block {
1132
1154
  position: TripleArray;
1133
1155
  }
1134
1156
 
1135
1157
  declare class SchematicParser {
1136
- static parse(): Promise<MultiBlockStructure>;
1158
+ static parse(nbt: NBT): Promise<MultiBlockStructure>;
1137
1159
  }
1138
1160
 
1139
1161
  declare class StructureParser {
1140
1162
  static parse(_nbt: NBT, paletteIndex?: number): Promise<MultiBlockStructure>;
1141
1163
  }
1142
1164
  interface StructureNBT {
1143
- DataVersion: {
1165
+ DataVersion?: {
1144
1166
  type: "int";
1145
1167
  value: number;
1146
1168
  };
@@ -1152,7 +1174,13 @@ interface StructureNBT {
1152
1174
  };
1153
1175
  };
1154
1176
  palette?: Palette;
1155
- palettes?: Palette[];
1177
+ palettes?: {
1178
+ type: "list";
1179
+ value: {
1180
+ type: "list";
1181
+ value: Palette["value"][];
1182
+ };
1183
+ };
1156
1184
  blocks: {
1157
1185
  type: "list";
1158
1186
  value: {
@@ -1160,7 +1188,32 @@ interface StructureNBT {
1160
1188
  value: BlockEntry[];
1161
1189
  };
1162
1190
  };
1163
- entities: {};
1191
+ entities?: {
1192
+ type: "list";
1193
+ value: {
1194
+ type: "compound";
1195
+ value: {
1196
+ pos: {
1197
+ type: "list";
1198
+ value: {
1199
+ type: "double";
1200
+ value: TripleArray;
1201
+ };
1202
+ };
1203
+ blockPos: {
1204
+ type: "list";
1205
+ value: {
1206
+ type: "int";
1207
+ value: TripleArray;
1208
+ };
1209
+ };
1210
+ nbt: {
1211
+ type: "compound";
1212
+ value: any;
1213
+ };
1214
+ }[];
1215
+ };
1216
+ };
1164
1217
  }
1165
1218
  interface Palette {
1166
1219
  type: "list";
@@ -1204,9 +1257,12 @@ interface BlockEntry {
1204
1257
  }
1205
1258
 
1206
1259
  declare class NBTHelper {
1207
- static fromBuffer(buffer: Buffer): Promise<NBTAsset>;
1260
+ static fromBuffer(data: Uint8Array | ArrayBuffer, format?: NBTFormat): Promise<NBTAsset>;
1208
1261
  }
1209
1262
  interface NBTAsset extends MinecraftAsset, NBT {
1263
+ format?: NBTFormat;
1264
+ metadata?: Metadata;
1265
+ compression?: "gzip" | "none";
1210
1266
  }
1211
1267
 
1212
1268
  interface ResponseParser<T extends MinecraftAsset> {
@@ -1678,6 +1734,51 @@ declare function mergeVertices(geometry: BufferGeometry, tolerance?: number): Bu
1678
1734
  declare function toTrianglesDrawMode(geometry: BufferGeometry, drawMode: TrianglesDrawModes): BufferGeometry;
1679
1735
  declare function computeMorphedAttributes(object: Mesh | Line | Points): object;
1680
1736
 
1737
+ declare class ChunkData {
1738
+ private readonly indices;
1739
+ private readonly palette;
1740
+ private readonly paletteIds;
1741
+ private readonly freeIds;
1742
+ private readonly nbt;
1743
+ get(index: number): Maybe<Block>;
1744
+ snapshot(index: number): Maybe<() => Block>;
1745
+ set(index: number, block?: Block): void;
1746
+ clear(): void;
1747
+ static isAir(block: Maybe<Block>): boolean;
1748
+ private static copyBlock;
1749
+ private static validateIndex;
1750
+ }
1751
+
1752
+ type RegionInput = Uint8Array | ArrayBuffer;
1753
+ interface AnvilRegion {
1754
+ chunks: AnvilChunk[];
1755
+ }
1756
+ interface AnvilChunk {
1757
+ x: number;
1758
+ z: number;
1759
+ dataVersion?: number;
1760
+ sections: {
1761
+ y: number;
1762
+ data: ChunkData;
1763
+ }[];
1764
+ entities?: MultiBlockEntity[];
1765
+ }
1766
+ declare class AnvilParser {
1767
+ static getChunkList(data: RegionInput): {
1768
+ x: number;
1769
+ z: number;
1770
+ }[];
1771
+ static parse(data: RegionInput): Promise<AnvilRegion>;
1772
+ static parseChunk(data: RegionInput, localX: number, localZ: number): Promise<AnvilChunk | undefined>;
1773
+ private static bytes;
1774
+ private static locations;
1775
+ private static readChunk;
1776
+ private static compounds;
1777
+ private static integer;
1778
+ private static block;
1779
+ private static unpack;
1780
+ }
1781
+
1681
1782
  interface BlockInfo {
1682
1783
  /** Detached block data; use world or chunk setters to update stored blocks. */
1683
1784
  readonly block: Block;
@@ -1685,13 +1786,14 @@ interface BlockInfo {
1685
1786
  }
1686
1787
 
1687
1788
  declare class Chunk {
1789
+ private readonly onBlocksChanged?;
1688
1790
  readonly scene: MineRenderScene;
1689
1791
  readonly x: number;
1690
1792
  readonly y: number;
1691
1793
  readonly z: number;
1692
1794
  private readonly data;
1693
1795
  private readonly renderedBlocks;
1694
- constructor(scene: MineRenderScene, x: number, y: number, z: number);
1796
+ constructor(scene: MineRenderScene, x: number, y: number, z: number, onBlocksChanged?: ((positions: Vector3[]) => Promise<void>) | undefined);
1695
1797
  getBlockAt(x: number, y: number, z: number): Maybe<BlockInfo>;
1696
1798
  getBlockAt(pos: Vector3): Maybe<BlockInfo>;
1697
1799
  getBlockAt(pos: TripleArray): Maybe<BlockInfo>;
@@ -1713,24 +1815,11 @@ declare class Chunk {
1713
1815
  chunkPosToWorldPos(pos: Vector3): Vector3;
1714
1816
  }
1715
1817
 
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
-
1731
1818
  declare class MineRenderWorld {
1732
1819
  readonly scene: MineRenderScene;
1733
1820
  private readonly _chunks;
1821
+ private readonly pendingCulling;
1822
+ private culling?;
1734
1823
  constructor(scene: MineRenderScene);
1735
1824
  getBlockAt(x: number, y: number, z: number): Maybe<BlockInfo>;
1736
1825
  getBlockAt(pos: Vector3): Maybe<BlockInfo>;
@@ -1739,7 +1828,10 @@ declare class MineRenderWorld {
1739
1828
  setBlockAt(pos: Vector3, block: Maybe<Block>): Promise<Maybe<BlockInfo>>;
1740
1829
  setBlockAt(pos: TripleArray, block: Maybe<Block>): Promise<Maybe<BlockInfo>>;
1741
1830
  placeMultiBlock(multiblock: MultiBlockStructure, useBatches?: boolean, executor?: BatchedExecutor): Promise<void>;
1831
+ /** Replaces one chunk column's blocks. Entity NBT remains available on the parsed chunk. */
1832
+ placeChunk(chunk: AnvilChunk, executor?: BatchedExecutor): Promise<void>;
1742
1833
  clear(): Promise<void>;
1834
+ private updateCulling;
1743
1835
  private getOrCreateChunkAt;
1744
1836
  getChunkAt(pos: Vector3): Maybe<Chunk>;
1745
1837
  static worldToScenePosition(pos: Vector3): Vector3;
@@ -1784,4 +1876,4 @@ declare class BrowserCache extends PersistentCache<LocalForage> {
1784
1876
  */
1785
1877
  declare function probeImageSize(data: Uint8Array): ImageSizeInfo;
1786
1878
 
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 };
1879
+ export { AXES, type AnimationFrame, type AnimationMeta, type AnimatorFunction, type AnvilChunk, AnvilParser, type AnvilRegion, 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, CUBE_FACE_OFFSETS, 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, ModelCulling, type ModelDisplay, type ModelElement, type ModelFaces, ModelGenerator, ModelMerger, ModelObject, type ModelObjectOptions, ModelTextures, Models, type MultiBlockBlock, type MultiBlockEntity, 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 };
@@ -2,8 +2,8 @@ import * as three from 'three';
2
2
  import { Vector3, PixelFormat, BoxGeometry, Material, Mesh, Euler, Vector2, BufferAttribute, Float32BufferAttribute, BufferGeometry, Object3D, Box3, InstancedMesh, PerspectiveCamera, OrthographicCamera, Matrix4, Scene, Object3DEventMap, Texture, Camera, MOUSE, TOUCH, WebGLRenderer, EventDispatcher, Raycaster, Intersection, MeshBasicMaterial, CanvasTexture, InterleavedBufferAttribute, TrianglesDrawModes, Line, Points } from 'three';
3
3
  import * as nodeCanvas from 'canvas';
4
4
  import { ImageData as ImageData$1, CanvasRenderingContext2D } from 'canvas';
5
- import { Buffer as Buffer$1 } from 'buffer';
6
- import { NBT } from 'prismarine-nbt';
5
+ import { Buffer } from 'buffer';
6
+ import { NBT, NBTFormat, Metadata } from 'prismarine-nbt';
7
7
  import { ZipReader } from '@zip.js/zip.js';
8
8
  import { AsyncLoadingCache, SimpleCache } from '@inventivetalent/loading-cache';
9
9
  import Stats from 'stats.js';
@@ -38,6 +38,7 @@ declare enum CubeFaceIndex {
38
38
  NORTH = 5
39
39
  }
40
40
  declare const CUBE_FACES: CubeFace[];
41
+ declare const CUBE_FACE_OFFSETS: readonly [readonly [1, 0, 0], readonly [-1, 0, 0], readonly [0, 1, 0], readonly [0, -1, 0], readonly [0, 0, 1], readonly [0, 0, -1]];
41
42
 
42
43
  interface Disposable {
43
44
  dispose(): void;
@@ -319,7 +320,7 @@ interface ImageInfo {
319
320
  width: number;
320
321
  height: number;
321
322
  type?: string;
322
- data: Buffer$1;
323
+ data: Buffer;
323
324
  }
324
325
  declare class ImageLoader {
325
326
  protected static _createImage(): CompatImage;
@@ -804,6 +805,11 @@ declare class DisplayTransforms {
804
805
  static apply(geometry: BufferGeometry, matrix: Matrix4): void;
805
806
  }
806
807
 
808
+ declare class ModelCulling {
809
+ static toLocalMask(worldMask: number, rotation: Euler): number;
810
+ static isOpaqueFullCube(atlas: Maybe<TextureAtlas>): boolean;
811
+ }
812
+
807
813
  declare class ModelGenerator {
808
814
  static readonly ITEM_LAYERS: string[];
809
815
  static generateItemModel(imageData: ImageData$1, layer: string): ModelElement[];
@@ -881,6 +887,7 @@ declare class ModelObject extends SceneObject {
881
887
  constructor(originalModel: Model, options?: Partial<ModelObjectOptions>);
882
888
  init(): Promise<void>;
883
889
  get textureAtlas(): Maybe<TextureAtlas>;
890
+ get isOpaqueFullCube(): boolean;
884
891
  protected loadTextures(): Promise<void>;
885
892
  protected createMeshes(force?: boolean): void;
886
893
  protected applyTextures(): void;
@@ -892,6 +899,8 @@ interface ModelObjectOptions extends SceneObjectOptions {
892
899
  uvLockRotation?: TripleArray;
893
900
  /** sRGB 0xRRGGBB colors by face tint index; omitted indices stay white. */
894
901
  tints?: Record<number, number>;
902
+ /** Hidden neighbor directions in CUBE_FACES order, before the model's block rotation. */
903
+ cullMask?: number;
895
904
  }
896
905
  declare function isModelObject(obj: any): obj is ModelObject;
897
906
 
@@ -1095,11 +1104,17 @@ declare class BlockObject extends SceneObject {
1095
1104
  private _instanceModel;
1096
1105
  private _variants;
1097
1106
  private _models;
1107
+ private _cullMask;
1098
1108
  constructor(blockState: BlockState, options?: Partial<BlockObjectOptions>);
1099
1109
  init(): Promise<void>;
1100
1110
  dispose(): void;
1101
1111
  removeFromScene(): void;
1102
1112
  private clearModels;
1113
+ private removeModels;
1114
+ get isOccluding(): boolean;
1115
+ private getModelMatrix;
1116
+ private getModelCullMask;
1117
+ setCullMask(worldMask: number): Promise<void>;
1103
1118
  get state(): {
1104
1119
  [key: string]: string;
1105
1120
  };
@@ -1127,20 +1142,27 @@ declare function isBlockObject(obj: any): obj is BlockObject;
1127
1142
  interface MultiBlockStructure {
1128
1143
  readonly size: TripleArray;
1129
1144
  readonly blocks: MultiBlockBlock[];
1145
+ readonly dataVersion?: number;
1146
+ readonly entities?: MultiBlockEntity[];
1147
+ }
1148
+ interface MultiBlockEntity {
1149
+ position: TripleArray;
1150
+ blockPosition?: TripleArray;
1151
+ nbt: unknown;
1130
1152
  }
1131
1153
  interface MultiBlockBlock extends Block {
1132
1154
  position: TripleArray;
1133
1155
  }
1134
1156
 
1135
1157
  declare class SchematicParser {
1136
- static parse(): Promise<MultiBlockStructure>;
1158
+ static parse(nbt: NBT): Promise<MultiBlockStructure>;
1137
1159
  }
1138
1160
 
1139
1161
  declare class StructureParser {
1140
1162
  static parse(_nbt: NBT, paletteIndex?: number): Promise<MultiBlockStructure>;
1141
1163
  }
1142
1164
  interface StructureNBT {
1143
- DataVersion: {
1165
+ DataVersion?: {
1144
1166
  type: "int";
1145
1167
  value: number;
1146
1168
  };
@@ -1152,7 +1174,13 @@ interface StructureNBT {
1152
1174
  };
1153
1175
  };
1154
1176
  palette?: Palette;
1155
- palettes?: Palette[];
1177
+ palettes?: {
1178
+ type: "list";
1179
+ value: {
1180
+ type: "list";
1181
+ value: Palette["value"][];
1182
+ };
1183
+ };
1156
1184
  blocks: {
1157
1185
  type: "list";
1158
1186
  value: {
@@ -1160,7 +1188,32 @@ interface StructureNBT {
1160
1188
  value: BlockEntry[];
1161
1189
  };
1162
1190
  };
1163
- entities: {};
1191
+ entities?: {
1192
+ type: "list";
1193
+ value: {
1194
+ type: "compound";
1195
+ value: {
1196
+ pos: {
1197
+ type: "list";
1198
+ value: {
1199
+ type: "double";
1200
+ value: TripleArray;
1201
+ };
1202
+ };
1203
+ blockPos: {
1204
+ type: "list";
1205
+ value: {
1206
+ type: "int";
1207
+ value: TripleArray;
1208
+ };
1209
+ };
1210
+ nbt: {
1211
+ type: "compound";
1212
+ value: any;
1213
+ };
1214
+ }[];
1215
+ };
1216
+ };
1164
1217
  }
1165
1218
  interface Palette {
1166
1219
  type: "list";
@@ -1204,9 +1257,12 @@ interface BlockEntry {
1204
1257
  }
1205
1258
 
1206
1259
  declare class NBTHelper {
1207
- static fromBuffer(buffer: Buffer): Promise<NBTAsset>;
1260
+ static fromBuffer(data: Uint8Array | ArrayBuffer, format?: NBTFormat): Promise<NBTAsset>;
1208
1261
  }
1209
1262
  interface NBTAsset extends MinecraftAsset, NBT {
1263
+ format?: NBTFormat;
1264
+ metadata?: Metadata;
1265
+ compression?: "gzip" | "none";
1210
1266
  }
1211
1267
 
1212
1268
  interface ResponseParser<T extends MinecraftAsset> {
@@ -1678,6 +1734,51 @@ declare function mergeVertices(geometry: BufferGeometry, tolerance?: number): Bu
1678
1734
  declare function toTrianglesDrawMode(geometry: BufferGeometry, drawMode: TrianglesDrawModes): BufferGeometry;
1679
1735
  declare function computeMorphedAttributes(object: Mesh | Line | Points): object;
1680
1736
 
1737
+ declare class ChunkData {
1738
+ private readonly indices;
1739
+ private readonly palette;
1740
+ private readonly paletteIds;
1741
+ private readonly freeIds;
1742
+ private readonly nbt;
1743
+ get(index: number): Maybe<Block>;
1744
+ snapshot(index: number): Maybe<() => Block>;
1745
+ set(index: number, block?: Block): void;
1746
+ clear(): void;
1747
+ static isAir(block: Maybe<Block>): boolean;
1748
+ private static copyBlock;
1749
+ private static validateIndex;
1750
+ }
1751
+
1752
+ type RegionInput = Uint8Array | ArrayBuffer;
1753
+ interface AnvilRegion {
1754
+ chunks: AnvilChunk[];
1755
+ }
1756
+ interface AnvilChunk {
1757
+ x: number;
1758
+ z: number;
1759
+ dataVersion?: number;
1760
+ sections: {
1761
+ y: number;
1762
+ data: ChunkData;
1763
+ }[];
1764
+ entities?: MultiBlockEntity[];
1765
+ }
1766
+ declare class AnvilParser {
1767
+ static getChunkList(data: RegionInput): {
1768
+ x: number;
1769
+ z: number;
1770
+ }[];
1771
+ static parse(data: RegionInput): Promise<AnvilRegion>;
1772
+ static parseChunk(data: RegionInput, localX: number, localZ: number): Promise<AnvilChunk | undefined>;
1773
+ private static bytes;
1774
+ private static locations;
1775
+ private static readChunk;
1776
+ private static compounds;
1777
+ private static integer;
1778
+ private static block;
1779
+ private static unpack;
1780
+ }
1781
+
1681
1782
  interface BlockInfo {
1682
1783
  /** Detached block data; use world or chunk setters to update stored blocks. */
1683
1784
  readonly block: Block;
@@ -1685,13 +1786,14 @@ interface BlockInfo {
1685
1786
  }
1686
1787
 
1687
1788
  declare class Chunk {
1789
+ private readonly onBlocksChanged?;
1688
1790
  readonly scene: MineRenderScene;
1689
1791
  readonly x: number;
1690
1792
  readonly y: number;
1691
1793
  readonly z: number;
1692
1794
  private readonly data;
1693
1795
  private readonly renderedBlocks;
1694
- constructor(scene: MineRenderScene, x: number, y: number, z: number);
1796
+ constructor(scene: MineRenderScene, x: number, y: number, z: number, onBlocksChanged?: ((positions: Vector3[]) => Promise<void>) | undefined);
1695
1797
  getBlockAt(x: number, y: number, z: number): Maybe<BlockInfo>;
1696
1798
  getBlockAt(pos: Vector3): Maybe<BlockInfo>;
1697
1799
  getBlockAt(pos: TripleArray): Maybe<BlockInfo>;
@@ -1713,24 +1815,11 @@ declare class Chunk {
1713
1815
  chunkPosToWorldPos(pos: Vector3): Vector3;
1714
1816
  }
1715
1817
 
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
-
1731
1818
  declare class MineRenderWorld {
1732
1819
  readonly scene: MineRenderScene;
1733
1820
  private readonly _chunks;
1821
+ private readonly pendingCulling;
1822
+ private culling?;
1734
1823
  constructor(scene: MineRenderScene);
1735
1824
  getBlockAt(x: number, y: number, z: number): Maybe<BlockInfo>;
1736
1825
  getBlockAt(pos: Vector3): Maybe<BlockInfo>;
@@ -1739,7 +1828,10 @@ declare class MineRenderWorld {
1739
1828
  setBlockAt(pos: Vector3, block: Maybe<Block>): Promise<Maybe<BlockInfo>>;
1740
1829
  setBlockAt(pos: TripleArray, block: Maybe<Block>): Promise<Maybe<BlockInfo>>;
1741
1830
  placeMultiBlock(multiblock: MultiBlockStructure, useBatches?: boolean, executor?: BatchedExecutor): Promise<void>;
1831
+ /** Replaces one chunk column's blocks. Entity NBT remains available on the parsed chunk. */
1832
+ placeChunk(chunk: AnvilChunk, executor?: BatchedExecutor): Promise<void>;
1742
1833
  clear(): Promise<void>;
1834
+ private updateCulling;
1743
1835
  private getOrCreateChunkAt;
1744
1836
  getChunkAt(pos: Vector3): Maybe<Chunk>;
1745
1837
  static worldToScenePosition(pos: Vector3): Vector3;
@@ -1784,4 +1876,4 @@ declare class BrowserCache extends PersistentCache<LocalForage> {
1784
1876
  */
1785
1877
  declare function probeImageSize(data: Uint8Array): ImageSizeInfo;
1786
1878
 
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 };
1879
+ export { AXES, type AnimationFrame, type AnimationMeta, type AnimatorFunction, type AnvilChunk, AnvilParser, type AnvilRegion, 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, CUBE_FACE_OFFSETS, 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, ModelCulling, type ModelDisplay, type ModelElement, type ModelFaces, ModelGenerator, ModelMerger, ModelObject, type ModelObjectOptions, ModelTextures, Models, type MultiBlockBlock, type MultiBlockEntity, 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 };