@woosh/meep-engine 2.131.9 → 2.131.10

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.
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "description": "Pure JavaScript game engine. Fully featured and production ready.",
6
6
  "type": "module",
7
7
  "author": "Alexander Goldring",
8
- "version": "2.131.9",
8
+ "version": "2.131.10",
9
9
  "main": "build/meep.module.js",
10
10
  "module": "build/meep.module.js",
11
11
  "exports": {
@@ -1,6 +1,8 @@
1
1
  /**
2
2
  * Utility for loading multiple assets together.
3
3
  *
4
+ * NOTE: A pre-loader is not intended to be re-used. You have one collection of assets to be loaded, use one {@link AssetPreloader} instance for it. For another batch - use a separate instance.
5
+ *
4
6
  * @example
5
7
  * const loader = new AssetPreloader();
6
8
  *
@@ -35,7 +37,6 @@ export class AssetPreloader {
35
37
  error: Signal<any, any, any, any, any, any, any, any>;
36
38
  loadStart: Signal<any, any, any, any, any, any, any, any>;
37
39
  completed: Signal<any, any, any, any, any, any, any, any>;
38
- resolved: Signal<any, any, any, any, any, any, any, any>;
39
40
  };
40
41
  /**
41
42
  *
@@ -1 +1 @@
1
- {"version":3,"file":"AssetPreloader.d.ts","sourceRoot":"","sources":["../../../../../src/engine/asset/preloader/AssetPreloader.js"],"names":[],"mappings":"AAqDA;;;;;;;;;;;;;;;GAeG;AACH;IACI;;;OAGG;IACH,iBAFU,MAAM,CAEI;IAEpB;;;OAGG;IACH,iBAFU,aAAa,EAAE,EAAE,CAEf;IAEZ;;OAEG;IACH;;;;;;;;MAQE;IAaF;;;;;;;OAOG;IACH,SANW,MAAM,QACN,MAAM,UACN,MAAM,aACN,MAAM,GACL,cAAc,CAqCzB;IAED;;;OAGG;IACH,aAFW;QAAC,GAAG,EAAC,MAAM,CAAC;QAAC,IAAI,EAAC,MAAM,CAAC;QAAC,KAAK,CAAC,EAAC,MAAM,CAAA;KAAC,EAAE,QAQpD;IAED;;;;OAIG;IACH,kCAFY,cAAc,CAyHzB;CACJ;AAED;;;GAGG;AACH,wBAFU,cAAc,CAEgB;AAjSxC;;GAEG;AACH;IA+BI;;;;OAIG;IACH,4BAFY,aAAa,CAQxB;IAxCG;;;OAGG;IACH,YAAe;IACf;;;OAGG;IACH,aAAgB;IAChB;;;OAGG;IACH,OAFU,MAAM,GAAC,UAAU,CAEK;IAChC;;;OAGG;IACH,UAFU,MAAM,CAEC;IAGrB;;;;;aAKC;CAcJ;mBAlDkB,uCAAuC;uBAEnC,iBAAiB"}
1
+ {"version":3,"file":"AssetPreloader.d.ts","sourceRoot":"","sources":["../../../../../src/engine/asset/preloader/AssetPreloader.js"],"names":[],"mappings":"AAsDA;;;;;;;;;;;;;;;;;GAiBG;AACH;IACI;;;OAGG;IACH,iBAFU,MAAM,CAEI;IAEpB;;;OAGG;IACH,iBAFU,aAAa,EAAE,EAAE,CAEf;IAEZ;;OAEG;IACH;;;;;;;MAOE;IAaF;;;;;;;OAOG;IACH,SANW,MAAM,QACN,MAAM,UACN,MAAM,aACN,MAAM,GACL,cAAc,CAqCzB;IAED;;;OAGG;IACH,aAFW;QAAC,GAAG,EAAC,MAAM,CAAC;QAAC,IAAI,EAAC,MAAM,CAAC;QAAC,KAAK,CAAC,EAAC,MAAM,CAAA;KAAC,EAAE,QAQpD;IAED;;;;OAIG;IACH,kCAFY,cAAc,CAmIzB;CACJ;AAED;;;GAGG;AACH,wBAFU,cAAc,CAEgB;AA5SxC;;GAEG;AACH;IA+BI;;;;OAIG;IACH,4BAFY,aAAa,CAQxB;IAxCG;;;OAGG;IACH,YAAe;IACf;;;OAGG;IACH,aAAgB;IAChB;;;OAGG;IACH,OAFU,MAAM,GAAC,UAAU,CAEK;IAChC;;;OAGG;IACH,UAFU,MAAM,CAEC;IAGrB;;;;;aAKC;CAcJ;mBAlDkB,uCAAuC;uBAEnC,iBAAiB"}
@@ -1,4 +1,5 @@
1
1
  import { assert } from "../../../core/assert.js";
2
+ import { array_push_if_unique } from "../../../core/collection/array/array_push_if_unique.js";
2
3
  import Signal from "../../../core/events/signal/Signal.js";
3
4
  import { clamp01 } from "../../../core/math/clamp01.js";
4
5
  import AssetLevel from "./AssetLevel.js";
@@ -54,6 +55,8 @@ class AssetLoadSpec {
54
55
  /**
55
56
  * Utility for loading multiple assets together.
56
57
  *
58
+ * NOTE: A pre-loader is not intended to be re-used. You have one collection of assets to be loaded, use one {@link AssetPreloader} instance for it. For another batch - use a separate instance.
59
+ *
57
60
  * @example
58
61
  * const loader = new AssetPreloader();
59
62
  *
@@ -90,7 +93,6 @@ export class AssetPreloader {
90
93
  error: new Signal(),
91
94
  loadStart: new Signal(),
92
95
  completed: new Signal(),
93
- resolved: new Signal(),
94
96
  };
95
97
 
96
98
  constructor() {
@@ -167,6 +169,9 @@ export class AssetPreloader {
167
169
  * @return {AssetPreloader}
168
170
  */
169
171
  load(assetManager) {
172
+ assert.defined(assetManager, 'assetManager');
173
+ assert.equal(assetManager.isAssetManager, true, 'assetManager.isAssetManager !== true');
174
+
170
175
  const on = this.on;
171
176
 
172
177
  //current level being processed
@@ -188,7 +193,7 @@ export class AssetPreloader {
188
193
  * submit requests in batches in order of importance
189
194
  * @param {number} level
190
195
  */
191
- function loadBatch(level) {
196
+ function load_level(level) {
192
197
  // filter out assets of the specified level
193
198
  const batch = assets[level];
194
199
 
@@ -243,7 +248,7 @@ export class AssetPreloader {
243
248
  return b.priotity - a.priotity;
244
249
  });
245
250
 
246
- batch.forEach(function (def) {
251
+ for (const def of batch) {
247
252
 
248
253
  assetManager.get({
249
254
  path: def.uri,
@@ -252,14 +257,17 @@ export class AssetPreloader {
252
257
  failure: assetLoadFailed
253
258
  });
254
259
 
255
- });
260
+ }
256
261
  }
257
262
 
263
+ /**
264
+ *
265
+ * @type {number[]}
266
+ */
258
267
  const levels = [];
268
+
259
269
  for (let level in assets) {
260
- if (assets.hasOwnProperty(level)) {
261
- levels.push(level);
262
- }
270
+ array_push_if_unique(levels, level);
263
271
  }
264
272
 
265
273
  let lastLoadedLevel = 0;
@@ -267,17 +275,21 @@ export class AssetPreloader {
267
275
  function prod() {
268
276
 
269
277
  if (lastLoadedLevel < levels.length) {
278
+
279
+ // load next
270
280
 
271
281
  const levelToLoad = lastLoadedLevel;
272
282
  lastLoadedLevel++;
273
283
  on.levelFinished.addOne(prod);
274
284
 
275
- //console.log('requesting load of level ',levelToLoad);
276
-
277
- loadBatch(levelToLoad);
285
+ load_level(levelToLoad);
278
286
 
279
287
  } else {
288
+
289
+ // we're done
290
+
280
291
  on.completed.send0();
292
+
281
293
  }
282
294
 
283
295
  }