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.
@@ -61,7 +61,7 @@ declare function createCanvas(width: number, height: number): CompatCanvas;
61
61
  declare abstract class PersistentCache<B = unknown> {
62
62
  readonly backing: B;
63
63
  /** Bump to invalidate every persisted entry. */
64
- static readonly VERSION = 1;
64
+ static readonly VERSION = 2;
65
65
  static open(name: string): PersistentCache;
66
66
  protected constructor(backing: B);
67
67
  abstract get<T>(key: string): Promise<T>;
@@ -535,14 +535,13 @@ declare class MinecraftFaceUV {
535
535
  }
536
536
 
537
537
  /**
538
- * Releases every long-lived timer MineRender holds, so a Node process can exit.
538
+ * Stops the shared Ticker and request queues, and clears the in-memory caches.
539
539
  *
540
- * Both `@inventivetalent/loading-cache` (cache expiry) and `jobqu` (request queue draining) use
541
- * self-rescheduling timers that are not unref'd, which keeps the event loop alive for as long as
542
- * the library is loaded. Browsers don't care, but anything headless - a render server, a CLI, a
543
- * test run - has to call this when it's done.
540
+ * Idle Node processes can exit without calling this: cache and Ticker timers are unref'd,
541
+ * and idle request queues hold no timer. Pending requests keep their normal timer references.
544
542
  *
545
- * The library stays usable afterwards; the caches and queues simply start over.
543
+ * Call this only when finished with MineRender. Waiting and future requests reject; requests
544
+ * already running can finish. Queue shutdown is permanent, and cache expiry timers do not restart.
546
545
  */
547
546
  declare function shutdown(): void;
548
547
 
@@ -622,6 +621,7 @@ declare class AssetLoader {
622
621
  static addSource(key: string, source: AssetSource, override?: boolean): void;
623
622
  static removeSource(key: string): Maybe<AssetSource>;
624
623
  static getAll<T extends MinecraftAsset>(key: AssetKey, parser: AssetParser | string): Promise<T[]>;
624
+ /** Returns the first defined result in source-priority order, without merging assets. */
625
625
  static get<T extends MinecraftAsset>(key: AssetKey, parser: AssetParser | string): Promise<Maybe<T>>;
626
626
  }
627
627
 
@@ -1219,8 +1219,8 @@ declare class Caching {
1219
1219
  /**
1220
1220
  * Clears every cache and stops its expiry timer.
1221
1221
  *
1222
- * loading-cache reschedules that timer indefinitely, so a Node process will not exit until
1223
- * this is called - see {@link shutdown}.
1222
+ * Expiry timers are unref'd in Node, so idle processes can exit without this cleanup.
1223
+ * Use {@link shutdown} to also stop requests and the shared Ticker.
1224
1224
  */
1225
1225
  static end(): void;
1226
1226
  static get cacheSizes(): {};
@@ -1473,8 +1473,9 @@ declare class Requests {
1473
1473
  mcAsset: number;
1474
1474
  };
1475
1475
  /**
1476
- * Stops both queue timers. jobqu reschedules itself indefinitely, so a Node process will not
1477
- * exit until this is called - see {@link shutdown}.
1476
+ * Permanently stops both queues and rejects waiting and future requests.
1477
+ * Requests already running can finish. Idle queues hold no timer, so Node can exit without
1478
+ * this cleanup. See {@link shutdown}.
1478
1479
  */
1479
1480
  static end(): void;
1480
1481
  }
@@ -61,7 +61,7 @@ declare function createCanvas(width: number, height: number): CompatCanvas;
61
61
  declare abstract class PersistentCache<B = unknown> {
62
62
  readonly backing: B;
63
63
  /** Bump to invalidate every persisted entry. */
64
- static readonly VERSION = 1;
64
+ static readonly VERSION = 2;
65
65
  static open(name: string): PersistentCache;
66
66
  protected constructor(backing: B);
67
67
  abstract get<T>(key: string): Promise<T>;
@@ -535,14 +535,13 @@ declare class MinecraftFaceUV {
535
535
  }
536
536
 
537
537
  /**
538
- * Releases every long-lived timer MineRender holds, so a Node process can exit.
538
+ * Stops the shared Ticker and request queues, and clears the in-memory caches.
539
539
  *
540
- * Both `@inventivetalent/loading-cache` (cache expiry) and `jobqu` (request queue draining) use
541
- * self-rescheduling timers that are not unref'd, which keeps the event loop alive for as long as
542
- * the library is loaded. Browsers don't care, but anything headless - a render server, a CLI, a
543
- * test run - has to call this when it's done.
540
+ * Idle Node processes can exit without calling this: cache and Ticker timers are unref'd,
541
+ * and idle request queues hold no timer. Pending requests keep their normal timer references.
544
542
  *
545
- * The library stays usable afterwards; the caches and queues simply start over.
543
+ * Call this only when finished with MineRender. Waiting and future requests reject; requests
544
+ * already running can finish. Queue shutdown is permanent, and cache expiry timers do not restart.
546
545
  */
547
546
  declare function shutdown(): void;
548
547
 
@@ -622,6 +621,7 @@ declare class AssetLoader {
622
621
  static addSource(key: string, source: AssetSource, override?: boolean): void;
623
622
  static removeSource(key: string): Maybe<AssetSource>;
624
623
  static getAll<T extends MinecraftAsset>(key: AssetKey, parser: AssetParser | string): Promise<T[]>;
624
+ /** Returns the first defined result in source-priority order, without merging assets. */
625
625
  static get<T extends MinecraftAsset>(key: AssetKey, parser: AssetParser | string): Promise<Maybe<T>>;
626
626
  }
627
627
 
@@ -1219,8 +1219,8 @@ declare class Caching {
1219
1219
  /**
1220
1220
  * Clears every cache and stops its expiry timer.
1221
1221
  *
1222
- * loading-cache reschedules that timer indefinitely, so a Node process will not exit until
1223
- * this is called - see {@link shutdown}.
1222
+ * Expiry timers are unref'd in Node, so idle processes can exit without this cleanup.
1223
+ * Use {@link shutdown} to also stop requests and the shared Ticker.
1224
1224
  */
1225
1225
  static end(): void;
1226
1226
  static get cacheSizes(): {};
@@ -1473,8 +1473,9 @@ declare class Requests {
1473
1473
  mcAsset: number;
1474
1474
  };
1475
1475
  /**
1476
- * Stops both queue timers. jobqu reschedules itself indefinitely, so a Node process will not
1477
- * exit until this is called - see {@link shutdown}.
1476
+ * Permanently stops both queues and rejects waiting and future requests.
1477
+ * Requests already running can finish. Idle queues hold no timer, so Node can exit without
1478
+ * this cleanup. See {@link shutdown}.
1478
1479
  */
1479
1480
  static end(): void;
1480
1481
  }
@@ -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
- exports2.default = merge11;
128
+ exports2.default = merge10;
129
129
  }
130
130
  });
131
131
 
@@ -319,7 +319,7 @@ var _PersistentCache = class _PersistentCache {
319
319
  }
320
320
  };
321
321
  /** Bump to invalidate every persisted entry. */
322
- _PersistentCache.VERSION = 1;
322
+ _PersistentCache.VERSION = 2;
323
323
  var PersistentCache = _PersistentCache;
324
324
 
325
325
  // src/env/node/NodeCache.ts
@@ -538,8 +538,8 @@ var Caching = class {
538
538
  /**
539
539
  * Clears every cache and stops its expiry timer.
540
540
  *
541
- * loading-cache reschedules that timer indefinitely, so a Node process will not exit until
542
- * this is called - see {@link shutdown}.
541
+ * Expiry timers are unref'd in Node, so idle processes can exit without this cleanup.
542
+ * Use {@link shutdown} to also stop requests and the shared Ticker.
543
543
  */
544
544
  static end() {
545
545
  for (const cache of this.all) {
@@ -787,13 +787,14 @@ var _Requests = class _Requests {
787
787
  }
788
788
  static get queueSizes() {
789
789
  return {
790
- generic: this.genericQueue.size,
791
- mcAsset: this.mcAssetRequestQueue.size
790
+ generic: this.genericQueue.size + this.genericQueue.activeSize,
791
+ mcAsset: this.mcAssetRequestQueue.size + this.mcAssetRequestQueue.activeSize
792
792
  };
793
793
  }
794
794
  /**
795
- * Stops both queue timers. jobqu reschedules itself indefinitely, so a Node process will not
796
- * exit until this is called - see {@link shutdown}.
795
+ * Permanently stops both queues and rejects waiting and future requests.
796
+ * Requests already running can finish. Idle queues hold no timer, so Node can exit without
797
+ * this cleanup. See {@link shutdown}.
797
798
  */
798
799
  static end() {
799
800
  this.genericQueue.end();
@@ -1774,7 +1775,6 @@ var ArchiveAssetSource = class _ArchiveAssetSource extends AssetSource {
1774
1775
  };
1775
1776
 
1776
1777
  // src/assets/AssetLoader.ts
1777
- var import_ts_deepmerge3 = __toESM(require_dist());
1778
1778
  var p5 = prefix("AssetLoader");
1779
1779
  var _AssetLoader = class _AssetLoader {
1780
1780
  static addSource(key, source, override = true) {
@@ -1798,7 +1798,6 @@ var _AssetLoader = class _AssetLoader {
1798
1798
  return void 0;
1799
1799
  }
1800
1800
  static async getAll(key, parser) {
1801
- console.log(this._SOURCES);
1802
1801
  let promises = [];
1803
1802
  for (const source of this._SOURCES) {
1804
1803
  promises.push(source.source.get(key, parser));
@@ -1807,24 +1806,16 @@ var _AssetLoader = class _AssetLoader {
1807
1806
  return results.filter((r) => r != void 0);
1808
1807
  });
1809
1808
  }
1809
+ /** Returns the first defined result in source-priority order, without merging assets. */
1810
1810
  static async get(key, parser) {
1811
- console.log(this._SOURCES);
1812
- let promises = [];
1813
- for (const source of this._SOURCES) {
1814
- promises.push(source.source.get(key, parser));
1815
- }
1816
- return Promise.all(promises).then((results) => {
1817
- const fallback = results[results.length - 1];
1818
- for (const result of results) {
1819
- if (result) {
1820
- if (fallback) {
1821
- return (0, import_ts_deepmerge3.default)({}, fallback, result);
1822
- }
1823
- return result;
1824
- }
1811
+ const sources = [...this._SOURCES];
1812
+ for (const source of sources) {
1813
+ const result = await source.source.get(key, parser);
1814
+ if (result !== void 0) {
1815
+ return result;
1825
1816
  }
1826
- return void 0;
1827
- });
1817
+ }
1818
+ return void 0;
1828
1819
  }
1829
1820
  };
1830
1821
  _AssetLoader.ROOT = DEFAULT_ROOT;
@@ -2648,7 +2639,7 @@ var MineRenderError = class _MineRenderError extends Error {
2648
2639
  };
2649
2640
 
2650
2641
  // src/renderer/SceneObject.ts
2651
- var import_ts_deepmerge4 = __toESM(require_dist());
2642
+ var import_ts_deepmerge3 = __toESM(require_dist());
2652
2643
  var p7 = prefix("SceneObject");
2653
2644
  var _SceneObject = class _SceneObject extends import_three9.Object3D {
2654
2645
  constructor(options) {
@@ -2657,7 +2648,7 @@ var _SceneObject = class _SceneObject extends import_three9.Object3D {
2657
2648
  this.materialCallbacks = {};
2658
2649
  this._isInstanced = false;
2659
2650
  this._instanceCounter = 0;
2660
- this.options = (0, import_ts_deepmerge4.default)({}, _SceneObject.DEFAULT_OPTIONS, options ?? {});
2651
+ this.options = (0, import_ts_deepmerge3.default)({}, _SceneObject.DEFAULT_OPTIONS, options ?? {});
2661
2652
  console.log("SceneObject options", this.options);
2662
2653
  }
2663
2654
  set scene(scene) {
@@ -3007,7 +2998,7 @@ var _SceneObject = class _SceneObject extends import_three9.Object3D {
3007
2998
  }
3008
2999
  //</editor-fold>
3009
3000
  };
3010
- _SceneObject.DEFAULT_OPTIONS = (0, import_ts_deepmerge4.default)({}, {
3001
+ _SceneObject.DEFAULT_OPTIONS = (0, import_ts_deepmerge3.default)({}, {
3011
3002
  instanceMeshes: true,
3012
3003
  maxInstanceCount: 50,
3013
3004
  mergeMeshes: true,
@@ -3019,7 +3010,7 @@ function isSceneObject(obj) {
3019
3010
  }
3020
3011
 
3021
3012
  // src/entity/scene/EntityObject.ts
3022
- var import_ts_deepmerge5 = __toESM(require_dist());
3013
+ var import_ts_deepmerge4 = __toESM(require_dist());
3023
3014
  var import_three11 = require("three");
3024
3015
  var THREE3 = __toESM(require("three"));
3025
3016
  var EntityObject = class extends SceneObject {
@@ -3028,7 +3019,7 @@ var EntityObject = class extends SceneObject {
3028
3019
  this.entity = entity;
3029
3020
  this.isEntityObject = true;
3030
3021
  this.meshesCreated = false;
3031
- this.options = (0, import_ts_deepmerge5.default)({}, SceneObject.DEFAULT_OPTIONS, options ?? {});
3022
+ this.options = (0, import_ts_deepmerge4.default)({}, SceneObject.DEFAULT_OPTIONS, options ?? {});
3032
3023
  }
3033
3024
  async init() {
3034
3025
  this.createMeshes();
@@ -3097,7 +3088,7 @@ var EntityObject = class extends SceneObject {
3097
3088
  }
3098
3089
  }
3099
3090
  };
3100
- EntityObject.DEFAULT_OPTIONS = (0, import_ts_deepmerge5.default)({}, SceneObject.DEFAULT_OPTIONS, {});
3091
+ EntityObject.DEFAULT_OPTIONS = (0, import_ts_deepmerge4.default)({}, SceneObject.DEFAULT_OPTIONS, {});
3101
3092
  function isEntityObject(obj) {
3102
3093
  return obj.isEntityObject;
3103
3094
  }
@@ -4089,7 +4080,7 @@ function computeMorphedAttributes(object) {
4089
4080
  }
4090
4081
 
4091
4082
  // src/model/scene/ModelObject.ts
4092
- var import_ts_deepmerge6 = __toESM(require_dist());
4083
+ var import_ts_deepmerge5 = __toESM(require_dist());
4093
4084
  var p10 = prefix("ModelObject");
4094
4085
  var _ModelObject = class _ModelObject extends SceneObject {
4095
4086
  constructor(originalModel, options) {
@@ -4097,7 +4088,7 @@ var _ModelObject = class _ModelObject extends SceneObject {
4097
4088
  this.originalModel = originalModel;
4098
4089
  this.isModelObject = true;
4099
4090
  this.meshesCreated = false;
4100
- this.options = (0, import_ts_deepmerge6.default)({}, _ModelObject.DEFAULT_OPTIONS, options ?? {});
4091
+ this.options = (0, import_ts_deepmerge5.default)({}, _ModelObject.DEFAULT_OPTIONS, options ?? {});
4101
4092
  console.log("ModelObject options", this.options);
4102
4093
  }
4103
4094
  async init() {
@@ -4197,14 +4188,14 @@ var _ModelObject = class _ModelObject extends SceneObject {
4197
4188
  }
4198
4189
  }
4199
4190
  };
4200
- _ModelObject.DEFAULT_OPTIONS = (0, import_ts_deepmerge6.default)({}, SceneObject.DEFAULT_OPTIONS, {});
4191
+ _ModelObject.DEFAULT_OPTIONS = (0, import_ts_deepmerge5.default)({}, SceneObject.DEFAULT_OPTIONS, {});
4201
4192
  var ModelObject = _ModelObject;
4202
4193
  function isModelObject(obj) {
4203
4194
  return obj.isModelObject;
4204
4195
  }
4205
4196
 
4206
4197
  // src/model/block/scene/BlockObject.ts
4207
- var import_ts_deepmerge7 = __toESM(require_dist());
4198
+ var import_ts_deepmerge6 = __toESM(require_dist());
4208
4199
  var import_three16 = require("three");
4209
4200
  var p11 = prefix("BlockObject");
4210
4201
  var _BlockObject = class _BlockObject extends SceneObject {
@@ -4220,7 +4211,7 @@ var _BlockObject = class _BlockObject extends SceneObject {
4220
4211
  this._instanceModel = [];
4221
4212
  this._variants = [];
4222
4213
  this._models = [];
4223
- this.options = (0, import_ts_deepmerge7.default)({}, _BlockObject.DEFAULT_OPTIONS, options ?? {});
4214
+ this.options = (0, import_ts_deepmerge6.default)({}, _BlockObject.DEFAULT_OPTIONS, options ?? {});
4224
4215
  }
4225
4216
  async init() {
4226
4217
  if (this.options.applyDefaultState) {
@@ -4509,7 +4500,7 @@ var _BlockObject = class _BlockObject extends SceneObject {
4509
4500
  //TODO: should override rotation + scale methods
4510
4501
  //TODO
4511
4502
  };
4512
- _BlockObject.DEFAULT_OPTIONS = (0, import_ts_deepmerge7.default)({}, ModelObject.DEFAULT_OPTIONS, {
4503
+ _BlockObject.DEFAULT_OPTIONS = (0, import_ts_deepmerge6.default)({}, ModelObject.DEFAULT_OPTIONS, {
4513
4504
  applyDefaultState: true
4514
4505
  });
4515
4506
  var BlockObject = _BlockObject;
@@ -4560,7 +4551,7 @@ var StructureParser = class {
4560
4551
 
4561
4552
  // src/renderer/MineRenderScene.ts
4562
4553
  var import_three17 = require("three");
4563
- var import_ts_deepmerge9 = __toESM(require_dist());
4554
+ var import_ts_deepmerge8 = __toESM(require_dist());
4564
4555
 
4565
4556
  // src/skin/SkinPart.ts
4566
4557
  var SkinPart = /* @__PURE__ */ ((SkinPart2) => {
@@ -5291,7 +5282,7 @@ var slimSkinGeometries = {
5291
5282
  };
5292
5283
 
5293
5284
  // src/skin/scene/SkinObject.ts
5294
- var import_ts_deepmerge8 = __toESM(require_dist());
5285
+ var import_ts_deepmerge7 = __toESM(require_dist());
5295
5286
  var SkinObject = class extends SceneObject {
5296
5287
  constructor(options) {
5297
5288
  super();
@@ -5299,7 +5290,7 @@ var SkinObject = class extends SceneObject {
5299
5290
  this.legacy = false;
5300
5291
  this.skinTextureWidth = 64;
5301
5292
  this.skinTextureHeight = 64;
5302
- this.options = (0, import_ts_deepmerge8.default)({}, SceneObject.DEFAULT_OPTIONS, options ?? {});
5293
+ this.options = (0, import_ts_deepmerge7.default)({}, SceneObject.DEFAULT_OPTIONS, options ?? {});
5303
5294
  }
5304
5295
  async init() {
5305
5296
  this.createMeshes();
@@ -5417,7 +5408,7 @@ var _MineRenderScene = class _MineRenderScene extends import_three17.Scene {
5417
5408
  this.dirty = true;
5418
5409
  }
5419
5410
  };
5420
- this.options = (0, import_ts_deepmerge9.default)({}, _MineRenderScene.DEFAULT_OPTIONS, options ?? {});
5411
+ this.options = (0, import_ts_deepmerge8.default)({}, _MineRenderScene.DEFAULT_OPTIONS, options ?? {});
5421
5412
  }
5422
5413
  add(...objects) {
5423
5414
  for (const object of objects) {
@@ -5514,7 +5505,7 @@ var _MineRenderScene = class _MineRenderScene extends import_three17.Scene {
5514
5505
  return this.addSceneObject(entity, () => new EntityObject(entity, options), options, parent);
5515
5506
  }
5516
5507
  };
5517
- _MineRenderScene.DEFAULT_OPTIONS = (0, import_ts_deepmerge9.default)({}, {});
5508
+ _MineRenderScene.DEFAULT_OPTIONS = (0, import_ts_deepmerge8.default)({}, {});
5518
5509
  var MineRenderScene = _MineRenderScene;
5519
5510
  function isMineRenderScene(obj) {
5520
5511
  return obj.isMineRenderScene;
@@ -5522,7 +5513,7 @@ function isMineRenderScene(obj) {
5522
5513
 
5523
5514
  // src/renderer/Renderer.ts
5524
5515
  var import_three19 = require("three");
5525
- var import_ts_deepmerge10 = __toESM(require_dist());
5516
+ var import_ts_deepmerge9 = __toESM(require_dist());
5526
5517
  var import_stats = __toESM(require("stats.js"));
5527
5518
  var import_postprocessing = require("postprocessing");
5528
5519
 
@@ -6179,7 +6170,7 @@ var _Renderer = class _Renderer {
6179
6170
  this._changeListener = () => {
6180
6171
  this._dirty = true;
6181
6172
  };
6182
- this.options = (0, import_ts_deepmerge10.default)({}, _Renderer.DEFAULT_OPTIONS, options ?? {});
6173
+ this.options = (0, import_ts_deepmerge9.default)({}, _Renderer.DEFAULT_OPTIONS, options ?? {});
6183
6174
  this._animationLoop = this.animate.bind(this);
6184
6175
  this._frameInterval = this.options.render.fpsLimit > 0 ? 1e3 / this.options.render.fpsLimit : void 0;
6185
6176
  this._scene = this.createScene();
@@ -6470,7 +6461,7 @@ var _Renderer = class _Renderer {
6470
6461
  }
6471
6462
  ///
6472
6463
  };
6473
- _Renderer.DEFAULT_OPTIONS = (0, import_ts_deepmerge10.default)({}, {
6464
+ _Renderer.DEFAULT_OPTIONS = (0, import_ts_deepmerge9.default)({}, {
6474
6465
  camera: {
6475
6466
  type: "perspective",
6476
6467
  near: 1,