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.
@@ -653,6 +653,14 @@ declare abstract class AssetSource {
653
653
  protected constructor();
654
654
  abstract get<T extends MinecraftAsset>(key: AssetKey, parser: AssetParser | string): Promise<Maybe<T>>;
655
655
  }
656
+ /** A source failed to load or parse an asset; cause retains the original failure. */
657
+ declare class AssetLoadError extends Error {
658
+ readonly source: AssetSource;
659
+ readonly key: AssetKey;
660
+ readonly path: string;
661
+ readonly cause: unknown;
662
+ constructor(source: AssetSource, key: AssetKey, path: string, cause: unknown);
663
+ }
656
664
 
657
665
  declare class AssetLoader {
658
666
  static ROOT: string;
@@ -1651,4 +1659,4 @@ declare class BrowserCache extends PersistentCache<LocalForage> {
1651
1659
  */
1652
1660
  declare function probeImageSize(data: Uint8Array): ImageSizeInfo;
1653
1661
 
1654
- 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, BrowserCache, BrowserEnv, 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, 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, probeImageSize, registerBrowserEnv, serializeBoxGeometryKey, serializeImageKey, serializeMaterialKey, serializeMeshKey, serializeTextureKey, sha1, sha256, sha512, shutdown, sleep, slimSkinGeometries, slimSkinTextureCoordinates, timingEnd, timingStart, toDegrees, toRadians, toTrianglesDrawMode };
1662
+ 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, BrowserCache, BrowserEnv, 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, 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, probeImageSize, registerBrowserEnv, serializeBoxGeometryKey, serializeImageKey, serializeMaterialKey, serializeMeshKey, serializeTextureKey, sha1, sha256, sha512, shutdown, sleep, slimSkinGeometries, slimSkinTextureCoordinates, timingEnd, timingStart, toDegrees, toRadians, toTrianglesDrawMode };
@@ -653,6 +653,14 @@ declare abstract class AssetSource {
653
653
  protected constructor();
654
654
  abstract get<T extends MinecraftAsset>(key: AssetKey, parser: AssetParser | string): Promise<Maybe<T>>;
655
655
  }
656
+ /** A source failed to load or parse an asset; cause retains the original failure. */
657
+ declare class AssetLoadError extends Error {
658
+ readonly source: AssetSource;
659
+ readonly key: AssetKey;
660
+ readonly path: string;
661
+ readonly cause: unknown;
662
+ constructor(source: AssetSource, key: AssetKey, path: string, cause: unknown);
663
+ }
656
664
 
657
665
  declare class AssetLoader {
658
666
  static ROOT: string;
@@ -1651,4 +1659,4 @@ declare class BrowserCache extends PersistentCache<LocalForage> {
1651
1659
  */
1652
1660
  declare function probeImageSize(data: Uint8Array): ImageSizeInfo;
1653
1661
 
1654
- 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, BrowserCache, BrowserEnv, 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, 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, probeImageSize, registerBrowserEnv, serializeBoxGeometryKey, serializeImageKey, serializeMaterialKey, serializeMeshKey, serializeTextureKey, sha1, sha256, sha512, shutdown, sleep, slimSkinGeometries, slimSkinTextureCoordinates, timingEnd, timingStart, toDegrees, toRadians, toTrianglesDrawMode };
1662
+ 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, BrowserCache, BrowserEnv, 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, 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, probeImageSize, registerBrowserEnv, 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_browser_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,
@@ -1304,12 +1305,12 @@ var AssetKey = class _AssetKey extends BasicAssetKey {
1304
1305
  return a.join("/");
1305
1306
  }
1306
1307
  getFullPath() {
1307
- let p13 = [];
1308
+ let p12 = [];
1308
1309
  if (this.type) {
1309
- p13.push(this.type);
1310
+ p12.push(this.type);
1310
1311
  }
1311
- p13.push(this.path);
1312
- return p13.join("/");
1312
+ p12.push(this.path);
1313
+ return p12.join("/");
1313
1314
  }
1314
1315
  toNamespacedString() {
1315
1316
  return this.namespace + ":" + this.getFullPath();
@@ -1334,7 +1335,7 @@ var ModelMerger = class {
1334
1335
  merged = (0, import_ts_deepmerge.default)(merged, parentModel);
1335
1336
  }
1336
1337
  merged = (0, import_ts_deepmerge.default)(merged, model);
1337
- merged.hierarchy = models.map((m) => m.parent).filter((p13) => `${p13}`);
1338
+ merged.hierarchy = models.map((m) => m.parent).filter((p12) => `${p12}`);
1338
1339
  merged.hierarchy.push(`${merged.parent}`);
1339
1340
  return merged;
1340
1341
  }
@@ -1521,6 +1522,16 @@ var AssetSource = class {
1521
1522
  constructor() {
1522
1523
  }
1523
1524
  };
1525
+ var AssetLoadError = class extends Error {
1526
+ constructor(source, key, path, cause) {
1527
+ super(`Failed to load ${key.toNamespacedString()} from ${path}${cause instanceof Error ? `: ${cause.message}` : ""}`);
1528
+ this.source = source;
1529
+ this.key = key;
1530
+ this.path = path;
1531
+ this.cause = cause;
1532
+ this.name = "AssetLoadError";
1533
+ }
1534
+ };
1524
1535
 
1525
1536
  // src/util/BatchedExecutor.ts
1526
1537
  var BatchedExecutor = class {
@@ -1699,31 +1710,25 @@ var _HostedAssetSource = class _HostedAssetSource extends AssetSource {
1699
1710
  console.info(p3, "Loading", key);
1700
1711
  const url = `${this.assetBasePath(key)}${key.type !== void 0 ? key.type + "/" : ""}${key.path}${key.extension}`;
1701
1712
  console.debug(p3, url);
1702
- let req = {
1703
- url
1704
- };
1705
- parser.config(req);
1706
- return await Requests.mcAssetRequest(req).then((response) => {
1707
- if (response && response.data) {
1708
- try {
1709
- return parser.parse(response);
1710
- } catch (e) {
1711
- console.warn("Parser failed to process response", response, e);
1712
- throw e;
1713
- }
1714
- }
1715
- return void 0;
1716
- }).catch((err) => {
1717
- if (err.response) {
1718
- let response = err.response;
1719
- if (response.status === 404) {
1720
- console.debug(p3, key, "not found");
1713
+ const request = { url };
1714
+ try {
1715
+ parser.config(request);
1716
+ let response;
1717
+ try {
1718
+ response = await Requests.mcAssetRequest(request);
1719
+ } catch (cause) {
1720
+ if (cause instanceof RequestError && cause.response?.status === 404) {
1721
1721
  return void 0;
1722
1722
  }
1723
+ throw cause;
1723
1724
  }
1724
- console.debug(p3, "Failed to load", key, err?.message);
1725
- return void 0;
1726
- });
1725
+ if (response.data === void 0) {
1726
+ throw new Error("Asset response has no data");
1727
+ }
1728
+ return await parser.parse(response);
1729
+ } catch (cause) {
1730
+ throw new AssetLoadError(this, key, request.url, cause);
1731
+ }
1727
1732
  }
1728
1733
  assetBasePath(key) {
1729
1734
  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 + "/" : ""}`;
@@ -1830,7 +1835,6 @@ var BrowserArchiveProxy = class {
1830
1835
  };
1831
1836
 
1832
1837
  // src/assets/source/archive/ArchiveAssetSource.ts
1833
- var p4 = prefix("ArchiveAssetSource");
1834
1838
  var ArchiveAssetSource = class _ArchiveAssetSource extends AssetSource {
1835
1839
  constructor(archiveProxy) {
1836
1840
  super();
@@ -1849,74 +1853,31 @@ var ArchiveAssetSource = class _ArchiveAssetSource extends AssetSource {
1849
1853
  }
1850
1854
  async get(key, parser) {
1851
1855
  const responseParser = HostedAssetSource.PARSER_MAP.get(parser);
1852
- console.log("ArchiveAssetSource.get", key, parser);
1853
- let entries = await this.getEntries();
1854
- const path = `${this.assetBasePath(key)}${key.type !== void 0 ? key.type + "/" : ""}${key.path}${key.extension}`;
1855
- console.log(path);
1856
- const entry = await this.getEntry(path);
1857
- console.log(entry);
1858
- if (!entry) {
1859
- return void 0;
1860
- }
1861
- let blob = await entry.getData();
1862
- const url = URL.createObjectURL(blob);
1863
- console.log(url);
1864
- let req = {
1865
- url
1866
- };
1867
- responseParser.config(req);
1868
- return Requests.genericRequest(req).then((response) => {
1869
- if (response && response.data) {
1870
- try {
1871
- return responseParser.parse(response);
1872
- } catch (e) {
1873
- console.warn("Parser failed to process response", response, e);
1874
- throw e;
1875
- }
1876
- }
1877
- return void 0;
1878
- }).catch((err) => {
1879
- if (err.response) {
1880
- let response = err.response;
1881
- if (response.status === 404) {
1882
- console.debug(p4, key, "not found");
1883
- return void 0;
1884
- }
1885
- }
1886
- console.debug(p4, "Failed to load", key, err?.message);
1887
- return void 0;
1888
- });
1856
+ return this.load(key, responseParser);
1889
1857
  }
1890
- //TODO: abstract this
1891
1858
  async load(key, parser) {
1892
- console.info(p4, "Loading", key);
1893
- const url = `${this.assetBasePath(key)}${key.type !== void 0 ? key.type + "/" : ""}${key.path}${key.extension}`;
1894
- console.debug(p4, url);
1895
- let req = {
1896
- url
1897
- };
1898
- parser.config(req);
1899
- return await Requests.genericRequest(req).then((response) => {
1900
- if (response && response.data) {
1901
- try {
1902
- return parser.parse(response);
1903
- } catch (e) {
1904
- console.warn("Parser failed to process response", response, e);
1905
- throw e;
1906
- }
1859
+ const path = `${this.assetBasePath(key)}${key.type !== void 0 ? key.type + "/" : ""}${key.path}${key.extension}`;
1860
+ let url;
1861
+ try {
1862
+ const entry = await this.getEntry(path);
1863
+ if (!entry) {
1864
+ return void 0;
1907
1865
  }
1908
- return void 0;
1909
- }).catch((err) => {
1910
- if (err.response) {
1911
- let response = err.response;
1912
- if (response.status === 404) {
1913
- console.debug(p4, key, "not found");
1914
- return void 0;
1915
- }
1866
+ url = URL.createObjectURL(await entry.getData());
1867
+ const request = { url };
1868
+ parser.config(request);
1869
+ const response = await Requests.genericRequest(request);
1870
+ if (response.data === void 0) {
1871
+ throw new Error("Asset response has no data");
1916
1872
  }
1917
- console.debug(p4, "Failed to load", key, err?.message);
1918
- return void 0;
1919
- });
1873
+ return await parser.parse(response);
1874
+ } catch (cause) {
1875
+ throw new AssetLoadError(this, key, path, cause);
1876
+ } finally {
1877
+ if (url !== void 0) {
1878
+ URL.revokeObjectURL(url);
1879
+ }
1880
+ }
1920
1881
  }
1921
1882
  assetBasePath(key) {
1922
1883
  return `${key.rootType !== void 0 ? key.rootType + "/" : ""}${key.namespace !== void 0 ? key.namespace + "/" : ""}${key.assetType !== void 0 ? key.assetType + "/" : ""}`;
@@ -1924,17 +1885,17 @@ var ArchiveAssetSource = class _ArchiveAssetSource extends AssetSource {
1924
1885
  };
1925
1886
 
1926
1887
  // src/assets/AssetLoader.ts
1927
- var p5 = prefix("AssetLoader");
1888
+ var p4 = prefix("AssetLoader");
1928
1889
  var _AssetLoader = class _AssetLoader {
1929
1890
  static addSource(key, source, override = true) {
1930
1891
  if (override) {
1931
1892
  const existing = this.removeSource(key);
1932
1893
  if (existing) {
1933
- console.log(p5, "Removed existing AssetSource", key);
1894
+ console.log(p4, "Removed existing AssetSource", key);
1934
1895
  }
1935
1896
  }
1936
1897
  this._SOURCES.unshift({ key, source });
1937
- console.log(p5, "Added AssetSource", key);
1898
+ console.log(p4, "Added AssetSource", key);
1938
1899
  }
1939
1900
  static removeSource(key) {
1940
1901
  const index = this._SOURCES.findIndex((s) => s.key === key);
@@ -2184,7 +2145,7 @@ var ModelGenerator = class {
2184
2145
  ModelGenerator.ITEM_LAYERS = ["layer0", "layer1", "layer2", "layer3", "layer4"];
2185
2146
 
2186
2147
  // src/UVMapper.ts
2187
- var p6 = prefix("UVMapper");
2148
+ var p5 = prefix("UVMapper");
2188
2149
  var DEFAULT_UV = [0, 0, 16, 16];
2189
2150
  var X = 0;
2190
2151
  var Y = 1;
@@ -2361,7 +2322,7 @@ var UVMapper = class {
2361
2322
  const metaMap = {};
2362
2323
  const model = { ...originalModel };
2363
2324
  const isItemModel = !("elements" in model);
2364
- console.debug(p6, "Creating Atlas for", model.key);
2325
+ console.debug(p5, "Creating Atlas for", model.key);
2365
2326
  if (model.textures) {
2366
2327
  const promises = [];
2367
2328
  const uniqueTextureNames = [];
@@ -2375,7 +2336,7 @@ var UVMapper = class {
2375
2336
  const assetKey = AssetKey.parse("textures", textureValue, model.key);
2376
2337
  promises.push(ModelTextures.get(assetKey).then((asset) => {
2377
2338
  if (!asset) {
2378
- console.warn(p6, "Missing texture", assetKey);
2339
+ console.warn(p5, "Missing texture", assetKey);
2379
2340
  return;
2380
2341
  }
2381
2342
  textureMap[textureKey] = new WrappedImage(asset);
@@ -2387,7 +2348,7 @@ var UVMapper = class {
2387
2348
  }
2388
2349
  await Promise.all(promises);
2389
2350
  const textureCount = uniqueTextureNames.length;
2390
- console.debug(p6, "Creating Atlas for", textureCount, "textures");
2351
+ console.debug(p5, "Creating Atlas for", textureCount, "textures");
2391
2352
  this.fillMissingTextureKeys(model.textures, textureMap);
2392
2353
  this.fillMissingTextureKeys(model.textures, metaMap);
2393
2354
  const sizes = {};
@@ -2407,7 +2368,7 @@ var UVMapper = class {
2407
2368
  this.fillMissingTextureKeys(model.textures, sizes);
2408
2369
  const s = Math.ceil(Math.sqrt(textureCount + 1));
2409
2370
  const size = Math.ceil(s * maxWidth);
2410
- console.debug(p6, "Atlas size:", size);
2371
+ console.debug(p5, "Atlas size:", size);
2411
2372
  const squaredSize = size * size;
2412
2373
  const missing = await ImageLoader.getData("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABAAQMAAACQp+OdAAAABlBMVEX/AP8AAACfphTyAAAAFUlEQVQoz2MIhQKGVVAwKjIqQrwIAHRz/wFI17TEAAAAAElFTkSuQmCC");
2413
2374
  const empty = await ImageLoader.getData("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABAAQMAAACQp+OdAAAAA1BMVEUAAACnej3aAAAAAXRSTlMAQObYZgAAAA5JREFUKM9jGAWjgAIAAAJAAAFSSwuTAAAAAElFTkSuQmCC");
@@ -2462,10 +2423,10 @@ var UVMapper = class {
2462
2423
  }
2463
2424
  }
2464
2425
  const atlasImageData = image.toDataURL();
2465
- console.log(p6, "Atlas Image for", model.key, atlasImageData);
2426
+ console.log(p5, "Atlas Image for", model.key, atlasImageData);
2466
2427
  this.fillMissingTextureKeys(model.textures, positions);
2467
2428
  if (isItemModel) {
2468
- console.debug(p6, "Generating item model for", model);
2429
+ console.debug(p5, "Generating item model for", model);
2469
2430
  model.elements = [];
2470
2431
  for (let layerName of ModelGenerator.ITEM_LAYERS) {
2471
2432
  const textureImage = textureMap[layerName];
@@ -2473,7 +2434,7 @@ var UVMapper = class {
2473
2434
  model.elements.push(...ModelGenerator.generateItemModel(textureImage.data, layerName));
2474
2435
  }
2475
2436
  }
2476
- console.debug(p6, "Item model elements", model.elements);
2437
+ console.debug(p5, "Item model elements", model.elements);
2477
2438
  }
2478
2439
  if (!model.elements) {
2479
2440
  }
@@ -2533,7 +2494,7 @@ var UVMapper = class {
2533
2494
  hasTransparency
2534
2495
  );
2535
2496
  } else {
2536
- console.warn(p6, "Model does not have any textures", model);
2497
+ console.warn(p5, "Model does not have any textures", model);
2537
2498
  }
2538
2499
  return void 0;
2539
2500
  }
@@ -2794,7 +2755,7 @@ var MineRenderError = class _MineRenderError extends Error {
2794
2755
 
2795
2756
  // src/renderer/SceneObject.ts
2796
2757
  var import_ts_deepmerge3 = __toESM(require_dist());
2797
- var p7 = prefix("SceneObject");
2758
+ var p6 = prefix("SceneObject");
2798
2759
  var _SceneObject = class _SceneObject extends import_three9.Object3D {
2799
2760
  constructor(options) {
2800
2761
  super();
@@ -2973,9 +2934,9 @@ var _SceneObject = class _SceneObject extends import_three9.Object3D {
2973
2934
  if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
2974
2935
  const i = this._instanceCounter++;
2975
2936
  this.setMatrixAt(i, new import_three9.Matrix4());
2976
- console.debug(p7, "nextInstance " + i);
2937
+ console.debug(p6, "nextInstance " + i);
2977
2938
  if (i === this.options.maxInstanceCount) {
2978
- console.warn(p7, "Max instance count reached for " + this);
2939
+ console.warn(p6, "Max instance count reached for " + this);
2979
2940
  }
2980
2941
  if (this.scene) {
2981
2942
  this.scene.stats.instanceCount++;
@@ -3257,7 +3218,7 @@ var GuiObject = class extends SceneObject {
3257
3218
 
3258
3219
  // src/inspector/SceneInspector.ts
3259
3220
  var import_three12 = require("three");
3260
- var p8 = prefix("SceneInspector");
3221
+ var p7 = prefix("SceneInspector");
3261
3222
  var help = "<span>Ctrl+Click to Select<br/></span><br/>";
3262
3223
  var SceneInspector = class {
3263
3224
  constructor(renderer) {
@@ -3326,7 +3287,7 @@ var SceneInspector = class {
3326
3287
  }
3327
3288
  selectObject(targetObject, targetIntersection) {
3328
3289
  this.selectedObject = targetObject;
3329
- console.log(p8, "selected", targetObject);
3290
+ console.log(p7, "selected", targetObject);
3330
3291
  this.redraw(targetObject, targetIntersection);
3331
3292
  }
3332
3293
  redraw(targetObject, targetIntersection) {
@@ -3624,7 +3585,7 @@ var SceneStatsDisplay = class {
3624
3585
  };
3625
3586
 
3626
3587
  // src/instance/InstanceManager.ts
3627
- var p9 = prefix("InstanceManager");
3588
+ var p8 = prefix("InstanceManager");
3628
3589
  var InstanceManager = class {
3629
3590
  constructor() {
3630
3591
  this.isInstanceManager = true;
@@ -3632,7 +3593,7 @@ var InstanceManager = class {
3632
3593
  }
3633
3594
  async get(key) {
3634
3595
  if (key in this.instanceCache) {
3635
- console.debug(p9, "key in cache", key);
3596
+ console.debug(p8, "key in cache", key);
3636
3597
  return (await this.instanceCache[key]).nextInstance();
3637
3598
  }
3638
3599
  return void 0;
@@ -3641,13 +3602,17 @@ var InstanceManager = class {
3641
3602
  if (key in this.instanceCache) {
3642
3603
  return await this.get(key);
3643
3604
  }
3644
- console.debug(p9, "key not in cache", key);
3645
- this.instanceCache[key] = new Promise(async (resolve) => {
3646
- const obj = await supplier();
3647
- const instance = obj.nextInstance();
3648
- resolve(instance);
3649
- });
3650
- return await this.instanceCache[key];
3605
+ console.debug(p8, "key not in cache", key);
3606
+ const pending = Promise.resolve().then(supplier).then((obj) => obj.nextInstance());
3607
+ this.instanceCache[key] = pending;
3608
+ try {
3609
+ return await pending;
3610
+ } catch (error) {
3611
+ if (this.instanceCache[key] === pending) {
3612
+ delete this.instanceCache[key];
3613
+ }
3614
+ throw error;
3615
+ }
3651
3616
  }
3652
3617
  reset() {
3653
3618
  for (let instanceCacheKey in this.instanceCache) {
@@ -4237,7 +4202,7 @@ function computeMorphedAttributes(object) {
4237
4202
 
4238
4203
  // src/model/scene/ModelObject.ts
4239
4204
  var import_ts_deepmerge5 = __toESM(require_dist());
4240
- var p10 = prefix("ModelObject");
4205
+ var p9 = prefix("ModelObject");
4241
4206
  var _ModelObject = class _ModelObject extends SceneObject {
4242
4207
  constructor(originalModel, options) {
4243
4208
  super(options);
@@ -4287,10 +4252,10 @@ var _ModelObject = class _ModelObject extends SceneObject {
4287
4252
  }
4288
4253
  });
4289
4254
  } else {
4290
- console.debug(p10, this.atlas.model, "has no elements");
4255
+ console.debug(p9, this.atlas.model, "has no elements");
4291
4256
  }
4292
4257
  } else {
4293
- console.debug(p10, "Missing atlas for", this);
4258
+ console.debug(p9, "Missing atlas for", this);
4294
4259
  }
4295
4260
  if (this.options.mergeMeshes) {
4296
4261
  let combinedGeo;
@@ -4351,7 +4316,7 @@ function isModelObject(obj) {
4351
4316
  // src/model/block/scene/BlockObject.ts
4352
4317
  var import_ts_deepmerge6 = __toESM(require_dist());
4353
4318
  var import_three16 = require("three");
4354
- var p11 = prefix("BlockObject");
4319
+ var p10 = prefix("BlockObject");
4355
4320
  var _BlockObject = class _BlockObject extends SceneObject {
4356
4321
  constructor(blockState, options) {
4357
4322
  super(options);
@@ -4369,7 +4334,7 @@ var _BlockObject = class _BlockObject extends SceneObject {
4369
4334
  }
4370
4335
  async init() {
4371
4336
  if (this.options.applyDefaultState) {
4372
- const defaultState = this.blockState.key ? BlockStates.getDefaultState(this.blockState.key) : void 0;
4337
+ const defaultState = this.blockState.key ? await BlockStates.getDefaultState(this.blockState.key) : void 0;
4373
4338
  if (defaultState && Object.keys(defaultState).length > 0) {
4374
4339
  const state = {};
4375
4340
  for (let k in defaultState) {
@@ -4445,7 +4410,7 @@ var _BlockObject = class _BlockObject extends SceneObject {
4445
4410
  } else if (this.blockState.multipart) {
4446
4411
  for (let part of this.blockState.multipart) {
4447
4412
  if (!part.apply) {
4448
- console.debug(p11, "Missing apply for blockState part", part);
4413
+ console.debug(p10, "Missing apply for blockState part", part);
4449
4414
  continue;
4450
4415
  }
4451
4416
  if (!part.when) {
@@ -6906,7 +6871,7 @@ var MineRenderWorld = class {
6906
6871
  };
6907
6872
 
6908
6873
  // src/world/Chunk.ts
6909
- var p12 = prefix("Chunk");
6874
+ var p11 = prefix("Chunk");
6910
6875
  var Chunk = class _Chunk {
6911
6876
  constructor(scene, x, y, z) {
6912
6877
  this._blocks = [];
@@ -6958,7 +6923,7 @@ var Chunk = class _Chunk {
6958
6923
  const index = _Chunk.chunkPosToBlockIndex(pos);
6959
6924
  const current = this._blocks[index];
6960
6925
  if (typeof current !== "undefined") {
6961
- console.debug(p12, "deleting existing block at", pos, worldPos, index);
6926
+ console.debug(p11, "deleting existing block at", pos, worldPos, index);
6962
6927
  current.object.removeFromScene();
6963
6928
  delete this._blocks[index];
6964
6929
  }