minerender 2.1.0-alpha.41 → 2.1.0-alpha.43

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.
@@ -1,5 +1,5 @@
1
1
  import * as three from 'three';
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';
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, Group } from 'three';
3
3
  import * as nodeCanvas from 'canvas';
4
4
  import { ImageData as ImageData$1, CanvasRenderingContext2D } from 'canvas';
5
5
  import { Buffer } from 'buffer';
@@ -827,6 +827,14 @@ interface Block {
827
827
  nbt?: any;
828
828
  }
829
829
 
830
+ declare class BlockStateResolver {
831
+ static defaults(blockState: BlockState): Promise<BlockStateProperties>;
832
+ static select(blockState: BlockState, state: BlockStateProperties, choose?: (variants: BlockStateVariant | BlockStateVariant[]) => BlockStateVariant): BlockStateVariant[];
833
+ static matching(blockState: BlockState, state: BlockStateProperties): (BlockStateVariant | BlockStateVariant[])[];
834
+ static choose(variants: BlockStateVariant | BlockStateVariant[]): BlockStateVariant;
835
+ static rotation(variant: BlockStateVariant): Euler;
836
+ }
837
+
830
838
  declare class BlockTints {
831
839
  /** Resolves block preview colors without biome context; explicit tints take precedence. */
832
840
  static get(key: AssetKey | undefined, state: BlockStateProperties, model: Model, tints?: Record<number, number>): Promise<Record<number, number> | undefined>;
@@ -1065,6 +1073,8 @@ declare class SceneObject extends Object3D<Object3DEventMap & {
1065
1073
  get instanceCounter(): number;
1066
1074
  protected constructInstanceReference(i: number): InstanceReference<SceneObject>;
1067
1075
  nextInstance(): InstanceReference<SceneObject>;
1076
+ /** Returns the live reference for a raycast hit on this object's instance mesh. */
1077
+ getInstanceReference(mesh: Object3D, index: number): Maybe<InstanceReference<SceneObject>>;
1068
1078
  isInstanceActive(index: number, reference: InstanceReference<Instanceable>): boolean;
1069
1079
  removeInstanceAt(index: number): void;
1070
1080
  private growInstances;
@@ -1616,17 +1626,21 @@ declare class SceneInspector {
1616
1626
  protected readonly raycaster: Raycaster;
1617
1627
  private readonly mouse;
1618
1628
  private selectedObject?;
1629
+ private pointer?;
1630
+ private readonly listeners;
1619
1631
  constructor(renderer: Renderer);
1620
1632
  protected init(): void;
1633
+ dispose(): void;
1621
1634
  findMeshChildren(from: Object3D, out?: Mesh[]): Mesh<three.BufferGeometry<three.NormalBufferAttributes>, three.Material | three.Material[], three.Object3DEventMap>[];
1622
- onClick(event: any): void;
1635
+ onClick(event: MouseEvent): void;
1623
1636
  appendTo(el: HTMLElement): void;
1624
1637
  protected handleRaycasterObjects(intersections: Intersection[]): void;
1625
- selectObject(targetObject: Object3D, targetIntersection?: Intersection): void;
1626
- protected redraw(targetObject: Object3D, targetIntersection?: Intersection): void;
1627
- protected addControls(object: Object3D, intersection?: Intersection): void;
1638
+ private getIntersectionInstance;
1639
+ selectObject(targetObject: Object3D, targetIntersection?: Intersection, instance?: Maybe<InstanceReference<SceneObject>>): void;
1640
+ protected redraw(targetObject: Object3D, targetIntersection?: Intersection, instance?: InstanceReference<SceneObject>): void;
1641
+ protected addControls(object: Object3D, intersection?: Intersection, instance?: InstanceReference<SceneObject>): void;
1628
1642
  protected addInfoLine(name: string, id: string, value: any): HTMLElement;
1629
- protected addObjectControls(target: Object3D, intersection: Maybe<Intersection>, container: HTMLElement): void;
1643
+ protected addObjectControls(target: Object3D, intersection: Maybe<Intersection>, container: HTMLElement, instance?: InstanceReference<SceneObject>): void;
1630
1644
  protected buttonControl(name: string, id: string, click: () => void): HTMLElement;
1631
1645
  protected selectControl(name: string, id: string, options: string[], change: (v: string) => void): HTMLElement;
1632
1646
  protected toggleControl(name: string, id: string, val: boolean, change: (v: boolean) => void): HTMLElement;
@@ -1782,34 +1796,69 @@ declare class AnvilParser {
1782
1796
  private static unpack;
1783
1797
  }
1784
1798
 
1785
- interface BlockInfo {
1799
+ interface BlockInfo<SectionMeshing extends boolean = false> {
1786
1800
  /** Detached block data; use world or chunk setters to update stored blocks. */
1787
1801
  readonly block: Block;
1788
- object: BlockObject;
1802
+ /** Merged terrain has no individual render object in section-meshing mode. */
1803
+ object: SectionMeshing extends false ? BlockObject : BlockObject | undefined;
1789
1804
  }
1790
1805
 
1791
- declare class Chunk {
1806
+ interface SectionMeshTemplate {
1807
+ geometry: BufferGeometry;
1808
+ atlas: TextureAtlas;
1809
+ cullFaces: readonly number[];
1810
+ }
1811
+ interface SectionMeshEntry {
1812
+ index: number;
1813
+ template: SectionMeshTemplate;
1814
+ cullMask: number;
1815
+ }
1816
+ declare class SectionMesh extends Group {
1817
+ private readonly ownedMeshes;
1818
+ static build(entries: readonly SectionMeshEntry[], maxAtlasSize?: number): SectionMesh;
1819
+ dispose(): void;
1820
+ }
1821
+
1822
+ declare class SectionModels {
1823
+ readonly maxAtlasSize: number;
1824
+ private states;
1825
+ private models;
1826
+ private readonly templates;
1827
+ constructor(maxAtlasSize?: number);
1828
+ get(blockState: BlockState, properties?: BlockStateProperties): Promise<SectionMeshTemplate | undefined>;
1829
+ private prepare;
1830
+ clear(): void;
1831
+ }
1832
+
1833
+ declare class Chunk<SectionMeshing extends boolean = false> {
1792
1834
  private readonly onBlocksChanged?;
1835
+ private readonly sectionModels?;
1793
1836
  readonly scene: MineRenderScene;
1794
1837
  readonly x: number;
1795
1838
  readonly y: number;
1796
1839
  readonly z: number;
1797
1840
  private readonly data;
1798
1841
  private readonly renderedBlocks;
1799
- constructor(scene: MineRenderScene, x: number, y: number, z: number, onBlocksChanged?: ((positions: Vector3[]) => Promise<void>) | undefined);
1800
- getBlockAt(x: number, y: number, z: number): Maybe<BlockInfo>;
1801
- getBlockAt(pos: Vector3): Maybe<BlockInfo>;
1802
- getBlockAt(pos: TripleArray): Maybe<BlockInfo>;
1842
+ private readonly sectionBlocks;
1843
+ private sectionMesh?;
1844
+ private meshDirty;
1845
+ constructor(scene: MineRenderScene, x: number, y: number, z: number, onBlocksChanged?: ((positions: Vector3[]) => Promise<void>) | undefined, sectionModels?: SectionModels | undefined);
1846
+ getBlockAt(x: number, y: number, z: number): Maybe<BlockInfo<SectionMeshing>>;
1847
+ getBlockAt(pos: Vector3): Maybe<BlockInfo<SectionMeshing>>;
1848
+ getBlockAt(pos: TripleArray): Maybe<BlockInfo<SectionMeshing>>;
1803
1849
  /**
1804
1850
  * Set block at a _world_ position
1805
1851
  */
1806
- setBlockAt(x: number, y: number, z: number, block: Maybe<Block>): Promise<Maybe<BlockInfo>>;
1807
- setBlockAt(pos: Vector3, block: Maybe<Block>): Promise<Maybe<BlockInfo>>;
1808
- setBlockAt(pos: TripleArray, block: Maybe<Block>): Promise<Maybe<BlockInfo>>;
1852
+ setBlockAt(x: number, y: number, z: number, block: Maybe<Block>): Promise<Maybe<BlockInfo<SectionMeshing>>>;
1853
+ setBlockAt(pos: Vector3, block: Maybe<Block>): Promise<Maybe<BlockInfo<SectionMeshing>>>;
1854
+ setBlockAt(pos: TripleArray, block: Maybe<Block>): Promise<Maybe<BlockInfo<SectionMeshing>>>;
1809
1855
  /**
1810
1856
  * Set a block at integer chunk-local coordinates from 0 to 15.
1811
1857
  */
1812
- setBlockInChunkAt(pos: Vector3, block?: Block, worldPos?: Vector3, onBlocksChanged?: ((positions: Vector3[]) => Promise<void>) | undefined): Promise<Maybe<BlockInfo>>;
1858
+ setBlockInChunkAt(pos: Vector3, block?: Block, worldPos?: Vector3, onBlocksChanged?: ((positions: Vector3[]) => Promise<void>) | undefined): Promise<Maybe<BlockInfo<SectionMeshing>>>;
1859
+ isOccludingAt(pos: Vector3): boolean;
1860
+ setCullMaskAt(pos: Vector3, mask: number): Promise<void>;
1861
+ rebuildSectionMesh(): void;
1813
1862
  clear(onBlocksChanged?: ((positions: Vector3[]) => Promise<void>) | undefined): Promise<void>;
1814
1863
  dispose(): Promise<void>;
1815
1864
  static isAir(block: Maybe<Block>): boolean;
@@ -1818,18 +1867,19 @@ declare class Chunk {
1818
1867
  chunkPosToWorldPos(pos: Vector3): Vector3;
1819
1868
  }
1820
1869
 
1821
- declare class MineRenderWorld {
1870
+ declare class MineRenderWorld<SectionMeshing extends boolean = false> {
1822
1871
  readonly scene: MineRenderScene;
1823
1872
  private readonly _chunks;
1873
+ private readonly sectionModels?;
1824
1874
  private readonly pendingCulling;
1825
1875
  private culling?;
1826
- constructor(scene: MineRenderScene);
1827
- getBlockAt(x: number, y: number, z: number): Maybe<BlockInfo>;
1828
- getBlockAt(pos: Vector3): Maybe<BlockInfo>;
1829
- getBlockAt(pos: TripleArray): Maybe<BlockInfo>;
1830
- setBlockAt(x: number, y: number, z: number, block: Maybe<Block>): Promise<Maybe<BlockInfo>>;
1831
- setBlockAt(pos: Vector3, block: Maybe<Block>): Promise<Maybe<BlockInfo>>;
1832
- setBlockAt(pos: TripleArray, block: Maybe<Block>): Promise<Maybe<BlockInfo>>;
1876
+ constructor(scene: MineRenderScene, options?: MineRenderWorldOptions<SectionMeshing>);
1877
+ getBlockAt(x: number, y: number, z: number): Maybe<BlockInfo<SectionMeshing>>;
1878
+ getBlockAt(pos: Vector3): Maybe<BlockInfo<SectionMeshing>>;
1879
+ getBlockAt(pos: TripleArray): Maybe<BlockInfo<SectionMeshing>>;
1880
+ setBlockAt(x: number, y: number, z: number, block: Maybe<Block>): Promise<Maybe<BlockInfo<SectionMeshing>>>;
1881
+ setBlockAt(pos: Vector3, block: Maybe<Block>): Promise<Maybe<BlockInfo<SectionMeshing>>>;
1882
+ setBlockAt(pos: TripleArray, block: Maybe<Block>): Promise<Maybe<BlockInfo<SectionMeshing>>>;
1833
1883
  private placeBlock;
1834
1884
  placeMultiBlock(multiblock: MultiBlockStructure, useBatches?: boolean, executor?: BatchedExecutor): Promise<void>;
1835
1885
  private placeBlocks;
@@ -1838,12 +1888,18 @@ declare class MineRenderWorld {
1838
1888
  clear(): Promise<void>;
1839
1889
  private updateCulling;
1840
1890
  private getOrCreateChunkAt;
1841
- getChunkAt(pos: Vector3): Maybe<Chunk>;
1891
+ getChunkAt(pos: Vector3): Maybe<Chunk<SectionMeshing>>;
1842
1892
  static worldToScenePosition(pos: Vector3): Vector3;
1843
1893
  static sceneToWorldPosition(pos: Vector3): Vector3;
1844
1894
  worldPosToChunkKey(pos: Vector3): string;
1845
1895
  validatePosBounds(pos: Vector3): void;
1846
1896
  }
1897
+ interface MineRenderWorldOptions<SectionMeshing extends boolean = boolean> {
1898
+ /** Merge static opaque cubes into section meshes. Merged blocks have no individual object. */
1899
+ sectionMeshing?: SectionMeshing;
1900
+ /** Maximum width and height of each section atlas page, in pixels. */
1901
+ maxAtlasSize?: number;
1902
+ }
1847
1903
 
1848
1904
  /**
1849
1905
  * {@link EnvProvider} for headless Node.
@@ -1883,4 +1939,4 @@ declare class NodeCache extends PersistentCache<LocalStorage> {
1883
1939
  forEach<T>(callback: (v: T, k: string) => void): Promise<void>;
1884
1940
  }
1885
1941
 
1886
- 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 };
1942
+ 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, BlockStateResolver, 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 MineRenderWorldOptions, 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, SectionMesh, type SectionMeshEntry, type SectionMeshTemplate, SectionModels, 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 };
@@ -1,5 +1,5 @@
1
1
  import * as three from 'three';
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';
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, Group } from 'three';
3
3
  import * as nodeCanvas from 'canvas';
4
4
  import { ImageData as ImageData$1, CanvasRenderingContext2D } from 'canvas';
5
5
  import { Buffer } from 'buffer';
@@ -827,6 +827,14 @@ interface Block {
827
827
  nbt?: any;
828
828
  }
829
829
 
830
+ declare class BlockStateResolver {
831
+ static defaults(blockState: BlockState): Promise<BlockStateProperties>;
832
+ static select(blockState: BlockState, state: BlockStateProperties, choose?: (variants: BlockStateVariant | BlockStateVariant[]) => BlockStateVariant): BlockStateVariant[];
833
+ static matching(blockState: BlockState, state: BlockStateProperties): (BlockStateVariant | BlockStateVariant[])[];
834
+ static choose(variants: BlockStateVariant | BlockStateVariant[]): BlockStateVariant;
835
+ static rotation(variant: BlockStateVariant): Euler;
836
+ }
837
+
830
838
  declare class BlockTints {
831
839
  /** Resolves block preview colors without biome context; explicit tints take precedence. */
832
840
  static get(key: AssetKey | undefined, state: BlockStateProperties, model: Model, tints?: Record<number, number>): Promise<Record<number, number> | undefined>;
@@ -1065,6 +1073,8 @@ declare class SceneObject extends Object3D<Object3DEventMap & {
1065
1073
  get instanceCounter(): number;
1066
1074
  protected constructInstanceReference(i: number): InstanceReference<SceneObject>;
1067
1075
  nextInstance(): InstanceReference<SceneObject>;
1076
+ /** Returns the live reference for a raycast hit on this object's instance mesh. */
1077
+ getInstanceReference(mesh: Object3D, index: number): Maybe<InstanceReference<SceneObject>>;
1068
1078
  isInstanceActive(index: number, reference: InstanceReference<Instanceable>): boolean;
1069
1079
  removeInstanceAt(index: number): void;
1070
1080
  private growInstances;
@@ -1616,17 +1626,21 @@ declare class SceneInspector {
1616
1626
  protected readonly raycaster: Raycaster;
1617
1627
  private readonly mouse;
1618
1628
  private selectedObject?;
1629
+ private pointer?;
1630
+ private readonly listeners;
1619
1631
  constructor(renderer: Renderer);
1620
1632
  protected init(): void;
1633
+ dispose(): void;
1621
1634
  findMeshChildren(from: Object3D, out?: Mesh[]): Mesh<three.BufferGeometry<three.NormalBufferAttributes>, three.Material | three.Material[], three.Object3DEventMap>[];
1622
- onClick(event: any): void;
1635
+ onClick(event: MouseEvent): void;
1623
1636
  appendTo(el: HTMLElement): void;
1624
1637
  protected handleRaycasterObjects(intersections: Intersection[]): void;
1625
- selectObject(targetObject: Object3D, targetIntersection?: Intersection): void;
1626
- protected redraw(targetObject: Object3D, targetIntersection?: Intersection): void;
1627
- protected addControls(object: Object3D, intersection?: Intersection): void;
1638
+ private getIntersectionInstance;
1639
+ selectObject(targetObject: Object3D, targetIntersection?: Intersection, instance?: Maybe<InstanceReference<SceneObject>>): void;
1640
+ protected redraw(targetObject: Object3D, targetIntersection?: Intersection, instance?: InstanceReference<SceneObject>): void;
1641
+ protected addControls(object: Object3D, intersection?: Intersection, instance?: InstanceReference<SceneObject>): void;
1628
1642
  protected addInfoLine(name: string, id: string, value: any): HTMLElement;
1629
- protected addObjectControls(target: Object3D, intersection: Maybe<Intersection>, container: HTMLElement): void;
1643
+ protected addObjectControls(target: Object3D, intersection: Maybe<Intersection>, container: HTMLElement, instance?: InstanceReference<SceneObject>): void;
1630
1644
  protected buttonControl(name: string, id: string, click: () => void): HTMLElement;
1631
1645
  protected selectControl(name: string, id: string, options: string[], change: (v: string) => void): HTMLElement;
1632
1646
  protected toggleControl(name: string, id: string, val: boolean, change: (v: boolean) => void): HTMLElement;
@@ -1782,34 +1796,69 @@ declare class AnvilParser {
1782
1796
  private static unpack;
1783
1797
  }
1784
1798
 
1785
- interface BlockInfo {
1799
+ interface BlockInfo<SectionMeshing extends boolean = false> {
1786
1800
  /** Detached block data; use world or chunk setters to update stored blocks. */
1787
1801
  readonly block: Block;
1788
- object: BlockObject;
1802
+ /** Merged terrain has no individual render object in section-meshing mode. */
1803
+ object: SectionMeshing extends false ? BlockObject : BlockObject | undefined;
1789
1804
  }
1790
1805
 
1791
- declare class Chunk {
1806
+ interface SectionMeshTemplate {
1807
+ geometry: BufferGeometry;
1808
+ atlas: TextureAtlas;
1809
+ cullFaces: readonly number[];
1810
+ }
1811
+ interface SectionMeshEntry {
1812
+ index: number;
1813
+ template: SectionMeshTemplate;
1814
+ cullMask: number;
1815
+ }
1816
+ declare class SectionMesh extends Group {
1817
+ private readonly ownedMeshes;
1818
+ static build(entries: readonly SectionMeshEntry[], maxAtlasSize?: number): SectionMesh;
1819
+ dispose(): void;
1820
+ }
1821
+
1822
+ declare class SectionModels {
1823
+ readonly maxAtlasSize: number;
1824
+ private states;
1825
+ private models;
1826
+ private readonly templates;
1827
+ constructor(maxAtlasSize?: number);
1828
+ get(blockState: BlockState, properties?: BlockStateProperties): Promise<SectionMeshTemplate | undefined>;
1829
+ private prepare;
1830
+ clear(): void;
1831
+ }
1832
+
1833
+ declare class Chunk<SectionMeshing extends boolean = false> {
1792
1834
  private readonly onBlocksChanged?;
1835
+ private readonly sectionModels?;
1793
1836
  readonly scene: MineRenderScene;
1794
1837
  readonly x: number;
1795
1838
  readonly y: number;
1796
1839
  readonly z: number;
1797
1840
  private readonly data;
1798
1841
  private readonly renderedBlocks;
1799
- constructor(scene: MineRenderScene, x: number, y: number, z: number, onBlocksChanged?: ((positions: Vector3[]) => Promise<void>) | undefined);
1800
- getBlockAt(x: number, y: number, z: number): Maybe<BlockInfo>;
1801
- getBlockAt(pos: Vector3): Maybe<BlockInfo>;
1802
- getBlockAt(pos: TripleArray): Maybe<BlockInfo>;
1842
+ private readonly sectionBlocks;
1843
+ private sectionMesh?;
1844
+ private meshDirty;
1845
+ constructor(scene: MineRenderScene, x: number, y: number, z: number, onBlocksChanged?: ((positions: Vector3[]) => Promise<void>) | undefined, sectionModels?: SectionModels | undefined);
1846
+ getBlockAt(x: number, y: number, z: number): Maybe<BlockInfo<SectionMeshing>>;
1847
+ getBlockAt(pos: Vector3): Maybe<BlockInfo<SectionMeshing>>;
1848
+ getBlockAt(pos: TripleArray): Maybe<BlockInfo<SectionMeshing>>;
1803
1849
  /**
1804
1850
  * Set block at a _world_ position
1805
1851
  */
1806
- setBlockAt(x: number, y: number, z: number, block: Maybe<Block>): Promise<Maybe<BlockInfo>>;
1807
- setBlockAt(pos: Vector3, block: Maybe<Block>): Promise<Maybe<BlockInfo>>;
1808
- setBlockAt(pos: TripleArray, block: Maybe<Block>): Promise<Maybe<BlockInfo>>;
1852
+ setBlockAt(x: number, y: number, z: number, block: Maybe<Block>): Promise<Maybe<BlockInfo<SectionMeshing>>>;
1853
+ setBlockAt(pos: Vector3, block: Maybe<Block>): Promise<Maybe<BlockInfo<SectionMeshing>>>;
1854
+ setBlockAt(pos: TripleArray, block: Maybe<Block>): Promise<Maybe<BlockInfo<SectionMeshing>>>;
1809
1855
  /**
1810
1856
  * Set a block at integer chunk-local coordinates from 0 to 15.
1811
1857
  */
1812
- setBlockInChunkAt(pos: Vector3, block?: Block, worldPos?: Vector3, onBlocksChanged?: ((positions: Vector3[]) => Promise<void>) | undefined): Promise<Maybe<BlockInfo>>;
1858
+ setBlockInChunkAt(pos: Vector3, block?: Block, worldPos?: Vector3, onBlocksChanged?: ((positions: Vector3[]) => Promise<void>) | undefined): Promise<Maybe<BlockInfo<SectionMeshing>>>;
1859
+ isOccludingAt(pos: Vector3): boolean;
1860
+ setCullMaskAt(pos: Vector3, mask: number): Promise<void>;
1861
+ rebuildSectionMesh(): void;
1813
1862
  clear(onBlocksChanged?: ((positions: Vector3[]) => Promise<void>) | undefined): Promise<void>;
1814
1863
  dispose(): Promise<void>;
1815
1864
  static isAir(block: Maybe<Block>): boolean;
@@ -1818,18 +1867,19 @@ declare class Chunk {
1818
1867
  chunkPosToWorldPos(pos: Vector3): Vector3;
1819
1868
  }
1820
1869
 
1821
- declare class MineRenderWorld {
1870
+ declare class MineRenderWorld<SectionMeshing extends boolean = false> {
1822
1871
  readonly scene: MineRenderScene;
1823
1872
  private readonly _chunks;
1873
+ private readonly sectionModels?;
1824
1874
  private readonly pendingCulling;
1825
1875
  private culling?;
1826
- constructor(scene: MineRenderScene);
1827
- getBlockAt(x: number, y: number, z: number): Maybe<BlockInfo>;
1828
- getBlockAt(pos: Vector3): Maybe<BlockInfo>;
1829
- getBlockAt(pos: TripleArray): Maybe<BlockInfo>;
1830
- setBlockAt(x: number, y: number, z: number, block: Maybe<Block>): Promise<Maybe<BlockInfo>>;
1831
- setBlockAt(pos: Vector3, block: Maybe<Block>): Promise<Maybe<BlockInfo>>;
1832
- setBlockAt(pos: TripleArray, block: Maybe<Block>): Promise<Maybe<BlockInfo>>;
1876
+ constructor(scene: MineRenderScene, options?: MineRenderWorldOptions<SectionMeshing>);
1877
+ getBlockAt(x: number, y: number, z: number): Maybe<BlockInfo<SectionMeshing>>;
1878
+ getBlockAt(pos: Vector3): Maybe<BlockInfo<SectionMeshing>>;
1879
+ getBlockAt(pos: TripleArray): Maybe<BlockInfo<SectionMeshing>>;
1880
+ setBlockAt(x: number, y: number, z: number, block: Maybe<Block>): Promise<Maybe<BlockInfo<SectionMeshing>>>;
1881
+ setBlockAt(pos: Vector3, block: Maybe<Block>): Promise<Maybe<BlockInfo<SectionMeshing>>>;
1882
+ setBlockAt(pos: TripleArray, block: Maybe<Block>): Promise<Maybe<BlockInfo<SectionMeshing>>>;
1833
1883
  private placeBlock;
1834
1884
  placeMultiBlock(multiblock: MultiBlockStructure, useBatches?: boolean, executor?: BatchedExecutor): Promise<void>;
1835
1885
  private placeBlocks;
@@ -1838,12 +1888,18 @@ declare class MineRenderWorld {
1838
1888
  clear(): Promise<void>;
1839
1889
  private updateCulling;
1840
1890
  private getOrCreateChunkAt;
1841
- getChunkAt(pos: Vector3): Maybe<Chunk>;
1891
+ getChunkAt(pos: Vector3): Maybe<Chunk<SectionMeshing>>;
1842
1892
  static worldToScenePosition(pos: Vector3): Vector3;
1843
1893
  static sceneToWorldPosition(pos: Vector3): Vector3;
1844
1894
  worldPosToChunkKey(pos: Vector3): string;
1845
1895
  validatePosBounds(pos: Vector3): void;
1846
1896
  }
1897
+ interface MineRenderWorldOptions<SectionMeshing extends boolean = boolean> {
1898
+ /** Merge static opaque cubes into section meshes. Merged blocks have no individual object. */
1899
+ sectionMeshing?: SectionMeshing;
1900
+ /** Maximum width and height of each section atlas page, in pixels. */
1901
+ maxAtlasSize?: number;
1902
+ }
1847
1903
 
1848
1904
  /**
1849
1905
  * {@link EnvProvider} for headless Node.
@@ -1883,4 +1939,4 @@ declare class NodeCache extends PersistentCache<LocalStorage> {
1883
1939
  forEach<T>(callback: (v: T, k: string) => void): Promise<void>;
1884
1940
  }
1885
1941
 
1886
- 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 };
1942
+ 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, BlockStateResolver, 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 MineRenderWorldOptions, 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, SectionMesh, type SectionMeshEntry, type SectionMeshTemplate, SectionModels, 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 };