@woosh/meep-engine 2.48.13 → 2.48.15
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/font/FontAssetLoader.js +2 -2
- package/src/core/math/bessel_3.js +3 -1
- package/src/core/path/computeFileExtension.js +3 -2
- package/src/engine/Engine.js +5 -3
- package/src/engine/achievements/AchievementManager.js +16 -16
- package/src/engine/asset/AssetManager.d.ts +1 -1
- package/src/engine/asset/AssetManager.js +58 -16
- package/src/engine/asset/AssetManager.spec.js +1 -1
- package/src/engine/asset/AssetRequest.js +19 -1
- package/src/engine/asset/AssetRequestScope.d.ts +3 -0
- package/src/engine/asset/AssetRequestScope.js +64 -0
- package/src/engine/asset/PendingAsset.js +1 -1
- package/src/engine/asset/loaders/ArrayBufferLoader.js +1 -1
- package/src/engine/asset/loaders/AssetLoader.d.ts +3 -1
- package/src/engine/asset/loaders/AssetLoader.js +3 -2
- package/src/engine/asset/loaders/GLTFAssetLoader.d.ts +1 -1
- package/src/engine/asset/loaders/GLTFAssetLoader.js +1 -1
- package/src/engine/asset/loaders/JavascriptAssetLoader.js +17 -12
- package/src/engine/asset/loaders/JsonAssetLoader.js +1 -1
- package/src/engine/asset/loaders/LegacyThreeJSONAssetLoader.js +4 -1
- package/src/engine/asset/loaders/SVGAssetLoader.js +1 -1
- package/src/engine/asset/loaders/SoundAssetLoader.js +1 -1
- package/src/engine/asset/loaders/TextAssetLoader.js +1 -1
- package/src/engine/asset/loaders/image/ImageRGBADataLoader.js +24 -17
- package/src/engine/asset/loaders/texture/TextureAssetLoader.d.ts +1 -1
- package/src/engine/asset/loaders/texture/TextureAssetLoader.js +1 -1
- package/src/engine/asset/preloader/Preloader.js +1 -1
- package/src/engine/ecs/foliage/ecs/Foliage2System.js +7 -5
- package/src/engine/ecs/sockets/serialization/AttachmentSocketsAssetLoader.js +2 -2
- package/src/engine/ecs/terrain/ecs/PromiseSamplerHeight.js +16 -9
- package/src/engine/ecs/terrain/ecs/splat/SplatMapping.js +16 -11
- package/src/engine/ecs/terrain/serialization/TerrainSerializationAdapter.js +1 -1
- package/src/engine/graphics/ecs/animation/animator/graph/definition/serialization/AnimationGraphDefinitionAssetLoader.js +18 -15
- package/src/engine/graphics/ecs/mesh/MeshSystem.js +1 -1
- package/src/engine/graphics/ecs/path/tube/build/TubePathBuilder.js +6 -4
- package/src/engine/graphics/material/getTextureImmediate.js +5 -3
- package/src/engine/graphics/texture/atlas/ManagedTextureAtlas.js +1 -1
- package/src/engine/graphics/texture/sampler/Sampler2D.js +20 -11
- package/src/engine/graphics/texture/sampler/filter/box.js +3 -3
- package/src/engine/graphics/texture/sampler/filter/kaiser_bessel_window.js +2 -1
- package/src/engine/graphics/texture/sampler/genericResampleSampler2D.js +9 -8
- package/src/engine/graphics/texture/sampler/loadSampler2D.js +18 -16
- package/src/engine/graphics/texture/sampler/sampler2d_scale_down_linear.js +8 -11
- package/src/engine/graphics/texture/virtual/tile/TileLoader.js +1 -1
- package/src/engine/graphics/trail/x/RibbonXPlugin.js +5 -3
- package/src/engine/knowledge/database/StaticKnowledgeDataTable.js +1 -1
- package/src/engine/navigation/ecs/components/Path.d.ts +2 -0
- package/src/engine/sound/ecs/emitter/loadSoundTrackAsset.js +1 -1
- package/src/view/elements/MeshPreview.js +66 -64
- package/src/view/elements/image/SvgImageView.js +8 -6
- package/src/view/renderModel.js +1 -1
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@ import { FontAsset } from "./FontAsset.js";
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
export class FontAssetLoader extends AssetLoader {
|
|
7
|
-
load(path, success, failure, progress) {
|
|
7
|
+
load(scope,path, success, failure, progress) {
|
|
8
8
|
load(path, function (err, font) {
|
|
9
9
|
if (err) {
|
|
10
10
|
failure(err);
|
|
@@ -15,6 +15,6 @@ export class FontAssetLoader extends AssetLoader {
|
|
|
15
15
|
success(asset);
|
|
16
16
|
|
|
17
17
|
}
|
|
18
|
-
});
|
|
18
|
+
},{});
|
|
19
19
|
}
|
|
20
20
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Kaiser Bessel Function of third kind
|
|
3
|
+
* NOTE: this is an approximation, if input value is sufficiently large - results will be way off
|
|
3
4
|
* @see https://www.shadertoy.com/view/wlf3RH
|
|
4
5
|
* @returns {number}
|
|
5
6
|
* @param {number} x
|
|
@@ -7,5 +8,6 @@
|
|
|
7
8
|
export function bessel_3(x) {
|
|
8
9
|
const y = 0.5 * x;
|
|
9
10
|
const y2 = (y * y);
|
|
10
|
-
return (y2 * y * (1.0 / 6.0 + y2 * (1.0 / 24.0 + y2 * (1.0 / 240.0 + y2 * (1.0 / 4320.0 + y2 / 120960.0)))));
|
|
11
|
+
// return (y2 * y * (1.0 / 6.0 + y2 * (1.0 / 24.0 + y2 * (1.0 / 240.0 + y2 * (1.0 / 4320.0 + y2 / 120960.0)))));
|
|
12
|
+
return (y2 * y * (0.16666666666666666 + y2 * (0.041666666666666664 + y2 * (0.004166666666666667 + y2 * (2.314814814814815E-4 + y2 * 8.267195767195768E-6)))));
|
|
11
13
|
}
|
|
@@ -6,8 +6,9 @@ import { computePathBase } from "./computePathBase.js";
|
|
|
6
6
|
* @returns {String|null}
|
|
7
7
|
*/
|
|
8
8
|
export function computeFileExtension(path) {
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
const type_of_path = typeof path;
|
|
10
|
+
if (type_of_path !== "string") {
|
|
11
|
+
throw new Error(`path must be a string, instead was '${type_of_path}'`);
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
//get base
|
package/src/engine/Engine.js
CHANGED
|
@@ -378,9 +378,11 @@ class Engine {
|
|
|
378
378
|
loadAssetList(listURL) {
|
|
379
379
|
const preloader = new Preloader();
|
|
380
380
|
const assetManager = this.assetManager;
|
|
381
|
-
assetManager.get(
|
|
382
|
-
|
|
383
|
-
|
|
381
|
+
assetManager.get({
|
|
382
|
+
path: listURL, type: "json", callback: function (asset) {
|
|
383
|
+
preloader.addAll(asset.create());
|
|
384
|
+
preloader.load(assetManager);
|
|
385
|
+
}
|
|
384
386
|
});
|
|
385
387
|
return preloader;
|
|
386
388
|
}
|
|
@@ -244,31 +244,31 @@ export class AchievementManager extends EnginePlugin {
|
|
|
244
244
|
loadDefinitions(assetManager) {
|
|
245
245
|
return new Promise((resolve, reject) => {
|
|
246
246
|
assetManager.get(
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
try {
|
|
247
|
+
{
|
|
248
|
+
path: "data/database/achievements/data.json", type: GameAssetType.JSON, callback: (asset) => {
|
|
249
|
+
try {
|
|
251
250
|
|
|
252
|
-
|
|
251
|
+
const json = asset.create();
|
|
253
252
|
|
|
254
|
-
|
|
255
|
-
|
|
253
|
+
json.forEach(def => {
|
|
254
|
+
const achievement = new Achievement();
|
|
256
255
|
|
|
257
|
-
|
|
256
|
+
achievement.fromJSON(def);
|
|
258
257
|
|
|
259
|
-
|
|
260
|
-
|
|
258
|
+
this.entries.push(achievement);
|
|
259
|
+
});
|
|
261
260
|
|
|
262
|
-
|
|
261
|
+
} catch (e) {
|
|
263
262
|
|
|
264
|
-
|
|
263
|
+
reject(e);
|
|
265
264
|
|
|
266
|
-
|
|
267
|
-
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
268
267
|
|
|
269
|
-
|
|
268
|
+
resolve();
|
|
270
269
|
|
|
271
|
-
|
|
270
|
+
}, failure: reject
|
|
271
|
+
});
|
|
272
272
|
});
|
|
273
273
|
}
|
|
274
274
|
|
|
@@ -13,7 +13,7 @@ interface AssetManagerOptions<CTX> {
|
|
|
13
13
|
executor?: ConcurrentExecutor
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
export class AssetManager<CTX> {
|
|
16
|
+
export declare class AssetManager<CTX> {
|
|
17
17
|
constructor(options?: AssetManagerOptions<CTX>)
|
|
18
18
|
|
|
19
19
|
public readonly crossOriginConfig: CrossOriginConfig
|
|
@@ -20,6 +20,9 @@ import FastBinaryHeap from "../../core/collection/heap/FastBinaryHeap.js";
|
|
|
20
20
|
import { AssetLoadState } from "./AssetLoadState.js";
|
|
21
21
|
import { PendingAsset } from "./PendingAsset.js";
|
|
22
22
|
import ConcurrentExecutor from "../../core/process/executor/ConcurrentExecutor.js";
|
|
23
|
+
import { AssetLoader } from "./loaders/AssetLoader.js";
|
|
24
|
+
import { array_push_if_unique } from "../../core/collection/array/array_push_if_unique.js";
|
|
25
|
+
import { AssetRequestScope } from "./AssetRequestScope.js";
|
|
23
26
|
|
|
24
27
|
|
|
25
28
|
class Response {
|
|
@@ -250,12 +253,19 @@ export class AssetManager {
|
|
|
250
253
|
/**
|
|
251
254
|
* @param {String} path
|
|
252
255
|
* @param {String} type
|
|
256
|
+
* @param {AssetRequestScope} [scope]
|
|
253
257
|
* @param {boolean} [skip_queue] if true will skip the queue and dispatch request immediately
|
|
254
258
|
* @returns {Promise<Asset>}
|
|
255
259
|
*/
|
|
256
|
-
promise(path, type, { skip_queue = false } = {}) {
|
|
260
|
+
promise(path, type, { scope, skip_queue = false } = {}) {
|
|
257
261
|
return new Promise((resolve, reject) => {
|
|
258
|
-
this.get(
|
|
262
|
+
this.get({
|
|
263
|
+
path,
|
|
264
|
+
type,
|
|
265
|
+
callback: resolve,
|
|
266
|
+
failure: reject,
|
|
267
|
+
scope
|
|
268
|
+
});
|
|
259
269
|
});
|
|
260
270
|
}
|
|
261
271
|
|
|
@@ -267,10 +277,20 @@ export class AssetManager {
|
|
|
267
277
|
* @param {function(*)} [failure]
|
|
268
278
|
* @param {function(loaded:number, total:number)} [progress]
|
|
269
279
|
* @param {boolean} [skip_queue]
|
|
270
|
-
|
|
271
|
-
|
|
280
|
+
* @param {AssetRequestScope} [scope]
|
|
281
|
+
*/
|
|
282
|
+
get({
|
|
283
|
+
path,
|
|
284
|
+
type,
|
|
285
|
+
callback,
|
|
286
|
+
failure = console.error,
|
|
287
|
+
progress = noop,
|
|
288
|
+
skip_queue = false,
|
|
289
|
+
scope = null
|
|
290
|
+
}) {
|
|
291
|
+
|
|
272
292
|
if (typeof path !== "string") {
|
|
273
|
-
throw new
|
|
293
|
+
throw new TypeError(`Path must be string. instead was '${typeof path}'`);
|
|
274
294
|
}
|
|
275
295
|
|
|
276
296
|
if (typeof type !== "string") {
|
|
@@ -287,6 +307,7 @@ export class AssetManager {
|
|
|
287
307
|
//create request object
|
|
288
308
|
const assetRequest = new AssetRequest(callback, failure, progress);
|
|
289
309
|
|
|
310
|
+
assetRequest.scope = scope;
|
|
290
311
|
assetRequest.writeFlag(AssetRequestFlags.SkipQueue, skip_queue);
|
|
291
312
|
|
|
292
313
|
//submit request
|
|
@@ -539,18 +560,34 @@ export class AssetManager {
|
|
|
539
560
|
pendingAsset.progress.setUpperLimit(total);
|
|
540
561
|
}
|
|
541
562
|
|
|
542
|
-
|
|
543
|
-
|
|
563
|
+
// collect scopes
|
|
564
|
+
const scopes = [];
|
|
544
565
|
|
|
545
|
-
|
|
566
|
+
for (let i = 0; i < requests.length; i++) {
|
|
567
|
+
const request = requests[i];
|
|
568
|
+
const request_scope = request.scope;
|
|
546
569
|
|
|
547
|
-
|
|
570
|
+
if (request_scope !== null) {
|
|
571
|
+
array_push_if_unique(scopes, request_scope)
|
|
572
|
+
}
|
|
573
|
+
}
|
|
548
574
|
|
|
549
|
-
|
|
575
|
+
let scope;
|
|
576
|
+
if (scopes.length > 0) {
|
|
577
|
+
scope = AssetRequestScope.from(scopes);
|
|
578
|
+
} else {
|
|
579
|
+
scope = AssetRequestScope.GLOBAL;
|
|
580
|
+
}
|
|
550
581
|
|
|
551
|
-
loader.load(fullPath, success, failure, progress);
|
|
552
582
|
|
|
553
|
-
|
|
583
|
+
const full_path = this.rootPath + path;
|
|
584
|
+
|
|
585
|
+
// console.log(`Request type: ${type}, path: ${path}, scope: ${scope}`);
|
|
586
|
+
|
|
587
|
+
try {
|
|
588
|
+
|
|
589
|
+
|
|
590
|
+
loader.load(scope, full_path, success, failure, progress);
|
|
554
591
|
|
|
555
592
|
} catch (e) {
|
|
556
593
|
console.error(`Loader failed on invocation. path=${path}, type=${type}`, 'Loader exception: ', e);
|
|
@@ -702,20 +739,25 @@ export class AssetManager {
|
|
|
702
739
|
}
|
|
703
740
|
}
|
|
704
741
|
|
|
705
|
-
if (typeof loader === "function") {
|
|
706
742
|
|
|
743
|
+
let _loader = loader;
|
|
744
|
+
|
|
745
|
+
if (typeof _loader === "function") {
|
|
746
|
+
|
|
747
|
+
_loader = new AssetLoader();
|
|
748
|
+
_loader.load = loader;
|
|
707
749
|
|
|
708
750
|
console.warn(`function-based loaders are deprecated (${type})`);
|
|
709
751
|
|
|
710
752
|
} else {
|
|
711
753
|
|
|
712
|
-
await
|
|
754
|
+
await _loader.link(this, this.#context);
|
|
713
755
|
|
|
714
756
|
}
|
|
715
757
|
|
|
716
|
-
this.#loaders[type] =
|
|
758
|
+
this.#loaders[type] = _loader;
|
|
717
759
|
|
|
718
|
-
return
|
|
760
|
+
return _loader;
|
|
719
761
|
}
|
|
720
762
|
|
|
721
763
|
/**
|
|
@@ -38,7 +38,13 @@ export class AssetRequest {
|
|
|
38
38
|
* Higher priority requests should be handled first
|
|
39
39
|
* @type {number}
|
|
40
40
|
*/
|
|
41
|
-
this.priority =
|
|
41
|
+
this.priority = 1;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
*
|
|
45
|
+
* @type {AssetRequestScope}
|
|
46
|
+
*/
|
|
47
|
+
this.scope = null;
|
|
42
48
|
|
|
43
49
|
/**
|
|
44
50
|
*
|
|
@@ -47,6 +53,18 @@ export class AssetRequest {
|
|
|
47
53
|
this.flags = 0;
|
|
48
54
|
}
|
|
49
55
|
|
|
56
|
+
get scoped_priority() {
|
|
57
|
+
const _p = this.priority;
|
|
58
|
+
|
|
59
|
+
const scope = this.scope;
|
|
60
|
+
|
|
61
|
+
if (scope === null) {
|
|
62
|
+
return _p;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return _p * scope.final_priority;
|
|
66
|
+
}
|
|
67
|
+
|
|
50
68
|
/**
|
|
51
69
|
*
|
|
52
70
|
* @param {number|AssetRequestFlags} flag
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
let id_counter = 0;
|
|
2
|
+
|
|
3
|
+
export class AssetRequestScope {
|
|
4
|
+
id = id_counter++;
|
|
5
|
+
|
|
6
|
+
priority = 1
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
*
|
|
10
|
+
* @type {AssetRequestScope[]}
|
|
11
|
+
*/
|
|
12
|
+
sources = []
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
get final_priority() {
|
|
16
|
+
const sources = this.sources;
|
|
17
|
+
const n = sources.length;
|
|
18
|
+
|
|
19
|
+
if (n === 0) {
|
|
20
|
+
return this.priority;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
let max = sources[0].final_priority;
|
|
25
|
+
|
|
26
|
+
for (let i = 0; i < n; i++) {
|
|
27
|
+
const source = sources[i];
|
|
28
|
+
|
|
29
|
+
const source_priority = source.final_priority;
|
|
30
|
+
|
|
31
|
+
if (source_priority > max) {
|
|
32
|
+
max = source_priority;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return this.priority * max;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
*
|
|
41
|
+
* @param {AssetRequestScope[]} sources
|
|
42
|
+
* @return {AssetRequestScope}
|
|
43
|
+
*/
|
|
44
|
+
static from(sources) {
|
|
45
|
+
const r = new AssetRequestScope();
|
|
46
|
+
|
|
47
|
+
r.sources = sources;
|
|
48
|
+
|
|
49
|
+
return r;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
toString() {
|
|
53
|
+
const sources = this.sources.length > 0 ? `[ ${this.sources.join(', ')} ]` : 'none';
|
|
54
|
+
return `Scope{ id:${this.id}, sources:${sources} }`;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* @readonly
|
|
62
|
+
* @type {Readonly<AssetRequestScope>}
|
|
63
|
+
*/
|
|
64
|
+
AssetRequestScope.GLOBAL = Object.freeze(new AssetRequestScope());
|
|
@@ -22,7 +22,7 @@ export class ArrayBufferLoader extends AssetLoader {
|
|
|
22
22
|
this.__fetch_priority = fetch_priority;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
load(path, success, failure = console.error, progress = noop) {
|
|
25
|
+
load(scope, path, success, failure = console.error, progress = noop) {
|
|
26
26
|
const coc = this.assetManager !== null ? this.assetManager.crossOriginConfig : CrossOriginConfig.default;
|
|
27
27
|
|
|
28
28
|
const headers = new Headers();
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import {Asset} from "../Asset";
|
|
2
|
+
import {AssetRequestScope} from "../AssetRequestScope";
|
|
2
3
|
|
|
3
|
-
export class AssetLoader<T,CTX> {
|
|
4
|
+
export declare class AssetLoader<T, CTX> {
|
|
4
5
|
public load(
|
|
6
|
+
scope: AssetRequestScope,
|
|
5
7
|
path: string,
|
|
6
8
|
success: (asset: Asset<T>) => void,
|
|
7
9
|
failure: (reason: any) => void,
|
|
@@ -11,7 +11,7 @@ export class AssetLoader {
|
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
*
|
|
14
|
-
* @type {
|
|
14
|
+
* @type {CTX}
|
|
15
15
|
*/
|
|
16
16
|
context = null;
|
|
17
17
|
|
|
@@ -34,12 +34,13 @@ export class AssetLoader {
|
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
36
|
*
|
|
37
|
+
* @param {AssetRequestScope} scope
|
|
37
38
|
* @param {string} path
|
|
38
39
|
* @param {function(Asset)} success
|
|
39
40
|
* @param {function} failure
|
|
40
41
|
* @param {function(current:number, total:number)} progress
|
|
41
42
|
*/
|
|
42
|
-
load(path, success, failure, progress) {
|
|
43
|
+
load(scope, path, success, failure, progress) {
|
|
43
44
|
failure('Not Implemented');
|
|
44
45
|
}
|
|
45
46
|
}
|
|
@@ -21,22 +21,27 @@ class JavascriptAsset extends Asset {
|
|
|
21
21
|
|
|
22
22
|
export class JavascriptAssetLoader extends AssetLoader {
|
|
23
23
|
|
|
24
|
-
load(path, success, failure, progress) {
|
|
25
|
-
this.assetManager.get(
|
|
24
|
+
load(scope, path, success, failure, progress) {
|
|
25
|
+
this.assetManager.get({
|
|
26
|
+
path: path,
|
|
27
|
+
scope,
|
|
28
|
+
type: GameAssetType.Text,
|
|
29
|
+
callback: (textAsset) => {
|
|
26
30
|
|
|
27
|
-
|
|
31
|
+
const text = textAsset.create();
|
|
28
32
|
|
|
29
|
-
|
|
33
|
+
let asset;
|
|
30
34
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
try {
|
|
36
|
+
asset = new JavascriptAsset(text);
|
|
37
|
+
} catch (e) {
|
|
38
|
+
failure(e);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
37
41
|
|
|
38
|
-
|
|
42
|
+
success(asset);
|
|
39
43
|
|
|
40
|
-
|
|
44
|
+
}, failure: failure, progress: progress
|
|
45
|
+
});
|
|
41
46
|
}
|
|
42
47
|
}
|
|
@@ -2,7 +2,7 @@ import xhr from "../../network/xhr.js";
|
|
|
2
2
|
import { AssetLoader } from "./AssetLoader.js";
|
|
3
3
|
|
|
4
4
|
export class JsonAssetLoader extends AssetLoader {
|
|
5
|
-
load(path, callback, failure, progress) {
|
|
5
|
+
load(scope, path, callback, failure, progress) {
|
|
6
6
|
xhr(path, function (data) {
|
|
7
7
|
let object;
|
|
8
8
|
try {
|
|
@@ -20,8 +20,11 @@ const placeholderTexture = checkerTexture.create();
|
|
|
20
20
|
|
|
21
21
|
const placeholderMaterial = new ThreeMeshLambertMaterial({ map: placeholderTexture });
|
|
22
22
|
|
|
23
|
+
/**
|
|
24
|
+
* @deprecated
|
|
25
|
+
*/
|
|
23
26
|
export class LegacyThreeJSONAssetLoader extends AssetLoader {
|
|
24
|
-
load(path, success, failure, progress) {
|
|
27
|
+
load(scope, path, success, failure, progress) {
|
|
25
28
|
|
|
26
29
|
console.warn(`JSON loader is deprecated. Attempting to load model '${path}'`);
|
|
27
30
|
|
|
@@ -16,7 +16,7 @@ export class SoundAssetLoader extends AssetLoader {
|
|
|
16
16
|
this.audioContext = context;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
load(path, success, failure, progress) {
|
|
19
|
+
load(scope, path, success, failure, progress) {
|
|
20
20
|
// Load a sound file using an ArrayBuffer XMLHttpRequest.
|
|
21
21
|
const request = new XMLHttpRequest();
|
|
22
22
|
|
|
@@ -2,7 +2,7 @@ import xhr from "../../network/xhr.js";
|
|
|
2
2
|
import { AssetLoader } from "./AssetLoader.js";
|
|
3
3
|
|
|
4
4
|
export class TextAssetLoader extends AssetLoader {
|
|
5
|
-
load(path, callback, failure, progress) {
|
|
5
|
+
load(scope,path, callback, failure, progress) {
|
|
6
6
|
xhr(path, function (data) {
|
|
7
7
|
const asset = {
|
|
8
8
|
create: function () {
|
|
@@ -32,11 +32,12 @@ export class ImageRGBADataLoader extends AssetLoader {
|
|
|
32
32
|
/**
|
|
33
33
|
*
|
|
34
34
|
* @param {string} path
|
|
35
|
+
* @param {AssetRequestScope} scope
|
|
35
36
|
* @returns {Promise<{data:ArrayBuffer, width: number, height:number, itemSize: number, bitDepth:number}>}
|
|
36
37
|
* @private
|
|
37
38
|
*/
|
|
38
|
-
async __decode_via_worker(path) {
|
|
39
|
-
const asset = await this.assetManager.promise(path, ASSET_TYPE_ARRAY_BUFFER);
|
|
39
|
+
async __decode_via_worker(path, scope) {
|
|
40
|
+
const asset = await this.assetManager.promise(path, ASSET_TYPE_ARRAY_BUFFER, { scope });
|
|
40
41
|
|
|
41
42
|
/**
|
|
42
43
|
* @type {ArrayBuffer}
|
|
@@ -49,12 +50,13 @@ export class ImageRGBADataLoader extends AssetLoader {
|
|
|
49
50
|
/**
|
|
50
51
|
*
|
|
51
52
|
* @param {String} path
|
|
53
|
+
* @param {AssetRequestScope} scope
|
|
52
54
|
* @return {Promise<ImageRGBADataAsset>}
|
|
53
55
|
* @private
|
|
54
56
|
*/
|
|
55
|
-
async __standard(path) {
|
|
57
|
+
async __standard(path, scope) {
|
|
56
58
|
|
|
57
|
-
const bitmap = await this.__decode_via_worker(path);
|
|
59
|
+
const bitmap = await this.__decode_via_worker(path, scope);
|
|
58
60
|
|
|
59
61
|
|
|
60
62
|
let data;
|
|
@@ -75,32 +77,37 @@ export class ImageRGBADataLoader extends AssetLoader {
|
|
|
75
77
|
return new ImageRGBADataAsset(data, bitmap.width, bitmap.height, bitmap.itemSize);
|
|
76
78
|
}
|
|
77
79
|
|
|
78
|
-
load(path, success, failure, progress) {
|
|
80
|
+
load(scope, path, success, failure, progress) {
|
|
79
81
|
const extension = computeFileExtension(path);
|
|
80
82
|
|
|
81
83
|
if (extension === 'dds') {
|
|
82
84
|
//compressed texture
|
|
83
|
-
this.assetManager.get(
|
|
85
|
+
this.assetManager.get({
|
|
86
|
+
path: path,
|
|
87
|
+
scope,
|
|
88
|
+
type: GameAssetType.Texture,
|
|
89
|
+
callback: asset => {
|
|
84
90
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
91
|
+
/**
|
|
92
|
+
*
|
|
93
|
+
* @type {Texture}
|
|
94
|
+
*/
|
|
95
|
+
const texture = asset.create();
|
|
90
96
|
|
|
91
|
-
|
|
97
|
+
const sampler2D = convertTexture2Sampler2D(texture);
|
|
92
98
|
|
|
93
|
-
|
|
99
|
+
texture.dispose();
|
|
94
100
|
|
|
95
|
-
|
|
101
|
+
const f = new ImageRGBADataAsset(sampler2D.data, sampler2D.width, sampler2D.height, sampler2D.itemSize);
|
|
96
102
|
|
|
97
|
-
|
|
103
|
+
success(f);
|
|
98
104
|
|
|
99
|
-
|
|
105
|
+
}, failure: failure, progress: progress
|
|
106
|
+
});
|
|
100
107
|
|
|
101
108
|
} else {
|
|
102
109
|
|
|
103
|
-
this.__standard(path).then(success, failure);
|
|
110
|
+
this.__standard(path, scope).then(success, failure);
|
|
104
111
|
|
|
105
112
|
}
|
|
106
113
|
}
|
|
@@ -4,7 +4,7 @@ import { loadStandardImageTexture } from "./loadStandardImageTexture.js";
|
|
|
4
4
|
import { computeFileExtension } from "../../../../core/path/computeFileExtension.js";
|
|
5
5
|
|
|
6
6
|
export class TextureAssetLoader extends AssetLoader {
|
|
7
|
-
load(path, success, failure, progress) {
|
|
7
|
+
load(scope, path, success, failure, progress) {
|
|
8
8
|
//figure out what kind of a texture it is
|
|
9
9
|
let fileExtension = computeFileExtension(path);
|
|
10
10
|
|
|
@@ -158,7 +158,7 @@ Preloader.prototype.load = function (assetManager) {
|
|
|
158
158
|
});
|
|
159
159
|
|
|
160
160
|
batch.forEach(function (def) {
|
|
161
|
-
assetManager.get(def.uri, def.type, assetLoadSuccess, assetLoadFailed);
|
|
161
|
+
assetManager.get({ path: def.uri, type: def.type, callback: assetLoadSuccess, failure: assetLoadFailed });
|
|
162
162
|
});
|
|
163
163
|
}
|
|
164
164
|
|