@woosh/meep-engine 2.131.10 → 2.131.12

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.10",
8
+ "version": "2.131.12",
9
9
  "main": "build/meep.module.js",
10
10
  "module": "build/meep.module.js",
11
11
  "exports": {
@@ -12,7 +12,7 @@
12
12
  * const assetManager:AssetManager = ...; // Obtain your asset manager
13
13
  *
14
14
  * loader.on.progress.add(({global}) => console.log(`loaded ${global.ratio*100}%`));
15
- * loader.on.completed.add(()=> console.log("preload complete"));
15
+ * loader.on.succeeded.add(()=> console.log("preload complete"));
16
16
  *
17
17
  * loader.load(assetManager);
18
18
  */
@@ -31,12 +31,36 @@ export class AssetPreloader {
31
31
  * @readonly
32
32
  */
33
33
  readonly on: {
34
- added: Signal<any, any, any, any, any, any, any, any>;
35
- progress: Signal<any, any, any, any, any, any, any, any>;
36
- levelFinished: Signal<any, any, any, any, any, any, any, any>;
34
+ /**
35
+ * @type {Signal<AssetLoadSpec,number>}
36
+ */
37
+ added: Signal<AssetLoadSpec, number>;
38
+ /**
39
+ * Progress event
40
+ * @type {Signal<?>}
41
+ */
42
+ progress: Signal<unknown>;
43
+ /**
44
+ * Single priority has finished loading
45
+ * @type {Signal}
46
+ */
47
+ levelFinished: Signal;
48
+ /**
49
+ * An asset has failed to load
50
+ */
37
51
  error: Signal<any, any, any, any, any, any, any, any>;
38
- loadStart: Signal<any, any, any, any, any, any, any, any>;
39
- completed: Signal<any, any, any, any, any, any, any, any>;
52
+ started: Signal<any, any, any, any, any, any, any, any>;
53
+ /**
54
+ * Dispatched when all scheduled assets have been successfully loaded (no errors).
55
+ * @type {Signal<number>}
56
+ */
57
+ succeeded: Signal<number>;
58
+ /**
59
+ * All assets are processed, even if some have errored out.
60
+ * This is a more permissive version of {@link succeeded} signal.
61
+ * @type {Signal<number,number>}
62
+ */
63
+ resolved: Signal<number, number>;
40
64
  };
41
65
  /**
42
66
  *
@@ -1 +1 @@
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
+ {"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;QACI;;WAEG;eADO,OAAO,aAAa,EAAC,MAAM,CAAC;QAGtC;;;WAGG;kBADO,eAAS;QAGnB;;;WAGG;uBADO,MAAM;QAGhB;;WAEG;;;QAGH;;;WAGG;mBADO,OAAO,MAAM,CAAC;QAGxB;;;;WAIG;kBADO,OAAO,MAAM,EAAC,MAAM,CAAC;MAGjC;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,CAkKzB;CACJ;AAED;;;GAGG;AACH,wBAFU,cAAc,CAEgB;AAnWxC;;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"}
@@ -66,7 +66,7 @@ class AssetLoadSpec {
66
66
  * const assetManager:AssetManager = ...; // Obtain your asset manager
67
67
  *
68
68
  * loader.on.progress.add(({global}) => console.log(`loaded ${global.ratio*100}%`));
69
- * loader.on.completed.add(()=> console.log("preload complete"));
69
+ * loader.on.succeeded.add(()=> console.log("preload complete"));
70
70
  *
71
71
  * loader.load(assetManager);
72
72
  */
@@ -87,12 +87,36 @@ export class AssetPreloader {
87
87
  * @readonly
88
88
  */
89
89
  on = {
90
+ /**
91
+ * @type {Signal<AssetLoadSpec,number>}
92
+ */
90
93
  added: new Signal(),
94
+ /**
95
+ * Progress event
96
+ * @type {Signal<?>}
97
+ */
91
98
  progress: new Signal(),
99
+ /**
100
+ * Single priority has finished loading
101
+ * @type {Signal}
102
+ */
92
103
  levelFinished: new Signal(),
104
+ /**
105
+ * An asset has failed to load
106
+ */
93
107
  error: new Signal(),
94
- loadStart: new Signal(),
95
- completed: new Signal(),
108
+ started: new Signal(),
109
+ /**
110
+ * Dispatched when all scheduled assets have been successfully loaded (no errors).
111
+ * @type {Signal<number>}
112
+ */
113
+ succeeded: new Signal(),
114
+ /**
115
+ * All assets are processed, even if some have errored out.
116
+ * This is a more permissive version of {@link succeeded} signal.
117
+ * @type {Signal<number,number>}
118
+ */
119
+ resolved: new Signal(),
96
120
  };
97
121
 
98
122
  constructor() {
@@ -185,9 +209,35 @@ export class AssetPreloader {
185
209
  };
186
210
  });
187
211
 
188
- on.loadStart.send1(initEvent);
212
+ on.started.send1(initEvent);
189
213
  const numAssets = this.totalAssetCount;
214
+
190
215
  let numAssetsLoaded = 0;
216
+ let numAssetsFailed = 0;
217
+
218
+ let finished = false;
219
+
220
+ function try_finish() {
221
+ if (finished) {
222
+ // already done
223
+ return;
224
+ }
225
+
226
+ const totalProcessed = numAssetsLoaded + numAssetsFailed;
227
+
228
+ if (totalProcessed <= numAssets) {
229
+ // not done yet
230
+ return;
231
+ }
232
+
233
+ if (numAssetsFailed === 0) {
234
+ on.succeeded.send1(numAssetsLoaded);
235
+ }
236
+
237
+ on.resolved.send2(numAssetsLoaded, numAssetsFailed);
238
+
239
+ finished = true;
240
+ }
191
241
 
192
242
  /**
193
243
  * submit requests in batches in order of importance
@@ -208,6 +258,7 @@ export class AssetPreloader {
208
258
  }
209
259
 
210
260
  let batchElementLoadedCount = 0;
261
+ let batchElementFailedCount = 0;
211
262
 
212
263
  function assetLoadSuccess(asset) {
213
264
  batchElementLoadedCount++;
@@ -233,14 +284,20 @@ export class AssetPreloader {
233
284
  });
234
285
 
235
286
  //monitor completion
236
- if (batchElementLoadedCount >= batchElementCount) {
287
+ if ((batchElementLoadedCount + batchElementFailedCount) >= batchElementCount) {
237
288
  on.levelFinished.dispatch(level);
238
289
  }
239
290
 
291
+ try_finish();
240
292
  }
241
293
 
242
294
  function assetLoadFailed(e) {
295
+ numAssetsFailed++;
296
+ batchElementFailedCount++;
297
+
243
298
  on.error.dispatch(e);
299
+
300
+ try_finish();
244
301
  }
245
302
 
246
303
  //sort batch by priority
@@ -275,7 +332,7 @@ export class AssetPreloader {
275
332
  function prod() {
276
333
 
277
334
  if (lastLoadedLevel < levels.length) {
278
-
335
+
279
336
  // load next
280
337
 
281
338
  const levelToLoad = lastLoadedLevel;
@@ -288,8 +345,6 @@ export class AssetPreloader {
288
345
 
289
346
  // we're done
290
347
 
291
- on.completed.send0();
292
-
293
348
  }
294
349
 
295
350
  }
@@ -61,7 +61,7 @@ class BinaryBufferDeSerializer {
61
61
  task = deserializeTask(numSerializedTypes, buffer, context, dataset, this.registry);
62
62
  }
63
63
 
64
- task.on.completed.add(function () {
64
+ task.on.succeeded.add(function () {
65
65
  const entity_count_after = dataset.entityCount;
66
66
 
67
67
  const execution_time = task.getExecutedCpuTime();
@@ -1,6 +1,10 @@
1
1
  export default PreloaderView;
2
2
  declare class PreloaderView extends View<HTMLElement> {
3
- constructor(preloader: any);
3
+ /**
4
+ *
5
+ * @param {AssetPreloader} preloader
6
+ */
7
+ constructor(preloader: AssetPreloader);
4
8
  el: HTMLDivElement;
5
9
  }
6
10
  import View from "../View.js";
@@ -1 +1 @@
1
- {"version":3,"file":"PreloaderView.d.ts","sourceRoot":"","sources":["../../../../src/view/asset/PreloaderView.js"],"names":[],"mappings":";AAGA;IACI,4BAiDC;IA9Cc,mBAAuC;CA+CzD;iBArDgB,YAAY"}
1
+ {"version":3,"file":"PreloaderView.d.ts","sourceRoot":"","sources":["../../../../src/view/asset/PreloaderView.js"],"names":[],"mappings":";AAGA;IACI;;;OAGG;IACH,uCAiDC;IA9Cc,mBAAuC;CA+CzD;iBAzDgB,YAAY"}
@@ -2,6 +2,10 @@ import SmoothProgressBar from "../elements/progress/SmoothProgressBar.js";
2
2
  import View from "../View.js";
3
3
 
4
4
  class PreloaderView extends View {
5
+ /**
6
+ *
7
+ * @param {AssetPreloader} preloader
8
+ */
5
9
  constructor(preloader) {
6
10
  super();
7
11