@galacean/engine 1.3.19 → 1.3.20

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/dist/browser.js CHANGED
@@ -288,6 +288,16 @@
288
288
  return this;
289
289
  };
290
290
  /**
291
+ * Copy to vector3 like object.
292
+ * @param target - Vector3 like object
293
+ * @returns This Vector3 like object
294
+ */ _proto.copyTo = function copyTo(target) {
295
+ target.x = this._x;
296
+ target.y = this._y;
297
+ target.z = this._z;
298
+ return target;
299
+ };
300
+ /**
291
301
  * Copy the value of this vector from an array.
292
302
  * @param array - The array
293
303
  * @param offset - The start offset of the array
@@ -2206,6 +2216,17 @@
2206
2216
  return this;
2207
2217
  };
2208
2218
  /**
2219
+ * Copy this quaternion to the specified quaternion.
2220
+ * @param target - The specified quaternion
2221
+ * @returns This specified quaternion
2222
+ */ _proto.copyTo = function copyTo(target) {
2223
+ target.x = this._x;
2224
+ target.y = this._y;
2225
+ target.z = this._z;
2226
+ target.w = this._w;
2227
+ return target;
2228
+ };
2229
+ /**
2209
2230
  * Copy the value of this quaternion from an array.
2210
2231
  * @param array - The array
2211
2232
  * @param offset - The start offset of the array
@@ -3771,6 +3792,15 @@
3771
3792
  return this;
3772
3793
  };
3773
3794
  /**
3795
+ * Copy to vector2 like object.
3796
+ * @param target - Vector2 like object
3797
+ * @returns This Vector2 like object
3798
+ */ _proto.copyTo = function copyTo(target) {
3799
+ target.x = this._x;
3800
+ target.y = this._y;
3801
+ return target;
3802
+ };
3803
+ /**
3774
3804
  * Copy the value of this vector from an array.
3775
3805
  * @param array - The array
3776
3806
  * @param offset - The start offset of the array
@@ -4117,6 +4147,17 @@
4117
4147
  return this;
4118
4148
  };
4119
4149
  /**
4150
+ * Copy to vector4 like object.
4151
+ * @param target - Vector4 like object
4152
+ * @returns This Vector4 like object
4153
+ */ _proto.copyTo = function copyTo(target) {
4154
+ target.x = this._x;
4155
+ target.y = this._y;
4156
+ target.z = this._z;
4157
+ target.w = this._w;
4158
+ return target;
4159
+ };
4160
+ /**
4120
4161
  * Copy the value of this vector by an array.
4121
4162
  * @param array - The array
4122
4163
  * @param offset - The start offset of the array
@@ -4486,6 +4527,17 @@
4486
4527
  return this;
4487
4528
  };
4488
4529
  /**
4530
+ * Copy to color like object.
4531
+ * @param target - Color like object.
4532
+ * @returns This Color like object
4533
+ */ _proto.copyTo = function copyTo(target) {
4534
+ target.r = this._r;
4535
+ target.g = this._g;
4536
+ target.b = this._b;
4537
+ target.a = this._a;
4538
+ return target;
4539
+ };
4540
+ /**
4489
4541
  * Copy from array like object.
4490
4542
  * @param source - Array like object
4491
4543
  * @param offset - The start offset
@@ -23417,8 +23469,20 @@
23417
23469
  mesh.setVertexElements([
23418
23470
  new VertexElement("POSITION_UV", 0, exports.VertexElementFormat.Vector4, 0)
23419
23471
  ]);
23420
- mesh.setVertexBufferBinding(new Buffer(engine, exports.BufferBindFlag.VertexBuffer, vertices, exports.BufferUsage.Static), 16);
23472
+ var buffer = new Buffer(engine, exports.BufferBindFlag.VertexBuffer, vertices, exports.BufferUsage.Static, true);
23473
+ mesh.setVertexBufferBinding(buffer, 16);
23421
23474
  mesh.addSubMesh(0, 3, exports.MeshTopology.Triangles);
23475
+ engine.resourceManager.addContentRestorer(new /*#__PURE__*/ (function(ContentRestorer) {
23476
+ var _class = function _class() {
23477
+ return ContentRestorer.call(this, mesh);
23478
+ };
23479
+ _inherits$2(_class, ContentRestorer);
23480
+ var _proto = _class.prototype;
23481
+ _proto.restoreContent = function restoreContent() {
23482
+ buffer.setData(buffer.data);
23483
+ };
23484
+ return _class;
23485
+ }(ContentRestorer))());
23422
23486
  return mesh;
23423
23487
  };
23424
23488
  _proto._create1x1Texture = function _create1x1Texture(engine, type, format, pixel) {
@@ -24197,6 +24261,150 @@
24197
24261
  PromiseState["Rejected"] = "rejected";
24198
24262
  PromiseState["Canceled"] = "canceled";
24199
24263
  })(PromiseState || (PromiseState = {}));
24264
+ var mimeType = {
24265
+ json: "json",
24266
+ gltf: "json",
24267
+ mtl: "json",
24268
+ prefab: "json",
24269
+ txt: "text",
24270
+ bin: "arraybuffer",
24271
+ png: "image",
24272
+ webp: "image",
24273
+ jpg: "image"
24274
+ };
24275
+ var defaultRetryCount = 1;
24276
+ var defaultTimeout = Infinity;
24277
+ var defaultInterval = 500;
24278
+ /**
24279
+ * Web request.
24280
+ * @param url - The link
24281
+ * @param config - Load configuration
24282
+ */ function request(url, config) {
24283
+ if (config === void 0) config = {};
24284
+ return new AssetPromise(function(resolve, reject, setTaskCompleteProgress, setTaskDetailProgress) {
24285
+ var _config_retryCount;
24286
+ var retryCount = (_config_retryCount = config.retryCount) != null ? _config_retryCount : defaultRetryCount;
24287
+ var _config_retryInterval;
24288
+ var retryInterval = (_config_retryInterval = config.retryInterval) != null ? _config_retryInterval : defaultInterval;
24289
+ var _config_timeout;
24290
+ config.timeout = (_config_timeout = config.timeout) != null ? _config_timeout : defaultTimeout;
24291
+ var _config_type;
24292
+ config.type = (_config_type = config.type) != null ? _config_type : getMimeTypeFromUrl(url);
24293
+ var executor = new MultiExecutor(function() {
24294
+ return requestRes(url, config).onProgress(setTaskCompleteProgress, setTaskDetailProgress);
24295
+ }, retryCount, retryInterval);
24296
+ executor.start().onError(reject).onComplete(resolve);
24297
+ });
24298
+ }
24299
+ function requestRes(url, config) {
24300
+ return new AssetPromise(function(resolve, reject, setTaskCompleteProgress, setTaskDetailProgress) {
24301
+ var xhr = new XMLHttpRequest();
24302
+ var isImg = config.type === "image";
24303
+ xhr.timeout = config.timeout;
24304
+ var _config_method;
24305
+ config.method = (_config_method = config.method) != null ? _config_method : "get";
24306
+ xhr.onload = function() {
24307
+ if (xhr.status < 200 || xhr.status >= 300) {
24308
+ reject(new Error("request failed from: " + url));
24309
+ return;
24310
+ }
24311
+ var _xhr_response;
24312
+ var result = (_xhr_response = xhr.response) != null ? _xhr_response : xhr.responseText;
24313
+ if (isImg) {
24314
+ var img = new Image();
24315
+ img.onload = function() {
24316
+ // Call requestAnimationFrame to avoid iOS's bug.
24317
+ requestAnimationFrame(function() {
24318
+ setTaskCompleteProgress(1, 1);
24319
+ //@ts-ignore
24320
+ resolve(img);
24321
+ img.onload = null;
24322
+ img.onerror = null;
24323
+ img.onabort = null;
24324
+ URL.revokeObjectURL(img.src);
24325
+ });
24326
+ };
24327
+ img.onerror = img.onabort = function() {
24328
+ reject(new Error("request " + img.src + " fail"));
24329
+ URL.revokeObjectURL(img.src);
24330
+ };
24331
+ img.crossOrigin = "anonymous";
24332
+ img.src = URL.createObjectURL(result);
24333
+ } else {
24334
+ setTaskCompleteProgress(1, 1);
24335
+ resolve(result);
24336
+ }
24337
+ };
24338
+ xhr.onerror = function() {
24339
+ reject(new Error("request failed from: " + url));
24340
+ };
24341
+ xhr.ontimeout = function() {
24342
+ reject(new Error("request timeout from: " + url));
24343
+ };
24344
+ xhr.onprogress = function(e) {
24345
+ if (e.lengthComputable) {
24346
+ setTaskDetailProgress(url, e.loaded, e.total);
24347
+ }
24348
+ };
24349
+ xhr.open(config.method, url, true);
24350
+ xhr.withCredentials = config.credentials === "include";
24351
+ // @ts-ignore
24352
+ xhr.responseType = isImg ? "blob" : config.type;
24353
+ var headers = config.headers;
24354
+ if (headers) {
24355
+ Object.keys(headers).forEach(function(name1) {
24356
+ xhr.setRequestHeader(name1, headers[name1]);
24357
+ });
24358
+ }
24359
+ // @ts-ignore
24360
+ xhr.send(config.body);
24361
+ });
24362
+ }
24363
+ function getMimeTypeFromUrl(url) {
24364
+ var extname = url.substring(url.lastIndexOf(".") + 1);
24365
+ return mimeType[extname];
24366
+ }
24367
+ var MultiExecutor = /*#__PURE__*/ function() {
24368
+ var MultiExecutor = function MultiExecutor(execFunc, totalCount, interval) {
24369
+ this.execFunc = execFunc;
24370
+ this.totalCount = totalCount;
24371
+ this.interval = interval;
24372
+ this._timeoutId = -100;
24373
+ this._currentCount = 0;
24374
+ this.exec = this.exec.bind(this);
24375
+ };
24376
+ var _proto = MultiExecutor.prototype;
24377
+ _proto.start = function start() {
24378
+ this.exec();
24379
+ return this;
24380
+ };
24381
+ _proto.onComplete = function onComplete(func) {
24382
+ this._onComplete = func;
24383
+ return this;
24384
+ };
24385
+ _proto.onError = function onError(func) {
24386
+ this._onError = func;
24387
+ return this;
24388
+ };
24389
+ _proto.cancel = function cancel() {
24390
+ window.clearTimeout(this._timeoutId);
24391
+ };
24392
+ _proto.exec = function exec() {
24393
+ var _this = this;
24394
+ if (this._currentCount >= this.totalCount) {
24395
+ this._onError && this._onError(this._error);
24396
+ return;
24397
+ }
24398
+ this._currentCount++;
24399
+ this.execFunc(this._currentCount).then(function(result) {
24400
+ return _this._onComplete && _this._onComplete(result);
24401
+ }).catch(function(e) {
24402
+ _this._error = e;
24403
+ _this._timeoutId = window.setTimeout(_this.exec, _this.interval);
24404
+ });
24405
+ };
24406
+ return MultiExecutor;
24407
+ }();
24200
24408
  /**
24201
24409
  * ResourceManager
24202
24410
  */ var ResourceManager = /*#__PURE__*/ function() {
@@ -24291,6 +24499,23 @@
24291
24499
  };
24292
24500
  /**
24293
24501
  * @internal
24502
+ */ _proto._getRemoteUrl = function _getRemoteUrl(url) {
24503
+ var _this__virtualPathMap_url;
24504
+ return (_this__virtualPathMap_url = this._virtualPathMap[url]) != null ? _this__virtualPathMap_url : url;
24505
+ };
24506
+ /**
24507
+ * @internal
24508
+ */ _proto._requestByRemoteUrl = function _requestByRemoteUrl(url, config) {
24509
+ return request(url, config);
24510
+ };
24511
+ /**
24512
+ * @internal
24513
+ */ _proto._request = function _request(url, config) {
24514
+ var remoteUrl = this._getRemoteUrl(url);
24515
+ return this._requestByRemoteUrl(remoteUrl, config);
24516
+ };
24517
+ /**
24518
+ * @internal
24294
24519
  */ _proto._onSubAssetSuccess = function _onSubAssetSuccess(assetBaseURL, assetSubPath, value) {
24295
24520
  var _this__subAssetPromiseCallbacks_remoteAssetBaseURL;
24296
24521
  var _this__virtualPathMap_assetBaseURL;
@@ -28744,7 +28969,21 @@
28744
28969
  mesh.uploadData(false);
28745
28970
  };
28746
28971
  _proto._initMesh = function _initMesh(engine) {
28747
- this._mesh = this._createPlane(engine);
28972
+ var mesh = this._mesh = this._createPlane(engine);
28973
+ engine.resourceManager.addContentRestorer(new /*#__PURE__*/ (function(ContentRestorer) {
28974
+ var _class = function _class() {
28975
+ return ContentRestorer.call(this, mesh);
28976
+ };
28977
+ _inherits$2(_class, ContentRestorer);
28978
+ var _proto = _class.prototype;
28979
+ _proto.restoreContent = function restoreContent() {
28980
+ mesh.setPositions(mesh.getPositions());
28981
+ mesh.setUVs(mesh.getUVs());
28982
+ mesh.setIndices(mesh.getIndices());
28983
+ mesh.uploadData(false);
28984
+ };
28985
+ return _class;
28986
+ }(ContentRestorer))());
28748
28987
  this._mesh._addReferCount(1);
28749
28988
  };
28750
28989
  _proto._initMaterial = function _initMaterial(engine) {
@@ -30962,162 +31201,12 @@
30962
31201
  __decorate$1([
30963
31202
  ignoreClone
30964
31203
  ], Script.prototype, "_entityScriptsIndex", void 0);
30965
- var mimeType = {
30966
- json: "json",
30967
- gltf: "json",
30968
- mtl: "json",
30969
- prefab: "json",
30970
- txt: "text",
30971
- bin: "arraybuffer",
30972
- png: "image",
30973
- webp: "image",
30974
- jpg: "image"
30975
- };
30976
- var defaultRetryCount = 1;
30977
- var defaultTimeout = Infinity;
30978
- var defaultInterval = 500;
30979
- /**
30980
- * Web request.
30981
- * @param url - The link
30982
- * @param config - Load configuration
30983
- */ function request(url, config) {
30984
- if (config === void 0) config = {};
30985
- return new AssetPromise(function(resolve, reject, setTaskCompleteProgress, setTaskDetailProgress) {
30986
- var _config_retryCount;
30987
- var retryCount = (_config_retryCount = config.retryCount) != null ? _config_retryCount : defaultRetryCount;
30988
- var _config_retryInterval;
30989
- var retryInterval = (_config_retryInterval = config.retryInterval) != null ? _config_retryInterval : defaultInterval;
30990
- var _config_timeout;
30991
- config.timeout = (_config_timeout = config.timeout) != null ? _config_timeout : defaultTimeout;
30992
- var _config_type;
30993
- config.type = (_config_type = config.type) != null ? _config_type : getMimeTypeFromUrl(url);
30994
- var executor = new MultiExecutor(function() {
30995
- return requestRes(url, config).onProgress(setTaskCompleteProgress, setTaskDetailProgress);
30996
- }, retryCount, retryInterval);
30997
- executor.start().onError(reject).onComplete(resolve);
30998
- });
30999
- }
31000
- function requestRes(url, config) {
31001
- return new AssetPromise(function(resolve, reject, setTaskCompleteProgress, setTaskDetailProgress) {
31002
- var xhr = new XMLHttpRequest();
31003
- var isImg = config.type === "image";
31004
- xhr.timeout = config.timeout;
31005
- var _config_method;
31006
- config.method = (_config_method = config.method) != null ? _config_method : "get";
31007
- xhr.onload = function() {
31008
- if (xhr.status < 200 || xhr.status >= 300) {
31009
- reject(new Error("request failed from: " + url));
31010
- return;
31011
- }
31012
- var _xhr_response;
31013
- var result = (_xhr_response = xhr.response) != null ? _xhr_response : xhr.responseText;
31014
- if (isImg) {
31015
- var img = new Image();
31016
- img.onload = function() {
31017
- // Call requestAnimationFrame to avoid iOS's bug.
31018
- requestAnimationFrame(function() {
31019
- setTaskCompleteProgress(1, 1);
31020
- //@ts-ignore
31021
- resolve(img);
31022
- img.onload = null;
31023
- img.onerror = null;
31024
- img.onabort = null;
31025
- URL.revokeObjectURL(img.src);
31026
- });
31027
- };
31028
- img.onerror = img.onabort = function() {
31029
- reject(new Error("request " + img.src + " fail"));
31030
- URL.revokeObjectURL(img.src);
31031
- };
31032
- img.crossOrigin = "anonymous";
31033
- img.src = URL.createObjectURL(result);
31034
- } else {
31035
- setTaskCompleteProgress(1, 1);
31036
- resolve(result);
31037
- }
31038
- };
31039
- xhr.onerror = function() {
31040
- reject(new Error("request failed from: " + url));
31041
- };
31042
- xhr.ontimeout = function() {
31043
- reject(new Error("request timeout from: " + url));
31044
- };
31045
- xhr.onprogress = function(e) {
31046
- if (e.lengthComputable) {
31047
- setTaskDetailProgress(url, e.loaded, e.total);
31048
- }
31049
- };
31050
- xhr.open(config.method, url, true);
31051
- xhr.withCredentials = config.credentials === "include";
31052
- // @ts-ignore
31053
- xhr.responseType = isImg ? "blob" : config.type;
31054
- var headers = config.headers;
31055
- if (headers) {
31056
- Object.keys(headers).forEach(function(name1) {
31057
- xhr.setRequestHeader(name1, headers[name1]);
31058
- });
31059
- }
31060
- // @ts-ignore
31061
- xhr.send(config.body);
31062
- });
31063
- }
31064
- function getMimeTypeFromUrl(url) {
31065
- var extname = url.substring(url.lastIndexOf(".") + 1);
31066
- return mimeType[extname];
31067
- }
31068
- var MultiExecutor = /*#__PURE__*/ function() {
31069
- var MultiExecutor = function MultiExecutor(execFunc, totalCount, interval) {
31070
- this.execFunc = execFunc;
31071
- this.totalCount = totalCount;
31072
- this.interval = interval;
31073
- this._timeoutId = -100;
31074
- this._currentCount = 0;
31075
- this.exec = this.exec.bind(this);
31076
- };
31077
- var _proto = MultiExecutor.prototype;
31078
- _proto.start = function start() {
31079
- this.exec();
31080
- return this;
31081
- };
31082
- _proto.onComplete = function onComplete(func) {
31083
- this._onComplete = func;
31084
- return this;
31085
- };
31086
- _proto.onError = function onError(func) {
31087
- this._onError = func;
31088
- return this;
31089
- };
31090
- _proto.cancel = function cancel() {
31091
- window.clearTimeout(this._timeoutId);
31092
- };
31093
- _proto.exec = function exec() {
31094
- var _this = this;
31095
- if (this._currentCount >= this.totalCount) {
31096
- this._onError && this._onError(this._error);
31097
- return;
31098
- }
31099
- this._currentCount++;
31100
- this.execFunc(this._currentCount).then(function(result) {
31101
- return _this._onComplete && _this._onComplete(result);
31102
- }).catch(function(e) {
31103
- _this._error = e;
31104
- _this._timeoutId = window.setTimeout(_this.exec, _this.interval);
31105
- });
31106
- };
31107
- return MultiExecutor;
31108
- }();
31109
31204
  /**
31110
31205
  * Loader abstract class.
31111
31206
  */ var Loader = /*#__PURE__*/ function() {
31112
31207
  var Loader = function Loader(useCache) {
31113
31208
  this.useCache = useCache;
31114
31209
  };
31115
- var _proto = Loader.prototype;
31116
- _proto.request = function request1(url, resourceManager, config) {
31117
- var _resourceManager__virtualPathMap_url;
31118
- var remoteUrl = (_resourceManager__virtualPathMap_url = resourceManager._virtualPathMap[url]) != null ? _resourceManager__virtualPathMap_url : url;
31119
- return request(remoteUrl, config);
31120
- };
31121
31210
  /**
31122
31211
  * Register a class with a string name for serialization and deserialization.
31123
31212
  * @param key - class name
@@ -36033,6 +36122,7 @@
36033
36122
  /** Control how the Particle Generator applies its Transform component to the particles it emits. */ this.scalingMode = exports.ParticleScaleMode.Local;
36034
36123
  /** If set to true, the Particle Generator automatically begins to play on startup. */ this.playOnEnabled = true;
36035
36124
  /** @internal */ this._maxParticleBuffer = 1000;
36125
+ /** @internal */ this._startDelayRand = new Rand(0, ParticleRandomSubSeeds.StartDelay);
36036
36126
  /** @internal */ this._startSpeedRand = new Rand(0, ParticleRandomSubSeeds.StartSpeed);
36037
36127
  /** @internal */ this._startLifeTimeRand = new Rand(0, ParticleRandomSubSeeds.StartLifetime);
36038
36128
  /** @internal */ this._startColorRand = new Rand(0, ParticleRandomSubSeeds.StartColor);
@@ -36317,6 +36407,9 @@
36317
36407
  __decorate$1([
36318
36408
  ignoreClone
36319
36409
  ], MainModule.prototype, "_maxParticleBuffer", void 0);
36410
+ __decorate$1([
36411
+ ignoreClone
36412
+ ], MainModule.prototype, "_startDelayRand", void 0);
36320
36413
  __decorate$1([
36321
36414
  ignoreClone
36322
36415
  ], MainModule.prototype, "_startSpeedRand", void 0);
@@ -37155,6 +37248,7 @@
37155
37248
  this._transformedBoundsCount = 0;
37156
37249
  this._firstActiveTransformedBoundingBox = 0;
37157
37250
  this._firstFreeTransformedBoundingBox = 0;
37251
+ this._playStartDelay = 0;
37158
37252
  this._renderer = renderer;
37159
37253
  var subPrimitive = new SubPrimitive();
37160
37254
  subPrimitive.start = 0;
@@ -37183,6 +37277,7 @@
37183
37277
  if (this.useAutoRandomSeed) {
37184
37278
  this._resetGlobalRandSeed(Math.floor(Math.random() * 0xffffffff)); // 2^32 - 1
37185
37279
  }
37280
+ this._playStartDelay = this.main.startDelay.evaluate(undefined, this.main._startDelayRand.random());
37186
37281
  }
37187
37282
  };
37188
37283
  /**
@@ -37252,7 +37347,18 @@
37252
37347
  var _this = this, main = _this.main, emission = _this.emission;
37253
37348
  var duration = main.duration;
37254
37349
  var lastPlayTime = this._playTime;
37255
- this._playTime += elapsedTime * main.simulationSpeed;
37350
+ var deltaTime = elapsedTime * main.simulationSpeed;
37351
+ // Process start delay time
37352
+ if (this._playStartDelay > 0) {
37353
+ var remainingDelay = this._playStartDelay -= deltaTime;
37354
+ if (remainingDelay < 0) {
37355
+ this._playTime -= remainingDelay;
37356
+ this._playStartDelay = 0;
37357
+ } else {
37358
+ return;
37359
+ }
37360
+ }
37361
+ this._playTime += deltaTime;
37256
37362
  this._retireActiveParticles();
37257
37363
  this._freeRetiredParticles();
37258
37364
  if (main.simulationSpace === exports.ParticleSimulationSpace.World) {
@@ -38029,6 +38135,9 @@
38029
38135
  __decorate$1([
38030
38136
  ignoreClone
38031
38137
  ], ParticleGenerator.prototype, "_firstFreeTransformedBoundingBox", void 0);
38138
+ __decorate$1([
38139
+ ignoreClone
38140
+ ], ParticleGenerator.prototype, "_playStartDelay", void 0);
38032
38141
  /**
38033
38142
  * Particle Material.
38034
38143
  */ var ParticleMaterial = /*#__PURE__*/ function(BaseMaterial1) {
@@ -42678,9 +42787,9 @@
42678
42787
  _inherits(EditorTextureLoader, Loader1);
42679
42788
  var _proto = EditorTextureLoader.prototype;
42680
42789
  _proto.load = function load(item, resourceManager) {
42681
- var _this = this;
42682
42790
  return new AssetPromise(function(resolve, reject) {
42683
- _this.request(item.url, resourceManager, _extends({}, item, {
42791
+ resourceManager // @ts-ignore
42792
+ ._request(item.url, _extends({}, item, {
42684
42793
  type: "arraybuffer"
42685
42794
  })).then(function(data) {
42686
42795
  decode(data, resourceManager.engine).then(function(texture) {
@@ -42718,7 +42827,8 @@
42718
42827
  _proto.load = function load(item, resourceManager) {
42719
42828
  var _this = this;
42720
42829
  return new AssetPromise(function(resolve, reject) {
42721
- _this.request(item.url, resourceManager, _extends({}, item, {
42830
+ resourceManager // @ts-ignore
42831
+ ._request(item.url, _extends({}, item, {
42722
42832
  type: "arraybuffer"
42723
42833
  })).then(function(data) {
42724
42834
  return decode(data, resourceManager.engine).then(function(clip) {
@@ -42769,7 +42879,8 @@
42769
42879
  _proto.load = function load(item, resourceManager) {
42770
42880
  var _this = this;
42771
42881
  return new AssetPromise(function(resolve, reject) {
42772
- _this.request(item.url, resourceManager, _extends({}, item, {
42882
+ resourceManager // @ts-ignore
42883
+ ._request(item.url, _extends({}, item, {
42773
42884
  type: "json"
42774
42885
  })).then(function(data) {
42775
42886
  var animatorController = new AnimatorController(resourceManager.engine);
@@ -42884,7 +42995,8 @@
42884
42995
  resolve(result.buffer);
42885
42996
  });
42886
42997
  }
42887
- return this.request(url, resourceManager, _extends({}, item, {
42998
+ // @ts-ignore
42999
+ return resourceManager._request(url, _extends({}, item, {
42888
43000
  type: "arraybuffer"
42889
43001
  }));
42890
43002
  };
@@ -42903,9 +43015,9 @@
42903
43015
  _inherits(EnvLoader, Loader1);
42904
43016
  var _proto = EnvLoader.prototype;
42905
43017
  _proto.load = function load(item, resourceManager) {
42906
- var _this = this;
42907
43018
  return new AssetPromise(function(resolve, reject) {
42908
- _this.request(item.url, resourceManager, _extends({}, item, {
43019
+ resourceManager // @ts-ignore
43020
+ ._request(item.url, _extends({}, item, {
42909
43021
  type: "arraybuffer"
42910
43022
  })).then(function(arraybuffer) {
42911
43023
  var _this;
@@ -42981,7 +43093,8 @@
42981
43093
  _proto.load = function load(item, resourceManager) {
42982
43094
  var _this = this;
42983
43095
  return new AssetPromise(function(resolve, reject) {
42984
- _this.request(item.url, resourceManager, _extends({}, item, {
43096
+ resourceManager // @ts-ignore
43097
+ ._request(item.url, _extends({}, item, {
42985
43098
  type: "json"
42986
43099
  })).then(function(data) {
42987
43100
  var fontName = data.fontName, fontUrl = data.fontUrl;
@@ -43721,28 +43834,29 @@
43721
43834
  BIN: 0x004e4942
43722
43835
  };
43723
43836
  var dataView = new DataView(originBuffer);
43724
- // read header
43837
+ // Read header
43725
43838
  var header = {
43726
43839
  magic: dataView.getUint32(0, true),
43727
43840
  version: dataView.getUint32(UINT32_LENGTH, true),
43728
43841
  length: dataView.getUint32(2 * UINT32_LENGTH, true)
43729
43842
  };
43843
+ // Return the original buffer if it is not a glb
43730
43844
  if (header.magic !== GLB_HEADER_MAGIC) {
43731
43845
  return {
43732
43846
  originBuffer: originBuffer
43733
43847
  };
43734
43848
  }
43735
- // read main data
43849
+ // Read main data
43736
43850
  var chunkLength = dataView.getUint32(GLB_HEADER_LENGTH, true);
43737
43851
  var chunkType = dataView.getUint32(GLB_HEADER_LENGTH + UINT32_LENGTH, true);
43738
- // read glTF json
43852
+ // Read glTF json
43739
43853
  if (chunkType !== GLB_CHUNK_TYPES.JSON) {
43740
43854
  console.error("Invalid glb chunk type. Expected 0x4E4F534A, found 0x" + chunkType.toString(16));
43741
43855
  return null;
43742
43856
  }
43743
43857
  var glTFData = new Uint8Array(originBuffer, GLB_HEADER_LENGTH + 2 * UINT32_LENGTH, chunkLength);
43744
43858
  var glTF = JSON.parse(Utils.decodeText(glTFData));
43745
- // read all buffers
43859
+ // Read all buffers
43746
43860
  var buffers = [];
43747
43861
  var byteOffset = GLB_HEADER_LENGTH + 2 * UINT32_LENGTH + chunkLength;
43748
43862
  var restoreGLBBufferSlice = context.contentRestorer.glbBufferSlices;
@@ -44623,9 +44737,9 @@
44623
44737
  /**
44624
44738
  * @internal
44625
44739
  */ _proto.load = function load(item, resourceManager) {
44626
- var _this = this;
44627
44740
  return new AssetPromise(function(resolve, reject, setTaskCompleteProgress, setTaskDetailProgress) {
44628
- _this.request(item.url, resourceManager, {
44741
+ resourceManager // @ts-ignore
44742
+ ._request(item.url, {
44629
44743
  type: "arraybuffer"
44630
44744
  }).onProgress(setTaskCompleteProgress, setTaskDetailProgress).then(function(buffer) {
44631
44745
  return exports.KTX2Loader._parseBuffer(new Uint8Array(buffer), resourceManager.engine, item.params).then(function(param) {
@@ -45154,18 +45268,23 @@
45154
45268
  _inherits(GLTFSchemaParser, GLTFParser1);
45155
45269
  var _proto = GLTFSchemaParser.prototype;
45156
45270
  _proto.parse = function parse(context) {
45157
- var glTFResource = context.glTFResource, contentRestorer = context.contentRestorer;
45271
+ var glTFResource = context.glTFResource, contentRestorer = context.contentRestorer, resourceManager = context.resourceManager;
45158
45272
  var url = glTFResource.url;
45159
45273
  var restoreBufferRequests = contentRestorer.bufferRequests;
45160
45274
  var requestConfig = {
45161
45275
  type: "arraybuffer"
45162
45276
  };
45163
- var _context_resourceManager__virtualPathMap_url;
45164
45277
  // @ts-ignore
45165
- var remoteUrl = (_context_resourceManager__virtualPathMap_url = context.resourceManager._virtualPathMap[url]) != null ? _context_resourceManager__virtualPathMap_url : url;
45166
- return request(remoteUrl, requestConfig).onProgress(undefined, context._onTaskDetail).then(function(buffer) {
45167
- restoreBufferRequests.push(new BufferRequestInfo(remoteUrl, requestConfig));
45168
- return GLTFUtils.parseGLB(context, buffer);
45278
+ var remoteUrl = resourceManager._getRemoteUrl(url);
45279
+ return resourceManager // @ts-ignore
45280
+ ._requestByRemoteUrl(remoteUrl, requestConfig).onProgress(undefined, context._onTaskDetail).then(function(buffer) {
45281
+ var _parseResult;
45282
+ var parseResult = GLTFUtils.parseGLB(context, buffer);
45283
+ // If the buffer is a GLB file, we need to restore the buffer data
45284
+ if ((_parseResult = parseResult) == null ? void 0 : _parseResult.glTF) {
45285
+ restoreBufferRequests.push(new BufferRequestInfo(remoteUrl, requestConfig));
45286
+ }
45287
+ return parseResult;
45169
45288
  }).then(function(result) {
45170
45289
  var _result;
45171
45290
  if ((_result = result) == null ? void 0 : _result.glTF) {
@@ -45388,18 +45507,18 @@
45388
45507
  return context.buffers ? Promise.resolve(context.buffers[index]) : this._parseSingleBuffer(context, buffers[index]);
45389
45508
  };
45390
45509
  _proto._parseSingleBuffer = function _parseSingleBuffer(context, bufferInfo) {
45391
- var glTFResource = context.glTFResource, contentRestorer = context.contentRestorer;
45510
+ var glTFResource = context.glTFResource, contentRestorer = context.contentRestorer, resourceManager = context.resourceManager;
45392
45511
  var url = glTFResource.url;
45393
- var _context_resourceManager__virtualPathMap_url;
45394
45512
  // @ts-ignore
45395
- var remoteUrl = (_context_resourceManager__virtualPathMap_url = context.resourceManager._virtualPathMap[url]) != null ? _context_resourceManager__virtualPathMap_url : url;
45513
+ var remoteUrl = resourceManager._getRemoteUrl(url);
45396
45514
  var restoreBufferRequests = contentRestorer.bufferRequests;
45397
45515
  var requestConfig = {
45398
45516
  type: "arraybuffer"
45399
45517
  };
45400
45518
  var absoluteUrl = Utils.resolveAbsoluteUrl(remoteUrl, bufferInfo.uri);
45401
45519
  restoreBufferRequests.push(new BufferRequestInfo(absoluteUrl, requestConfig));
45402
- var promise = request(absoluteUrl, requestConfig).onProgress(undefined, context._onTaskDetail);
45520
+ var promise = resourceManager // @ts-ignore
45521
+ ._requestByRemoteUrl(absoluteUrl, requestConfig).onProgress(undefined, context._onTaskDetail);
45403
45522
  context._addTaskCompletePromise(promise);
45404
45523
  return promise;
45405
45524
  };
@@ -46493,10 +46612,10 @@
46493
46612
  _inherits(PrefabLoader, Loader1);
46494
46613
  var _proto = PrefabLoader.prototype;
46495
46614
  _proto.load = function load(item, resourceManager) {
46496
- var _this = this;
46497
46615
  var engine = resourceManager.engine;
46498
46616
  return new AssetPromise(function(resolve, reject) {
46499
- _this.request(item.url, resourceManager, _extends({}, item, {
46617
+ resourceManager // @ts-ignore
46618
+ ._request(item.url, _extends({}, item, {
46500
46619
  type: "json"
46501
46620
  })).then(function(data) {
46502
46621
  PrefabParser.parse(engine, item.url, data).then(resolve).catch(reject);
@@ -46519,26 +46638,34 @@
46519
46638
  _inherits(HDRLoader1, Loader1);
46520
46639
  var _proto = HDRLoader1.prototype;
46521
46640
  _proto.load = function load(item, resourceManager) {
46522
- var _this = this;
46523
46641
  return new AssetPromise(function(resolve, reject) {
46524
46642
  var engine = resourceManager.engine;
46525
- _this.request(item.url, resourceManager, _extends({}, item, {
46643
+ var requestConfig = _extends({}, item, {
46526
46644
  type: "arraybuffer"
46527
- })).then(function(buffer) {
46528
- var uint8Array = new Uint8Array(buffer);
46529
- var _HDRLoader__parseHeader = HDRLoader._parseHeader(uint8Array), width = _HDRLoader__parseHeader.width, height = _HDRLoader__parseHeader.height, dataPosition = _HDRLoader__parseHeader.dataPosition;
46530
- var pixels = HDRLoader._readPixels(uint8Array.subarray(dataPosition), width, height);
46531
- var cubeSize = height >> 1;
46532
- var cubeMapData = HDRLoader._convertToCubemap(pixels, width, height, cubeSize);
46533
- var texture = new TextureCube(engine, cubeSize);
46534
- for(var faceIndex = 0; faceIndex < 6; faceIndex++){
46535
- texture.setPixelBuffer(exports.TextureCubeFace.PositiveX + faceIndex, cubeMapData[faceIndex], 0);
46536
- }
46537
- texture.generateMipmaps();
46645
+ });
46646
+ resourceManager // @ts-ignore
46647
+ ._request(item.url, requestConfig).then(function(buffer) {
46648
+ var texture = HDRLoader._setTextureByBuffer(engine, buffer);
46649
+ engine.resourceManager.addContentRestorer(new HDRContentRestorer(texture, item.url, requestConfig));
46538
46650
  resolve(texture);
46539
46651
  }).catch(reject);
46540
46652
  });
46541
46653
  };
46654
+ /**
46655
+ * @internal
46656
+ */ HDRLoader1._setTextureByBuffer = function _setTextureByBuffer(engine, buffer, texture) {
46657
+ var bufferArray = new Uint8Array(buffer);
46658
+ var _HDRLoader__parseHeader = HDRLoader._parseHeader(bufferArray), width = _HDRLoader__parseHeader.width, height = _HDRLoader__parseHeader.height, dataPosition = _HDRLoader__parseHeader.dataPosition;
46659
+ var cubeSize = height >> 1;
46660
+ texture || (texture = new TextureCube(engine, cubeSize));
46661
+ var pixels = HDRLoader._readPixels(bufferArray.subarray(dataPosition), width, height);
46662
+ var cubeMapData = HDRLoader._convertToCubemap(pixels, width, height, cubeSize);
46663
+ for(var faceIndex = 0; faceIndex < 6; faceIndex++){
46664
+ texture.setPixelBuffer(exports.TextureCubeFace.PositiveX + faceIndex, cubeMapData[faceIndex], 0);
46665
+ }
46666
+ texture.generateMipmaps();
46667
+ return texture;
46668
+ };
46542
46669
  HDRLoader1._convertToCubemap = function _convertToCubemap(pixels, inputWidth, inputHeight, size) {
46543
46670
  if (!pixels) {
46544
46671
  throw "ConvertPanoramaToCubemap: input cannot be null";
@@ -46830,6 +46957,29 @@
46830
46957
  "hdr"
46831
46958
  ])
46832
46959
  ], HDRLoader);
46960
+ /**
46961
+ * @internal
46962
+ */ var HDRContentRestorer = /*#__PURE__*/ function(ContentRestorer1) {
46963
+ var HDRContentRestorer = function HDRContentRestorer(resource, url, requestConfig) {
46964
+ var _this;
46965
+ _this = ContentRestorer1.call(this, resource) || this;
46966
+ _this.url = url;
46967
+ _this.requestConfig = requestConfig;
46968
+ return _this;
46969
+ };
46970
+ _inherits(HDRContentRestorer, ContentRestorer1);
46971
+ var _proto = HDRContentRestorer.prototype;
46972
+ _proto.restoreContent = function restoreContent() {
46973
+ var _this = this;
46974
+ return new AssetPromise(function(resolve, reject) {
46975
+ request(_this.url, _this.requestConfig).then(function(buffer) {
46976
+ HDRLoader._setTextureByBuffer(_this.resource.engine, buffer, _this.resource);
46977
+ resolve(_this.resource);
46978
+ }).catch(reject);
46979
+ });
46980
+ };
46981
+ return HDRContentRestorer;
46982
+ }(ContentRestorer);
46833
46983
  var JSONLoader = /*#__PURE__*/ function(Loader1) {
46834
46984
  var JSONLoader = function JSONLoader() {
46835
46985
  return Loader1.apply(this, arguments);
@@ -46837,7 +46987,8 @@
46837
46987
  _inherits(JSONLoader, Loader1);
46838
46988
  var _proto = JSONLoader.prototype;
46839
46989
  _proto.load = function load(item, resourceManager) {
46840
- return this.request(item.url, resourceManager, _extends({}, item, {
46990
+ // @ts-ignore
46991
+ return resourceManager._request(item.url, _extends({}, item, {
46841
46992
  type: "json"
46842
46993
  }));
46843
46994
  };
@@ -47038,10 +47189,9 @@
47038
47189
  _inherits(KTXCubeLoader, Loader1);
47039
47190
  var _proto = KTXCubeLoader.prototype;
47040
47191
  _proto.load = function load(item, resourceManager) {
47041
- var _this = this;
47042
47192
  return new AssetPromise(function(resolve, reject) {
47043
47193
  Promise.all(item.urls.map(function(url) {
47044
- return _this.request(url, resourceManager, _extends({}, item, {
47194
+ return resourceManager._request(url, _extends({}, item, {
47045
47195
  type: "arraybuffer"
47046
47196
  }));
47047
47197
  })).then(function(data) {
@@ -47074,9 +47224,9 @@
47074
47224
  _inherits(KTXLoader, Loader1);
47075
47225
  var _proto = KTXLoader.prototype;
47076
47226
  _proto.load = function load(item, resourceManager) {
47077
- var _this = this;
47078
47227
  return new AssetPromise(function(resolve, reject) {
47079
- _this.request(item.url, resourceManager, _extends({}, item, {
47228
+ resourceManager // @ts-ignore
47229
+ ._request(item.url, _extends({}, item, {
47080
47230
  type: "arraybuffer"
47081
47231
  })).then(function(bin) {
47082
47232
  var parsedData = parseSingleKTX(bin);
@@ -47118,7 +47268,8 @@
47118
47268
  _proto.load = function load(item, resourceManager) {
47119
47269
  var _this = this;
47120
47270
  return new AssetPromise(function(resolve, reject) {
47121
- _this.request(item.url, resourceManager, _extends({}, item, {
47271
+ resourceManager // @ts-ignore
47272
+ ._request(item.url, _extends({}, item, {
47122
47273
  type: "json"
47123
47274
  })).then(function(materialSchema) {
47124
47275
  var engine = resourceManager.engine;
@@ -47200,9 +47351,9 @@
47200
47351
  _inherits(MeshLoader, Loader1);
47201
47352
  var _proto = MeshLoader.prototype;
47202
47353
  _proto.load = function load(item, resourceManager) {
47203
- var _this = this;
47204
47354
  return new AssetPromise(function(resolve, reject) {
47205
- _this.request(item.url, resourceManager, _extends({}, item, {
47355
+ resourceManager // @ts-ignore
47356
+ ._request(item.url, _extends({}, item, {
47206
47357
  type: "arraybuffer"
47207
47358
  })).then(function(data) {
47208
47359
  return decode(data, resourceManager.engine);
@@ -47226,7 +47377,8 @@
47226
47377
  var _proto = PrimitiveMeshLoader.prototype;
47227
47378
  _proto.load = function load(item, resourceManager) {
47228
47379
  var engine = resourceManager.engine;
47229
- return this.request(item.url, resourceManager, _extends({}, item, {
47380
+ return resourceManager // @ts-ignore
47381
+ ._request(item.url, _extends({}, item, {
47230
47382
  type: "json"
47231
47383
  })).then(function(data) {
47232
47384
  switch(data.type){
@@ -47271,10 +47423,10 @@
47271
47423
  _inherits(ProjectLoader, Loader1);
47272
47424
  var _proto = ProjectLoader.prototype;
47273
47425
  _proto.load = function load(item, resourceManager) {
47274
- var _this = this;
47275
47426
  var engine = resourceManager.engine;
47276
47427
  return new AssetPromise(function(resolve, reject) {
47277
- _this.request(item.url, resourceManager, _extends({}, item, {
47428
+ resourceManager // @ts-ignore
47429
+ ._request(item.url, _extends({}, item, {
47278
47430
  type: "json"
47279
47431
  })).then(function(data) {
47280
47432
  // @ts-ignore
@@ -47305,9 +47457,8 @@
47305
47457
  _proto.load = function load(item, resourceManager) {
47306
47458
  var _this = this;
47307
47459
  return new AssetPromise(function(resolve, reject) {
47308
- var _resourceManager__virtualPathMap_item_url;
47309
47460
  // @ts-ignore
47310
- var url = (_resourceManager__virtualPathMap_item_url = resourceManager._virtualPathMap[item.url]) != null ? _resourceManager__virtualPathMap_item_url : item.url;
47461
+ var url = resourceManager._getRemoteUrl(item.url);
47311
47462
  _this._registerFont(url, url).then(function() {
47312
47463
  var font = new Font(resourceManager.engine, url);
47313
47464
  resolve(font);
@@ -47366,7 +47517,8 @@
47366
47517
  chainPromises[i].cancel();
47367
47518
  }
47368
47519
  });
47369
- var configPromise = _this.request(item.url, resourceManager, _extends({}, item, {
47520
+ // @ts-ignore
47521
+ var configPromise = resourceManager._request(item.url, _extends({}, item, {
47370
47522
  type: "json"
47371
47523
  }));
47372
47524
  chainPromises.push(configPromise);
@@ -47448,7 +47600,8 @@
47448
47600
  var _proto = SpriteLoader.prototype;
47449
47601
  _proto.load = function load(item, resourceManager) {
47450
47602
  var _this = this;
47451
- return this.request(item.url, resourceManager, _extends({}, item, {
47603
+ return resourceManager // @ts-ignore
47604
+ ._request(item.url, _extends({}, item, {
47452
47605
  type: "json"
47453
47606
  })).then(function(data) {
47454
47607
  return data.belongToAtlas ? _this._loadFromAtlas(resourceManager, data) : _this._loadFromTexture(resourceManager, data);
@@ -47518,13 +47671,13 @@
47518
47671
  _inherits(Texture2DLoader, Loader1);
47519
47672
  var _proto = Texture2DLoader.prototype;
47520
47673
  _proto.load = function load(item, resourceManager) {
47521
- var _this = this;
47522
47674
  return new AssetPromise(function(resolve, reject, setTaskCompleteProgress, setTaskDetailProgress) {
47523
47675
  var url = item.url;
47524
47676
  var requestConfig = _extends({}, item, {
47525
47677
  type: "image"
47526
47678
  });
47527
- _this.request(url, resourceManager, requestConfig).onProgress(setTaskCompleteProgress, setTaskDetailProgress).then(function(image) {
47679
+ resourceManager // @ts-ignore
47680
+ ._request(url, requestConfig).onProgress(setTaskCompleteProgress, setTaskDetailProgress).then(function(image) {
47528
47681
  var _item_params;
47529
47682
  var _ref = (_item_params = item.params) != null ? _item_params : {}, format = _ref.format, mipmap = _ref.mipmap, anisoLevel = _ref.anisoLevel, wrapModeU = _ref.wrapModeU, wrapModeV = _ref.wrapModeV, filterMode = _ref.filterMode;
47530
47683
  var texture = new Texture2D(resourceManager.engine, image.width, image.height, format, mipmap);
@@ -47593,14 +47746,14 @@
47593
47746
  _inherits(TextureCubeLoader, Loader1);
47594
47747
  var _proto = TextureCubeLoader.prototype;
47595
47748
  _proto.load = function load(item, resourceManager) {
47596
- var _this = this;
47597
47749
  return new AssetPromise(function(resolve, reject) {
47598
47750
  var urls = item.urls;
47599
47751
  var requestConfig = _extends({}, item, {
47600
47752
  type: "image"
47601
47753
  });
47754
+ // @ts-ignore
47602
47755
  Promise.all(urls.map(function(url) {
47603
- return _this.request(url, resourceManager, requestConfig);
47756
+ return resourceManager._request(url, requestConfig);
47604
47757
  })).then(function(images) {
47605
47758
  var _images_ = images[0], width = _images_.width, height = _images_.height;
47606
47759
  if (width !== height) {
@@ -47635,7 +47788,8 @@
47635
47788
  var _proto = ShaderChunkLoader1.prototype;
47636
47789
  _proto.load = function load(item, resourceManager) {
47637
47790
  var url = item.url;
47638
- return this.request(url, resourceManager, _extends({}, item, {
47791
+ // @ts-ignore
47792
+ return resourceManager._request(url, _extends({}, item, {
47639
47793
  type: "text"
47640
47794
  })).then(function(code) {
47641
47795
  ShaderFactory.registerInclude(url.substring(1), code);
@@ -47680,7 +47834,8 @@
47680
47834
  _proto.load = function load(item, resourceManager) {
47681
47835
  var _this = this;
47682
47836
  var url = item.url;
47683
- return this.request(url, resourceManager, _extends({}, item, {
47837
+ // @ts-ignore
47838
+ return resourceManager._request(url, _extends({}, item, {
47684
47839
  type: "text"
47685
47840
  })).then(function(code) {
47686
47841
  var builtinShader = _this._getBuiltinShader(code);
@@ -47716,10 +47871,10 @@
47716
47871
  _inherits(SceneLoader, Loader1);
47717
47872
  var _proto = SceneLoader.prototype;
47718
47873
  _proto.load = function load(item, resourceManager) {
47719
- var _this = this;
47720
47874
  var engine = resourceManager.engine;
47721
47875
  return new AssetPromise(function(resolve, reject) {
47722
- _this.request(item.url, resourceManager, _extends({}, item, {
47876
+ resourceManager // @ts-ignore
47877
+ ._request(item.url, _extends({}, item, {
47723
47878
  type: "json"
47724
47879
  })).then(function(data) {
47725
47880
  return SceneParser.parse(engine, data).then(function(scene) {
@@ -48268,7 +48423,7 @@
48268
48423
  ], EXT_texture_webp);
48269
48424
 
48270
48425
  //@ts-ignore
48271
- var version = "1.3.19";
48426
+ var version = "1.3.20";
48272
48427
  console.log("Galacean engine version: " + version);
48273
48428
  for(var key in CoreObjects){
48274
48429
  Loader.registerClass(key, CoreObjects[key]);