minerender 2.1.0-alpha.40 → 2.1.0-alpha.42
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.
- package/dist/browser/index.d.mts +72 -22
- package/dist/browser/index.d.ts +72 -22
- package/dist/browser/index.js +470 -217
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/index.mjs +384 -131
- package/dist/browser/index.mjs.map +1 -1
- package/dist/bundle.js +812 -553
- package/dist/bundle.js.map +1 -1
- package/dist/node/index.d.mts +72 -22
- package/dist/node/index.d.ts +72 -22
- package/dist/node/index.js +473 -217
- package/dist/node/index.js.map +1 -1
- package/dist/node/index.mjs +384 -131
- package/dist/node/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/browser/index.d.mts
CHANGED
|
@@ -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>;
|
|
@@ -1781,34 +1789,69 @@ declare class AnvilParser {
|
|
|
1781
1789
|
private static unpack;
|
|
1782
1790
|
}
|
|
1783
1791
|
|
|
1784
|
-
interface BlockInfo {
|
|
1792
|
+
interface BlockInfo<SectionMeshing extends boolean = false> {
|
|
1785
1793
|
/** Detached block data; use world or chunk setters to update stored blocks. */
|
|
1786
1794
|
readonly block: Block;
|
|
1787
|
-
object
|
|
1795
|
+
/** Merged terrain has no individual render object in section-meshing mode. */
|
|
1796
|
+
object: SectionMeshing extends false ? BlockObject : BlockObject | undefined;
|
|
1797
|
+
}
|
|
1798
|
+
|
|
1799
|
+
interface SectionMeshTemplate {
|
|
1800
|
+
geometry: BufferGeometry;
|
|
1801
|
+
atlas: TextureAtlas;
|
|
1802
|
+
cullFaces: readonly number[];
|
|
1803
|
+
}
|
|
1804
|
+
interface SectionMeshEntry {
|
|
1805
|
+
index: number;
|
|
1806
|
+
template: SectionMeshTemplate;
|
|
1807
|
+
cullMask: number;
|
|
1808
|
+
}
|
|
1809
|
+
declare class SectionMesh extends Group {
|
|
1810
|
+
private readonly ownedMeshes;
|
|
1811
|
+
static build(entries: readonly SectionMeshEntry[], maxAtlasSize?: number): SectionMesh;
|
|
1812
|
+
dispose(): void;
|
|
1813
|
+
}
|
|
1814
|
+
|
|
1815
|
+
declare class SectionModels {
|
|
1816
|
+
readonly maxAtlasSize: number;
|
|
1817
|
+
private states;
|
|
1818
|
+
private models;
|
|
1819
|
+
private readonly templates;
|
|
1820
|
+
constructor(maxAtlasSize?: number);
|
|
1821
|
+
get(blockState: BlockState, properties?: BlockStateProperties): Promise<SectionMeshTemplate | undefined>;
|
|
1822
|
+
private prepare;
|
|
1823
|
+
clear(): void;
|
|
1788
1824
|
}
|
|
1789
1825
|
|
|
1790
|
-
declare class Chunk {
|
|
1826
|
+
declare class Chunk<SectionMeshing extends boolean = false> {
|
|
1791
1827
|
private readonly onBlocksChanged?;
|
|
1828
|
+
private readonly sectionModels?;
|
|
1792
1829
|
readonly scene: MineRenderScene;
|
|
1793
1830
|
readonly x: number;
|
|
1794
1831
|
readonly y: number;
|
|
1795
1832
|
readonly z: number;
|
|
1796
1833
|
private readonly data;
|
|
1797
1834
|
private readonly renderedBlocks;
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1835
|
+
private readonly sectionBlocks;
|
|
1836
|
+
private sectionMesh?;
|
|
1837
|
+
private meshDirty;
|
|
1838
|
+
constructor(scene: MineRenderScene, x: number, y: number, z: number, onBlocksChanged?: ((positions: Vector3[]) => Promise<void>) | undefined, sectionModels?: SectionModels | undefined);
|
|
1839
|
+
getBlockAt(x: number, y: number, z: number): Maybe<BlockInfo<SectionMeshing>>;
|
|
1840
|
+
getBlockAt(pos: Vector3): Maybe<BlockInfo<SectionMeshing>>;
|
|
1841
|
+
getBlockAt(pos: TripleArray): Maybe<BlockInfo<SectionMeshing>>;
|
|
1802
1842
|
/**
|
|
1803
1843
|
* Set block at a _world_ position
|
|
1804
1844
|
*/
|
|
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
|
|
1845
|
+
setBlockAt(x: number, y: number, z: number, block: Maybe<Block>): Promise<Maybe<BlockInfo<SectionMeshing>>>;
|
|
1846
|
+
setBlockAt(pos: Vector3, block: Maybe<Block>): Promise<Maybe<BlockInfo<SectionMeshing>>>;
|
|
1847
|
+
setBlockAt(pos: TripleArray, block: Maybe<Block>): Promise<Maybe<BlockInfo<SectionMeshing>>>;
|
|
1808
1848
|
/**
|
|
1809
1849
|
* Set a block at integer chunk-local coordinates from 0 to 15.
|
|
1810
1850
|
*/
|
|
1811
|
-
setBlockInChunkAt(pos: Vector3, block?: Block, worldPos?: Vector3, onBlocksChanged?: ((positions: Vector3[]) => Promise<void>) | undefined): Promise<Maybe<BlockInfo
|
|
1851
|
+
setBlockInChunkAt(pos: Vector3, block?: Block, worldPos?: Vector3, onBlocksChanged?: ((positions: Vector3[]) => Promise<void>) | undefined): Promise<Maybe<BlockInfo<SectionMeshing>>>;
|
|
1852
|
+
isOccludingAt(pos: Vector3): boolean;
|
|
1853
|
+
setCullMaskAt(pos: Vector3, mask: number): Promise<void>;
|
|
1854
|
+
rebuildSectionMesh(): void;
|
|
1812
1855
|
clear(onBlocksChanged?: ((positions: Vector3[]) => Promise<void>) | undefined): Promise<void>;
|
|
1813
1856
|
dispose(): Promise<void>;
|
|
1814
1857
|
static isAir(block: Maybe<Block>): boolean;
|
|
@@ -1817,18 +1860,19 @@ declare class Chunk {
|
|
|
1817
1860
|
chunkPosToWorldPos(pos: Vector3): Vector3;
|
|
1818
1861
|
}
|
|
1819
1862
|
|
|
1820
|
-
declare class MineRenderWorld {
|
|
1863
|
+
declare class MineRenderWorld<SectionMeshing extends boolean = false> {
|
|
1821
1864
|
readonly scene: MineRenderScene;
|
|
1822
1865
|
private readonly _chunks;
|
|
1866
|
+
private readonly sectionModels?;
|
|
1823
1867
|
private readonly pendingCulling;
|
|
1824
1868
|
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
|
|
1869
|
+
constructor(scene: MineRenderScene, options?: MineRenderWorldOptions<SectionMeshing>);
|
|
1870
|
+
getBlockAt(x: number, y: number, z: number): Maybe<BlockInfo<SectionMeshing>>;
|
|
1871
|
+
getBlockAt(pos: Vector3): Maybe<BlockInfo<SectionMeshing>>;
|
|
1872
|
+
getBlockAt(pos: TripleArray): Maybe<BlockInfo<SectionMeshing>>;
|
|
1873
|
+
setBlockAt(x: number, y: number, z: number, block: Maybe<Block>): Promise<Maybe<BlockInfo<SectionMeshing>>>;
|
|
1874
|
+
setBlockAt(pos: Vector3, block: Maybe<Block>): Promise<Maybe<BlockInfo<SectionMeshing>>>;
|
|
1875
|
+
setBlockAt(pos: TripleArray, block: Maybe<Block>): Promise<Maybe<BlockInfo<SectionMeshing>>>;
|
|
1832
1876
|
private placeBlock;
|
|
1833
1877
|
placeMultiBlock(multiblock: MultiBlockStructure, useBatches?: boolean, executor?: BatchedExecutor): Promise<void>;
|
|
1834
1878
|
private placeBlocks;
|
|
@@ -1837,12 +1881,18 @@ declare class MineRenderWorld {
|
|
|
1837
1881
|
clear(): Promise<void>;
|
|
1838
1882
|
private updateCulling;
|
|
1839
1883
|
private getOrCreateChunkAt;
|
|
1840
|
-
getChunkAt(pos: Vector3): Maybe<Chunk
|
|
1884
|
+
getChunkAt(pos: Vector3): Maybe<Chunk<SectionMeshing>>;
|
|
1841
1885
|
static worldToScenePosition(pos: Vector3): Vector3;
|
|
1842
1886
|
static sceneToWorldPosition(pos: Vector3): Vector3;
|
|
1843
1887
|
worldPosToChunkKey(pos: Vector3): string;
|
|
1844
1888
|
validatePosBounds(pos: Vector3): void;
|
|
1845
1889
|
}
|
|
1890
|
+
interface MineRenderWorldOptions<SectionMeshing extends boolean = boolean> {
|
|
1891
|
+
/** Merge static opaque cubes into section meshes. Merged blocks have no individual object. */
|
|
1892
|
+
sectionMeshing?: SectionMeshing;
|
|
1893
|
+
/** Maximum width and height of each section atlas page, in pixels. */
|
|
1894
|
+
maxAtlasSize?: number;
|
|
1895
|
+
}
|
|
1846
1896
|
|
|
1847
1897
|
/**
|
|
1848
1898
|
* {@link EnvProvider} backed by the DOM. Uses nothing outside of standard browser APIs and
|
|
@@ -1880,4 +1930,4 @@ declare class BrowserCache extends PersistentCache<LocalForage> {
|
|
|
1880
1930
|
*/
|
|
1881
1931
|
declare function probeImageSize(data: Uint8Array): ImageSizeInfo;
|
|
1882
1932
|
|
|
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 };
|
|
1933
|
+
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 };
|
package/dist/browser/index.d.ts
CHANGED
|
@@ -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>;
|
|
@@ -1781,34 +1789,69 @@ declare class AnvilParser {
|
|
|
1781
1789
|
private static unpack;
|
|
1782
1790
|
}
|
|
1783
1791
|
|
|
1784
|
-
interface BlockInfo {
|
|
1792
|
+
interface BlockInfo<SectionMeshing extends boolean = false> {
|
|
1785
1793
|
/** Detached block data; use world or chunk setters to update stored blocks. */
|
|
1786
1794
|
readonly block: Block;
|
|
1787
|
-
object
|
|
1795
|
+
/** Merged terrain has no individual render object in section-meshing mode. */
|
|
1796
|
+
object: SectionMeshing extends false ? BlockObject : BlockObject | undefined;
|
|
1797
|
+
}
|
|
1798
|
+
|
|
1799
|
+
interface SectionMeshTemplate {
|
|
1800
|
+
geometry: BufferGeometry;
|
|
1801
|
+
atlas: TextureAtlas;
|
|
1802
|
+
cullFaces: readonly number[];
|
|
1803
|
+
}
|
|
1804
|
+
interface SectionMeshEntry {
|
|
1805
|
+
index: number;
|
|
1806
|
+
template: SectionMeshTemplate;
|
|
1807
|
+
cullMask: number;
|
|
1808
|
+
}
|
|
1809
|
+
declare class SectionMesh extends Group {
|
|
1810
|
+
private readonly ownedMeshes;
|
|
1811
|
+
static build(entries: readonly SectionMeshEntry[], maxAtlasSize?: number): SectionMesh;
|
|
1812
|
+
dispose(): void;
|
|
1813
|
+
}
|
|
1814
|
+
|
|
1815
|
+
declare class SectionModels {
|
|
1816
|
+
readonly maxAtlasSize: number;
|
|
1817
|
+
private states;
|
|
1818
|
+
private models;
|
|
1819
|
+
private readonly templates;
|
|
1820
|
+
constructor(maxAtlasSize?: number);
|
|
1821
|
+
get(blockState: BlockState, properties?: BlockStateProperties): Promise<SectionMeshTemplate | undefined>;
|
|
1822
|
+
private prepare;
|
|
1823
|
+
clear(): void;
|
|
1788
1824
|
}
|
|
1789
1825
|
|
|
1790
|
-
declare class Chunk {
|
|
1826
|
+
declare class Chunk<SectionMeshing extends boolean = false> {
|
|
1791
1827
|
private readonly onBlocksChanged?;
|
|
1828
|
+
private readonly sectionModels?;
|
|
1792
1829
|
readonly scene: MineRenderScene;
|
|
1793
1830
|
readonly x: number;
|
|
1794
1831
|
readonly y: number;
|
|
1795
1832
|
readonly z: number;
|
|
1796
1833
|
private readonly data;
|
|
1797
1834
|
private readonly renderedBlocks;
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1835
|
+
private readonly sectionBlocks;
|
|
1836
|
+
private sectionMesh?;
|
|
1837
|
+
private meshDirty;
|
|
1838
|
+
constructor(scene: MineRenderScene, x: number, y: number, z: number, onBlocksChanged?: ((positions: Vector3[]) => Promise<void>) | undefined, sectionModels?: SectionModels | undefined);
|
|
1839
|
+
getBlockAt(x: number, y: number, z: number): Maybe<BlockInfo<SectionMeshing>>;
|
|
1840
|
+
getBlockAt(pos: Vector3): Maybe<BlockInfo<SectionMeshing>>;
|
|
1841
|
+
getBlockAt(pos: TripleArray): Maybe<BlockInfo<SectionMeshing>>;
|
|
1802
1842
|
/**
|
|
1803
1843
|
* Set block at a _world_ position
|
|
1804
1844
|
*/
|
|
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
|
|
1845
|
+
setBlockAt(x: number, y: number, z: number, block: Maybe<Block>): Promise<Maybe<BlockInfo<SectionMeshing>>>;
|
|
1846
|
+
setBlockAt(pos: Vector3, block: Maybe<Block>): Promise<Maybe<BlockInfo<SectionMeshing>>>;
|
|
1847
|
+
setBlockAt(pos: TripleArray, block: Maybe<Block>): Promise<Maybe<BlockInfo<SectionMeshing>>>;
|
|
1808
1848
|
/**
|
|
1809
1849
|
* Set a block at integer chunk-local coordinates from 0 to 15.
|
|
1810
1850
|
*/
|
|
1811
|
-
setBlockInChunkAt(pos: Vector3, block?: Block, worldPos?: Vector3, onBlocksChanged?: ((positions: Vector3[]) => Promise<void>) | undefined): Promise<Maybe<BlockInfo
|
|
1851
|
+
setBlockInChunkAt(pos: Vector3, block?: Block, worldPos?: Vector3, onBlocksChanged?: ((positions: Vector3[]) => Promise<void>) | undefined): Promise<Maybe<BlockInfo<SectionMeshing>>>;
|
|
1852
|
+
isOccludingAt(pos: Vector3): boolean;
|
|
1853
|
+
setCullMaskAt(pos: Vector3, mask: number): Promise<void>;
|
|
1854
|
+
rebuildSectionMesh(): void;
|
|
1812
1855
|
clear(onBlocksChanged?: ((positions: Vector3[]) => Promise<void>) | undefined): Promise<void>;
|
|
1813
1856
|
dispose(): Promise<void>;
|
|
1814
1857
|
static isAir(block: Maybe<Block>): boolean;
|
|
@@ -1817,18 +1860,19 @@ declare class Chunk {
|
|
|
1817
1860
|
chunkPosToWorldPos(pos: Vector3): Vector3;
|
|
1818
1861
|
}
|
|
1819
1862
|
|
|
1820
|
-
declare class MineRenderWorld {
|
|
1863
|
+
declare class MineRenderWorld<SectionMeshing extends boolean = false> {
|
|
1821
1864
|
readonly scene: MineRenderScene;
|
|
1822
1865
|
private readonly _chunks;
|
|
1866
|
+
private readonly sectionModels?;
|
|
1823
1867
|
private readonly pendingCulling;
|
|
1824
1868
|
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
|
|
1869
|
+
constructor(scene: MineRenderScene, options?: MineRenderWorldOptions<SectionMeshing>);
|
|
1870
|
+
getBlockAt(x: number, y: number, z: number): Maybe<BlockInfo<SectionMeshing>>;
|
|
1871
|
+
getBlockAt(pos: Vector3): Maybe<BlockInfo<SectionMeshing>>;
|
|
1872
|
+
getBlockAt(pos: TripleArray): Maybe<BlockInfo<SectionMeshing>>;
|
|
1873
|
+
setBlockAt(x: number, y: number, z: number, block: Maybe<Block>): Promise<Maybe<BlockInfo<SectionMeshing>>>;
|
|
1874
|
+
setBlockAt(pos: Vector3, block: Maybe<Block>): Promise<Maybe<BlockInfo<SectionMeshing>>>;
|
|
1875
|
+
setBlockAt(pos: TripleArray, block: Maybe<Block>): Promise<Maybe<BlockInfo<SectionMeshing>>>;
|
|
1832
1876
|
private placeBlock;
|
|
1833
1877
|
placeMultiBlock(multiblock: MultiBlockStructure, useBatches?: boolean, executor?: BatchedExecutor): Promise<void>;
|
|
1834
1878
|
private placeBlocks;
|
|
@@ -1837,12 +1881,18 @@ declare class MineRenderWorld {
|
|
|
1837
1881
|
clear(): Promise<void>;
|
|
1838
1882
|
private updateCulling;
|
|
1839
1883
|
private getOrCreateChunkAt;
|
|
1840
|
-
getChunkAt(pos: Vector3): Maybe<Chunk
|
|
1884
|
+
getChunkAt(pos: Vector3): Maybe<Chunk<SectionMeshing>>;
|
|
1841
1885
|
static worldToScenePosition(pos: Vector3): Vector3;
|
|
1842
1886
|
static sceneToWorldPosition(pos: Vector3): Vector3;
|
|
1843
1887
|
worldPosToChunkKey(pos: Vector3): string;
|
|
1844
1888
|
validatePosBounds(pos: Vector3): void;
|
|
1845
1889
|
}
|
|
1890
|
+
interface MineRenderWorldOptions<SectionMeshing extends boolean = boolean> {
|
|
1891
|
+
/** Merge static opaque cubes into section meshes. Merged blocks have no individual object. */
|
|
1892
|
+
sectionMeshing?: SectionMeshing;
|
|
1893
|
+
/** Maximum width and height of each section atlas page, in pixels. */
|
|
1894
|
+
maxAtlasSize?: number;
|
|
1895
|
+
}
|
|
1846
1896
|
|
|
1847
1897
|
/**
|
|
1848
1898
|
* {@link EnvProvider} backed by the DOM. Uses nothing outside of standard browser APIs and
|
|
@@ -1880,4 +1930,4 @@ declare class BrowserCache extends PersistentCache<LocalForage> {
|
|
|
1880
1930
|
*/
|
|
1881
1931
|
declare function probeImageSize(data: Uint8Array): ImageSizeInfo;
|
|
1882
1932
|
|
|
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 };
|
|
1933
|
+
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 };
|