minerender 2.1.0-alpha.10 → 2.1.0-alpha.11

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.
@@ -654,6 +654,14 @@ declare abstract class AssetSource {
654
654
  protected constructor();
655
655
  abstract get<T extends MinecraftAsset>(key: AssetKey, parser: AssetParser | string): Promise<Maybe<T>>;
656
656
  }
657
+ /** A source failed to load or parse an asset; cause retains the original failure. */
658
+ declare class AssetLoadError extends Error {
659
+ readonly source: AssetSource;
660
+ readonly key: AssetKey;
661
+ readonly path: string;
662
+ readonly cause: unknown;
663
+ constructor(source: AssetSource, key: AssetKey, path: string, cause: unknown);
664
+ }
657
665
 
658
666
  declare class AssetLoader {
659
667
  static ROOT: string;
@@ -1654,4 +1662,4 @@ declare class NodeCache extends PersistentCache<LocalStorage> {
1654
1662
  forEach<T>(callback: (v: T, k: string) => void): Promise<void>;
1655
1663
  }
1656
1664
 
1657
- export { AXES, type AnimationFrame, type AnimationMeta, type AnimatorFunction, ArchiveAssetSource, type ArchiveEntry, type ArchiveProxy, AssetKey, 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, BlockEntityModels, 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, type BoxGeometryKey, BrowserArchiveProxy, CUBE_FACES, type CacheKey, Caching, type CameraOptions, CanvasImage, Chunk, type CompatCanvas, type CompatImage, type ComposerOptions, type ControlsOptions, type Cube, CubeFace, CubeFaceIndex, DEFAULT_ELEMENTS, DEFAULT_NAMESPACE, DEFAULT_ROOT, DEFAULT_UV, DISPLAY_POSITIONS, type DebugOptions, type DeepPartial, DefaultBlockStates, DisplayPosition, type Disposable, type DoubleArray, type ElementFace, type ElementRotation, Entities, type EntityModel, EntityModels, 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, type ModelPart, 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, SkinObject, type SkinObjectOptions, SkinPart, type SkinTextureCoordinates, 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, applyModelPartRotation, axisToVec3, base64decode, base64encode, 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 };
1665
+ 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, BlockEntityModels, 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, type BoxGeometryKey, BrowserArchiveProxy, CUBE_FACES, type CacheKey, Caching, type CameraOptions, CanvasImage, Chunk, type CompatCanvas, type CompatImage, type ComposerOptions, type ControlsOptions, type Cube, CubeFace, CubeFaceIndex, DEFAULT_ELEMENTS, DEFAULT_NAMESPACE, DEFAULT_ROOT, DEFAULT_UV, DISPLAY_POSITIONS, type DebugOptions, type DeepPartial, DefaultBlockStates, DisplayPosition, type Disposable, type DoubleArray, type ElementFace, type ElementRotation, Entities, type EntityModel, EntityModels, 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, type ModelPart, 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, SkinObject, type SkinObjectOptions, SkinPart, type SkinTextureCoordinates, 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, applyModelPartRotation, axisToVec3, base64decode, base64encode, 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 };
@@ -654,6 +654,14 @@ declare abstract class AssetSource {
654
654
  protected constructor();
655
655
  abstract get<T extends MinecraftAsset>(key: AssetKey, parser: AssetParser | string): Promise<Maybe<T>>;
656
656
  }
657
+ /** A source failed to load or parse an asset; cause retains the original failure. */
658
+ declare class AssetLoadError extends Error {
659
+ readonly source: AssetSource;
660
+ readonly key: AssetKey;
661
+ readonly path: string;
662
+ readonly cause: unknown;
663
+ constructor(source: AssetSource, key: AssetKey, path: string, cause: unknown);
664
+ }
657
665
 
658
666
  declare class AssetLoader {
659
667
  static ROOT: string;
@@ -1654,4 +1662,4 @@ declare class NodeCache extends PersistentCache<LocalStorage> {
1654
1662
  forEach<T>(callback: (v: T, k: string) => void): Promise<void>;
1655
1663
  }
1656
1664
 
1657
- export { AXES, type AnimationFrame, type AnimationMeta, type AnimatorFunction, ArchiveAssetSource, type ArchiveEntry, type ArchiveProxy, AssetKey, 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, BlockEntityModels, 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, type BoxGeometryKey, BrowserArchiveProxy, CUBE_FACES, type CacheKey, Caching, type CameraOptions, CanvasImage, Chunk, type CompatCanvas, type CompatImage, type ComposerOptions, type ControlsOptions, type Cube, CubeFace, CubeFaceIndex, DEFAULT_ELEMENTS, DEFAULT_NAMESPACE, DEFAULT_ROOT, DEFAULT_UV, DISPLAY_POSITIONS, type DebugOptions, type DeepPartial, DefaultBlockStates, DisplayPosition, type Disposable, type DoubleArray, type ElementFace, type ElementRotation, Entities, type EntityModel, EntityModels, 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, type ModelPart, 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, SkinObject, type SkinObjectOptions, SkinPart, type SkinTextureCoordinates, 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, applyModelPartRotation, axisToVec3, base64decode, base64encode, 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 };
1665
+ 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, BlockEntityModels, 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, type BoxGeometryKey, BrowserArchiveProxy, CUBE_FACES, type CacheKey, Caching, type CameraOptions, CanvasImage, Chunk, type CompatCanvas, type CompatImage, type ComposerOptions, type ControlsOptions, type Cube, CubeFace, CubeFaceIndex, DEFAULT_ELEMENTS, DEFAULT_NAMESPACE, DEFAULT_ROOT, DEFAULT_UV, DISPLAY_POSITIONS, type DebugOptions, type DeepPartial, DefaultBlockStates, DisplayPosition, type Disposable, type DoubleArray, type ElementFace, type ElementRotation, Entities, type EntityModel, EntityModels, 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, type ModelPart, 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, SkinObject, type SkinObjectOptions, SkinPart, type SkinTextureCoordinates, 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, applyModelPartRotation, axisToVec3, base64decode, base64encode, 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 };
@@ -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 p13 in s) if (Object.prototype.hasOwnProperty.call(s, p13))
41
- t[p13] = s[p13];
40
+ for (var p12 in s) if (Object.prototype.hasOwnProperty.call(s, p12))
41
+ t[p12] = s[p12];
42
42
  }
43
43
  return t;
44
44
  };
@@ -127,6 +127,7 @@ __export(index_node_exports, {
127
127
  AXES: () => AXES,
128
128
  ArchiveAssetSource: () => ArchiveAssetSource,
129
129
  AssetKey: () => AssetKey,
130
+ AssetLoadError: () => AssetLoadError,
130
131
  AssetLoader: () => AssetLoader,
131
132
  AssetParser: () => AssetParser,
132
133
  AssetSource: () => AssetSource,
@@ -1306,12 +1307,12 @@ var AssetKey = class _AssetKey extends BasicAssetKey {
1306
1307
  return a.join("/");
1307
1308
  }
1308
1309
  getFullPath() {
1309
- let p13 = [];
1310
+ let p12 = [];
1310
1311
  if (this.type) {
1311
- p13.push(this.type);
1312
+ p12.push(this.type);
1312
1313
  }
1313
- p13.push(this.path);
1314
- return p13.join("/");
1314
+ p12.push(this.path);
1315
+ return p12.join("/");
1315
1316
  }
1316
1317
  toNamespacedString() {
1317
1318
  return this.namespace + ":" + this.getFullPath();
@@ -1336,7 +1337,7 @@ var ModelMerger = class {
1336
1337
  merged = (0, import_ts_deepmerge.default)(merged, parentModel);
1337
1338
  }
1338
1339
  merged = (0, import_ts_deepmerge.default)(merged, model);
1339
- merged.hierarchy = models.map((m) => m.parent).filter((p13) => `${p13}`);
1340
+ merged.hierarchy = models.map((m) => m.parent).filter((p12) => `${p12}`);
1340
1341
  merged.hierarchy.push(`${merged.parent}`);
1341
1342
  return merged;
1342
1343
  }
@@ -1523,6 +1524,16 @@ var AssetSource = class {
1523
1524
  constructor() {
1524
1525
  }
1525
1526
  };
1527
+ var AssetLoadError = class extends Error {
1528
+ constructor(source, key, path, cause) {
1529
+ super(`Failed to load ${key.toNamespacedString()} from ${path}${cause instanceof Error ? `: ${cause.message}` : ""}`);
1530
+ this.source = source;
1531
+ this.key = key;
1532
+ this.path = path;
1533
+ this.cause = cause;
1534
+ this.name = "AssetLoadError";
1535
+ }
1536
+ };
1526
1537
 
1527
1538
  // src/util/BatchedExecutor.ts
1528
1539
  var BatchedExecutor = class {
@@ -1777,31 +1788,25 @@ var HostedAssetSource = class _HostedAssetSource extends AssetSource {
1777
1788
  console.info(p3, "Loading", key);
1778
1789
  const url = `${this.assetBasePath(key)}${key.type !== void 0 ? key.type + "/" : ""}${key.path}${key.extension}`;
1779
1790
  console.debug(p3, url);
1780
- let req = {
1781
- url
1782
- };
1783
- parser.config(req);
1784
- return await Requests.mcAssetRequest(req).then((response) => {
1785
- if (response && response.data) {
1786
- try {
1787
- return parser.parse(response);
1788
- } catch (e) {
1789
- console.warn("Parser failed to process response", response, e);
1790
- throw e;
1791
- }
1792
- }
1793
- return void 0;
1794
- }).catch((err) => {
1795
- if (err.response) {
1796
- let response = err.response;
1797
- if (response.status === 404) {
1798
- console.debug(p3, key, "not found");
1791
+ const request = { url };
1792
+ try {
1793
+ parser.config(request);
1794
+ let response;
1795
+ try {
1796
+ response = await Requests.mcAssetRequest(request);
1797
+ } catch (cause) {
1798
+ if (cause instanceof RequestError && cause.response?.status === 404) {
1799
1799
  return void 0;
1800
1800
  }
1801
+ throw cause;
1801
1802
  }
1802
- console.debug(p3, "Failed to load", key, err?.message);
1803
- return void 0;
1804
- });
1803
+ if (response.data === void 0) {
1804
+ throw new Error("Asset response has no data");
1805
+ }
1806
+ return await parser.parse(response);
1807
+ } catch (cause) {
1808
+ throw new AssetLoadError(this, key, request.url, cause);
1809
+ }
1805
1810
  }
1806
1811
  assetBasePath(key) {
1807
1812
  return `${key.root ?? this.root ?? AssetLoader.ROOT}/${key.rootType !== void 0 ? key.rootType + "/" : ""}${key.namespace !== void 0 ? key.namespace + "/" : ""}${key.assetType !== void 0 ? key.assetType + "/" : ""}`;
@@ -1847,7 +1852,6 @@ var BrowserArchiveProxy = class {
1847
1852
  };
1848
1853
 
1849
1854
  // src/assets/source/archive/ArchiveAssetSource.ts
1850
- var p4 = prefix("ArchiveAssetSource");
1851
1855
  var ArchiveAssetSource = class _ArchiveAssetSource extends AssetSource {
1852
1856
  constructor(archiveProxy) {
1853
1857
  super();
@@ -1866,74 +1870,31 @@ var ArchiveAssetSource = class _ArchiveAssetSource extends AssetSource {
1866
1870
  }
1867
1871
  async get(key, parser) {
1868
1872
  const responseParser = HostedAssetSource.PARSER_MAP.get(parser);
1869
- console.log("ArchiveAssetSource.get", key, parser);
1870
- let entries = await this.getEntries();
1871
- const path = `${this.assetBasePath(key)}${key.type !== void 0 ? key.type + "/" : ""}${key.path}${key.extension}`;
1872
- console.log(path);
1873
- const entry = await this.getEntry(path);
1874
- console.log(entry);
1875
- if (!entry) {
1876
- return void 0;
1877
- }
1878
- let blob = await entry.getData();
1879
- const url = URL.createObjectURL(blob);
1880
- console.log(url);
1881
- let req = {
1882
- url
1883
- };
1884
- responseParser.config(req);
1885
- return Requests.genericRequest(req).then((response) => {
1886
- if (response && response.data) {
1887
- try {
1888
- return responseParser.parse(response);
1889
- } catch (e) {
1890
- console.warn("Parser failed to process response", response, e);
1891
- throw e;
1892
- }
1893
- }
1894
- return void 0;
1895
- }).catch((err) => {
1896
- if (err.response) {
1897
- let response = err.response;
1898
- if (response.status === 404) {
1899
- console.debug(p4, key, "not found");
1900
- return void 0;
1901
- }
1902
- }
1903
- console.debug(p4, "Failed to load", key, err?.message);
1904
- return void 0;
1905
- });
1873
+ return this.load(key, responseParser);
1906
1874
  }
1907
- //TODO: abstract this
1908
1875
  async load(key, parser) {
1909
- console.info(p4, "Loading", key);
1910
- const url = `${this.assetBasePath(key)}${key.type !== void 0 ? key.type + "/" : ""}${key.path}${key.extension}`;
1911
- console.debug(p4, url);
1912
- let req = {
1913
- url
1914
- };
1915
- parser.config(req);
1916
- return await Requests.genericRequest(req).then((response) => {
1917
- if (response && response.data) {
1918
- try {
1919
- return parser.parse(response);
1920
- } catch (e) {
1921
- console.warn("Parser failed to process response", response, e);
1922
- throw e;
1923
- }
1876
+ const path = `${this.assetBasePath(key)}${key.type !== void 0 ? key.type + "/" : ""}${key.path}${key.extension}`;
1877
+ let url;
1878
+ try {
1879
+ const entry = await this.getEntry(path);
1880
+ if (!entry) {
1881
+ return void 0;
1924
1882
  }
1925
- return void 0;
1926
- }).catch((err) => {
1927
- if (err.response) {
1928
- let response = err.response;
1929
- if (response.status === 404) {
1930
- console.debug(p4, key, "not found");
1931
- return void 0;
1932
- }
1883
+ url = URL.createObjectURL(await entry.getData());
1884
+ const request = { url };
1885
+ parser.config(request);
1886
+ const response = await Requests.genericRequest(request);
1887
+ if (response.data === void 0) {
1888
+ throw new Error("Asset response has no data");
1933
1889
  }
1934
- console.debug(p4, "Failed to load", key, err?.message);
1935
- return void 0;
1936
- });
1890
+ return await parser.parse(response);
1891
+ } catch (cause) {
1892
+ throw new AssetLoadError(this, key, path, cause);
1893
+ } finally {
1894
+ if (url !== void 0) {
1895
+ URL.revokeObjectURL(url);
1896
+ }
1897
+ }
1937
1898
  }
1938
1899
  assetBasePath(key) {
1939
1900
  return `${key.rootType !== void 0 ? key.rootType + "/" : ""}${key.namespace !== void 0 ? key.namespace + "/" : ""}${key.assetType !== void 0 ? key.assetType + "/" : ""}`;
@@ -1941,7 +1902,7 @@ var ArchiveAssetSource = class _ArchiveAssetSource extends AssetSource {
1941
1902
  };
1942
1903
 
1943
1904
  // src/assets/AssetLoader.ts
1944
- var p5 = prefix("AssetLoader");
1905
+ var p4 = prefix("AssetLoader");
1945
1906
  var AssetLoader = class {
1946
1907
  static {
1947
1908
  this.ROOT = DEFAULT_ROOT;
@@ -1953,11 +1914,11 @@ var AssetLoader = class {
1953
1914
  if (override) {
1954
1915
  const existing = this.removeSource(key);
1955
1916
  if (existing) {
1956
- console.log(p5, "Removed existing AssetSource", key);
1917
+ console.log(p4, "Removed existing AssetSource", key);
1957
1918
  }
1958
1919
  }
1959
1920
  this._SOURCES.unshift({ key, source });
1960
- console.log(p5, "Added AssetSource", key);
1921
+ console.log(p4, "Added AssetSource", key);
1961
1922
  }
1962
1923
  static removeSource(key) {
1963
1924
  const index = this._SOURCES.findIndex((s) => s.key === key);
@@ -2221,7 +2182,7 @@ var ModelGenerator = class {
2221
2182
  };
2222
2183
 
2223
2184
  // src/UVMapper.ts
2224
- var p6 = prefix("UVMapper");
2185
+ var p5 = prefix("UVMapper");
2225
2186
  var DEFAULT_UV = [0, 0, 16, 16];
2226
2187
  var X = 0;
2227
2188
  var Y = 1;
@@ -2398,7 +2359,7 @@ var UVMapper = class {
2398
2359
  const metaMap = {};
2399
2360
  const model = { ...originalModel };
2400
2361
  const isItemModel = !("elements" in model);
2401
- console.debug(p6, "Creating Atlas for", model.key);
2362
+ console.debug(p5, "Creating Atlas for", model.key);
2402
2363
  if (model.textures) {
2403
2364
  const promises = [];
2404
2365
  const uniqueTextureNames = [];
@@ -2412,7 +2373,7 @@ var UVMapper = class {
2412
2373
  const assetKey = AssetKey.parse("textures", textureValue, model.key);
2413
2374
  promises.push(ModelTextures.get(assetKey).then((asset) => {
2414
2375
  if (!asset) {
2415
- console.warn(p6, "Missing texture", assetKey);
2376
+ console.warn(p5, "Missing texture", assetKey);
2416
2377
  return;
2417
2378
  }
2418
2379
  textureMap[textureKey] = new WrappedImage(asset);
@@ -2424,7 +2385,7 @@ var UVMapper = class {
2424
2385
  }
2425
2386
  await Promise.all(promises);
2426
2387
  const textureCount = uniqueTextureNames.length;
2427
- console.debug(p6, "Creating Atlas for", textureCount, "textures");
2388
+ console.debug(p5, "Creating Atlas for", textureCount, "textures");
2428
2389
  this.fillMissingTextureKeys(model.textures, textureMap);
2429
2390
  this.fillMissingTextureKeys(model.textures, metaMap);
2430
2391
  const sizes = {};
@@ -2444,7 +2405,7 @@ var UVMapper = class {
2444
2405
  this.fillMissingTextureKeys(model.textures, sizes);
2445
2406
  const s = Math.ceil(Math.sqrt(textureCount + 1));
2446
2407
  const size = Math.ceil(s * maxWidth);
2447
- console.debug(p6, "Atlas size:", size);
2408
+ console.debug(p5, "Atlas size:", size);
2448
2409
  const squaredSize = size * size;
2449
2410
  const missing = await ImageLoader.getData("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABAAQMAAACQp+OdAAAABlBMVEX/AP8AAACfphTyAAAAFUlEQVQoz2MIhQKGVVAwKjIqQrwIAHRz/wFI17TEAAAAAElFTkSuQmCC");
2450
2411
  const empty = await ImageLoader.getData("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABAAQMAAACQp+OdAAAAA1BMVEUAAACnej3aAAAAAXRSTlMAQObYZgAAAA5JREFUKM9jGAWjgAIAAAJAAAFSSwuTAAAAAElFTkSuQmCC");
@@ -2499,10 +2460,10 @@ var UVMapper = class {
2499
2460
  }
2500
2461
  }
2501
2462
  const atlasImageData = image.toDataURL();
2502
- console.log(p6, "Atlas Image for", model.key, atlasImageData);
2463
+ console.log(p5, "Atlas Image for", model.key, atlasImageData);
2503
2464
  this.fillMissingTextureKeys(model.textures, positions);
2504
2465
  if (isItemModel) {
2505
- console.debug(p6, "Generating item model for", model);
2466
+ console.debug(p5, "Generating item model for", model);
2506
2467
  model.elements = [];
2507
2468
  for (let layerName of ModelGenerator.ITEM_LAYERS) {
2508
2469
  const textureImage = textureMap[layerName];
@@ -2510,7 +2471,7 @@ var UVMapper = class {
2510
2471
  model.elements.push(...ModelGenerator.generateItemModel(textureImage.data, layerName));
2511
2472
  }
2512
2473
  }
2513
- console.debug(p6, "Item model elements", model.elements);
2474
+ console.debug(p5, "Item model elements", model.elements);
2514
2475
  }
2515
2476
  if (!model.elements) {
2516
2477
  }
@@ -2570,7 +2531,7 @@ var UVMapper = class {
2570
2531
  hasTransparency
2571
2532
  );
2572
2533
  } else {
2573
- console.warn(p6, "Model does not have any textures", model);
2534
+ console.warn(p5, "Model does not have any textures", model);
2574
2535
  }
2575
2536
  return void 0;
2576
2537
  }
@@ -2831,7 +2792,7 @@ var MineRenderError = class _MineRenderError extends Error {
2831
2792
 
2832
2793
  // src/renderer/SceneObject.ts
2833
2794
  var import_ts_deepmerge3 = __toESM(require_dist());
2834
- var p7 = prefix("SceneObject");
2795
+ var p6 = prefix("SceneObject");
2835
2796
  var SceneObject = class _SceneObject extends import_three9.Object3D {
2836
2797
  constructor(options) {
2837
2798
  super();
@@ -3018,9 +2979,9 @@ var SceneObject = class _SceneObject extends import_three9.Object3D {
3018
2979
  if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
3019
2980
  const i = this._instanceCounter++;
3020
2981
  this.setMatrixAt(i, new import_three9.Matrix4());
3021
- console.debug(p7, "nextInstance " + i);
2982
+ console.debug(p6, "nextInstance " + i);
3022
2983
  if (i === this.options.maxInstanceCount) {
3023
- console.warn(p7, "Max instance count reached for " + this);
2984
+ console.warn(p6, "Max instance count reached for " + this);
3024
2985
  }
3025
2986
  if (this.scene) {
3026
2987
  this.scene.stats.instanceCount++;
@@ -3297,7 +3258,7 @@ var GuiObject = class extends SceneObject {
3297
3258
 
3298
3259
  // src/inspector/SceneInspector.ts
3299
3260
  var import_three12 = require("three");
3300
- var p8 = prefix("SceneInspector");
3261
+ var p7 = prefix("SceneInspector");
3301
3262
  var help = "<span>Ctrl+Click to Select<br/></span><br/>";
3302
3263
  var SceneInspector = class {
3303
3264
  constructor(renderer) {
@@ -3366,7 +3327,7 @@ var SceneInspector = class {
3366
3327
  }
3367
3328
  selectObject(targetObject, targetIntersection) {
3368
3329
  this.selectedObject = targetObject;
3369
- console.log(p8, "selected", targetObject);
3330
+ console.log(p7, "selected", targetObject);
3370
3331
  this.redraw(targetObject, targetIntersection);
3371
3332
  }
3372
3333
  redraw(targetObject, targetIntersection) {
@@ -3664,7 +3625,7 @@ var SceneStatsDisplay = class {
3664
3625
  };
3665
3626
 
3666
3627
  // src/instance/InstanceManager.ts
3667
- var p9 = prefix("InstanceManager");
3628
+ var p8 = prefix("InstanceManager");
3668
3629
  var InstanceManager = class {
3669
3630
  constructor() {
3670
3631
  this.isInstanceManager = true;
@@ -3672,7 +3633,7 @@ var InstanceManager = class {
3672
3633
  }
3673
3634
  async get(key) {
3674
3635
  if (key in this.instanceCache) {
3675
- console.debug(p9, "key in cache", key);
3636
+ console.debug(p8, "key in cache", key);
3676
3637
  return (await this.instanceCache[key]).nextInstance();
3677
3638
  }
3678
3639
  return void 0;
@@ -3681,13 +3642,17 @@ var InstanceManager = class {
3681
3642
  if (key in this.instanceCache) {
3682
3643
  return await this.get(key);
3683
3644
  }
3684
- console.debug(p9, "key not in cache", key);
3685
- this.instanceCache[key] = new Promise(async (resolve) => {
3686
- const obj = await supplier();
3687
- const instance = obj.nextInstance();
3688
- resolve(instance);
3689
- });
3690
- return await this.instanceCache[key];
3645
+ console.debug(p8, "key not in cache", key);
3646
+ const pending = Promise.resolve().then(supplier).then((obj) => obj.nextInstance());
3647
+ this.instanceCache[key] = pending;
3648
+ try {
3649
+ return await pending;
3650
+ } catch (error) {
3651
+ if (this.instanceCache[key] === pending) {
3652
+ delete this.instanceCache[key];
3653
+ }
3654
+ throw error;
3655
+ }
3691
3656
  }
3692
3657
  reset() {
3693
3658
  for (let instanceCacheKey in this.instanceCache) {
@@ -4277,7 +4242,7 @@ function computeMorphedAttributes(object) {
4277
4242
 
4278
4243
  // src/model/scene/ModelObject.ts
4279
4244
  var import_ts_deepmerge5 = __toESM(require_dist());
4280
- var p10 = prefix("ModelObject");
4245
+ var p9 = prefix("ModelObject");
4281
4246
  var ModelObject = class _ModelObject extends SceneObject {
4282
4247
  constructor(originalModel, options) {
4283
4248
  super(options);
@@ -4330,10 +4295,10 @@ var ModelObject = class _ModelObject extends SceneObject {
4330
4295
  }
4331
4296
  });
4332
4297
  } else {
4333
- console.debug(p10, this.atlas.model, "has no elements");
4298
+ console.debug(p9, this.atlas.model, "has no elements");
4334
4299
  }
4335
4300
  } else {
4336
- console.debug(p10, "Missing atlas for", this);
4301
+ console.debug(p9, "Missing atlas for", this);
4337
4302
  }
4338
4303
  if (this.options.mergeMeshes) {
4339
4304
  let combinedGeo;
@@ -4392,7 +4357,7 @@ function isModelObject(obj) {
4392
4357
  // src/model/block/scene/BlockObject.ts
4393
4358
  var import_ts_deepmerge6 = __toESM(require_dist());
4394
4359
  var import_three16 = require("three");
4395
- var p11 = prefix("BlockObject");
4360
+ var p10 = prefix("BlockObject");
4396
4361
  var BlockObject = class _BlockObject extends SceneObject {
4397
4362
  constructor(blockState, options) {
4398
4363
  super(options);
@@ -4415,7 +4380,7 @@ var BlockObject = class _BlockObject extends SceneObject {
4415
4380
  }
4416
4381
  async init() {
4417
4382
  if (this.options.applyDefaultState) {
4418
- const defaultState = this.blockState.key ? BlockStates.getDefaultState(this.blockState.key) : void 0;
4383
+ const defaultState = this.blockState.key ? await BlockStates.getDefaultState(this.blockState.key) : void 0;
4419
4384
  if (defaultState && Object.keys(defaultState).length > 0) {
4420
4385
  const state = {};
4421
4386
  for (let k in defaultState) {
@@ -4491,7 +4456,7 @@ var BlockObject = class _BlockObject extends SceneObject {
4491
4456
  } else if (this.blockState.multipart) {
4492
4457
  for (let part of this.blockState.multipart) {
4493
4458
  if (!part.apply) {
4494
- console.debug(p11, "Missing apply for blockState part", part);
4459
+ console.debug(p10, "Missing apply for blockState part", part);
4495
4460
  continue;
4496
4461
  }
4497
4462
  if (!part.when) {
@@ -6950,7 +6915,7 @@ var MineRenderWorld = class {
6950
6915
  };
6951
6916
 
6952
6917
  // src/world/Chunk.ts
6953
- var p12 = prefix("Chunk");
6918
+ var p11 = prefix("Chunk");
6954
6919
  var Chunk = class _Chunk {
6955
6920
  constructor(scene, x, y, z) {
6956
6921
  this._blocks = [];
@@ -7002,7 +6967,7 @@ var Chunk = class _Chunk {
7002
6967
  const index = _Chunk.chunkPosToBlockIndex(pos);
7003
6968
  const current = this._blocks[index];
7004
6969
  if (typeof current !== "undefined") {
7005
- console.debug(p12, "deleting existing block at", pos, worldPos, index);
6970
+ console.debug(p11, "deleting existing block at", pos, worldPos, index);
7006
6971
  current.object.removeFromScene();
7007
6972
  delete this._blocks[index];
7008
6973
  }
@@ -7069,6 +7034,7 @@ var Chunk = class _Chunk {
7069
7034
  AXES,
7070
7035
  ArchiveAssetSource,
7071
7036
  AssetKey,
7037
+ AssetLoadError,
7072
7038
  AssetLoader,
7073
7039
  AssetParser,
7074
7040
  AssetSource,