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