@woosh/meep-engine 2.131.7 → 2.131.9
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 +1 -1
- package/src/core/events/signal/Signal.d.ts +2 -0
- package/src/core/events/signal/Signal.d.ts.map +1 -1
- package/src/core/events/signal/Signal.js +25 -0
- package/src/engine/asset/AssetManager.js +1 -1
- package/src/engine/asset/preloader/AssetPreloader.d.ts +1 -0
- package/src/engine/asset/preloader/AssetPreloader.d.ts.map +1 -1
- package/src/engine/asset/preloader/AssetPreloader.js +16 -9
- package/src/view/asset/PreloaderView.js +2 -2
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.
|
|
8
|
+
"version": "2.131.9",
|
|
9
9
|
"main": "build/meep.module.js",
|
|
10
10
|
"module": "build/meep.module.js",
|
|
11
11
|
"exports": {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Signal.d.ts","sourceRoot":"","sources":["../../../../../src/core/events/signal/Signal.js"],"names":[],"mappings":"AAMA;;;;;;;GAOG;AACH;IACI;;;;OAIG;IACH,iBAAqB;IAErB;;;;OAIG;IACH,cAAU;IAEV;;;OAGG;IACH,YAFU,MAAM,CAED;IAWf;;;OAGG;IACH,yBAEC;IAfD;;;OAGG;IACH,sBAEC;IAYD;;;;OAIG;IACH,cAHW,MAAM;;KAAY,GAChB,IAAI,CAIhB;IAED;;;;OAIG;IACH,gBAHW,MAAM;;KAAY,GAChB,IAAI,CAIhB;IAED;;;;OAIG;IACH,gBAHW,MAAM;;KAAY,SAClB,OAAO,QAQjB;IAED;;;;OAIG;IACH,cAHW,MAAM;;KAAY,GAChB,OAAO,CAInB;IAGD;;;;;OAKG;IACH,4CAFa,OAAO,CAcnB;IAED,aAEC;IAED,eAEC;IAED;;;OAGG;IACH,eAFa,OAAO,CAInB;IAED;;;;OAIG;IACH,yCAQC;IAED;;;;OAIG;IACH,sCAOC;IA8BD;;;;;OAKG;IACH,oCAFa,OAAO,CA2CnB;IAED
|
|
1
|
+
{"version":3,"file":"Signal.d.ts","sourceRoot":"","sources":["../../../../../src/core/events/signal/Signal.js"],"names":[],"mappings":"AAMA;;;;;;;GAOG;AACH;IACI;;;;OAIG;IACH,iBAAqB;IAErB;;;;OAIG;IACH,cAAU;IAEV;;;OAGG;IACH,YAFU,MAAM,CAED;IAWf;;;OAGG;IACH,yBAEC;IAfD;;;OAGG;IACH,sBAEC;IAYD;;;;OAIG;IACH,cAHW,MAAM;;KAAY,GAChB,IAAI,CAIhB;IAED;;;;OAIG;IACH,gBAHW,MAAM;;KAAY,GAChB,IAAI,CAIhB;IAED;;;;OAIG;IACH,gBAHW,MAAM;;KAAY,SAClB,OAAO,QAQjB;IAED;;;;OAIG;IACH,cAHW,MAAM;;KAAY,GAChB,OAAO,CAInB;IAGD;;;;;OAKG;IACH,4CAFa,OAAO,CAcnB;IAED,aAEC;IAED,eAEC;IAED;;;OAGG;IACH,eAFa,OAAO,CAInB;IAED;;;;OAIG;IACH,yCAQC;IAED;;;;OAIG;IACH,sCAOC;IA8BD;;;;;OAKG;IACH,oCAFa,OAAO,CA2CnB;IAED;;;;;;;;OAQG;IACH,kBAEC;IAqDD;;;;;;;;;;;;;;OAcG;IACH,WAZY,QAAQ,EAAE,CAAC,CAkBtB;IAED;;;OAGG;IACH,+BA2CC;IAGD;;;OAGG;IACH,4BA6CC;IAED;;;;OAIG;IACH,sCA4CC;IAED;;;;OAIG;IACH,4CA2CC;IAED;;;;;OAKG;IACH,oDA2CC;IAED;;;;;;OAMG;IACH,4DA2CC;IAED;;;;;;;;OAQG;IACH,4EA2CC;IAED;;;;;;;;;;OAUG;IACH,4FA2CC;IAED;;;;OAIG;IACH,aAHW,MAAM,GACJ,MAAM,CAalB;IAIL;;;OAGG;IACH,mBAFU,OAAO,CAEQ;;CAPxB"}
|
|
@@ -235,6 +235,8 @@ export class Signal {
|
|
|
235
235
|
}
|
|
236
236
|
|
|
237
237
|
/**
|
|
238
|
+
* **UNSAFE**
|
|
239
|
+
*
|
|
238
240
|
* Remove all handlers.
|
|
239
241
|
* Please note that this will remove even all handlers, irrespective of where they were added from. If another script is attaching to the same signal, using this method will potentially break that code.
|
|
240
242
|
* For most use cases, prefer to use {@link remove} method instead, or make use of {@link SignalBinding} if you need to keep track of multiple handlers
|
|
@@ -296,6 +298,29 @@ export class Signal {
|
|
|
296
298
|
return false;
|
|
297
299
|
}
|
|
298
300
|
|
|
301
|
+
/**
|
|
302
|
+
* Utility method, useful in asynchronous programming.
|
|
303
|
+
* Will resolve at the next {@link dispatch}/{@link send0}/etc.
|
|
304
|
+
* @return {Promise<[]>}
|
|
305
|
+
* @see addOne
|
|
306
|
+
*
|
|
307
|
+
* @example
|
|
308
|
+
* const s = new Signal<number,number>();
|
|
309
|
+
*
|
|
310
|
+
* // ...
|
|
311
|
+
* const [x,y] = await s.promise(); // will trigger at the next dispatch
|
|
312
|
+
*
|
|
313
|
+
* // ... then somewhere else
|
|
314
|
+
* s.send2(7,-3);
|
|
315
|
+
*/
|
|
316
|
+
promise(){
|
|
317
|
+
return new Promise((resolve, reject)=>{
|
|
318
|
+
this.addOne((...args)=>{
|
|
319
|
+
resolve(args);
|
|
320
|
+
})
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
|
|
299
324
|
/**
|
|
300
325
|
* NOTE: because of polymorphic call-site nature of this method, it's always better for performance to use monomorphic methods like `send0`, `send1` etc.
|
|
301
326
|
* @param {...*} args
|
|
@@ -273,7 +273,7 @@ export class AssetManager {
|
|
|
273
273
|
* @template T
|
|
274
274
|
* @param {String} path
|
|
275
275
|
* @param {String} type
|
|
276
|
-
* @param {function(asset:Asset<T>)} [callback]
|
|
276
|
+
* @param {function(asset:Asset<T>)} [callback] success callback
|
|
277
277
|
* @param {function(*)} [failure]
|
|
278
278
|
* @param {function(loaded:number, total:number)} [progress]
|
|
279
279
|
* @param {boolean} [skip_queue]
|
|
@@ -35,6 +35,7 @@ export class AssetPreloader {
|
|
|
35
35
|
error: Signal<any, any, any, any, any, any, any, any>;
|
|
36
36
|
loadStart: Signal<any, any, any, any, any, any, any, any>;
|
|
37
37
|
completed: Signal<any, any, any, any, any, any, any, any>;
|
|
38
|
+
resolved: Signal<any, any, any, any, any, any, any, any>;
|
|
38
39
|
};
|
|
39
40
|
/**
|
|
40
41
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AssetPreloader.d.ts","sourceRoot":"","sources":["../../../../../src/engine/asset/preloader/AssetPreloader.js"],"names":[],"mappings":"
|
|
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,5 +1,6 @@
|
|
|
1
1
|
import { assert } from "../../../core/assert.js";
|
|
2
2
|
import Signal from "../../../core/events/signal/Signal.js";
|
|
3
|
+
import { clamp01 } from "../../../core/math/clamp01.js";
|
|
3
4
|
import AssetLevel from "./AssetLevel.js";
|
|
4
5
|
|
|
5
6
|
/**
|
|
@@ -88,7 +89,8 @@ export class AssetPreloader {
|
|
|
88
89
|
levelFinished: new Signal(),
|
|
89
90
|
error: new Signal(),
|
|
90
91
|
loadStart: new Signal(),
|
|
91
|
-
completed: new Signal()
|
|
92
|
+
completed: new Signal(),
|
|
93
|
+
resolved: new Signal(),
|
|
92
94
|
};
|
|
93
95
|
|
|
94
96
|
constructor() {
|
|
@@ -193,7 +195,7 @@ export class AssetPreloader {
|
|
|
193
195
|
const batchElementCount = batch.length;
|
|
194
196
|
|
|
195
197
|
if (batchElementCount === 0) {
|
|
196
|
-
// batch of 0 elements
|
|
198
|
+
// a batch of 0 elements.
|
|
197
199
|
// dispatch completion event
|
|
198
200
|
on.levelFinished.dispatch(level);
|
|
199
201
|
//early exit
|
|
@@ -206,19 +208,22 @@ export class AssetPreloader {
|
|
|
206
208
|
batchElementLoadedCount++;
|
|
207
209
|
numAssetsLoaded++;
|
|
208
210
|
|
|
209
|
-
let
|
|
211
|
+
let total_ratio = numAssets > 0 ? clamp01(numAssetsLoaded / numAssets) : 1;
|
|
212
|
+
|
|
213
|
+
const level_ratio = batchElementCount > 0 ? clamp01(batchElementLoadedCount / batchElementCount) : 1;
|
|
210
214
|
|
|
211
215
|
//dispatch progress
|
|
212
|
-
on.progress.
|
|
216
|
+
on.progress.send1({
|
|
213
217
|
level: {
|
|
214
218
|
id: level,
|
|
215
|
-
|
|
216
|
-
|
|
219
|
+
current: batchElementLoadedCount,
|
|
220
|
+
total: batchElementCount,
|
|
221
|
+
progress: level_ratio,
|
|
217
222
|
},
|
|
218
223
|
global: {
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
224
|
+
current: numAssetsLoaded,
|
|
225
|
+
total: numAssets,
|
|
226
|
+
progress: total_ratio
|
|
222
227
|
}
|
|
223
228
|
});
|
|
224
229
|
|
|
@@ -239,12 +244,14 @@ export class AssetPreloader {
|
|
|
239
244
|
});
|
|
240
245
|
|
|
241
246
|
batch.forEach(function (def) {
|
|
247
|
+
|
|
242
248
|
assetManager.get({
|
|
243
249
|
path: def.uri,
|
|
244
250
|
type: def.type,
|
|
245
251
|
callback: assetLoadSuccess,
|
|
246
252
|
failure: assetLoadFailed
|
|
247
253
|
});
|
|
254
|
+
|
|
248
255
|
});
|
|
249
256
|
}
|
|
250
257
|
|