@woosh/meep-engine 2.131.8 → 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/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": {
|
|
@@ -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
|
|