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/node/index.d.mts
CHANGED
|
@@ -585,13 +585,11 @@ declare class BatchedExecutor {
|
|
|
585
585
|
readonly interval: number;
|
|
586
586
|
readonly batch: number;
|
|
587
587
|
private readonly queue;
|
|
588
|
-
private readonly task;
|
|
589
588
|
constructor(interval?: number, batch?: number);
|
|
590
|
-
submit(task: Task):
|
|
591
|
-
|
|
592
|
-
private runNext;
|
|
589
|
+
submit<T>(task: Task<T>): Promise<T>;
|
|
590
|
+
stop(): void;
|
|
593
591
|
}
|
|
594
|
-
type Task = () =>
|
|
592
|
+
type Task<T = unknown> = () => T | Promise<T>;
|
|
595
593
|
|
|
596
594
|
declare function prefix(prefix?: string): string;
|
|
597
595
|
|
|
@@ -1682,7 +1680,8 @@ declare function toTrianglesDrawMode(geometry: BufferGeometry, drawMode: Triangl
|
|
|
1682
1680
|
declare function computeMorphedAttributes(object: Mesh | Line | Points): object;
|
|
1683
1681
|
|
|
1684
1682
|
interface BlockInfo {
|
|
1685
|
-
block
|
|
1683
|
+
/** Detached block data; use world or chunk setters to update stored blocks. */
|
|
1684
|
+
readonly block: Block;
|
|
1686
1685
|
object: BlockObject;
|
|
1687
1686
|
}
|
|
1688
1687
|
|
|
@@ -1691,7 +1690,8 @@ declare class Chunk {
|
|
|
1691
1690
|
readonly x: number;
|
|
1692
1691
|
readonly y: number;
|
|
1693
1692
|
readonly z: number;
|
|
1694
|
-
private readonly
|
|
1693
|
+
private readonly data;
|
|
1694
|
+
private readonly renderedBlocks;
|
|
1695
1695
|
constructor(scene: MineRenderScene, x: number, y: number, z: number);
|
|
1696
1696
|
getBlockAt(x: number, y: number, z: number): Maybe<BlockInfo>;
|
|
1697
1697
|
getBlockAt(pos: Vector3): Maybe<BlockInfo>;
|
|
@@ -1714,6 +1714,21 @@ declare class Chunk {
|
|
|
1714
1714
|
chunkPosToWorldPos(pos: Vector3): Vector3;
|
|
1715
1715
|
}
|
|
1716
1716
|
|
|
1717
|
+
declare class ChunkData {
|
|
1718
|
+
private readonly indices;
|
|
1719
|
+
private readonly palette;
|
|
1720
|
+
private readonly paletteIds;
|
|
1721
|
+
private readonly freeIds;
|
|
1722
|
+
private readonly nbt;
|
|
1723
|
+
get(index: number): Maybe<Block>;
|
|
1724
|
+
snapshot(index: number): Maybe<() => Block>;
|
|
1725
|
+
set(index: number, block?: Block): void;
|
|
1726
|
+
clear(): void;
|
|
1727
|
+
static isAir(block: Maybe<Block>): boolean;
|
|
1728
|
+
private static copyBlock;
|
|
1729
|
+
private static validateIndex;
|
|
1730
|
+
}
|
|
1731
|
+
|
|
1717
1732
|
declare class MineRenderWorld {
|
|
1718
1733
|
readonly scene: MineRenderScene;
|
|
1719
1734
|
private readonly _chunks;
|
|
@@ -1772,4 +1787,4 @@ declare class NodeCache extends PersistentCache<LocalStorage> {
|
|
|
1772
1787
|
forEach<T>(callback: (v: T, k: string) => void): Promise<void>;
|
|
1773
1788
|
}
|
|
1774
1789
|
|
|
1775
|
-
export { AXES, type AnimationFrame, type AnimationMeta, type AnimatorFunction, ArchiveAssetSource, type ArchiveEntry, type ArchiveProxy, AssetKey, AssetLoadError, AssetLoader, AssetParser, AssetSource, type AssetType, Assets, Axis, BUILTIN_ENTITY, BUILTIN_GENERATED, BasicAssetKey, type BasicMinecraftAsset, BatchedExecutor, type BedrockBone, type BedrockCube, type BedrockEntityDescription, type BedrockEntityFile, type BedrockGeometry, type BedrockGeometryFile, type Block, type BlockInfo, type BlockModel, type BlockModelTextures, BlockObject, type BlockObjectOptions, type BlockState, type BlockStateMultipart, type BlockStateProperties, type BlockStateProperty, type BlockStatePropertyDefaults, type BlockStatePropertyValue, type BlockStateVariant, type BlockStateVariants, BlockStates, BlockTints, type BoxGeometryKey, BrowserArchiveProxy, CUBE_FACES, type CacheKey, Caching, type CameraOptions, CanvasImage, type CapeLayout, Chunk, type CompatCanvas, type CompatImage, type ComposerOptions, type ControlsOptions, CubeFace, CubeFaceIndex, DEFAULT_ELEMENTS, DEFAULT_NAMESPACE, DEFAULT_ROOT, DEFAULT_UV, DISPLAY_POSITIONS, type DebugOptions, type DeepPartial, DefaultBlockStates, DisplayPosition, DisplayTransforms, type Disposable, type DoubleArray, type ElementFace, type ElementRotation, Entities, type EntityLayer, type EntityModel, type EntityModelCube, type EntityModelFile, type EntityModelLayer, type EntityModelOptions, type EntityModelPart, EntityObject, type EntityObjectOptions, Env, type EnvProvider, type ExtractableImageData, type FromTo, Geometries, GuiLight, GuiObject, type GuiObjectOptions, HostedAssetSource, type IModelTextures, ITEM_GENERATED, type ImageInfo, ImageLoader, type ImageSizeInfo, InstanceManager, InstanceReference, type Instanceable, type ItemModel, type ItemModelTextures, type ListAsset, MapControls, type MaterialKey, Materials, type Maybe, type MeshKey, Meshes, MineRenderError, MineRenderScene, type MineRenderSceneOptions, MineRenderWorld, type MinecraftAsset, MinecraftCubeTexture, MinecraftFaceUV, type MinecraftTextureMeta, type Model, type ModelDisplay, type ModelElement, type ModelFaces, ModelGenerator, ModelMerger, ModelObject, type ModelObjectOptions, ModelTextures, Models, type MultiBlockBlock, type MultiBlockStructure, type MultipartCondition, type NBTAsset, NBTHelper, NodeCache, NodeEnv, OrbitControls, PersistentCache, type QuadArray, type RawImageKey, type RenderOptions, Renderer, type RendererOptions, type RequestConfig, RequestError, type RequestResponse, Requests, type ResponseParser, SKIN_PARTS, SceneInspector, SceneObject, type SceneObjectOptions, SceneStats, SceneStatsDisplay, SchematicParser, type Serializable, type SkinGeometries, SkinImage, SkinObject, type SkinObjectOptions, SkinPart, type SkinTexture, type SkinTextureCoordinates, SkinTextures, Skins, type StructureNBT, StructureParser, type TextureAsset, TextureAtlas, type TextureKey, TextureLoader, Textures, Ticker, type TickerFunction, TintColors, type Transformable, type TripleArray, UVMapper, WrappedImage, addBox3WireframeToObject, addWireframeToMesh, addWireframeToObject, applyElementRotation, applyGenericRotation, axisToVec3, base64decode, base64encode, capeTextureSizes, captureException, changeEvent, clampRotationDegrees, classicSkinGeometries, classicSkinTextureCoordinates, computeMorphedAttributes, createCanvas, createImage, estimateBytesUsed, interleaveAttributes, isAssetKey, isBasicAssetKey, isBlockObject, isDisposable, isDoubleArray, isEntityObject, isInstanceManager, isInstanceReference, isInstanceable, isInstancedMesh, isMesh, isMineRenderScene, isModelObject, isObject3D, isOrthographicCamera, isPerspectiveCamera, isQuadArray, isSceneObject, isTransformable, isTripleArray, isVector3, md5, mergeBufferAttributes, mergeBufferGeometries, mergeVertices, prefix, registerNodeEnv, serializeBoxGeometryKey, serializeImageKey, serializeMaterialKey, serializeMeshKey, serializeTextureKey, sha1, sha256, sha512, shutdown, sleep, slimSkinGeometries, slimSkinTextureCoordinates, timingEnd, timingStart, toDegrees, toRadians, toTrianglesDrawMode };
|
|
1790
|
+
export { AXES, type AnimationFrame, type AnimationMeta, type AnimatorFunction, ArchiveAssetSource, type ArchiveEntry, type ArchiveProxy, AssetKey, AssetLoadError, AssetLoader, AssetParser, AssetSource, type AssetType, Assets, Axis, BUILTIN_ENTITY, BUILTIN_GENERATED, BasicAssetKey, type BasicMinecraftAsset, BatchedExecutor, type BedrockBone, type BedrockCube, type BedrockEntityDescription, type BedrockEntityFile, type BedrockGeometry, type BedrockGeometryFile, type Block, type BlockInfo, type BlockModel, type BlockModelTextures, BlockObject, type BlockObjectOptions, type BlockState, type BlockStateMultipart, type BlockStateProperties, type BlockStateProperty, type BlockStatePropertyDefaults, type BlockStatePropertyValue, type BlockStateVariant, type BlockStateVariants, BlockStates, BlockTints, type BoxGeometryKey, BrowserArchiveProxy, CUBE_FACES, type CacheKey, Caching, type CameraOptions, CanvasImage, type CapeLayout, Chunk, ChunkData, type CompatCanvas, type CompatImage, type ComposerOptions, type ControlsOptions, CubeFace, CubeFaceIndex, DEFAULT_ELEMENTS, DEFAULT_NAMESPACE, DEFAULT_ROOT, DEFAULT_UV, DISPLAY_POSITIONS, type DebugOptions, type DeepPartial, DefaultBlockStates, DisplayPosition, DisplayTransforms, type Disposable, type DoubleArray, type ElementFace, type ElementRotation, Entities, type EntityLayer, type EntityModel, type EntityModelCube, type EntityModelFile, type EntityModelLayer, type EntityModelOptions, type EntityModelPart, EntityObject, type EntityObjectOptions, Env, type EnvProvider, type ExtractableImageData, type FromTo, Geometries, GuiLight, GuiObject, type GuiObjectOptions, HostedAssetSource, type IModelTextures, ITEM_GENERATED, type ImageInfo, ImageLoader, type ImageSizeInfo, InstanceManager, InstanceReference, type Instanceable, type ItemModel, type ItemModelTextures, type ListAsset, MapControls, type MaterialKey, Materials, type Maybe, type MeshKey, Meshes, MineRenderError, MineRenderScene, type MineRenderSceneOptions, MineRenderWorld, type MinecraftAsset, MinecraftCubeTexture, MinecraftFaceUV, type MinecraftTextureMeta, type Model, type ModelDisplay, type ModelElement, type ModelFaces, ModelGenerator, ModelMerger, ModelObject, type ModelObjectOptions, ModelTextures, Models, type MultiBlockBlock, type MultiBlockStructure, type MultipartCondition, type NBTAsset, NBTHelper, NodeCache, NodeEnv, OrbitControls, PersistentCache, type QuadArray, type RawImageKey, type RenderOptions, Renderer, type RendererOptions, type RequestConfig, RequestError, type RequestResponse, Requests, type ResponseParser, SKIN_PARTS, SceneInspector, SceneObject, type SceneObjectOptions, SceneStats, SceneStatsDisplay, SchematicParser, type Serializable, type SkinGeometries, SkinImage, SkinObject, type SkinObjectOptions, SkinPart, type SkinTexture, type SkinTextureCoordinates, SkinTextures, Skins, type StructureNBT, StructureParser, type TextureAsset, TextureAtlas, type TextureKey, TextureLoader, Textures, Ticker, type TickerFunction, TintColors, type Transformable, type TripleArray, UVMapper, WrappedImage, addBox3WireframeToObject, addWireframeToMesh, addWireframeToObject, applyElementRotation, applyGenericRotation, axisToVec3, base64decode, base64encode, capeTextureSizes, captureException, changeEvent, clampRotationDegrees, classicSkinGeometries, classicSkinTextureCoordinates, computeMorphedAttributes, createCanvas, createImage, estimateBytesUsed, interleaveAttributes, isAssetKey, isBasicAssetKey, isBlockObject, isDisposable, isDoubleArray, isEntityObject, isInstanceManager, isInstanceReference, isInstanceable, isInstancedMesh, isMesh, isMineRenderScene, isModelObject, isObject3D, isOrthographicCamera, isPerspectiveCamera, isQuadArray, isSceneObject, isTransformable, isTripleArray, isVector3, md5, mergeBufferAttributes, mergeBufferGeometries, mergeVertices, prefix, registerNodeEnv, serializeBoxGeometryKey, serializeImageKey, serializeMaterialKey, serializeMeshKey, serializeTextureKey, sha1, sha256, sha512, shutdown, sleep, slimSkinGeometries, slimSkinTextureCoordinates, timingEnd, timingStart, toDegrees, toRadians, toTrianglesDrawMode };
|
package/dist/node/index.d.ts
CHANGED
|
@@ -585,13 +585,11 @@ declare class BatchedExecutor {
|
|
|
585
585
|
readonly interval: number;
|
|
586
586
|
readonly batch: number;
|
|
587
587
|
private readonly queue;
|
|
588
|
-
private readonly task;
|
|
589
588
|
constructor(interval?: number, batch?: number);
|
|
590
|
-
submit(task: Task):
|
|
591
|
-
|
|
592
|
-
private runNext;
|
|
589
|
+
submit<T>(task: Task<T>): Promise<T>;
|
|
590
|
+
stop(): void;
|
|
593
591
|
}
|
|
594
|
-
type Task = () =>
|
|
592
|
+
type Task<T = unknown> = () => T | Promise<T>;
|
|
595
593
|
|
|
596
594
|
declare function prefix(prefix?: string): string;
|
|
597
595
|
|
|
@@ -1682,7 +1680,8 @@ declare function toTrianglesDrawMode(geometry: BufferGeometry, drawMode: Triangl
|
|
|
1682
1680
|
declare function computeMorphedAttributes(object: Mesh | Line | Points): object;
|
|
1683
1681
|
|
|
1684
1682
|
interface BlockInfo {
|
|
1685
|
-
block
|
|
1683
|
+
/** Detached block data; use world or chunk setters to update stored blocks. */
|
|
1684
|
+
readonly block: Block;
|
|
1686
1685
|
object: BlockObject;
|
|
1687
1686
|
}
|
|
1688
1687
|
|
|
@@ -1691,7 +1690,8 @@ declare class Chunk {
|
|
|
1691
1690
|
readonly x: number;
|
|
1692
1691
|
readonly y: number;
|
|
1693
1692
|
readonly z: number;
|
|
1694
|
-
private readonly
|
|
1693
|
+
private readonly data;
|
|
1694
|
+
private readonly renderedBlocks;
|
|
1695
1695
|
constructor(scene: MineRenderScene, x: number, y: number, z: number);
|
|
1696
1696
|
getBlockAt(x: number, y: number, z: number): Maybe<BlockInfo>;
|
|
1697
1697
|
getBlockAt(pos: Vector3): Maybe<BlockInfo>;
|
|
@@ -1714,6 +1714,21 @@ declare class Chunk {
|
|
|
1714
1714
|
chunkPosToWorldPos(pos: Vector3): Vector3;
|
|
1715
1715
|
}
|
|
1716
1716
|
|
|
1717
|
+
declare class ChunkData {
|
|
1718
|
+
private readonly indices;
|
|
1719
|
+
private readonly palette;
|
|
1720
|
+
private readonly paletteIds;
|
|
1721
|
+
private readonly freeIds;
|
|
1722
|
+
private readonly nbt;
|
|
1723
|
+
get(index: number): Maybe<Block>;
|
|
1724
|
+
snapshot(index: number): Maybe<() => Block>;
|
|
1725
|
+
set(index: number, block?: Block): void;
|
|
1726
|
+
clear(): void;
|
|
1727
|
+
static isAir(block: Maybe<Block>): boolean;
|
|
1728
|
+
private static copyBlock;
|
|
1729
|
+
private static validateIndex;
|
|
1730
|
+
}
|
|
1731
|
+
|
|
1717
1732
|
declare class MineRenderWorld {
|
|
1718
1733
|
readonly scene: MineRenderScene;
|
|
1719
1734
|
private readonly _chunks;
|
|
@@ -1772,4 +1787,4 @@ declare class NodeCache extends PersistentCache<LocalStorage> {
|
|
|
1772
1787
|
forEach<T>(callback: (v: T, k: string) => void): Promise<void>;
|
|
1773
1788
|
}
|
|
1774
1789
|
|
|
1775
|
-
export { AXES, type AnimationFrame, type AnimationMeta, type AnimatorFunction, ArchiveAssetSource, type ArchiveEntry, type ArchiveProxy, AssetKey, AssetLoadError, AssetLoader, AssetParser, AssetSource, type AssetType, Assets, Axis, BUILTIN_ENTITY, BUILTIN_GENERATED, BasicAssetKey, type BasicMinecraftAsset, BatchedExecutor, type BedrockBone, type BedrockCube, type BedrockEntityDescription, type BedrockEntityFile, type BedrockGeometry, type BedrockGeometryFile, type Block, type BlockInfo, type BlockModel, type BlockModelTextures, BlockObject, type BlockObjectOptions, type BlockState, type BlockStateMultipart, type BlockStateProperties, type BlockStateProperty, type BlockStatePropertyDefaults, type BlockStatePropertyValue, type BlockStateVariant, type BlockStateVariants, BlockStates, BlockTints, type BoxGeometryKey, BrowserArchiveProxy, CUBE_FACES, type CacheKey, Caching, type CameraOptions, CanvasImage, type CapeLayout, Chunk, type CompatCanvas, type CompatImage, type ComposerOptions, type ControlsOptions, CubeFace, CubeFaceIndex, DEFAULT_ELEMENTS, DEFAULT_NAMESPACE, DEFAULT_ROOT, DEFAULT_UV, DISPLAY_POSITIONS, type DebugOptions, type DeepPartial, DefaultBlockStates, DisplayPosition, DisplayTransforms, type Disposable, type DoubleArray, type ElementFace, type ElementRotation, Entities, type EntityLayer, type EntityModel, type EntityModelCube, type EntityModelFile, type EntityModelLayer, type EntityModelOptions, type EntityModelPart, EntityObject, type EntityObjectOptions, Env, type EnvProvider, type ExtractableImageData, type FromTo, Geometries, GuiLight, GuiObject, type GuiObjectOptions, HostedAssetSource, type IModelTextures, ITEM_GENERATED, type ImageInfo, ImageLoader, type ImageSizeInfo, InstanceManager, InstanceReference, type Instanceable, type ItemModel, type ItemModelTextures, type ListAsset, MapControls, type MaterialKey, Materials, type Maybe, type MeshKey, Meshes, MineRenderError, MineRenderScene, type MineRenderSceneOptions, MineRenderWorld, type MinecraftAsset, MinecraftCubeTexture, MinecraftFaceUV, type MinecraftTextureMeta, type Model, type ModelDisplay, type ModelElement, type ModelFaces, ModelGenerator, ModelMerger, ModelObject, type ModelObjectOptions, ModelTextures, Models, type MultiBlockBlock, type MultiBlockStructure, type MultipartCondition, type NBTAsset, NBTHelper, NodeCache, NodeEnv, OrbitControls, PersistentCache, type QuadArray, type RawImageKey, type RenderOptions, Renderer, type RendererOptions, type RequestConfig, RequestError, type RequestResponse, Requests, type ResponseParser, SKIN_PARTS, SceneInspector, SceneObject, type SceneObjectOptions, SceneStats, SceneStatsDisplay, SchematicParser, type Serializable, type SkinGeometries, SkinImage, SkinObject, type SkinObjectOptions, SkinPart, type SkinTexture, type SkinTextureCoordinates, SkinTextures, Skins, type StructureNBT, StructureParser, type TextureAsset, TextureAtlas, type TextureKey, TextureLoader, Textures, Ticker, type TickerFunction, TintColors, type Transformable, type TripleArray, UVMapper, WrappedImage, addBox3WireframeToObject, addWireframeToMesh, addWireframeToObject, applyElementRotation, applyGenericRotation, axisToVec3, base64decode, base64encode, capeTextureSizes, captureException, changeEvent, clampRotationDegrees, classicSkinGeometries, classicSkinTextureCoordinates, computeMorphedAttributes, createCanvas, createImage, estimateBytesUsed, interleaveAttributes, isAssetKey, isBasicAssetKey, isBlockObject, isDisposable, isDoubleArray, isEntityObject, isInstanceManager, isInstanceReference, isInstanceable, isInstancedMesh, isMesh, isMineRenderScene, isModelObject, isObject3D, isOrthographicCamera, isPerspectiveCamera, isQuadArray, isSceneObject, isTransformable, isTripleArray, isVector3, md5, mergeBufferAttributes, mergeBufferGeometries, mergeVertices, prefix, registerNodeEnv, serializeBoxGeometryKey, serializeImageKey, serializeMaterialKey, serializeMeshKey, serializeTextureKey, sha1, sha256, sha512, shutdown, sleep, slimSkinGeometries, slimSkinTextureCoordinates, timingEnd, timingStart, toDegrees, toRadians, toTrianglesDrawMode };
|
|
1790
|
+
export { AXES, type AnimationFrame, type AnimationMeta, type AnimatorFunction, ArchiveAssetSource, type ArchiveEntry, type ArchiveProxy, AssetKey, AssetLoadError, AssetLoader, AssetParser, AssetSource, type AssetType, Assets, Axis, BUILTIN_ENTITY, BUILTIN_GENERATED, BasicAssetKey, type BasicMinecraftAsset, BatchedExecutor, type BedrockBone, type BedrockCube, type BedrockEntityDescription, type BedrockEntityFile, type BedrockGeometry, type BedrockGeometryFile, type Block, type BlockInfo, type BlockModel, type BlockModelTextures, BlockObject, type BlockObjectOptions, type BlockState, type BlockStateMultipart, type BlockStateProperties, type BlockStateProperty, type BlockStatePropertyDefaults, type BlockStatePropertyValue, type BlockStateVariant, type BlockStateVariants, BlockStates, BlockTints, type BoxGeometryKey, BrowserArchiveProxy, CUBE_FACES, type CacheKey, Caching, type CameraOptions, CanvasImage, type CapeLayout, Chunk, ChunkData, type CompatCanvas, type CompatImage, type ComposerOptions, type ControlsOptions, CubeFace, CubeFaceIndex, DEFAULT_ELEMENTS, DEFAULT_NAMESPACE, DEFAULT_ROOT, DEFAULT_UV, DISPLAY_POSITIONS, type DebugOptions, type DeepPartial, DefaultBlockStates, DisplayPosition, DisplayTransforms, type Disposable, type DoubleArray, type ElementFace, type ElementRotation, Entities, type EntityLayer, type EntityModel, type EntityModelCube, type EntityModelFile, type EntityModelLayer, type EntityModelOptions, type EntityModelPart, EntityObject, type EntityObjectOptions, Env, type EnvProvider, type ExtractableImageData, type FromTo, Geometries, GuiLight, GuiObject, type GuiObjectOptions, HostedAssetSource, type IModelTextures, ITEM_GENERATED, type ImageInfo, ImageLoader, type ImageSizeInfo, InstanceManager, InstanceReference, type Instanceable, type ItemModel, type ItemModelTextures, type ListAsset, MapControls, type MaterialKey, Materials, type Maybe, type MeshKey, Meshes, MineRenderError, MineRenderScene, type MineRenderSceneOptions, MineRenderWorld, type MinecraftAsset, MinecraftCubeTexture, MinecraftFaceUV, type MinecraftTextureMeta, type Model, type ModelDisplay, type ModelElement, type ModelFaces, ModelGenerator, ModelMerger, ModelObject, type ModelObjectOptions, ModelTextures, Models, type MultiBlockBlock, type MultiBlockStructure, type MultipartCondition, type NBTAsset, NBTHelper, NodeCache, NodeEnv, OrbitControls, PersistentCache, type QuadArray, type RawImageKey, type RenderOptions, Renderer, type RendererOptions, type RequestConfig, RequestError, type RequestResponse, Requests, type ResponseParser, SKIN_PARTS, SceneInspector, SceneObject, type SceneObjectOptions, SceneStats, SceneStatsDisplay, SchematicParser, type Serializable, type SkinGeometries, SkinImage, SkinObject, type SkinObjectOptions, SkinPart, type SkinTexture, type SkinTextureCoordinates, SkinTextures, Skins, type StructureNBT, StructureParser, type TextureAsset, TextureAtlas, type TextureKey, TextureLoader, Textures, Ticker, type TickerFunction, TintColors, type Transformable, type TripleArray, UVMapper, WrappedImage, addBox3WireframeToObject, addWireframeToMesh, addWireframeToObject, applyElementRotation, applyGenericRotation, axisToVec3, base64decode, base64encode, capeTextureSizes, captureException, changeEvent, clampRotationDegrees, classicSkinGeometries, classicSkinTextureCoordinates, computeMorphedAttributes, createCanvas, createImage, estimateBytesUsed, interleaveAttributes, isAssetKey, isBasicAssetKey, isBlockObject, isDisposable, isDoubleArray, isEntityObject, isInstanceManager, isInstanceReference, isInstanceable, isInstancedMesh, isMesh, isMineRenderScene, isModelObject, isObject3D, isOrthographicCamera, isPerspectiveCamera, isQuadArray, isSceneObject, isTransformable, isTripleArray, isVector3, md5, mergeBufferAttributes, mergeBufferGeometries, mergeVertices, prefix, registerNodeEnv, serializeBoxGeometryKey, serializeImageKey, serializeMaterialKey, serializeMeshKey, serializeTextureKey, sha1, sha256, sha512, shutdown, sleep, slimSkinGeometries, slimSkinTextureCoordinates, timingEnd, timingStart, toDegrees, toRadians, toTrianglesDrawMode };
|
package/dist/node/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
|
};
|
|
@@ -145,6 +145,7 @@ __export(index_node_exports, {
|
|
|
145
145
|
Caching: () => Caching,
|
|
146
146
|
CanvasImage: () => CanvasImage,
|
|
147
147
|
Chunk: () => Chunk,
|
|
148
|
+
ChunkData: () => ChunkData,
|
|
148
149
|
CubeFace: () => CubeFace,
|
|
149
150
|
CubeFaceIndex: () => CubeFaceIndex,
|
|
150
151
|
DEFAULT_ELEMENTS: () => DEFAULT_ELEMENTS,
|
|
@@ -1329,12 +1330,12 @@ var AssetKey = class _AssetKey extends BasicAssetKey {
|
|
|
1329
1330
|
return a.join("/");
|
|
1330
1331
|
}
|
|
1331
1332
|
getFullPath() {
|
|
1332
|
-
let
|
|
1333
|
+
let p11 = [];
|
|
1333
1334
|
if (this.type) {
|
|
1334
|
-
|
|
1335
|
+
p11.push(this.type);
|
|
1335
1336
|
}
|
|
1336
|
-
|
|
1337
|
-
return
|
|
1337
|
+
p11.push(this.path);
|
|
1338
|
+
return p11.join("/");
|
|
1338
1339
|
}
|
|
1339
1340
|
toNamespacedString() {
|
|
1340
1341
|
return this.namespace + ":" + this.getFullPath();
|
|
@@ -1421,7 +1422,7 @@ var ModelMerger = class {
|
|
|
1421
1422
|
merged.display = { ...inheritedDisplay, ...DisplayTransforms.withHandFallbacks(source.display) };
|
|
1422
1423
|
}
|
|
1423
1424
|
}
|
|
1424
|
-
merged.hierarchy = models.map((m) => m.parent).filter((
|
|
1425
|
+
merged.hierarchy = models.map((m) => m.parent).filter((p11) => `${p11}`);
|
|
1425
1426
|
merged.hierarchy.push(`${merged.parent}`);
|
|
1426
1427
|
return merged;
|
|
1427
1428
|
}
|
|
@@ -1661,24 +1662,20 @@ var AssetLoadError = class extends Error {
|
|
|
1661
1662
|
};
|
|
1662
1663
|
|
|
1663
1664
|
// src/util/BatchedExecutor.ts
|
|
1665
|
+
var import_jobqu2 = require("jobqu");
|
|
1664
1666
|
var BatchedExecutor = class {
|
|
1665
1667
|
constructor(interval = 1, batch = 30) {
|
|
1668
|
+
if (!Number.isFinite(interval) || interval < 0) throw new RangeError("Batch interval must be finite and nonnegative");
|
|
1669
|
+
if (!Number.isInteger(batch) || batch < 1) throw new RangeError("Batch size must be a positive integer");
|
|
1666
1670
|
this.interval = interval;
|
|
1667
1671
|
this.batch = batch;
|
|
1668
|
-
this.queue =
|
|
1669
|
-
this.task = setInterval(() => this.run());
|
|
1672
|
+
this.queue = new import_jobqu2.JobQueue(async (task) => task(), { interval, maxPerRun: batch, maxActive: batch });
|
|
1670
1673
|
}
|
|
1671
1674
|
submit(task) {
|
|
1672
|
-
this.queue.
|
|
1675
|
+
return this.queue.add(() => task());
|
|
1673
1676
|
}
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
this.runNext();
|
|
1677
|
-
}
|
|
1678
|
-
}
|
|
1679
|
-
runNext() {
|
|
1680
|
-
let next = this.queue.shift();
|
|
1681
|
-
if (next) next();
|
|
1677
|
+
stop() {
|
|
1678
|
+
this.queue.end();
|
|
1682
1679
|
}
|
|
1683
1680
|
};
|
|
1684
1681
|
|
|
@@ -7384,6 +7381,87 @@ var Skins = class {
|
|
|
7384
7381
|
// src/world/Chunk.ts
|
|
7385
7382
|
var import_three25 = require("three");
|
|
7386
7383
|
|
|
7384
|
+
// src/world/ChunkData.ts
|
|
7385
|
+
var ChunkData = class _ChunkData {
|
|
7386
|
+
constructor() {
|
|
7387
|
+
this.indices = new Uint16Array(4096);
|
|
7388
|
+
this.palette = [void 0];
|
|
7389
|
+
this.paletteIds = /* @__PURE__ */ new Map();
|
|
7390
|
+
this.freeIds = [];
|
|
7391
|
+
this.nbt = /* @__PURE__ */ new Map();
|
|
7392
|
+
}
|
|
7393
|
+
get(index) {
|
|
7394
|
+
_ChunkData.validateIndex(index);
|
|
7395
|
+
const entry = this.palette[this.indices[index]];
|
|
7396
|
+
return entry ? _ChunkData.copyBlock(entry.state, this.nbt.get(index)) : void 0;
|
|
7397
|
+
}
|
|
7398
|
+
snapshot(index) {
|
|
7399
|
+
_ChunkData.validateIndex(index);
|
|
7400
|
+
const entry = this.palette[this.indices[index]];
|
|
7401
|
+
return entry ? _ChunkData.copyBlock.bind(void 0, entry.state, this.nbt.get(index)) : void 0;
|
|
7402
|
+
}
|
|
7403
|
+
set(index, block) {
|
|
7404
|
+
_ChunkData.validateIndex(index);
|
|
7405
|
+
let state;
|
|
7406
|
+
let key;
|
|
7407
|
+
let nbt;
|
|
7408
|
+
if (block && !_ChunkData.isAir(block)) {
|
|
7409
|
+
const type = AssetKey.parse("blockstates", block.type).toNamespacedString();
|
|
7410
|
+
const properties = Object.fromEntries(Object.keys(block.properties ?? {}).sort().map((name) => [name, block.properties[name]]));
|
|
7411
|
+
state = Object.freeze(Object.keys(properties).length ? { type, properties: Object.freeze(properties) } : { type });
|
|
7412
|
+
key = JSON.stringify([type, properties]);
|
|
7413
|
+
if (block.nbt !== void 0) nbt = structuredClone(block.nbt);
|
|
7414
|
+
}
|
|
7415
|
+
const previousId = this.indices[index];
|
|
7416
|
+
if (previousId !== 0) {
|
|
7417
|
+
const previous = this.palette[previousId];
|
|
7418
|
+
if (--previous.references === 0) {
|
|
7419
|
+
this.paletteIds.delete(previous.key);
|
|
7420
|
+
this.palette[previousId] = void 0;
|
|
7421
|
+
this.freeIds.push(previousId);
|
|
7422
|
+
}
|
|
7423
|
+
}
|
|
7424
|
+
let id = 0;
|
|
7425
|
+
if (state && key !== void 0) {
|
|
7426
|
+
const existingId = this.paletteIds.get(key);
|
|
7427
|
+
if (existingId !== void 0) {
|
|
7428
|
+
id = existingId;
|
|
7429
|
+
this.palette[id].references++;
|
|
7430
|
+
} else {
|
|
7431
|
+
id = this.freeIds.pop() ?? this.palette.length;
|
|
7432
|
+
this.palette[id] = { key, state, references: 1 };
|
|
7433
|
+
this.paletteIds.set(key, id);
|
|
7434
|
+
}
|
|
7435
|
+
}
|
|
7436
|
+
this.indices[index] = id;
|
|
7437
|
+
if (nbt !== void 0) this.nbt.set(index, nbt);
|
|
7438
|
+
else this.nbt.delete(index);
|
|
7439
|
+
}
|
|
7440
|
+
clear() {
|
|
7441
|
+
this.indices.fill(0);
|
|
7442
|
+
this.palette.length = 1;
|
|
7443
|
+
this.paletteIds.clear();
|
|
7444
|
+
this.freeIds.length = 0;
|
|
7445
|
+
this.nbt.clear();
|
|
7446
|
+
}
|
|
7447
|
+
static isAir(block) {
|
|
7448
|
+
if (typeof block === "undefined" || typeof block.type === "undefined") return true;
|
|
7449
|
+
const key = AssetKey.parse("blockstates", block.type);
|
|
7450
|
+
return key.namespace === "minecraft" && !key.type && ["air", "cave_air", "void_air"].includes(key.path);
|
|
7451
|
+
}
|
|
7452
|
+
static copyBlock(state, nbt) {
|
|
7453
|
+
const block = { type: state.type };
|
|
7454
|
+
if (state.properties) block.properties = { ...state.properties };
|
|
7455
|
+
if (nbt !== void 0) block.nbt = structuredClone(nbt);
|
|
7456
|
+
return block;
|
|
7457
|
+
}
|
|
7458
|
+
static validateIndex(index) {
|
|
7459
|
+
if (!Number.isInteger(index) || index < 0 || index >= 4096) {
|
|
7460
|
+
throw new RangeError("Block index must be an integer from 0 to 4095");
|
|
7461
|
+
}
|
|
7462
|
+
}
|
|
7463
|
+
};
|
|
7464
|
+
|
|
7387
7465
|
// src/world/MineRenderWorld.ts
|
|
7388
7466
|
var import_three24 = require("three");
|
|
7389
7467
|
var MineRenderWorld = class {
|
|
@@ -7413,22 +7491,39 @@ var MineRenderWorld = class {
|
|
|
7413
7491
|
const chunk = Chunk.isAir(value) ? this.getChunkAt(posOrX) : this.getOrCreateChunkAt(posOrX);
|
|
7414
7492
|
return chunk?.setBlockAt(posOrX, value);
|
|
7415
7493
|
}
|
|
7416
|
-
async placeMultiBlock(multiblock, useBatches = true, executor
|
|
7417
|
-
const keys =
|
|
7418
|
-
|
|
7419
|
-
|
|
7420
|
-
|
|
7421
|
-
|
|
7422
|
-
|
|
7423
|
-
|
|
7424
|
-
|
|
7425
|
-
|
|
7426
|
-
|
|
7427
|
-
|
|
7494
|
+
async placeMultiBlock(multiblock, useBatches = true, executor) {
|
|
7495
|
+
const keys = /* @__PURE__ */ new Map();
|
|
7496
|
+
for (const block of multiblock.blocks) {
|
|
7497
|
+
if (Chunk.isAir(block)) continue;
|
|
7498
|
+
const key = AssetKey.parse("blockstates", block.type);
|
|
7499
|
+
keys.set(key.serialize(), key);
|
|
7500
|
+
}
|
|
7501
|
+
await BlockStates.getAll(keys.values());
|
|
7502
|
+
if (!useBatches) {
|
|
7503
|
+
for (const block of multiblock.blocks) await this.setBlockAt(block.position, block);
|
|
7504
|
+
return;
|
|
7505
|
+
}
|
|
7506
|
+
const positions = /* @__PURE__ */ new Map();
|
|
7507
|
+
for (const block of multiblock.blocks) {
|
|
7508
|
+
const key = block.position.join(",");
|
|
7509
|
+
const group = positions.get(key);
|
|
7510
|
+
if (group) group.push(block);
|
|
7511
|
+
else positions.set(key, [block]);
|
|
7512
|
+
}
|
|
7513
|
+
const groups = [...positions.values()];
|
|
7514
|
+
const queue = executor ?? new BatchedExecutor();
|
|
7515
|
+
try {
|
|
7516
|
+
for (let i = 0; i < groups.length; i += queue.batch) {
|
|
7517
|
+
const results = await Promise.allSettled(groups.slice(i, i + queue.batch).map(
|
|
7518
|
+
(blocks) => queue.submit(async () => {
|
|
7519
|
+
for (const block of blocks) await this.setBlockAt(block.position, block);
|
|
7520
|
+
})
|
|
7521
|
+
));
|
|
7522
|
+
const failure = results.find((result) => result.status === "rejected");
|
|
7523
|
+
if (failure?.status === "rejected") throw failure.reason;
|
|
7428
7524
|
}
|
|
7429
|
-
}
|
|
7430
|
-
|
|
7431
|
-
await place(block);
|
|
7525
|
+
} finally {
|
|
7526
|
+
if (!executor) queue.stop();
|
|
7432
7527
|
}
|
|
7433
7528
|
}
|
|
7434
7529
|
async clear() {
|
|
@@ -7477,10 +7572,10 @@ var MineRenderWorld = class {
|
|
|
7477
7572
|
};
|
|
7478
7573
|
|
|
7479
7574
|
// src/world/Chunk.ts
|
|
7480
|
-
var p11 = prefix("Chunk");
|
|
7481
7575
|
var Chunk = class _Chunk {
|
|
7482
7576
|
constructor(scene, x, y, z) {
|
|
7483
|
-
this.
|
|
7577
|
+
this.data = new ChunkData();
|
|
7578
|
+
this.renderedBlocks = /* @__PURE__ */ new Map();
|
|
7484
7579
|
this.scene = scene;
|
|
7485
7580
|
this.x = x;
|
|
7486
7581
|
this.y = y;
|
|
@@ -7495,7 +7590,7 @@ var Chunk = class _Chunk {
|
|
|
7495
7590
|
}
|
|
7496
7591
|
const pos = this.worldPosToChunkPos(posOrX);
|
|
7497
7592
|
const index = _Chunk.chunkPosToBlockIndex(pos);
|
|
7498
|
-
return this.
|
|
7593
|
+
return this.renderedBlocks.get(index);
|
|
7499
7594
|
}
|
|
7500
7595
|
async setBlockAt(posOrX, yOrBlock, z, block) {
|
|
7501
7596
|
if (typeof posOrX == "number") {
|
|
@@ -7517,44 +7612,47 @@ var Chunk = class _Chunk {
|
|
|
7517
7612
|
worldPos = this.chunkPosToWorldPos(pos);
|
|
7518
7613
|
}
|
|
7519
7614
|
const index = _Chunk.chunkPosToBlockIndex(pos);
|
|
7520
|
-
|
|
7521
|
-
|
|
7522
|
-
|
|
7523
|
-
|
|
7524
|
-
|
|
7525
|
-
|
|
7526
|
-
|
|
7527
|
-
|
|
7528
|
-
|
|
7529
|
-
|
|
7615
|
+
this.data.set(index, block);
|
|
7616
|
+
const readBlock = this.data.snapshot(index);
|
|
7617
|
+
this.renderedBlocks.get(index)?.object.removeFromScene();
|
|
7618
|
+
this.renderedBlocks.delete(index);
|
|
7619
|
+
if (!readBlock) return void 0;
|
|
7620
|
+
const stored = readBlock();
|
|
7621
|
+
let object;
|
|
7622
|
+
try {
|
|
7623
|
+
const blockState = await BlockStates.get(AssetKey.parse("blockstates", stored.type));
|
|
7624
|
+
if (!blockState) {
|
|
7625
|
+
this.data.set(index, void 0);
|
|
7626
|
+
return void 0;
|
|
7627
|
+
}
|
|
7628
|
+
object = await this.scene.addBlock(blockState, {
|
|
7530
7629
|
mergeMeshes: true,
|
|
7531
7630
|
instanceMeshes: true,
|
|
7532
7631
|
maxInstanceCount: 2e3
|
|
7533
7632
|
});
|
|
7534
|
-
if (
|
|
7535
|
-
|
|
7536
|
-
|
|
7537
|
-
|
|
7538
|
-
|
|
7539
|
-
this.
|
|
7540
|
-
|
|
7541
|
-
|
|
7542
|
-
|
|
7543
|
-
|
|
7633
|
+
if (stored.properties) await object.setState(stored.properties);
|
|
7634
|
+
object.setPosition(MineRenderWorld.worldToScenePosition(worldPos));
|
|
7635
|
+
const info = { get block() {
|
|
7636
|
+
return readBlock();
|
|
7637
|
+
}, object };
|
|
7638
|
+
this.renderedBlocks.set(index, info);
|
|
7639
|
+
return info;
|
|
7640
|
+
} catch (error) {
|
|
7641
|
+
this.data.set(index, void 0);
|
|
7642
|
+
object?.removeFromScene();
|
|
7643
|
+
throw error;
|
|
7544
7644
|
}
|
|
7545
|
-
return void 0;
|
|
7546
7645
|
}
|
|
7547
7646
|
async clear() {
|
|
7548
|
-
this.
|
|
7549
|
-
this.
|
|
7647
|
+
for (const info of this.renderedBlocks.values()) info.object.removeFromScene();
|
|
7648
|
+
this.renderedBlocks.clear();
|
|
7649
|
+
this.data.clear();
|
|
7550
7650
|
}
|
|
7551
7651
|
async dispose() {
|
|
7552
7652
|
await this.clear();
|
|
7553
7653
|
}
|
|
7554
7654
|
static isAir(block) {
|
|
7555
|
-
|
|
7556
|
-
const key = AssetKey.parse("blockstates", block.type);
|
|
7557
|
-
return key.namespace === "minecraft" && !key.type && ["air", "cave_air", "void_air"].includes(key.path);
|
|
7655
|
+
return ChunkData.isAir(block);
|
|
7558
7656
|
}
|
|
7559
7657
|
static chunkPosToBlockIndex(pos) {
|
|
7560
7658
|
if ([pos.x, pos.y, pos.z].some((value) => !Number.isInteger(value) || value < 0 || value >= 16)) {
|
|
@@ -7600,6 +7698,7 @@ var Chunk = class _Chunk {
|
|
|
7600
7698
|
Caching,
|
|
7601
7699
|
CanvasImage,
|
|
7602
7700
|
Chunk,
|
|
7701
|
+
ChunkData,
|
|
7603
7702
|
CubeFace,
|
|
7604
7703
|
CubeFaceIndex,
|
|
7605
7704
|
DEFAULT_ELEMENTS,
|