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