minerender 2.1.0-alpha.144 → 2.1.0-alpha.145

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.
@@ -56,37 +56,6 @@ var init_Env = __esm({
56
56
  }
57
57
  });
58
58
 
59
- // src/cache/PersistentCache.ts
60
- var _PersistentCache, PersistentCache;
61
- var init_PersistentCache = __esm({
62
- "src/cache/PersistentCache.ts"() {
63
- init_Env();
64
- _PersistentCache = class _PersistentCache {
65
- constructor(backing) {
66
- this.backing = backing;
67
- }
68
- /** Opens a named store in the active environment using the current cache schema version. */
69
- static open(name) {
70
- return Env.provider.openCache(name, _PersistentCache.VERSION);
71
- }
72
- /** Loads a missing entry and stores only non-nullish results. */
73
- async getOrLoad(key, loader) {
74
- let v = await this.get(key);
75
- if (typeof v === "undefined" || v === null) {
76
- v = await loader(key);
77
- if (typeof v !== "undefined" && v !== null) {
78
- await this.put(key, v);
79
- }
80
- }
81
- return v;
82
- }
83
- };
84
- /** Bump to invalidate every persisted entry. */
85
- _PersistentCache.VERSION = 2;
86
- PersistentCache = _PersistentCache;
87
- }
88
- });
89
-
90
59
  // src/util/log.ts
91
60
  function readSwitch() {
92
61
  switchRead = true;
@@ -168,6 +137,37 @@ var init_log = __esm({
168
137
  }
169
138
  });
170
139
 
140
+ // src/cache/PersistentCache.ts
141
+ var _PersistentCache, PersistentCache;
142
+ var init_PersistentCache = __esm({
143
+ "src/cache/PersistentCache.ts"() {
144
+ init_Env();
145
+ _PersistentCache = class _PersistentCache {
146
+ constructor(backing) {
147
+ this.backing = backing;
148
+ }
149
+ /** Opens a named store in the active environment using the current cache schema version. */
150
+ static open(name) {
151
+ return Env.provider.openCache(name, _PersistentCache.VERSION);
152
+ }
153
+ /** Loads a missing entry and stores only non-nullish results. */
154
+ async getOrLoad(key, loader) {
155
+ let v = await this.get(key);
156
+ if (typeof v === "undefined" || v === null) {
157
+ v = await loader(key);
158
+ if (typeof v !== "undefined" && v !== null) {
159
+ await this.put(key, v);
160
+ }
161
+ }
162
+ return v;
163
+ }
164
+ };
165
+ /** Bump to invalidate every persisted entry. */
166
+ _PersistentCache.VERSION = 2;
167
+ PersistentCache = _PersistentCache;
168
+ }
169
+ });
170
+
171
171
  // src/Axis.ts
172
172
  function axisToVec3(axis) {
173
173
  switch (axis) {
@@ -511,12 +511,12 @@ async function abortable(promise, signal) {
511
511
  signal.removeEventListener("abort", abort);
512
512
  }
513
513
  }
514
- var import_jobqu, log2, RequestError, RequestQueue, Requests;
514
+ var import_jobqu, log3, RequestError, RequestQueue, Requests;
515
515
  var init_Requests = __esm({
516
516
  "src/request/Requests.ts"() {
517
517
  import_jobqu = require("jobqu");
518
518
  init_log();
519
- log2 = logger("Requests");
519
+ log3 = logger("Requests");
520
520
  RequestError = class extends Error {
521
521
  constructor(message, response, cause) {
522
522
  super(message);
@@ -543,7 +543,7 @@ var init_Requests = __esm({
543
543
  try {
544
544
  return await abortable(this.queue.add(request), signal);
545
545
  } catch (error) {
546
- log2.debug("Request failed", error);
546
+ log3.debug("Request failed", error);
547
547
  const delay = this.retryDelay(error, request, retries);
548
548
  if (delay === void 0) {
549
549
  throw error;
@@ -725,7 +725,7 @@ var init_base64 = __esm({
725
725
  });
726
726
 
727
727
  // src/image/ImageLoader.ts
728
- var log3, ImageLoader;
728
+ var log4, ImageLoader;
729
729
  var init_ImageLoader = __esm({
730
730
  "src/image/ImageLoader.ts"() {
731
731
  init_CanvasCompat();
@@ -736,7 +736,7 @@ var init_ImageLoader = __esm({
736
736
  init_WrappedImage();
737
737
  init_base64();
738
738
  init_log();
739
- log3 = logger("ImageLoader");
739
+ log4 = logger("ImageLoader");
740
740
  ImageLoader = class _ImageLoader {
741
741
  static _createImage() {
742
742
  return createImage();
@@ -761,7 +761,7 @@ var init_ImageLoader = __esm({
761
761
  return image;
762
762
  }
763
763
  static async loadData(src) {
764
- log3.debug("loadData", src);
764
+ log4.debug("loadData", src);
765
765
  const image = await this.loadCanvasData(src);
766
766
  return image.data.getImageData(0, 0, image.width, image.height);
767
767
  }
@@ -868,7 +868,7 @@ var init_ImageLoader = __esm({
868
868
  });
869
869
 
870
870
  // src/texture/TextureLoader.ts
871
- var import_three3, THREE, log4, TextureLoader;
871
+ var import_three3, THREE, log5, TextureLoader;
872
872
  var init_TextureLoader = __esm({
873
873
  "src/texture/TextureLoader.ts"() {
874
874
  import_three3 = require("three");
@@ -876,7 +876,7 @@ var init_TextureLoader = __esm({
876
876
  init_ImageLoader();
877
877
  init_Textures();
878
878
  init_log();
879
- log4 = logger("TextureLoader");
879
+ log5 = logger("TextureLoader");
880
880
  TextureLoader = class {
881
881
  /** Reports whether image loading failed, so cached textures can be retried. */
882
882
  static hasFailed(texture) {
@@ -892,7 +892,7 @@ var init_TextureLoader = __esm({
892
892
  texture.needsUpdate = true;
893
893
  }, (error) => {
894
894
  this.failedTextures.add(texture);
895
- log4.warn("Failed to load texture", src, error);
895
+ log5.warn("Failed to load texture", src, error);
896
896
  });
897
897
  texture.image = image;
898
898
  texture.format = format2;
@@ -908,7 +908,7 @@ var init_TextureLoader = __esm({
908
908
  texture.needsUpdate = true;
909
909
  }).catch((error) => {
910
910
  this.failedTextures.add(texture);
911
- log4.warn("Failed to load texture", src, error);
911
+ log5.warn("Failed to load texture", src, error);
912
912
  });
913
913
  texture.format = format2;
914
914
  texture.rotation = rotation;
@@ -984,7 +984,7 @@ var init_Textures = __esm({
984
984
  });
985
985
 
986
986
  // src/Materials.ts
987
- var import_three5, log5, Materials;
987
+ var import_three5, log6, Materials;
988
988
  var init_Materials = __esm({
989
989
  "src/Materials.ts"() {
990
990
  init_CacheKey();
@@ -993,7 +993,7 @@ var init_Materials = __esm({
993
993
  init_TextureLoader();
994
994
  init_Caching();
995
995
  init_log();
996
- log5 = logger("Materials");
996
+ log6 = logger("Materials");
997
997
  Materials = class _Materials {
998
998
  /** Shared checkerboard material, created on first access. */
999
999
  static get MISSING_TEXTURE() {
@@ -1264,7 +1264,7 @@ var init_Materials = __esm({
1264
1264
  Object.assign(material.defaultAttributeValues, { shade: [1], uvBounds: [0, 0, 1, 1] });
1265
1265
  return material;
1266
1266
  } catch (e) {
1267
- log5.warn(e);
1267
+ log6.warn(e);
1268
1268
  }
1269
1269
  return this.createBasicCanvasMaterial(canvas, transparent, shade);
1270
1270
  }
@@ -1634,7 +1634,7 @@ var init_merge = __esm({
1634
1634
  });
1635
1635
 
1636
1636
  // src/assets/source/HostedAssetSource.ts
1637
- var BINARY_TIMEOUT, log6, DEFAULT_OPTIONS, _HostedAssetSource, HostedAssetSource;
1637
+ var BINARY_TIMEOUT, log7, DEFAULT_OPTIONS, _HostedAssetSource, HostedAssetSource;
1638
1638
  var init_HostedAssetSource = __esm({
1639
1639
  "src/assets/source/HostedAssetSource.ts"() {
1640
1640
  init_AssetSource();
@@ -1648,7 +1648,7 @@ var init_HostedAssetSource = __esm({
1648
1648
  init_parser();
1649
1649
  init_merge();
1650
1650
  BINARY_TIMEOUT = 6e4;
1651
- log6 = logger("HostedAssetSource");
1651
+ log7 = logger("HostedAssetSource");
1652
1652
  DEFAULT_OPTIONS = {
1653
1653
  retryDefaults: true
1654
1654
  };
@@ -1660,14 +1660,14 @@ var init_HostedAssetSource = __esm({
1660
1660
  return direct;
1661
1661
  }
1662
1662
  if (key.namespace !== DEFAULT_NAMESPACE) {
1663
- log6.debug("Retrying", key, "with default namespace");
1663
+ log7.debug("Retrying", key, "with default namespace");
1664
1664
  const namespaceKey = new AssetKey(DEFAULT_NAMESPACE, key.path, key.assetType, key.type, key.rootType, key.extension, key.root);
1665
1665
  const namespaced = await this.load(namespaceKey, parser);
1666
1666
  if (typeof namespaced !== "undefined") {
1667
1667
  return namespaced;
1668
1668
  }
1669
1669
  if (typeof key.root !== "undefined" && key.root !== AssetLoader.ROOT || typeof this.root !== "undefined" && this.root !== AssetLoader.ROOT) {
1670
- log6.debug("Retrying", key, "with default root+namespace");
1670
+ log7.debug("Retrying", key, "with default root+namespace");
1671
1671
  const namespacedRootedKey = new AssetKey(DEFAULT_NAMESPACE, key.path, key.assetType, key.type, key.rootType, key.extension, AssetLoader.ROOT);
1672
1672
  const namespacedRooted = await this.load(namespacedRootedKey, parser);
1673
1673
  if (typeof namespacedRooted !== "undefined") {
@@ -1675,7 +1675,7 @@ var init_HostedAssetSource = __esm({
1675
1675
  }
1676
1676
  }
1677
1677
  } else if (typeof key.root !== "undefined" && key.root !== AssetLoader.ROOT || typeof this.root !== "undefined" && this.root !== AssetLoader.ROOT) {
1678
- log6.debug("Retrying", key, "with default root");
1678
+ log7.debug("Retrying", key, "with default root");
1679
1679
  const rootKey = new AssetKey(key.namespace, key.path, key.assetType, key.type, key.rootType, key.extension, AssetLoader.ROOT);
1680
1680
  const rooted = await this.load(rootKey, parser);
1681
1681
  if (typeof rooted !== "undefined") {
@@ -1686,7 +1686,7 @@ var init_HostedAssetSource = __esm({
1686
1686
  }
1687
1687
  async load(key, parser) {
1688
1688
  const url = `${this.assetBasePath(key)}${key.type !== void 0 ? key.type + "/" : ""}${key.path}${key.extension}`;
1689
- log6.debug("Loading", url);
1689
+ log7.debug("Loading", url);
1690
1690
  const request = { url };
1691
1691
  try {
1692
1692
  parser.config(request);
@@ -2139,7 +2139,7 @@ var init_source = __esm({
2139
2139
  });
2140
2140
 
2141
2141
  // src/assets/AssetLoader.ts
2142
- var log7, AssetLoader;
2142
+ var log8, AssetLoader;
2143
2143
  var init_AssetLoader = __esm({
2144
2144
  "src/assets/AssetLoader.ts"() {
2145
2145
  init_AssetDefaults();
@@ -2147,7 +2147,7 @@ var init_AssetLoader = __esm({
2147
2147
  init_log();
2148
2148
  init_source();
2149
2149
  init_Caching();
2150
- log7 = logger("AssetLoader");
2150
+ log8 = logger("AssetLoader");
2151
2151
  AssetLoader = class {
2152
2152
  static get _SOURCES() {
2153
2153
  return this.sources ?? (this.sources = [{ key: "mcassets", source: new HostedAssetSource(this.ROOT, { retryDefaults: false }) }]);
@@ -2202,11 +2202,11 @@ ${key}` : key;
2202
2202
  if (override) {
2203
2203
  const existing = this.removeSource(key);
2204
2204
  if (existing) {
2205
- log7.info("Removed existing AssetSource", key);
2205
+ log8.info("Removed existing AssetSource", key);
2206
2206
  }
2207
2207
  }
2208
2208
  this._SOURCES.unshift({ key, source });
2209
- log7.info("Added AssetSource", key);
2209
+ log8.info("Added AssetSource", key);
2210
2210
  }
2211
2211
  /** Removes and returns the first source with this name. Call {@link Caching.clear} to reload assets. */
2212
2212
  static removeSource(key) {
@@ -2386,11 +2386,11 @@ var init_CanvasImage = __esm({
2386
2386
  });
2387
2387
 
2388
2388
  // src/Ticker.ts
2389
- var log8, _Ticker, Ticker;
2389
+ var log9, _Ticker, Ticker;
2390
2390
  var init_Ticker = __esm({
2391
2391
  "src/Ticker.ts"() {
2392
2392
  init_log();
2393
- log8 = logger("Ticker");
2393
+ log9 = logger("Ticker");
2394
2394
  _Ticker = class _Ticker {
2395
2395
  static schedule(fn, ms) {
2396
2396
  const handle = setInterval(fn, ms);
@@ -2408,7 +2408,7 @@ var init_Ticker = __esm({
2408
2408
  try {
2409
2409
  t();
2410
2410
  } catch (e) {
2411
- log8.warn(e);
2411
+ log9.warn(e);
2412
2412
  }
2413
2413
  });
2414
2414
  _Ticker.oneSecondTicks++;
@@ -2653,7 +2653,7 @@ var init_cubeUv = __esm({
2653
2653
  });
2654
2654
 
2655
2655
  // src/UVMapper.ts
2656
- var import_three7, log9, X, Y, Z, FACE_UV_AXES, UVMapper, MinecraftFaceUV;
2656
+ var import_three7, log10, X, Y, Z, FACE_UV_AXES, UVMapper, MinecraftFaceUV;
2657
2657
  var init_UVMapper = __esm({
2658
2658
  "src/UVMapper.ts"() {
2659
2659
  import_three7 = require("three");
@@ -2668,7 +2668,7 @@ var init_UVMapper = __esm({
2668
2668
  init_ModelGenerator();
2669
2669
  init_log();
2670
2670
  init_cubeUv();
2671
- log9 = logger("UVMapper");
2671
+ log10 = logger("UVMapper");
2672
2672
  X = 0;
2673
2673
  Y = 1;
2674
2674
  Z = 2;
@@ -2901,7 +2901,7 @@ var init_UVMapper = __esm({
2901
2901
  model.elements = originalModel.elements.map((element) => ({ ...element }));
2902
2902
  }
2903
2903
  const isItemModel = !("elements" in model);
2904
- log9.debug("Creating Atlas for", model.key);
2904
+ log10.debug("Creating Atlas for", model.key);
2905
2905
  if (model.textures) {
2906
2906
  const promises = [];
2907
2907
  const uniqueTextureNames = [];
@@ -2915,7 +2915,7 @@ var init_UVMapper = __esm({
2915
2915
  const assetKey = AssetKey.parse("textures", textureValue, model.key);
2916
2916
  promises.push(ModelTextures.get(assetKey).then((asset2) => {
2917
2917
  if (!asset2) {
2918
- log9.warn("Missing texture", assetKey);
2918
+ log10.warn("Missing texture", assetKey);
2919
2919
  return;
2920
2920
  }
2921
2921
  textureMap[textureKey] = new WrappedImage(asset2);
@@ -2927,7 +2927,7 @@ var init_UVMapper = __esm({
2927
2927
  }
2928
2928
  await Promise.all(promises);
2929
2929
  const textureCount = uniqueTextureNames.length;
2930
- log9.debug("Creating Atlas for", textureCount, "textures");
2930
+ log10.debug("Creating Atlas for", textureCount, "textures");
2931
2931
  this.fillMissingTextureKeys(model.textures, textureMap);
2932
2932
  this.fillMissingTextureKeys(model.textures, metaMap);
2933
2933
  const sizes = {};
@@ -2958,7 +2958,7 @@ var init_UVMapper = __esm({
2958
2958
  this.fillMissingTextureKeys(model.textures, sizes);
2959
2959
  const s = Math.ceil(Math.sqrt(textureCount + 1));
2960
2960
  const size = Math.ceil(s * maxWidth);
2961
- log9.debug("Atlas size:", size);
2961
+ log10.debug("Atlas size:", size);
2962
2962
  const squaredSize = size * size;
2963
2963
  const image = new CanvasImage(size, size);
2964
2964
  const missing = Textures.getMissing().image;
@@ -3037,7 +3037,7 @@ var init_UVMapper = __esm({
3037
3037
  }
3038
3038
  this.fillMissingTextureKeys(model.textures, positions);
3039
3039
  if (isItemModel) {
3040
- log9.debug("Generating item model for", model);
3040
+ log10.debug("Generating item model for", model);
3041
3041
  model.elements = [];
3042
3042
  for (let layerName of ModelGenerator.ITEM_LAYERS) {
3043
3043
  const textureImage = textureMap[layerName];
@@ -3053,7 +3053,7 @@ var init_UVMapper = __esm({
3053
3053
  ), layerName));
3054
3054
  }
3055
3055
  }
3056
- log9.debug("Item model elements", model.elements);
3056
+ log10.debug("Item model elements", model.elements);
3057
3057
  }
3058
3058
  if (!model.elements) {
3059
3059
  }
@@ -3110,7 +3110,7 @@ var init_UVMapper = __esm({
3110
3110
  hasTranslucency
3111
3111
  );
3112
3112
  } else {
3113
- log9.warn("Model does not have any textures", model);
3113
+ log10.warn("Model does not have any textures", model);
3114
3114
  }
3115
3115
  return void 0;
3116
3116
  }
@@ -4592,7 +4592,7 @@ var init_Entities = __esm({
4592
4592
  });
4593
4593
 
4594
4594
  // src/assets/BlockEntities.ts
4595
- var import_three9, log10, BlockEntities;
4595
+ var import_three9, log11, BlockEntities;
4596
4596
  var init_BlockEntities = __esm({
4597
4597
  "src/assets/BlockEntities.ts"() {
4598
4598
  import_three9 = require("three");
@@ -4602,7 +4602,7 @@ var init_BlockEntities = __esm({
4602
4602
  init_source();
4603
4603
  init_Caching();
4604
4604
  init_log();
4605
- log10 = logger("BlockEntities");
4605
+ log11 = logger("BlockEntities");
4606
4606
  BlockEntities = class {
4607
4607
  /**
4608
4608
  * Loads the block index of a version. Versions and sources without one yield an empty index, and so does
@@ -4617,7 +4617,7 @@ var init_BlockEntities = __esm({
4617
4617
  key.root = await Entities.getDatasetRoot(root);
4618
4618
  return await AssetLoader.get(key, "json" /* JSON */) ?? {};
4619
4619
  } catch (error) {
4620
- log10.warn("Could not load the block entity index; block entities are drawn as plain block models", error);
4620
+ log11.warn("Could not load the block entity index; block entities are drawn as plain block models", error);
4621
4621
  return {};
4622
4622
  }
4623
4623
  });
@@ -4758,7 +4758,7 @@ async function parseUnihex(key) {
4758
4758
  }
4759
4759
  return { indices, rows, metrics };
4760
4760
  } catch (error) {
4761
- log11.warn(`Could not load Unihex file ${key.toNamespacedString()}`, error);
4761
+ log12.warn(`Could not load Unihex file ${key.toNamespacedString()}`, error);
4762
4762
  return void 0;
4763
4763
  }
4764
4764
  }
@@ -4777,7 +4777,7 @@ async function loadUnihex(provider, fontKey, characters) {
4777
4777
  return { ...override, from, to };
4778
4778
  });
4779
4779
  } catch (error) {
4780
- log11.warn(`Could not load Unihex file ${key.toNamespacedString()}`, error);
4780
+ log12.warn(`Could not load Unihex file ${key.toNamespacedString()}`, error);
4781
4781
  return glyphs;
4782
4782
  }
4783
4783
  const file = await Caching.unihexCache.get(key.serialize(), () => parseUnihex(key));
@@ -4825,7 +4825,7 @@ async function loadUnihex(provider, fontKey, characters) {
4825
4825
  }
4826
4826
  return glyphs;
4827
4827
  }
4828
- var import_zip2, log11, ATLAS_SIZE, GLYPH_HEIGHT, UnihexAtlas, atlases;
4828
+ var import_zip2, log12, ATLAS_SIZE, GLYPH_HEIGHT, UnihexAtlas, atlases;
4829
4829
  var init_Unihex = __esm({
4830
4830
  "src/assets/_fonts/Unihex.ts"() {
4831
4831
  import_zip2 = require("@zip.js/zip.js");
@@ -4836,7 +4836,7 @@ var init_Unihex = __esm({
4836
4836
  init_AssetParsers();
4837
4837
  init_CanvasCompat();
4838
4838
  init_log();
4839
- log11 = logger("Unihex");
4839
+ log12 = logger("Unihex");
4840
4840
  ATLAS_SIZE = 512;
4841
4841
  GLYPH_HEIGHT = 16;
4842
4842
  UnihexAtlas = class {
@@ -9030,13 +9030,13 @@ var init_ModelCulling = __esm({
9030
9030
  });
9031
9031
 
9032
9032
  // src/skin/Skins.ts
9033
- var log12, Skins;
9033
+ var log13, Skins;
9034
9034
  var init_Skins = __esm({
9035
9035
  "src/skin/Skins.ts"() {
9036
9036
  init_Requests();
9037
9037
  init_Caching();
9038
9038
  init_log();
9039
- log12 = logger("Skins");
9039
+ log13 = logger("Skins");
9040
9040
  Skins = class {
9041
9041
  //<editor-fold desc="Skins">
9042
9042
  /** Returns a skin URL for {@link MineRenderScene.addSkin}, or `undefined` if name lookup fails. */
@@ -9108,7 +9108,7 @@ var init_Skins = __esm({
9108
9108
  }
9109
9109
  return void 0;
9110
9110
  }).catch((err) => {
9111
- log12.warn(err);
9111
+ log13.warn(err);
9112
9112
  return void 0;
9113
9113
  });
9114
9114
  }
@@ -9123,7 +9123,7 @@ var init_Skins = __esm({
9123
9123
  }
9124
9124
  return void 0;
9125
9125
  }).catch((err) => {
9126
- log12.warn(err);
9126
+ log13.warn(err);
9127
9127
  return void 0;
9128
9128
  });
9129
9129
  }
@@ -9137,7 +9137,7 @@ var init_Skins = __esm({
9137
9137
  }
9138
9138
  return void 0;
9139
9139
  }).catch((err) => {
9140
- log12.warn(err);
9140
+ log13.warn(err);
9141
9141
  return void 0;
9142
9142
  });
9143
9143
  }
@@ -9161,7 +9161,7 @@ var init_Skins = __esm({
9161
9161
  }
9162
9162
  return void 0;
9163
9163
  }).catch((err) => {
9164
- log12.warn(err);
9164
+ log13.warn(err);
9165
9165
  return void 0;
9166
9166
  });
9167
9167
  }
@@ -9963,7 +9963,7 @@ __export(ModelObject_exports, {
9963
9963
  function isModelObject(obj) {
9964
9964
  return obj.isModelObject;
9965
9965
  }
9966
- var import_three27, log13, _ModelObject, ModelObject;
9966
+ var import_three27, log14, _ModelObject, ModelObject;
9967
9967
  var init_ModelObject = __esm({
9968
9968
  "src/model/scene/ModelObject.ts"() {
9969
9969
  init_SceneObject();
@@ -9983,7 +9983,7 @@ var init_ModelObject = __esm({
9983
9983
  init_GuiLight();
9984
9984
  init_ItemTints();
9985
9985
  init_ItemGlint();
9986
- log13 = logger("ModelObject");
9986
+ log14 = logger("ModelObject");
9987
9987
  _ModelObject = class _ModelObject extends SceneObject {
9988
9988
  constructor(originalModel, options) {
9989
9989
  super(options);
@@ -10165,10 +10165,10 @@ var init_ModelObject = __esm({
10165
10165
  }
10166
10166
  });
10167
10167
  } else {
10168
- log13.debug(this.atlas.model, "has no elements");
10168
+ log14.debug(this.atlas.model, "has no elements");
10169
10169
  }
10170
10170
  } else {
10171
- log13.debug("Missing atlas for", this);
10171
+ log14.debug("Missing atlas for", this);
10172
10172
  }
10173
10173
  if (this.options.mergeMeshes) {
10174
10174
  let combinedGeo;
@@ -10981,7 +10981,7 @@ __export(BlockObject_exports, {
10981
10981
  function isBlockObject(obj) {
10982
10982
  return obj.isBlockObject;
10983
10983
  }
10984
- var import_three34, log16, _BlockObject, BlockObject;
10984
+ var import_three34, log17, _BlockObject, BlockObject;
10985
10985
  var init_BlockObject = __esm({
10986
10986
  "src/model/block/scene/BlockObject.ts"() {
10987
10987
  init_SceneObject();
@@ -11001,7 +11001,7 @@ var init_BlockObject = __esm({
11001
11001
  init_Entities();
11002
11002
  init_Biomes();
11003
11003
  init_log();
11004
- log16 = logger("BlockObject");
11004
+ log17 = logger("BlockObject");
11005
11005
  _BlockObject = class _BlockObject extends SceneObject {
11006
11006
  constructor(blockState3, options) {
11007
11007
  super(options);
@@ -11106,7 +11106,7 @@ var init_BlockObject = __esm({
11106
11106
  created.push(await this.scene.addEntity(entity, { wireframe: this.options.wireframe }));
11107
11107
  }
11108
11108
  } catch (error) {
11109
- log16.warn(`Could not draw block entity ${key.toNamespacedString()}, using its block model`, error);
11109
+ log17.warn(`Could not draw block entity ${key.toNamespacedString()}, using its block model`, error);
11110
11110
  this.removeEntities(created);
11111
11111
  return false;
11112
11112
  }
@@ -11635,6 +11635,7 @@ module.exports = __toCommonJS(index_browser_exports);
11635
11635
 
11636
11636
  // src/env/browser/BrowserEnv.ts
11637
11637
  init_Env();
11638
+ init_log();
11638
11639
 
11639
11640
  // src/env/browser/BrowserCache.ts
11640
11641
  init_PersistentCache();
@@ -11735,6 +11736,7 @@ function probeImageSize(data) {
11735
11736
 
11736
11737
  // src/env/browser/BrowserEnv.ts
11737
11738
  var import_meta = {};
11739
+ var log2 = logger("BrowserEnv");
11738
11740
  function lazyLocalForage(options) {
11739
11741
  let instance;
11740
11742
  const store = () => instance ?? (instance = import("localforage").then((module2) => module2.default.createInstance(options)));
@@ -11750,7 +11752,8 @@ function lazyLocalForage(options) {
11750
11752
  };
11751
11753
  }
11752
11754
  var BrowserEnv = class {
11753
- constructor() {
11755
+ constructor(options = {}) {
11756
+ this.options = options;
11754
11757
  this.name = "browser";
11755
11758
  }
11756
11759
  createCanvas(width, height) {
@@ -11779,14 +11782,18 @@ var BrowserEnv = class {
11779
11782
  createWorker(name) {
11780
11783
  if (name !== "section" || typeof Worker === "undefined") return void 0;
11781
11784
  try {
11785
+ const sectionWorker = this.options.sectionWorker;
11786
+ if (typeof sectionWorker === "function") return sectionWorker();
11787
+ if (sectionWorker !== void 0) return new Worker(sectionWorker, { type: "module" });
11782
11788
  return new Worker(new URL("./section.worker.mjs", import_meta.url), { type: "module" });
11783
- } catch {
11789
+ } catch (error) {
11790
+ log2.warn("Could not start the section worker, so sections build on the main thread. Pass sectionWorker to registerBrowserEnv to load it from another URL.", error);
11784
11791
  return void 0;
11785
11792
  }
11786
11793
  }
11787
11794
  };
11788
- function registerBrowserEnv() {
11789
- const env = new BrowserEnv();
11795
+ function registerBrowserEnv(options) {
11796
+ const env = new BrowserEnv(options);
11790
11797
  Env.register(env);
11791
11798
  return env;
11792
11799
  }
@@ -13132,7 +13139,7 @@ init_SceneObject();
13132
13139
  init_util();
13133
13140
  init_log();
13134
13141
  init_three();
13135
- var log14 = logger("SceneInspector");
13142
+ var log15 = logger("SceneInspector");
13136
13143
  var help = "<span>Ctrl/Cmd+Click to Select<br/></span><br/>";
13137
13144
  var SceneInspector = class {
13138
13145
  constructor(renderer) {
@@ -13226,7 +13233,7 @@ var SceneInspector = class {
13226
13233
  }
13227
13234
  selectObject(targetObject, targetIntersection, instance = this.getIntersectionInstance(targetIntersection)) {
13228
13235
  this.selectedObject = targetObject;
13229
- log14.debug("selected", targetObject);
13236
+ log15.debug("selected", targetObject);
13230
13237
  this.redraw(targetObject, targetIntersection, instance);
13231
13238
  }
13232
13239
  redraw(targetObject, targetIntersection, instance) {
@@ -13486,7 +13493,7 @@ var SceneStatsDisplay = class {
13486
13493
 
13487
13494
  // src/instance/InstanceManager.ts
13488
13495
  init_log();
13489
- var log15 = logger("InstanceManager");
13496
+ var log16 = logger("InstanceManager");
13490
13497
  var InstanceManager = class {
13491
13498
  constructor() {
13492
13499
  this.isInstanceManager = true;
@@ -13495,7 +13502,7 @@ var InstanceManager = class {
13495
13502
  /** Allocates a new placement of a cached model, or returns `undefined` if the key is unknown. */
13496
13503
  async get(key) {
13497
13504
  if (key in this.instanceCache) {
13498
- log15.debug("key in cache", key);
13505
+ log16.debug("key in cache", key);
13499
13506
  return (await this.instanceCache[key]).nextInstance();
13500
13507
  }
13501
13508
  return void 0;
@@ -13505,7 +13512,7 @@ var InstanceManager = class {
13505
13512
  if (key in this.instanceCache) {
13506
13513
  return await this.get(key);
13507
13514
  }
13508
- log15.debug("key not in cache", key);
13515
+ log16.debug("key not in cache", key);
13509
13516
  const pending = Promise.resolve().then(supplier).then((obj) => obj.nextInstance());
13510
13517
  this.instanceCache[key] = pending;
13511
13518
  try {
@@ -16111,7 +16118,7 @@ var MapControls = class extends OrbitControls {
16111
16118
 
16112
16119
  // src/renderer/Renderer.ts
16113
16120
  init_log();
16114
- var log17 = logger("Renderer");
16121
+ var log18 = logger("Renderer");
16115
16122
  var _Renderer = class _Renderer {
16116
16123
  constructor(options, surface) {
16117
16124
  this._width = 0;
@@ -16356,10 +16363,10 @@ var _Renderer = class _Renderer {
16356
16363
  this._element = element;
16357
16364
  this._element.appendChild(this.renderer.domElement);
16358
16365
  if (this.viewWidth == 0) {
16359
- log17.warn("0 element width");
16366
+ log18.warn("0 element width");
16360
16367
  }
16361
16368
  if (this.viewHeight == 0) {
16362
- log17.warn("0 element height");
16369
+ log18.warn("0 element height");
16363
16370
  }
16364
16371
  this.resize(this.viewWidth, this.viewHeight);
16365
16372
  }
@@ -18392,7 +18399,7 @@ function hitNormal(hit) {
18392
18399
 
18393
18400
  // src/world/_entities/WorldEntities.ts
18394
18401
  init_log();
18395
- var log18 = logger("WorldEntities");
18402
+ var log19 = logger("WorldEntities");
18396
18403
  var WorldEntities = class {
18397
18404
  constructor(scene) {
18398
18405
  this.scene = scene;
@@ -18461,7 +18468,7 @@ var WorldEntities = class {
18461
18468
  placement.owner.set(object4, { type: key.toNamespacedString(), position: placement.position });
18462
18469
  this.scene.add(object4);
18463
18470
  } catch (error) {
18464
- log18.warn(`Could not draw saved entity ${placement.key.toNamespacedString()}, skipping it`, error);
18471
+ log19.warn(`Could not draw saved entity ${placement.key.toNamespacedString()}, skipping it`, error);
18465
18472
  } finally {
18466
18473
  if (object4 && !placement.owner.has(object4)) object4.dispose();
18467
18474
  }
@@ -18674,7 +18681,7 @@ function skipsBlockFace(data, rule, block, neighbor, face) {
18674
18681
 
18675
18682
  // src/world/MineRenderWorld.ts
18676
18683
  init_log();
18677
- var log19 = logger("MineRenderWorld");
18684
+ var log20 = logger("MineRenderWorld");
18678
18685
  var YIELD_INTERVAL_MS = 8;
18679
18686
  var MineRenderWorld = class {
18680
18687
  constructor(scene, options = {}) {
@@ -19002,7 +19009,7 @@ var MineRenderWorld = class {
19002
19009
  } finally {
19003
19010
  try {
19004
19011
  const failures = await this.refreshBiomes(true);
19005
- if (failures.size) log19.warn("Failed to refresh biome colors", failures.values().next().value);
19012
+ if (failures.size) log20.warn("Failed to refresh biome colors", failures.values().next().value);
19006
19013
  } catch (error) {
19007
19014
  if (!failed) {
19008
19015
  failed = true;
@@ -19108,7 +19115,7 @@ var MineRenderWorld = class {
19108
19115
  if (deferCulling) await this.updateCulling([...changes.values()], true);
19109
19116
  else {
19110
19117
  const failures = await this.refreshBiomes();
19111
- if (failures.size) log19.warn("Failed to refresh biome colors", failures.values().next().value);
19118
+ if (failures.size) log20.warn("Failed to refresh biome colors", failures.values().next().value);
19112
19119
  await this.updateCulling([...changes.values()]);
19113
19120
  }
19114
19121
  }
@@ -19147,7 +19154,7 @@ var MineRenderWorld = class {
19147
19154
  }
19148
19155
  } finally {
19149
19156
  const failures = await this.refreshBiomes(true);
19150
- if (failures.size) log19.warn("Failed to refresh biome colors", failures.values().next().value);
19157
+ if (failures.size) log20.warn("Failed to refresh biome colors", failures.values().next().value);
19151
19158
  await this.updateCulling([]);
19152
19159
  }
19153
19160
  }
@@ -19689,6 +19696,8 @@ function sectionGeometryTransferables(pages) {
19689
19696
 
19690
19697
  // src/world/SectionWorker.ts
19691
19698
  init_Env();
19699
+ init_log();
19700
+ var log21 = logger("SectionWorker");
19692
19701
  var _SectionWorker = class _SectionWorker {
19693
19702
  constructor(worker) {
19694
19703
  this.worker = worker;
@@ -19702,8 +19711,12 @@ var _SectionWorker = class _SectionWorker {
19702
19711
  if (reply.type === "pages") pending.resolve(reply.pages);
19703
19712
  else pending.reject(new Error(reply.message));
19704
19713
  });
19705
- worker.addEventListener("error", (event) => this.fail(event.message || "Section worker failed"));
19706
- worker.addEventListener("messageerror", () => this.fail("Section worker message could not be deserialized"));
19714
+ const fallBack = (message) => {
19715
+ log21.warn(`${message}, so sections build on the main thread`);
19716
+ this.fail(message);
19717
+ };
19718
+ worker.addEventListener("error", (event) => fallBack(event.message || "Section worker failed"));
19719
+ worker.addEventListener("messageerror", () => fallBack("Section worker message could not be deserialized"));
19707
19720
  }
19708
19721
  /** The shared worker, or undefined when the environment has none or a previous worker failed. */
19709
19722
  static shared() {