minerender 2.1.0-alpha.5 → 2.1.0-alpha.7

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.
@@ -60,7 +60,7 @@ declare function createCanvas(width: number, height: number): CompatCanvas;
60
60
  declare abstract class PersistentCache<B = unknown> {
61
61
  readonly backing: B;
62
62
  /** Bump to invalidate every persisted entry. */
63
- static readonly VERSION = 1;
63
+ static readonly VERSION = 2;
64
64
  static open(name: string): PersistentCache;
65
65
  protected constructor(backing: B);
66
66
  abstract get<T>(key: string): Promise<T>;
@@ -534,14 +534,13 @@ declare class MinecraftFaceUV {
534
534
  }
535
535
 
536
536
  /**
537
- * Releases every long-lived timer MineRender holds, so a Node process can exit.
537
+ * Stops the shared Ticker and request queues, and clears the in-memory caches.
538
538
  *
539
- * Both `@inventivetalent/loading-cache` (cache expiry) and `jobqu` (request queue draining) use
540
- * self-rescheduling timers that are not unref'd, which keeps the event loop alive for as long as
541
- * the library is loaded. Browsers don't care, but anything headless - a render server, a CLI, a
542
- * test run - has to call this when it's done.
539
+ * Idle Node processes can exit without calling this: cache and Ticker timers are unref'd,
540
+ * and idle request queues hold no timer. Pending requests keep their normal timer references.
543
541
  *
544
- * The library stays usable afterwards; the caches and queues simply start over.
542
+ * Call this only when finished with MineRender. Waiting and future requests reject; requests
543
+ * already running can finish. Queue shutdown is permanent, and cache expiry timers do not restart.
545
544
  */
546
545
  declare function shutdown(): void;
547
546
 
@@ -621,6 +620,7 @@ declare class AssetLoader {
621
620
  static addSource(key: string, source: AssetSource, override?: boolean): void;
622
621
  static removeSource(key: string): Maybe<AssetSource>;
623
622
  static getAll<T extends MinecraftAsset>(key: AssetKey, parser: AssetParser | string): Promise<T[]>;
623
+ /** Returns the first defined result in source-priority order, without merging assets. */
624
624
  static get<T extends MinecraftAsset>(key: AssetKey, parser: AssetParser | string): Promise<Maybe<T>>;
625
625
  }
626
626
 
@@ -1218,8 +1218,8 @@ declare class Caching {
1218
1218
  /**
1219
1219
  * Clears every cache and stops its expiry timer.
1220
1220
  *
1221
- * loading-cache reschedules that timer indefinitely, so a Node process will not exit until
1222
- * this is called - see {@link shutdown}.
1221
+ * Expiry timers are unref'd in Node, so idle processes can exit without this cleanup.
1222
+ * Use {@link shutdown} to also stop requests and the shared Ticker.
1223
1223
  */
1224
1224
  static end(): void;
1225
1225
  static get cacheSizes(): {};
@@ -1472,8 +1472,9 @@ declare class Requests {
1472
1472
  mcAsset: number;
1473
1473
  };
1474
1474
  /**
1475
- * Stops both queue timers. jobqu reschedules itself indefinitely, so a Node process will not
1476
- * exit until this is called - see {@link shutdown}.
1475
+ * Permanently stops both queues and rejects waiting and future requests.
1476
+ * Requests already running can finish. Idle queues hold no timer, so Node can exit without
1477
+ * this cleanup. See {@link shutdown}.
1477
1478
  */
1478
1479
  static end(): void;
1479
1480
  }
@@ -60,7 +60,7 @@ declare function createCanvas(width: number, height: number): CompatCanvas;
60
60
  declare abstract class PersistentCache<B = unknown> {
61
61
  readonly backing: B;
62
62
  /** Bump to invalidate every persisted entry. */
63
- static readonly VERSION = 1;
63
+ static readonly VERSION = 2;
64
64
  static open(name: string): PersistentCache;
65
65
  protected constructor(backing: B);
66
66
  abstract get<T>(key: string): Promise<T>;
@@ -534,14 +534,13 @@ declare class MinecraftFaceUV {
534
534
  }
535
535
 
536
536
  /**
537
- * Releases every long-lived timer MineRender holds, so a Node process can exit.
537
+ * Stops the shared Ticker and request queues, and clears the in-memory caches.
538
538
  *
539
- * Both `@inventivetalent/loading-cache` (cache expiry) and `jobqu` (request queue draining) use
540
- * self-rescheduling timers that are not unref'd, which keeps the event loop alive for as long as
541
- * the library is loaded. Browsers don't care, but anything headless - a render server, a CLI, a
542
- * test run - has to call this when it's done.
539
+ * Idle Node processes can exit without calling this: cache and Ticker timers are unref'd,
540
+ * and idle request queues hold no timer. Pending requests keep their normal timer references.
543
541
  *
544
- * The library stays usable afterwards; the caches and queues simply start over.
542
+ * Call this only when finished with MineRender. Waiting and future requests reject; requests
543
+ * already running can finish. Queue shutdown is permanent, and cache expiry timers do not restart.
545
544
  */
546
545
  declare function shutdown(): void;
547
546
 
@@ -621,6 +620,7 @@ declare class AssetLoader {
621
620
  static addSource(key: string, source: AssetSource, override?: boolean): void;
622
621
  static removeSource(key: string): Maybe<AssetSource>;
623
622
  static getAll<T extends MinecraftAsset>(key: AssetKey, parser: AssetParser | string): Promise<T[]>;
623
+ /** Returns the first defined result in source-priority order, without merging assets. */
624
624
  static get<T extends MinecraftAsset>(key: AssetKey, parser: AssetParser | string): Promise<Maybe<T>>;
625
625
  }
626
626
 
@@ -1218,8 +1218,8 @@ declare class Caching {
1218
1218
  /**
1219
1219
  * Clears every cache and stops its expiry timer.
1220
1220
  *
1221
- * loading-cache reschedules that timer indefinitely, so a Node process will not exit until
1222
- * this is called - see {@link shutdown}.
1221
+ * Expiry timers are unref'd in Node, so idle processes can exit without this cleanup.
1222
+ * Use {@link shutdown} to also stop requests and the shared Ticker.
1223
1223
  */
1224
1224
  static end(): void;
1225
1225
  static get cacheSizes(): {};
@@ -1472,8 +1472,9 @@ declare class Requests {
1472
1472
  mcAsset: number;
1473
1473
  };
1474
1474
  /**
1475
- * Stops both queue timers. jobqu reschedules itself indefinitely, so a Node process will not
1476
- * exit until this is called - see {@link shutdown}.
1475
+ * Permanently stops both queues and rejects waiting and future requests.
1476
+ * Requests already running can finish. Idle queues hold no timer, so Node can exit without
1477
+ * this cleanup. See {@link shutdown}.
1477
1478
  */
1478
1479
  static end(): void;
1479
1480
  }
@@ -90,7 +90,7 @@ var require_dist = __commonJS({
90
90
  return false;
91
91
  };
92
92
  var PROTECTED_KEYS = ["__proto__"];
93
- var merge11 = function() {
93
+ var merge10 = function() {
94
94
  var objects = [];
95
95
  for (var _i = 0; _i < arguments.length; _i++) {
96
96
  objects[_i] = arguments[_i];
@@ -101,9 +101,9 @@ var require_dist = __commonJS({
101
101
  return;
102
102
  }
103
103
  if (Array.isArray(result[key]) && Array.isArray(current[key])) {
104
- result[key] = merge11.options.mergeArrays ? Array.from(new Set(result[key].concat(current[key]))) : current[key];
104
+ result[key] = merge10.options.mergeArrays ? Array.from(new Set(result[key].concat(current[key]))) : current[key];
105
105
  } else if (isObject(result[key]) && isObject(current[key])) {
106
- result[key] = merge11(result[key], current[key]);
106
+ result[key] = merge10(result[key], current[key]);
107
107
  } else {
108
108
  result[key] = current[key];
109
109
  }
@@ -114,18 +114,18 @@ var require_dist = __commonJS({
114
114
  var defaultOptions = {
115
115
  mergeArrays: true
116
116
  };
117
- merge11.options = defaultOptions;
118
- merge11.withOptions = function(options) {
117
+ merge10.options = defaultOptions;
118
+ merge10.withOptions = function(options) {
119
119
  var objects = [];
120
120
  for (var _i = 1; _i < arguments.length; _i++) {
121
121
  objects[_i - 1] = arguments[_i];
122
122
  }
123
- merge11.options = __assign({ mergeArrays: true }, options);
124
- var result = merge11.apply(void 0, __spreadArray([], __read(objects), false));
125
- merge11.options = defaultOptions;
123
+ merge10.options = __assign({ mergeArrays: true }, options);
124
+ var result = merge10.apply(void 0, __spreadArray([], __read(objects), false));
125
+ merge10.options = defaultOptions;
126
126
  return result;
127
127
  };
128
- exports.default = merge11;
128
+ exports.default = merge10;
129
129
  }
130
130
  });
131
131
 
@@ -318,7 +318,7 @@ var _PersistentCache = class _PersistentCache {
318
318
  }
319
319
  };
320
320
  /** Bump to invalidate every persisted entry. */
321
- _PersistentCache.VERSION = 1;
321
+ _PersistentCache.VERSION = 2;
322
322
  var PersistentCache = _PersistentCache;
323
323
 
324
324
  // src/env/browser/BrowserCache.ts
@@ -419,7 +419,8 @@ var BrowserEnv = class {
419
419
  }
420
420
  openCache(name, version) {
421
421
  return new BrowserCache(import_localforage.default.createInstance({
422
- name,
422
+ // IndexedDB schema upgrades retain records; each cache generation needs its own database.
423
+ name: name + version,
423
424
  version
424
425
  }));
425
426
  }
@@ -575,8 +576,8 @@ var Caching = class {
575
576
  /**
576
577
  * Clears every cache and stops its expiry timer.
577
578
  *
578
- * loading-cache reschedules that timer indefinitely, so a Node process will not exit until
579
- * this is called - see {@link shutdown}.
579
+ * Expiry timers are unref'd in Node, so idle processes can exit without this cleanup.
580
+ * Use {@link shutdown} to also stop requests and the shared Ticker.
580
581
  */
581
582
  static end() {
582
583
  for (const cache of this.all) {
@@ -824,13 +825,14 @@ var _Requests = class _Requests {
824
825
  }
825
826
  static get queueSizes() {
826
827
  return {
827
- generic: this.genericQueue.size,
828
- mcAsset: this.mcAssetRequestQueue.size
828
+ generic: this.genericQueue.size + this.genericQueue.activeSize,
829
+ mcAsset: this.mcAssetRequestQueue.size + this.mcAssetRequestQueue.activeSize
829
830
  };
830
831
  }
831
832
  /**
832
- * Stops both queue timers. jobqu reschedules itself indefinitely, so a Node process will not
833
- * exit until this is called - see {@link shutdown}.
833
+ * Permanently stops both queues and rejects waiting and future requests.
834
+ * Requests already running can finish. Idle queues hold no timer, so Node can exit without
835
+ * this cleanup. See {@link shutdown}.
834
836
  */
835
837
  static end() {
836
838
  this.genericQueue.end();
@@ -1811,7 +1813,6 @@ var ArchiveAssetSource = class _ArchiveAssetSource extends AssetSource {
1811
1813
  };
1812
1814
 
1813
1815
  // src/assets/AssetLoader.ts
1814
- var import_ts_deepmerge3 = __toESM(require_dist());
1815
1816
  var p5 = prefix("AssetLoader");
1816
1817
  var _AssetLoader = class _AssetLoader {
1817
1818
  static addSource(key, source, override = true) {
@@ -1835,7 +1836,6 @@ var _AssetLoader = class _AssetLoader {
1835
1836
  return void 0;
1836
1837
  }
1837
1838
  static async getAll(key, parser) {
1838
- console.log(this._SOURCES);
1839
1839
  let promises = [];
1840
1840
  for (const source of this._SOURCES) {
1841
1841
  promises.push(source.source.get(key, parser));
@@ -1844,24 +1844,16 @@ var _AssetLoader = class _AssetLoader {
1844
1844
  return results.filter((r) => r != void 0);
1845
1845
  });
1846
1846
  }
1847
+ /** Returns the first defined result in source-priority order, without merging assets. */
1847
1848
  static async get(key, parser) {
1848
- console.log(this._SOURCES);
1849
- let promises = [];
1850
- for (const source of this._SOURCES) {
1851
- promises.push(source.source.get(key, parser));
1852
- }
1853
- return Promise.all(promises).then((results) => {
1854
- const fallback = results[results.length - 1];
1855
- for (const result of results) {
1856
- if (result) {
1857
- if (fallback) {
1858
- return (0, import_ts_deepmerge3.default)({}, fallback, result);
1859
- }
1860
- return result;
1861
- }
1849
+ const sources = [...this._SOURCES];
1850
+ for (const source of sources) {
1851
+ const result = await source.source.get(key, parser);
1852
+ if (result !== void 0) {
1853
+ return result;
1862
1854
  }
1863
- return void 0;
1864
- });
1855
+ }
1856
+ return void 0;
1865
1857
  }
1866
1858
  };
1867
1859
  _AssetLoader.ROOT = DEFAULT_ROOT;
@@ -2683,7 +2675,7 @@ var MineRenderError = class _MineRenderError extends Error {
2683
2675
  };
2684
2676
 
2685
2677
  // src/renderer/SceneObject.ts
2686
- var import_ts_deepmerge4 = __toESM(require_dist());
2678
+ var import_ts_deepmerge3 = __toESM(require_dist());
2687
2679
  var p7 = prefix("SceneObject");
2688
2680
  var _SceneObject = class _SceneObject extends import_three9.Object3D {
2689
2681
  constructor(options) {
@@ -2692,7 +2684,7 @@ var _SceneObject = class _SceneObject extends import_three9.Object3D {
2692
2684
  this.materialCallbacks = {};
2693
2685
  this._isInstanced = false;
2694
2686
  this._instanceCounter = 0;
2695
- this.options = (0, import_ts_deepmerge4.default)({}, _SceneObject.DEFAULT_OPTIONS, options ?? {});
2687
+ this.options = (0, import_ts_deepmerge3.default)({}, _SceneObject.DEFAULT_OPTIONS, options ?? {});
2696
2688
  console.log("SceneObject options", this.options);
2697
2689
  }
2698
2690
  set scene(scene) {
@@ -3041,7 +3033,7 @@ var _SceneObject = class _SceneObject extends import_three9.Object3D {
3041
3033
  }
3042
3034
  //</editor-fold>
3043
3035
  };
3044
- _SceneObject.DEFAULT_OPTIONS = (0, import_ts_deepmerge4.default)({}, {
3036
+ _SceneObject.DEFAULT_OPTIONS = (0, import_ts_deepmerge3.default)({}, {
3045
3037
  instanceMeshes: true,
3046
3038
  maxInstanceCount: 50,
3047
3039
  mergeMeshes: true,
@@ -3053,7 +3045,7 @@ function isSceneObject(obj) {
3053
3045
  }
3054
3046
 
3055
3047
  // src/entity/scene/EntityObject.ts
3056
- var import_ts_deepmerge5 = __toESM(require_dist());
3048
+ var import_ts_deepmerge4 = __toESM(require_dist());
3057
3049
  var import_three11 = require("three");
3058
3050
  var THREE3 = __toESM(require("three"));
3059
3051
  var EntityObject = class extends SceneObject {
@@ -3062,7 +3054,7 @@ var EntityObject = class extends SceneObject {
3062
3054
  this.entity = entity;
3063
3055
  this.isEntityObject = true;
3064
3056
  this.meshesCreated = false;
3065
- this.options = (0, import_ts_deepmerge5.default)({}, SceneObject.DEFAULT_OPTIONS, options ?? {});
3057
+ this.options = (0, import_ts_deepmerge4.default)({}, SceneObject.DEFAULT_OPTIONS, options ?? {});
3066
3058
  }
3067
3059
  async init() {
3068
3060
  this.createMeshes();
@@ -3129,7 +3121,7 @@ var EntityObject = class extends SceneObject {
3129
3121
  }
3130
3122
  }
3131
3123
  };
3132
- EntityObject.DEFAULT_OPTIONS = (0, import_ts_deepmerge5.default)({}, SceneObject.DEFAULT_OPTIONS, {});
3124
+ EntityObject.DEFAULT_OPTIONS = (0, import_ts_deepmerge4.default)({}, SceneObject.DEFAULT_OPTIONS, {});
3133
3125
  function isEntityObject(obj) {
3134
3126
  return obj.isEntityObject;
3135
3127
  }
@@ -4120,7 +4112,7 @@ function computeMorphedAttributes(object) {
4120
4112
  }
4121
4113
 
4122
4114
  // src/model/scene/ModelObject.ts
4123
- var import_ts_deepmerge6 = __toESM(require_dist());
4115
+ var import_ts_deepmerge5 = __toESM(require_dist());
4124
4116
  var p10 = prefix("ModelObject");
4125
4117
  var _ModelObject = class _ModelObject extends SceneObject {
4126
4118
  constructor(originalModel, options) {
@@ -4128,7 +4120,7 @@ var _ModelObject = class _ModelObject extends SceneObject {
4128
4120
  this.originalModel = originalModel;
4129
4121
  this.isModelObject = true;
4130
4122
  this.meshesCreated = false;
4131
- this.options = (0, import_ts_deepmerge6.default)({}, _ModelObject.DEFAULT_OPTIONS, options ?? {});
4123
+ this.options = (0, import_ts_deepmerge5.default)({}, _ModelObject.DEFAULT_OPTIONS, options ?? {});
4132
4124
  console.log("ModelObject options", this.options);
4133
4125
  }
4134
4126
  async init() {
@@ -4226,14 +4218,14 @@ var _ModelObject = class _ModelObject extends SceneObject {
4226
4218
  }
4227
4219
  }
4228
4220
  };
4229
- _ModelObject.DEFAULT_OPTIONS = (0, import_ts_deepmerge6.default)({}, SceneObject.DEFAULT_OPTIONS, {});
4221
+ _ModelObject.DEFAULT_OPTIONS = (0, import_ts_deepmerge5.default)({}, SceneObject.DEFAULT_OPTIONS, {});
4230
4222
  var ModelObject = _ModelObject;
4231
4223
  function isModelObject(obj) {
4232
4224
  return obj.isModelObject;
4233
4225
  }
4234
4226
 
4235
4227
  // src/model/block/scene/BlockObject.ts
4236
- var import_ts_deepmerge7 = __toESM(require_dist());
4228
+ var import_ts_deepmerge6 = __toESM(require_dist());
4237
4229
  var import_three16 = require("three");
4238
4230
  var p11 = prefix("BlockObject");
4239
4231
  var _BlockObject = class _BlockObject extends SceneObject {
@@ -4249,7 +4241,7 @@ var _BlockObject = class _BlockObject extends SceneObject {
4249
4241
  this._instanceModel = [];
4250
4242
  this._variants = [];
4251
4243
  this._models = [];
4252
- this.options = (0, import_ts_deepmerge7.default)({}, _BlockObject.DEFAULT_OPTIONS, options ?? {});
4244
+ this.options = (0, import_ts_deepmerge6.default)({}, _BlockObject.DEFAULT_OPTIONS, options ?? {});
4253
4245
  }
4254
4246
  async init() {
4255
4247
  if (this.options.applyDefaultState) {
@@ -4538,7 +4530,7 @@ var _BlockObject = class _BlockObject extends SceneObject {
4538
4530
  //TODO: should override rotation + scale methods
4539
4531
  //TODO
4540
4532
  };
4541
- _BlockObject.DEFAULT_OPTIONS = (0, import_ts_deepmerge7.default)({}, ModelObject.DEFAULT_OPTIONS, {
4533
+ _BlockObject.DEFAULT_OPTIONS = (0, import_ts_deepmerge6.default)({}, ModelObject.DEFAULT_OPTIONS, {
4542
4534
  applyDefaultState: true
4543
4535
  });
4544
4536
  var BlockObject = _BlockObject;
@@ -4588,7 +4580,7 @@ var StructureParser = class {
4588
4580
 
4589
4581
  // src/renderer/MineRenderScene.ts
4590
4582
  var import_three17 = require("three");
4591
- var import_ts_deepmerge9 = __toESM(require_dist());
4583
+ var import_ts_deepmerge8 = __toESM(require_dist());
4592
4584
 
4593
4585
  // src/skin/SkinPart.ts
4594
4586
  var SkinPart = /* @__PURE__ */ ((SkinPart2) => {
@@ -5319,7 +5311,7 @@ var slimSkinGeometries = {
5319
5311
  };
5320
5312
 
5321
5313
  // src/skin/scene/SkinObject.ts
5322
- var import_ts_deepmerge8 = __toESM(require_dist());
5314
+ var import_ts_deepmerge7 = __toESM(require_dist());
5323
5315
  var SkinObject = class extends SceneObject {
5324
5316
  constructor(options) {
5325
5317
  super();
@@ -5327,7 +5319,7 @@ var SkinObject = class extends SceneObject {
5327
5319
  this.legacy = false;
5328
5320
  this.skinTextureWidth = 64;
5329
5321
  this.skinTextureHeight = 64;
5330
- this.options = (0, import_ts_deepmerge8.default)({}, SceneObject.DEFAULT_OPTIONS, options ?? {});
5322
+ this.options = (0, import_ts_deepmerge7.default)({}, SceneObject.DEFAULT_OPTIONS, options ?? {});
5331
5323
  }
5332
5324
  async init() {
5333
5325
  this.createMeshes();
@@ -5444,7 +5436,7 @@ var _MineRenderScene = class _MineRenderScene extends import_three17.Scene {
5444
5436
  this.dirty = true;
5445
5437
  }
5446
5438
  };
5447
- this.options = (0, import_ts_deepmerge9.default)({}, _MineRenderScene.DEFAULT_OPTIONS, options ?? {});
5439
+ this.options = (0, import_ts_deepmerge8.default)({}, _MineRenderScene.DEFAULT_OPTIONS, options ?? {});
5448
5440
  }
5449
5441
  add(...objects) {
5450
5442
  for (const object of objects) {
@@ -5540,7 +5532,7 @@ var _MineRenderScene = class _MineRenderScene extends import_three17.Scene {
5540
5532
  return this.addSceneObject(entity, () => new EntityObject(entity, options), options, parent);
5541
5533
  }
5542
5534
  };
5543
- _MineRenderScene.DEFAULT_OPTIONS = (0, import_ts_deepmerge9.default)({}, {});
5535
+ _MineRenderScene.DEFAULT_OPTIONS = (0, import_ts_deepmerge8.default)({}, {});
5544
5536
  var MineRenderScene = _MineRenderScene;
5545
5537
  function isMineRenderScene(obj) {
5546
5538
  return obj.isMineRenderScene;
@@ -5548,7 +5540,7 @@ function isMineRenderScene(obj) {
5548
5540
 
5549
5541
  // src/renderer/Renderer.ts
5550
5542
  var import_three19 = require("three");
5551
- var import_ts_deepmerge10 = __toESM(require_dist());
5543
+ var import_ts_deepmerge9 = __toESM(require_dist());
5552
5544
  var import_stats = __toESM(require("stats.js"));
5553
5545
  var import_postprocessing = require("postprocessing");
5554
5546
 
@@ -6205,7 +6197,7 @@ var _Renderer = class _Renderer {
6205
6197
  this._changeListener = () => {
6206
6198
  this._dirty = true;
6207
6199
  };
6208
- this.options = (0, import_ts_deepmerge10.default)({}, _Renderer.DEFAULT_OPTIONS, options ?? {});
6200
+ this.options = (0, import_ts_deepmerge9.default)({}, _Renderer.DEFAULT_OPTIONS, options ?? {});
6209
6201
  this._animationLoop = this.animate.bind(this);
6210
6202
  this._frameInterval = this.options.render.fpsLimit > 0 ? 1e3 / this.options.render.fpsLimit : void 0;
6211
6203
  this._scene = this.createScene();
@@ -6490,7 +6482,7 @@ var _Renderer = class _Renderer {
6490
6482
  }
6491
6483
  ///
6492
6484
  };
6493
- _Renderer.DEFAULT_OPTIONS = (0, import_ts_deepmerge10.default)({}, {
6485
+ _Renderer.DEFAULT_OPTIONS = (0, import_ts_deepmerge9.default)({}, {
6494
6486
  camera: {
6495
6487
  type: "perspective",
6496
6488
  near: 1,