minerender 2.1.0-alpha.35 → 2.1.0-alpha.37
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 +23 -8
- package/dist/browser/index.d.ts +23 -8
- package/dist/browser/index.js +160 -62
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/index.mjs +160 -62
- package/dist/browser/index.mjs.map +1 -1
- package/dist/bundle.js +603 -502
- package/dist/bundle.js.map +1 -1
- package/dist/node/index.d.mts +23 -8
- package/dist/node/index.d.ts +23 -8
- package/dist/node/index.js +161 -62
- package/dist/node/index.js.map +1 -1
- package/dist/node/index.mjs +160 -62
- package/dist/node/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/browser/index.d.mts
CHANGED
|
@@ -584,13 +584,11 @@ declare class BatchedExecutor {
|
|
|
584
584
|
readonly interval: number;
|
|
585
585
|
readonly batch: number;
|
|
586
586
|
private readonly queue;
|
|
587
|
-
private readonly task;
|
|
588
587
|
constructor(interval?: number, batch?: number);
|
|
589
|
-
submit(task: Task):
|
|
590
|
-
|
|
591
|
-
private runNext;
|
|
588
|
+
submit<T>(task: Task<T>): Promise<T>;
|
|
589
|
+
stop(): void;
|
|
592
590
|
}
|
|
593
|
-
type Task = () =>
|
|
591
|
+
type Task<T = unknown> = () => T | Promise<T>;
|
|
594
592
|
|
|
595
593
|
declare function prefix(prefix?: string): string;
|
|
596
594
|
|
|
@@ -1681,7 +1679,8 @@ declare function toTrianglesDrawMode(geometry: BufferGeometry, drawMode: Triangl
|
|
|
1681
1679
|
declare function computeMorphedAttributes(object: Mesh | Line | Points): object;
|
|
1682
1680
|
|
|
1683
1681
|
interface BlockInfo {
|
|
1684
|
-
block
|
|
1682
|
+
/** Detached block data; use world or chunk setters to update stored blocks. */
|
|
1683
|
+
readonly block: Block;
|
|
1685
1684
|
object: BlockObject;
|
|
1686
1685
|
}
|
|
1687
1686
|
|
|
@@ -1690,7 +1689,8 @@ declare class Chunk {
|
|
|
1690
1689
|
readonly x: number;
|
|
1691
1690
|
readonly y: number;
|
|
1692
1691
|
readonly z: number;
|
|
1693
|
-
private readonly
|
|
1692
|
+
private readonly data;
|
|
1693
|
+
private readonly renderedBlocks;
|
|
1694
1694
|
constructor(scene: MineRenderScene, x: number, y: number, z: number);
|
|
1695
1695
|
getBlockAt(x: number, y: number, z: number): Maybe<BlockInfo>;
|
|
1696
1696
|
getBlockAt(pos: Vector3): Maybe<BlockInfo>;
|
|
@@ -1713,6 +1713,21 @@ declare class Chunk {
|
|
|
1713
1713
|
chunkPosToWorldPos(pos: Vector3): Vector3;
|
|
1714
1714
|
}
|
|
1715
1715
|
|
|
1716
|
+
declare class ChunkData {
|
|
1717
|
+
private readonly indices;
|
|
1718
|
+
private readonly palette;
|
|
1719
|
+
private readonly paletteIds;
|
|
1720
|
+
private readonly freeIds;
|
|
1721
|
+
private readonly nbt;
|
|
1722
|
+
get(index: number): Maybe<Block>;
|
|
1723
|
+
snapshot(index: number): Maybe<() => Block>;
|
|
1724
|
+
set(index: number, block?: Block): void;
|
|
1725
|
+
clear(): void;
|
|
1726
|
+
static isAir(block: Maybe<Block>): boolean;
|
|
1727
|
+
private static copyBlock;
|
|
1728
|
+
private static validateIndex;
|
|
1729
|
+
}
|
|
1730
|
+
|
|
1716
1731
|
declare class MineRenderWorld {
|
|
1717
1732
|
readonly scene: MineRenderScene;
|
|
1718
1733
|
private readonly _chunks;
|
|
@@ -1769,4 +1784,4 @@ declare class BrowserCache extends PersistentCache<LocalForage> {
|
|
|
1769
1784
|
*/
|
|
1770
1785
|
declare function probeImageSize(data: Uint8Array): ImageSizeInfo;
|
|
1771
1786
|
|
|
1772
|
-
export { AXES, type AnimationFrame, type AnimationMeta, type AnimatorFunction, ArchiveAssetSource, type ArchiveEntry, type ArchiveProxy, AssetKey, AssetLoadError, AssetLoader, AssetParser, AssetSource, type AssetType, Assets, Axis, BUILTIN_ENTITY, BUILTIN_GENERATED, BasicAssetKey, type BasicMinecraftAsset, BatchedExecutor, type BedrockBone, type BedrockCube, type BedrockEntityDescription, type BedrockEntityFile, type BedrockGeometry, type BedrockGeometryFile, type Block, type BlockInfo, type BlockModel, type BlockModelTextures, BlockObject, type BlockObjectOptions, type BlockState, type BlockStateMultipart, type BlockStateProperties, type BlockStateProperty, type BlockStatePropertyDefaults, type BlockStatePropertyValue, type BlockStateVariant, type BlockStateVariants, BlockStates, BlockTints, type BoxGeometryKey, BrowserArchiveProxy, BrowserCache, BrowserEnv, CUBE_FACES, type CacheKey, Caching, type CameraOptions, CanvasImage, type CapeLayout, Chunk, type CompatCanvas, type CompatImage, type ComposerOptions, type ControlsOptions, CubeFace, CubeFaceIndex, DEFAULT_ELEMENTS, DEFAULT_NAMESPACE, DEFAULT_ROOT, DEFAULT_UV, DISPLAY_POSITIONS, type DebugOptions, type DeepPartial, DefaultBlockStates, DisplayPosition, DisplayTransforms, type Disposable, type DoubleArray, type ElementFace, type ElementRotation, Entities, type EntityLayer, type EntityModel, type EntityModelCube, type EntityModelFile, type EntityModelLayer, type EntityModelOptions, type EntityModelPart, EntityObject, type EntityObjectOptions, Env, type EnvProvider, type ExtractableImageData, type FromTo, Geometries, GuiLight, GuiObject, type GuiObjectOptions, HostedAssetSource, type IModelTextures, ITEM_GENERATED, type ImageInfo, ImageLoader, type ImageSizeInfo, InstanceManager, InstanceReference, type Instanceable, type ItemModel, type ItemModelTextures, type ListAsset, MapControls, type MaterialKey, Materials, type Maybe, type MeshKey, Meshes, MineRenderError, MineRenderScene, type MineRenderSceneOptions, MineRenderWorld, type MinecraftAsset, MinecraftCubeTexture, MinecraftFaceUV, type MinecraftTextureMeta, type Model, type ModelDisplay, type ModelElement, type ModelFaces, ModelGenerator, ModelMerger, ModelObject, type ModelObjectOptions, ModelTextures, Models, type MultiBlockBlock, type MultiBlockStructure, type MultipartCondition, type NBTAsset, NBTHelper, OrbitControls, PersistentCache, type QuadArray, type RawImageKey, type RenderOptions, Renderer, type RendererOptions, type RequestConfig, RequestError, type RequestResponse, Requests, type ResponseParser, SKIN_PARTS, SceneInspector, SceneObject, type SceneObjectOptions, SceneStats, SceneStatsDisplay, SchematicParser, type Serializable, type SkinGeometries, SkinImage, SkinObject, type SkinObjectOptions, SkinPart, type SkinTexture, type SkinTextureCoordinates, SkinTextures, Skins, type StructureNBT, StructureParser, type TextureAsset, TextureAtlas, type TextureKey, TextureLoader, Textures, Ticker, type TickerFunction, TintColors, type Transformable, type TripleArray, UVMapper, WrappedImage, addBox3WireframeToObject, addWireframeToMesh, addWireframeToObject, applyElementRotation, applyGenericRotation, axisToVec3, base64decode, base64encode, capeTextureSizes, captureException, changeEvent, clampRotationDegrees, classicSkinGeometries, classicSkinTextureCoordinates, computeMorphedAttributes, createCanvas, createImage, estimateBytesUsed, interleaveAttributes, isAssetKey, isBasicAssetKey, isBlockObject, isDisposable, isDoubleArray, isEntityObject, isInstanceManager, isInstanceReference, isInstanceable, isInstancedMesh, isMesh, isMineRenderScene, isModelObject, isObject3D, isOrthographicCamera, isPerspectiveCamera, isQuadArray, isSceneObject, isTransformable, isTripleArray, isVector3, md5, mergeBufferAttributes, mergeBufferGeometries, mergeVertices, prefix, probeImageSize, registerBrowserEnv, serializeBoxGeometryKey, serializeImageKey, serializeMaterialKey, serializeMeshKey, serializeTextureKey, sha1, sha256, sha512, shutdown, sleep, slimSkinGeometries, slimSkinTextureCoordinates, timingEnd, timingStart, toDegrees, toRadians, toTrianglesDrawMode };
|
|
1787
|
+
export { AXES, type AnimationFrame, type AnimationMeta, type AnimatorFunction, ArchiveAssetSource, type ArchiveEntry, type ArchiveProxy, AssetKey, AssetLoadError, AssetLoader, AssetParser, AssetSource, type AssetType, Assets, Axis, BUILTIN_ENTITY, BUILTIN_GENERATED, BasicAssetKey, type BasicMinecraftAsset, BatchedExecutor, type BedrockBone, type BedrockCube, type BedrockEntityDescription, type BedrockEntityFile, type BedrockGeometry, type BedrockGeometryFile, type Block, type BlockInfo, type BlockModel, type BlockModelTextures, BlockObject, type BlockObjectOptions, type BlockState, type BlockStateMultipart, type BlockStateProperties, type BlockStateProperty, type BlockStatePropertyDefaults, type BlockStatePropertyValue, type BlockStateVariant, type BlockStateVariants, BlockStates, BlockTints, type BoxGeometryKey, BrowserArchiveProxy, BrowserCache, BrowserEnv, CUBE_FACES, type CacheKey, Caching, type CameraOptions, CanvasImage, type CapeLayout, Chunk, ChunkData, type CompatCanvas, type CompatImage, type ComposerOptions, type ControlsOptions, CubeFace, CubeFaceIndex, DEFAULT_ELEMENTS, DEFAULT_NAMESPACE, DEFAULT_ROOT, DEFAULT_UV, DISPLAY_POSITIONS, type DebugOptions, type DeepPartial, DefaultBlockStates, DisplayPosition, DisplayTransforms, type Disposable, type DoubleArray, type ElementFace, type ElementRotation, Entities, type EntityLayer, type EntityModel, type EntityModelCube, type EntityModelFile, type EntityModelLayer, type EntityModelOptions, type EntityModelPart, EntityObject, type EntityObjectOptions, Env, type EnvProvider, type ExtractableImageData, type FromTo, Geometries, GuiLight, GuiObject, type GuiObjectOptions, HostedAssetSource, type IModelTextures, ITEM_GENERATED, type ImageInfo, ImageLoader, type ImageSizeInfo, InstanceManager, InstanceReference, type Instanceable, type ItemModel, type ItemModelTextures, type ListAsset, MapControls, type MaterialKey, Materials, type Maybe, type MeshKey, Meshes, MineRenderError, MineRenderScene, type MineRenderSceneOptions, MineRenderWorld, type MinecraftAsset, MinecraftCubeTexture, MinecraftFaceUV, type MinecraftTextureMeta, type Model, type ModelDisplay, type ModelElement, type ModelFaces, ModelGenerator, ModelMerger, ModelObject, type ModelObjectOptions, ModelTextures, Models, type MultiBlockBlock, type MultiBlockStructure, type MultipartCondition, type NBTAsset, NBTHelper, OrbitControls, PersistentCache, type QuadArray, type RawImageKey, type RenderOptions, Renderer, type RendererOptions, type RequestConfig, RequestError, type RequestResponse, Requests, type ResponseParser, SKIN_PARTS, SceneInspector, SceneObject, type SceneObjectOptions, SceneStats, SceneStatsDisplay, SchematicParser, type Serializable, type SkinGeometries, SkinImage, SkinObject, type SkinObjectOptions, SkinPart, type SkinTexture, type SkinTextureCoordinates, SkinTextures, Skins, type StructureNBT, StructureParser, type TextureAsset, TextureAtlas, type TextureKey, TextureLoader, Textures, Ticker, type TickerFunction, TintColors, type Transformable, type TripleArray, UVMapper, WrappedImage, addBox3WireframeToObject, addWireframeToMesh, addWireframeToObject, applyElementRotation, applyGenericRotation, axisToVec3, base64decode, base64encode, capeTextureSizes, captureException, changeEvent, clampRotationDegrees, classicSkinGeometries, classicSkinTextureCoordinates, computeMorphedAttributes, createCanvas, createImage, estimateBytesUsed, interleaveAttributes, isAssetKey, isBasicAssetKey, isBlockObject, isDisposable, isDoubleArray, isEntityObject, isInstanceManager, isInstanceReference, isInstanceable, isInstancedMesh, isMesh, isMineRenderScene, isModelObject, isObject3D, isOrthographicCamera, isPerspectiveCamera, isQuadArray, isSceneObject, isTransformable, isTripleArray, isVector3, md5, mergeBufferAttributes, mergeBufferGeometries, mergeVertices, prefix, probeImageSize, registerBrowserEnv, serializeBoxGeometryKey, serializeImageKey, serializeMaterialKey, serializeMeshKey, serializeTextureKey, sha1, sha256, sha512, shutdown, sleep, slimSkinGeometries, slimSkinTextureCoordinates, timingEnd, timingStart, toDegrees, toRadians, toTrianglesDrawMode };
|
package/dist/browser/index.d.ts
CHANGED
|
@@ -584,13 +584,11 @@ declare class BatchedExecutor {
|
|
|
584
584
|
readonly interval: number;
|
|
585
585
|
readonly batch: number;
|
|
586
586
|
private readonly queue;
|
|
587
|
-
private readonly task;
|
|
588
587
|
constructor(interval?: number, batch?: number);
|
|
589
|
-
submit(task: Task):
|
|
590
|
-
|
|
591
|
-
private runNext;
|
|
588
|
+
submit<T>(task: Task<T>): Promise<T>;
|
|
589
|
+
stop(): void;
|
|
592
590
|
}
|
|
593
|
-
type Task = () =>
|
|
591
|
+
type Task<T = unknown> = () => T | Promise<T>;
|
|
594
592
|
|
|
595
593
|
declare function prefix(prefix?: string): string;
|
|
596
594
|
|
|
@@ -1681,7 +1679,8 @@ declare function toTrianglesDrawMode(geometry: BufferGeometry, drawMode: Triangl
|
|
|
1681
1679
|
declare function computeMorphedAttributes(object: Mesh | Line | Points): object;
|
|
1682
1680
|
|
|
1683
1681
|
interface BlockInfo {
|
|
1684
|
-
block
|
|
1682
|
+
/** Detached block data; use world or chunk setters to update stored blocks. */
|
|
1683
|
+
readonly block: Block;
|
|
1685
1684
|
object: BlockObject;
|
|
1686
1685
|
}
|
|
1687
1686
|
|
|
@@ -1690,7 +1689,8 @@ declare class Chunk {
|
|
|
1690
1689
|
readonly x: number;
|
|
1691
1690
|
readonly y: number;
|
|
1692
1691
|
readonly z: number;
|
|
1693
|
-
private readonly
|
|
1692
|
+
private readonly data;
|
|
1693
|
+
private readonly renderedBlocks;
|
|
1694
1694
|
constructor(scene: MineRenderScene, x: number, y: number, z: number);
|
|
1695
1695
|
getBlockAt(x: number, y: number, z: number): Maybe<BlockInfo>;
|
|
1696
1696
|
getBlockAt(pos: Vector3): Maybe<BlockInfo>;
|
|
@@ -1713,6 +1713,21 @@ declare class Chunk {
|
|
|
1713
1713
|
chunkPosToWorldPos(pos: Vector3): Vector3;
|
|
1714
1714
|
}
|
|
1715
1715
|
|
|
1716
|
+
declare class ChunkData {
|
|
1717
|
+
private readonly indices;
|
|
1718
|
+
private readonly palette;
|
|
1719
|
+
private readonly paletteIds;
|
|
1720
|
+
private readonly freeIds;
|
|
1721
|
+
private readonly nbt;
|
|
1722
|
+
get(index: number): Maybe<Block>;
|
|
1723
|
+
snapshot(index: number): Maybe<() => Block>;
|
|
1724
|
+
set(index: number, block?: Block): void;
|
|
1725
|
+
clear(): void;
|
|
1726
|
+
static isAir(block: Maybe<Block>): boolean;
|
|
1727
|
+
private static copyBlock;
|
|
1728
|
+
private static validateIndex;
|
|
1729
|
+
}
|
|
1730
|
+
|
|
1716
1731
|
declare class MineRenderWorld {
|
|
1717
1732
|
readonly scene: MineRenderScene;
|
|
1718
1733
|
private readonly _chunks;
|
|
@@ -1769,4 +1784,4 @@ declare class BrowserCache extends PersistentCache<LocalForage> {
|
|
|
1769
1784
|
*/
|
|
1770
1785
|
declare function probeImageSize(data: Uint8Array): ImageSizeInfo;
|
|
1771
1786
|
|
|
1772
|
-
export { AXES, type AnimationFrame, type AnimationMeta, type AnimatorFunction, ArchiveAssetSource, type ArchiveEntry, type ArchiveProxy, AssetKey, AssetLoadError, AssetLoader, AssetParser, AssetSource, type AssetType, Assets, Axis, BUILTIN_ENTITY, BUILTIN_GENERATED, BasicAssetKey, type BasicMinecraftAsset, BatchedExecutor, type BedrockBone, type BedrockCube, type BedrockEntityDescription, type BedrockEntityFile, type BedrockGeometry, type BedrockGeometryFile, type Block, type BlockInfo, type BlockModel, type BlockModelTextures, BlockObject, type BlockObjectOptions, type BlockState, type BlockStateMultipart, type BlockStateProperties, type BlockStateProperty, type BlockStatePropertyDefaults, type BlockStatePropertyValue, type BlockStateVariant, type BlockStateVariants, BlockStates, BlockTints, type BoxGeometryKey, BrowserArchiveProxy, BrowserCache, BrowserEnv, CUBE_FACES, type CacheKey, Caching, type CameraOptions, CanvasImage, type CapeLayout, Chunk, type CompatCanvas, type CompatImage, type ComposerOptions, type ControlsOptions, CubeFace, CubeFaceIndex, DEFAULT_ELEMENTS, DEFAULT_NAMESPACE, DEFAULT_ROOT, DEFAULT_UV, DISPLAY_POSITIONS, type DebugOptions, type DeepPartial, DefaultBlockStates, DisplayPosition, DisplayTransforms, type Disposable, type DoubleArray, type ElementFace, type ElementRotation, Entities, type EntityLayer, type EntityModel, type EntityModelCube, type EntityModelFile, type EntityModelLayer, type EntityModelOptions, type EntityModelPart, EntityObject, type EntityObjectOptions, Env, type EnvProvider, type ExtractableImageData, type FromTo, Geometries, GuiLight, GuiObject, type GuiObjectOptions, HostedAssetSource, type IModelTextures, ITEM_GENERATED, type ImageInfo, ImageLoader, type ImageSizeInfo, InstanceManager, InstanceReference, type Instanceable, type ItemModel, type ItemModelTextures, type ListAsset, MapControls, type MaterialKey, Materials, type Maybe, type MeshKey, Meshes, MineRenderError, MineRenderScene, type MineRenderSceneOptions, MineRenderWorld, type MinecraftAsset, MinecraftCubeTexture, MinecraftFaceUV, type MinecraftTextureMeta, type Model, type ModelDisplay, type ModelElement, type ModelFaces, ModelGenerator, ModelMerger, ModelObject, type ModelObjectOptions, ModelTextures, Models, type MultiBlockBlock, type MultiBlockStructure, type MultipartCondition, type NBTAsset, NBTHelper, OrbitControls, PersistentCache, type QuadArray, type RawImageKey, type RenderOptions, Renderer, type RendererOptions, type RequestConfig, RequestError, type RequestResponse, Requests, type ResponseParser, SKIN_PARTS, SceneInspector, SceneObject, type SceneObjectOptions, SceneStats, SceneStatsDisplay, SchematicParser, type Serializable, type SkinGeometries, SkinImage, SkinObject, type SkinObjectOptions, SkinPart, type SkinTexture, type SkinTextureCoordinates, SkinTextures, Skins, type StructureNBT, StructureParser, type TextureAsset, TextureAtlas, type TextureKey, TextureLoader, Textures, Ticker, type TickerFunction, TintColors, type Transformable, type TripleArray, UVMapper, WrappedImage, addBox3WireframeToObject, addWireframeToMesh, addWireframeToObject, applyElementRotation, applyGenericRotation, axisToVec3, base64decode, base64encode, capeTextureSizes, captureException, changeEvent, clampRotationDegrees, classicSkinGeometries, classicSkinTextureCoordinates, computeMorphedAttributes, createCanvas, createImage, estimateBytesUsed, interleaveAttributes, isAssetKey, isBasicAssetKey, isBlockObject, isDisposable, isDoubleArray, isEntityObject, isInstanceManager, isInstanceReference, isInstanceable, isInstancedMesh, isMesh, isMineRenderScene, isModelObject, isObject3D, isOrthographicCamera, isPerspectiveCamera, isQuadArray, isSceneObject, isTransformable, isTripleArray, isVector3, md5, mergeBufferAttributes, mergeBufferGeometries, mergeVertices, prefix, probeImageSize, registerBrowserEnv, serializeBoxGeometryKey, serializeImageKey, serializeMaterialKey, serializeMeshKey, serializeTextureKey, sha1, sha256, sha512, shutdown, sleep, slimSkinGeometries, slimSkinTextureCoordinates, timingEnd, timingStart, toDegrees, toRadians, toTrianglesDrawMode };
|
|
1787
|
+
export { AXES, type AnimationFrame, type AnimationMeta, type AnimatorFunction, ArchiveAssetSource, type ArchiveEntry, type ArchiveProxy, AssetKey, AssetLoadError, AssetLoader, AssetParser, AssetSource, type AssetType, Assets, Axis, BUILTIN_ENTITY, BUILTIN_GENERATED, BasicAssetKey, type BasicMinecraftAsset, BatchedExecutor, type BedrockBone, type BedrockCube, type BedrockEntityDescription, type BedrockEntityFile, type BedrockGeometry, type BedrockGeometryFile, type Block, type BlockInfo, type BlockModel, type BlockModelTextures, BlockObject, type BlockObjectOptions, type BlockState, type BlockStateMultipart, type BlockStateProperties, type BlockStateProperty, type BlockStatePropertyDefaults, type BlockStatePropertyValue, type BlockStateVariant, type BlockStateVariants, BlockStates, BlockTints, type BoxGeometryKey, BrowserArchiveProxy, BrowserCache, BrowserEnv, CUBE_FACES, type CacheKey, Caching, type CameraOptions, CanvasImage, type CapeLayout, Chunk, ChunkData, type CompatCanvas, type CompatImage, type ComposerOptions, type ControlsOptions, CubeFace, CubeFaceIndex, DEFAULT_ELEMENTS, DEFAULT_NAMESPACE, DEFAULT_ROOT, DEFAULT_UV, DISPLAY_POSITIONS, type DebugOptions, type DeepPartial, DefaultBlockStates, DisplayPosition, DisplayTransforms, type Disposable, type DoubleArray, type ElementFace, type ElementRotation, Entities, type EntityLayer, type EntityModel, type EntityModelCube, type EntityModelFile, type EntityModelLayer, type EntityModelOptions, type EntityModelPart, EntityObject, type EntityObjectOptions, Env, type EnvProvider, type ExtractableImageData, type FromTo, Geometries, GuiLight, GuiObject, type GuiObjectOptions, HostedAssetSource, type IModelTextures, ITEM_GENERATED, type ImageInfo, ImageLoader, type ImageSizeInfo, InstanceManager, InstanceReference, type Instanceable, type ItemModel, type ItemModelTextures, type ListAsset, MapControls, type MaterialKey, Materials, type Maybe, type MeshKey, Meshes, MineRenderError, MineRenderScene, type MineRenderSceneOptions, MineRenderWorld, type MinecraftAsset, MinecraftCubeTexture, MinecraftFaceUV, type MinecraftTextureMeta, type Model, type ModelDisplay, type ModelElement, type ModelFaces, ModelGenerator, ModelMerger, ModelObject, type ModelObjectOptions, ModelTextures, Models, type MultiBlockBlock, type MultiBlockStructure, type MultipartCondition, type NBTAsset, NBTHelper, OrbitControls, PersistentCache, type QuadArray, type RawImageKey, type RenderOptions, Renderer, type RendererOptions, type RequestConfig, RequestError, type RequestResponse, Requests, type ResponseParser, SKIN_PARTS, SceneInspector, SceneObject, type SceneObjectOptions, SceneStats, SceneStatsDisplay, SchematicParser, type Serializable, type SkinGeometries, SkinImage, SkinObject, type SkinObjectOptions, SkinPart, type SkinTexture, type SkinTextureCoordinates, SkinTextures, Skins, type StructureNBT, StructureParser, type TextureAsset, TextureAtlas, type TextureKey, TextureLoader, Textures, Ticker, type TickerFunction, TintColors, type Transformable, type TripleArray, UVMapper, WrappedImage, addBox3WireframeToObject, addWireframeToMesh, addWireframeToObject, applyElementRotation, applyGenericRotation, axisToVec3, base64decode, base64encode, capeTextureSizes, captureException, changeEvent, clampRotationDegrees, classicSkinGeometries, classicSkinTextureCoordinates, computeMorphedAttributes, createCanvas, createImage, estimateBytesUsed, interleaveAttributes, isAssetKey, isBasicAssetKey, isBlockObject, isDisposable, isDoubleArray, isEntityObject, isInstanceManager, isInstanceReference, isInstanceable, isInstancedMesh, isMesh, isMineRenderScene, isModelObject, isObject3D, isOrthographicCamera, isPerspectiveCamera, isQuadArray, isSceneObject, isTransformable, isTripleArray, isVector3, md5, mergeBufferAttributes, mergeBufferGeometries, mergeVertices, prefix, probeImageSize, registerBrowserEnv, serializeBoxGeometryKey, serializeImageKey, serializeMaterialKey, serializeMeshKey, serializeTextureKey, sha1, sha256, sha512, shutdown, sleep, slimSkinGeometries, slimSkinTextureCoordinates, timingEnd, timingStart, toDegrees, toRadians, toTrianglesDrawMode };
|
package/dist/browser/index.js
CHANGED
|
@@ -37,8 +37,8 @@ var require_dist = __commonJS({
|
|
|
37
37
|
__assign = Object.assign || function(t) {
|
|
38
38
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
39
39
|
s = arguments[i];
|
|
40
|
-
for (var
|
|
41
|
-
t[
|
|
40
|
+
for (var p11 in s) if (Object.prototype.hasOwnProperty.call(s, p11))
|
|
41
|
+
t[p11] = s[p11];
|
|
42
42
|
}
|
|
43
43
|
return t;
|
|
44
44
|
};
|
|
@@ -147,6 +147,7 @@ __export(index_browser_exports, {
|
|
|
147
147
|
Caching: () => Caching,
|
|
148
148
|
CanvasImage: () => CanvasImage,
|
|
149
149
|
Chunk: () => Chunk,
|
|
150
|
+
ChunkData: () => ChunkData,
|
|
150
151
|
CubeFace: () => CubeFace,
|
|
151
152
|
CubeFaceIndex: () => CubeFaceIndex,
|
|
152
153
|
DEFAULT_ELEMENTS: () => DEFAULT_ELEMENTS,
|
|
@@ -1323,12 +1324,12 @@ var AssetKey = class _AssetKey extends BasicAssetKey {
|
|
|
1323
1324
|
return a.join("/");
|
|
1324
1325
|
}
|
|
1325
1326
|
getFullPath() {
|
|
1326
|
-
let
|
|
1327
|
+
let p11 = [];
|
|
1327
1328
|
if (this.type) {
|
|
1328
|
-
|
|
1329
|
+
p11.push(this.type);
|
|
1329
1330
|
}
|
|
1330
|
-
|
|
1331
|
-
return
|
|
1331
|
+
p11.push(this.path);
|
|
1332
|
+
return p11.join("/");
|
|
1332
1333
|
}
|
|
1333
1334
|
toNamespacedString() {
|
|
1334
1335
|
return this.namespace + ":" + this.getFullPath();
|
|
@@ -1415,7 +1416,7 @@ var ModelMerger = class {
|
|
|
1415
1416
|
merged.display = { ...inheritedDisplay, ...DisplayTransforms.withHandFallbacks(source.display) };
|
|
1416
1417
|
}
|
|
1417
1418
|
}
|
|
1418
|
-
merged.hierarchy = models.map((m) => m.parent).filter((
|
|
1419
|
+
merged.hierarchy = models.map((m) => m.parent).filter((p11) => `${p11}`);
|
|
1419
1420
|
merged.hierarchy.push(`${merged.parent}`);
|
|
1420
1421
|
return merged;
|
|
1421
1422
|
}
|
|
@@ -1655,24 +1656,20 @@ var AssetLoadError = class extends Error {
|
|
|
1655
1656
|
};
|
|
1656
1657
|
|
|
1657
1658
|
// src/util/BatchedExecutor.ts
|
|
1659
|
+
var import_jobqu2 = require("jobqu");
|
|
1658
1660
|
var BatchedExecutor = class {
|
|
1659
1661
|
constructor(interval = 1, batch = 30) {
|
|
1662
|
+
if (!Number.isFinite(interval) || interval < 0) throw new RangeError("Batch interval must be finite and nonnegative");
|
|
1663
|
+
if (!Number.isInteger(batch) || batch < 1) throw new RangeError("Batch size must be a positive integer");
|
|
1660
1664
|
this.interval = interval;
|
|
1661
1665
|
this.batch = batch;
|
|
1662
|
-
this.queue =
|
|
1663
|
-
this.task = setInterval(() => this.run());
|
|
1666
|
+
this.queue = new import_jobqu2.JobQueue(async (task) => task(), { interval, maxPerRun: batch, maxActive: batch });
|
|
1664
1667
|
}
|
|
1665
1668
|
submit(task) {
|
|
1666
|
-
this.queue.
|
|
1669
|
+
return this.queue.add(() => task());
|
|
1667
1670
|
}
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
this.runNext();
|
|
1671
|
-
}
|
|
1672
|
-
}
|
|
1673
|
-
runNext() {
|
|
1674
|
-
let next = this.queue.shift();
|
|
1675
|
-
if (next) next();
|
|
1671
|
+
stop() {
|
|
1672
|
+
this.queue.end();
|
|
1676
1673
|
}
|
|
1677
1674
|
};
|
|
1678
1675
|
|
|
@@ -7335,6 +7332,87 @@ var Skins = class {
|
|
|
7335
7332
|
// src/world/Chunk.ts
|
|
7336
7333
|
var import_three25 = require("three");
|
|
7337
7334
|
|
|
7335
|
+
// src/world/ChunkData.ts
|
|
7336
|
+
var ChunkData = class _ChunkData {
|
|
7337
|
+
constructor() {
|
|
7338
|
+
this.indices = new Uint16Array(4096);
|
|
7339
|
+
this.palette = [void 0];
|
|
7340
|
+
this.paletteIds = /* @__PURE__ */ new Map();
|
|
7341
|
+
this.freeIds = [];
|
|
7342
|
+
this.nbt = /* @__PURE__ */ new Map();
|
|
7343
|
+
}
|
|
7344
|
+
get(index) {
|
|
7345
|
+
_ChunkData.validateIndex(index);
|
|
7346
|
+
const entry = this.palette[this.indices[index]];
|
|
7347
|
+
return entry ? _ChunkData.copyBlock(entry.state, this.nbt.get(index)) : void 0;
|
|
7348
|
+
}
|
|
7349
|
+
snapshot(index) {
|
|
7350
|
+
_ChunkData.validateIndex(index);
|
|
7351
|
+
const entry = this.palette[this.indices[index]];
|
|
7352
|
+
return entry ? _ChunkData.copyBlock.bind(void 0, entry.state, this.nbt.get(index)) : void 0;
|
|
7353
|
+
}
|
|
7354
|
+
set(index, block) {
|
|
7355
|
+
_ChunkData.validateIndex(index);
|
|
7356
|
+
let state;
|
|
7357
|
+
let key;
|
|
7358
|
+
let nbt;
|
|
7359
|
+
if (block && !_ChunkData.isAir(block)) {
|
|
7360
|
+
const type = AssetKey.parse("blockstates", block.type).toNamespacedString();
|
|
7361
|
+
const properties = Object.fromEntries(Object.keys(block.properties ?? {}).sort().map((name) => [name, block.properties[name]]));
|
|
7362
|
+
state = Object.freeze(Object.keys(properties).length ? { type, properties: Object.freeze(properties) } : { type });
|
|
7363
|
+
key = JSON.stringify([type, properties]);
|
|
7364
|
+
if (block.nbt !== void 0) nbt = structuredClone(block.nbt);
|
|
7365
|
+
}
|
|
7366
|
+
const previousId = this.indices[index];
|
|
7367
|
+
if (previousId !== 0) {
|
|
7368
|
+
const previous = this.palette[previousId];
|
|
7369
|
+
if (--previous.references === 0) {
|
|
7370
|
+
this.paletteIds.delete(previous.key);
|
|
7371
|
+
this.palette[previousId] = void 0;
|
|
7372
|
+
this.freeIds.push(previousId);
|
|
7373
|
+
}
|
|
7374
|
+
}
|
|
7375
|
+
let id = 0;
|
|
7376
|
+
if (state && key !== void 0) {
|
|
7377
|
+
const existingId = this.paletteIds.get(key);
|
|
7378
|
+
if (existingId !== void 0) {
|
|
7379
|
+
id = existingId;
|
|
7380
|
+
this.palette[id].references++;
|
|
7381
|
+
} else {
|
|
7382
|
+
id = this.freeIds.pop() ?? this.palette.length;
|
|
7383
|
+
this.palette[id] = { key, state, references: 1 };
|
|
7384
|
+
this.paletteIds.set(key, id);
|
|
7385
|
+
}
|
|
7386
|
+
}
|
|
7387
|
+
this.indices[index] = id;
|
|
7388
|
+
if (nbt !== void 0) this.nbt.set(index, nbt);
|
|
7389
|
+
else this.nbt.delete(index);
|
|
7390
|
+
}
|
|
7391
|
+
clear() {
|
|
7392
|
+
this.indices.fill(0);
|
|
7393
|
+
this.palette.length = 1;
|
|
7394
|
+
this.paletteIds.clear();
|
|
7395
|
+
this.freeIds.length = 0;
|
|
7396
|
+
this.nbt.clear();
|
|
7397
|
+
}
|
|
7398
|
+
static isAir(block) {
|
|
7399
|
+
if (typeof block === "undefined" || typeof block.type === "undefined") return true;
|
|
7400
|
+
const key = AssetKey.parse("blockstates", block.type);
|
|
7401
|
+
return key.namespace === "minecraft" && !key.type && ["air", "cave_air", "void_air"].includes(key.path);
|
|
7402
|
+
}
|
|
7403
|
+
static copyBlock(state, nbt) {
|
|
7404
|
+
const block = { type: state.type };
|
|
7405
|
+
if (state.properties) block.properties = { ...state.properties };
|
|
7406
|
+
if (nbt !== void 0) block.nbt = structuredClone(nbt);
|
|
7407
|
+
return block;
|
|
7408
|
+
}
|
|
7409
|
+
static validateIndex(index) {
|
|
7410
|
+
if (!Number.isInteger(index) || index < 0 || index >= 4096) {
|
|
7411
|
+
throw new RangeError("Block index must be an integer from 0 to 4095");
|
|
7412
|
+
}
|
|
7413
|
+
}
|
|
7414
|
+
};
|
|
7415
|
+
|
|
7338
7416
|
// src/world/MineRenderWorld.ts
|
|
7339
7417
|
var import_three24 = require("three");
|
|
7340
7418
|
var MineRenderWorld = class {
|
|
@@ -7364,22 +7442,39 @@ var MineRenderWorld = class {
|
|
|
7364
7442
|
const chunk = Chunk.isAir(value) ? this.getChunkAt(posOrX) : this.getOrCreateChunkAt(posOrX);
|
|
7365
7443
|
return chunk?.setBlockAt(posOrX, value);
|
|
7366
7444
|
}
|
|
7367
|
-
async placeMultiBlock(multiblock, useBatches = true, executor
|
|
7368
|
-
const keys =
|
|
7369
|
-
|
|
7370
|
-
|
|
7371
|
-
|
|
7372
|
-
|
|
7373
|
-
|
|
7374
|
-
|
|
7375
|
-
|
|
7376
|
-
|
|
7377
|
-
|
|
7378
|
-
|
|
7445
|
+
async placeMultiBlock(multiblock, useBatches = true, executor) {
|
|
7446
|
+
const keys = /* @__PURE__ */ new Map();
|
|
7447
|
+
for (const block of multiblock.blocks) {
|
|
7448
|
+
if (Chunk.isAir(block)) continue;
|
|
7449
|
+
const key = AssetKey.parse("blockstates", block.type);
|
|
7450
|
+
keys.set(key.serialize(), key);
|
|
7451
|
+
}
|
|
7452
|
+
await BlockStates.getAll(keys.values());
|
|
7453
|
+
if (!useBatches) {
|
|
7454
|
+
for (const block of multiblock.blocks) await this.setBlockAt(block.position, block);
|
|
7455
|
+
return;
|
|
7456
|
+
}
|
|
7457
|
+
const positions = /* @__PURE__ */ new Map();
|
|
7458
|
+
for (const block of multiblock.blocks) {
|
|
7459
|
+
const key = block.position.join(",");
|
|
7460
|
+
const group = positions.get(key);
|
|
7461
|
+
if (group) group.push(block);
|
|
7462
|
+
else positions.set(key, [block]);
|
|
7463
|
+
}
|
|
7464
|
+
const groups = [...positions.values()];
|
|
7465
|
+
const queue = executor ?? new BatchedExecutor();
|
|
7466
|
+
try {
|
|
7467
|
+
for (let i = 0; i < groups.length; i += queue.batch) {
|
|
7468
|
+
const results = await Promise.allSettled(groups.slice(i, i + queue.batch).map(
|
|
7469
|
+
(blocks) => queue.submit(async () => {
|
|
7470
|
+
for (const block of blocks) await this.setBlockAt(block.position, block);
|
|
7471
|
+
})
|
|
7472
|
+
));
|
|
7473
|
+
const failure = results.find((result) => result.status === "rejected");
|
|
7474
|
+
if (failure?.status === "rejected") throw failure.reason;
|
|
7379
7475
|
}
|
|
7380
|
-
}
|
|
7381
|
-
|
|
7382
|
-
await place(block);
|
|
7476
|
+
} finally {
|
|
7477
|
+
if (!executor) queue.stop();
|
|
7383
7478
|
}
|
|
7384
7479
|
}
|
|
7385
7480
|
async clear() {
|
|
@@ -7428,10 +7523,10 @@ var MineRenderWorld = class {
|
|
|
7428
7523
|
};
|
|
7429
7524
|
|
|
7430
7525
|
// src/world/Chunk.ts
|
|
7431
|
-
var p11 = prefix("Chunk");
|
|
7432
7526
|
var Chunk = class _Chunk {
|
|
7433
7527
|
constructor(scene, x, y, z) {
|
|
7434
|
-
this.
|
|
7528
|
+
this.data = new ChunkData();
|
|
7529
|
+
this.renderedBlocks = /* @__PURE__ */ new Map();
|
|
7435
7530
|
this.scene = scene;
|
|
7436
7531
|
this.x = x;
|
|
7437
7532
|
this.y = y;
|
|
@@ -7446,7 +7541,7 @@ var Chunk = class _Chunk {
|
|
|
7446
7541
|
}
|
|
7447
7542
|
const pos = this.worldPosToChunkPos(posOrX);
|
|
7448
7543
|
const index = _Chunk.chunkPosToBlockIndex(pos);
|
|
7449
|
-
return this.
|
|
7544
|
+
return this.renderedBlocks.get(index);
|
|
7450
7545
|
}
|
|
7451
7546
|
async setBlockAt(posOrX, yOrBlock, z, block) {
|
|
7452
7547
|
if (typeof posOrX == "number") {
|
|
@@ -7468,44 +7563,47 @@ var Chunk = class _Chunk {
|
|
|
7468
7563
|
worldPos = this.chunkPosToWorldPos(pos);
|
|
7469
7564
|
}
|
|
7470
7565
|
const index = _Chunk.chunkPosToBlockIndex(pos);
|
|
7471
|
-
|
|
7472
|
-
|
|
7473
|
-
|
|
7474
|
-
|
|
7475
|
-
|
|
7476
|
-
|
|
7477
|
-
|
|
7478
|
-
|
|
7479
|
-
|
|
7480
|
-
|
|
7566
|
+
this.data.set(index, block);
|
|
7567
|
+
const readBlock = this.data.snapshot(index);
|
|
7568
|
+
this.renderedBlocks.get(index)?.object.removeFromScene();
|
|
7569
|
+
this.renderedBlocks.delete(index);
|
|
7570
|
+
if (!readBlock) return void 0;
|
|
7571
|
+
const stored = readBlock();
|
|
7572
|
+
let object;
|
|
7573
|
+
try {
|
|
7574
|
+
const blockState = await BlockStates.get(AssetKey.parse("blockstates", stored.type));
|
|
7575
|
+
if (!blockState) {
|
|
7576
|
+
this.data.set(index, void 0);
|
|
7577
|
+
return void 0;
|
|
7578
|
+
}
|
|
7579
|
+
object = await this.scene.addBlock(blockState, {
|
|
7481
7580
|
mergeMeshes: true,
|
|
7482
7581
|
instanceMeshes: true,
|
|
7483
7582
|
maxInstanceCount: 2e3
|
|
7484
7583
|
});
|
|
7485
|
-
if (
|
|
7486
|
-
|
|
7487
|
-
|
|
7488
|
-
|
|
7489
|
-
|
|
7490
|
-
this.
|
|
7491
|
-
|
|
7492
|
-
|
|
7493
|
-
|
|
7494
|
-
|
|
7584
|
+
if (stored.properties) await object.setState(stored.properties);
|
|
7585
|
+
object.setPosition(MineRenderWorld.worldToScenePosition(worldPos));
|
|
7586
|
+
const info = { get block() {
|
|
7587
|
+
return readBlock();
|
|
7588
|
+
}, object };
|
|
7589
|
+
this.renderedBlocks.set(index, info);
|
|
7590
|
+
return info;
|
|
7591
|
+
} catch (error) {
|
|
7592
|
+
this.data.set(index, void 0);
|
|
7593
|
+
object?.removeFromScene();
|
|
7594
|
+
throw error;
|
|
7495
7595
|
}
|
|
7496
|
-
return void 0;
|
|
7497
7596
|
}
|
|
7498
7597
|
async clear() {
|
|
7499
|
-
this.
|
|
7500
|
-
this.
|
|
7598
|
+
for (const info of this.renderedBlocks.values()) info.object.removeFromScene();
|
|
7599
|
+
this.renderedBlocks.clear();
|
|
7600
|
+
this.data.clear();
|
|
7501
7601
|
}
|
|
7502
7602
|
async dispose() {
|
|
7503
7603
|
await this.clear();
|
|
7504
7604
|
}
|
|
7505
7605
|
static isAir(block) {
|
|
7506
|
-
|
|
7507
|
-
const key = AssetKey.parse("blockstates", block.type);
|
|
7508
|
-
return key.namespace === "minecraft" && !key.type && ["air", "cave_air", "void_air"].includes(key.path);
|
|
7606
|
+
return ChunkData.isAir(block);
|
|
7509
7607
|
}
|
|
7510
7608
|
static chunkPosToBlockIndex(pos) {
|
|
7511
7609
|
if ([pos.x, pos.y, pos.z].some((value) => !Number.isInteger(value) || value < 0 || value >= 16)) {
|