@galacean/engine-loader 1.0.0-alpha.6 → 1.0.0-beta.0

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/module.js CHANGED
@@ -1,56 +1,39 @@
1
- import { resourceLoader, AssetType, AssetPromise, AnimatorController, AnimatorControllerLayer, AnimatorStateMachine, Loader, AnimatorStateTransition, TextureCube, TextureFilterMode, TextureCubeFace, AmbientLight, DiffuseMode, Font, request, ContentRestorer, IndexFormat, VertexElementFormat, AnimationClip, InterpolationType, AnimationFloatArrayCurve, Keyframe, AnimationQuaternionCurve, AnimationVector3Curve, SkinnedMeshRenderer, Transform, Entity, PBRMaterial, Logger, PBRSpecularMaterial, TextureCoordinate, RenderFace, VertexElement, Buffer, BufferBindFlag, BufferUsage, BlendShape, ModelMesh, Camera, MeshRenderer, Animator, BlinnPhongMaterial, Skin, TextureWrapMode as TextureWrapMode$1, Texture2D, EngineObject, TextureFormat, PBRBaseMaterial, Shader, UnlitMaterial, DirectLight, ParticleRenderer, PointLight, SpotLight, Script, SpriteMask, SpriteRenderer, TextRenderer, AnimationEvent, AnimationColorCurve, AnimationVector4Curve, AnimationVector2Curve, AnimationArrayCurve, AnimationFloatCurve, Scene, SpriteAtlas, Sprite, BackgroundMode, SkyBoxMaterial, PrimitiveMesh } from '@galacean/engine-core';
1
+ import { resourceLoader, AssetType, AssetPromise, AnimatorController, AnimatorControllerLayer, AnimatorStateMachine, Loader, AnimatorStateTransition, TextureCube, TextureFilterMode, TextureCubeFace, AmbientLight, DiffuseMode, Font, request, ContentRestorer, IndexFormat, VertexElementFormat, Utils, AnimationClip, InterpolationType, AnimationFloatArrayCurve, Keyframe, AnimationQuaternionCurve, AnimationVector3Curve, SkinnedMeshRenderer, Transform, Entity, PBRMaterial, Logger, PBRSpecularMaterial, TextureCoordinate, RenderFace, VertexElement, Buffer, BufferBindFlag, BufferUsage, BlendShape, ModelMesh, Camera, MeshRenderer, Animator, BlinnPhongMaterial, Skin, TextureWrapMode as TextureWrapMode$1, Texture2D, EngineObject, TextureFormat, PBRBaseMaterial, Shader, UnlitMaterial, DirectLight, ParticleRenderer, PointLight, SpotLight, Script, SpriteMask, SpriteRenderer, TextRenderer, AnimationEvent, AnimationColorCurve, AnimationVector4Curve, AnimationVector2Curve, AnimationArrayCurve, AnimationFloatCurve, Scene, SpriteAtlas, Sprite, BackgroundMode, SkyBoxMaterial, PrimitiveMesh } from '@galacean/engine-core';
2
2
  import { SphericalHarmonics3, Vector2, Vector3, Vector4, Color, Quaternion, Matrix, Rect } from '@galacean/engine-math';
3
3
  import { GLCompressedTextureInternalFormat } from '@galacean/engine-rhi-webgl';
4
4
  import { DRACODecoder } from '@galacean/engine-draco';
5
5
 
6
- function extends_() {
7
- extends_ = Object.assign || function (target) {
8
- for (var i = 1; i < arguments.length; i++) {
9
- var source = arguments[i];
10
-
11
- for (var key in source) {
12
- if (Object.prototype.hasOwnProperty.call(source, key)) {
13
- target[key] = source[key];
6
+ function _extends() {
7
+ _extends = Object.assign || function assign(target) {
8
+ for (var i = 1; i < arguments.length; i++) {
9
+ var source = arguments[i];
10
+ for (var key in source) if (Object.prototype.hasOwnProperty.call(source, key)) target[key] = source[key];
14
11
  }
15
- }
16
- }
17
12
 
18
- return target;
19
- };
20
-
21
- return extends_.apply(this, arguments);
22
- }
13
+ return target;
14
+ };
23
15
 
24
- function _extends() {
25
- return extends_.apply(this, arguments);
16
+ return _extends.apply(this, arguments);
26
17
  }
27
18
 
28
- function setPrototypeOf(o, p) {
29
- setPrototypeOf = Object.setPrototypeOf || function setPrototypeOf(o, p) {
30
- o.__proto__ = p;
31
- return o;
32
- };
19
+ function _set_prototype_of(o, p) {
20
+ _set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
21
+ o.__proto__ = p;
33
22
 
34
- return setPrototypeOf(o, p);
35
- }
23
+ return o;
24
+ };
36
25
 
37
- function _setPrototypeOf(o, p) {
38
- return setPrototypeOf(o, p);
26
+ return _set_prototype_of(o, p);
39
27
  }
40
28
 
41
29
  function _inherits(subClass, superClass) {
42
- if (typeof superClass !== "function" && superClass !== null) {
43
- throw new TypeError("Super expression must either be null or a function");
44
- }
45
-
46
- subClass.prototype = Object.create(superClass && superClass.prototype, {
47
- constructor: {
48
- value: subClass,
49
- writable: true,
50
- configurable: true
30
+ if (typeof superClass !== "function" && superClass !== null) {
31
+ throw new TypeError("Super expression must either be null or a function");
51
32
  }
52
- });
53
- if (superClass) _setPrototypeOf(subClass, superClass);
33
+
34
+ subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } });
35
+
36
+ if (superClass) _set_prototype_of(subClass, superClass);
54
37
  }
55
38
 
56
39
  /******************************************************************************
@@ -269,39 +252,34 @@ EnvLoader = __decorate([
269
252
  ], EnvLoader);
270
253
 
271
254
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
272
- try {
273
- var info = gen[key](arg);
274
- var value = info.value;
275
- } catch (error) {
276
- reject(error);
277
- return;
278
- }
279
-
280
- if (info.done) {
281
- resolve(value);
282
- } else {
283
- Promise.resolve(value).then(_next, _throw);
284
- }
255
+ try {
256
+ var info = gen[key](arg);
257
+ var value = info.value;
258
+ } catch (error) {
259
+ reject(error);
260
+ return;
261
+ }
262
+ if (info.done) resolve(value);
263
+ else Promise.resolve(value).then(_next, _throw);
285
264
  }
265
+ function _async_to_generator(fn) {
266
+ return function() {
267
+ var self = this, args = arguments;
286
268
 
287
- function _asyncToGenerator(fn) {
288
- return function () {
289
- var self = this,
290
- args = arguments;
291
- return new Promise(function (resolve, reject) {
292
- var gen = fn.apply(self, args);
269
+ return new Promise(function(resolve, reject) {
270
+ var gen = fn.apply(self, args);
293
271
 
294
- function _next(value) {
295
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
296
- }
272
+ function _next(value) {
273
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
274
+ }
297
275
 
298
- function _throw(err) {
299
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
300
- }
276
+ function _throw(err) {
277
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
278
+ }
301
279
 
302
- _next(undefined);
303
- });
304
- };
280
+ _next(undefined);
281
+ });
282
+ };
305
283
  }
306
284
 
307
285
  var FontLoader = /*#__PURE__*/ function(Loader) {
@@ -334,7 +312,7 @@ var FontLoader = /*#__PURE__*/ function(Loader) {
334
312
  });
335
313
  };
336
314
  _proto._registerFont = function _registerFont(fontName, fontUrl) {
337
- return _asyncToGenerator(function() {
315
+ return _async_to_generator(function() {
338
316
  var fontFace;
339
317
  return __generator(this, function(_state) {
340
318
  switch(_state.label){
@@ -362,39 +340,43 @@ FontLoader = __decorate([
362
340
  ], false)
363
341
  ], FontLoader);
364
342
 
365
- function _arrayLikeToArray(arr, len) {
366
- if (len == null || len > arr.length) len = arr.length;
367
- for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
368
- return arr2;
343
+ function _array_like_to_array(arr, len) {
344
+ if (len == null || len > arr.length) len = arr.length;
345
+
346
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
347
+
348
+ return arr2;
369
349
  }
370
350
 
371
- function _unsupportedIterableToArray(o, minLen) {
372
- if (!o) return;
373
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
374
- var n = Object.prototype.toString.call(o).slice(8, -1);
375
- if (n === "Object" && o.constructor) n = o.constructor.name;
376
- if (n === "Map" || n === "Set") return Array.from(n);
377
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
378
- return _arrayLikeToArray(o, minLen);
351
+ function _unsupported_iterable_to_array(o, minLen) {
352
+ if (!o) return;
353
+ if (typeof o === "string") return _array_like_to_array(o, minLen);
354
+
355
+ var n = Object.prototype.toString.call(o).slice(8, -1);
356
+
357
+ if (n === "Object" && o.constructor) n = o.constructor.name;
358
+ if (n === "Map" || n === "Set") return Array.from(n);
359
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
379
360
  }
380
361
 
381
- function _createForOfIteratorHelperLoose(o, allowArrayLike) {
362
+ function _create_for_of_iterator_helper_loose(o, allowArrayLike) {
382
363
  var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
364
+
383
365
  if (it) return (it = it.call(o)).next.bind(it);
384
366
  // Fallback for engines without symbol support
385
- if (
386
- Array.isArray(o) ||
387
- (it = _unsupportedIterableToArray(o)) ||
388
- (allowArrayLike && o && typeof o.length === "number")
389
- ) {
367
+ if (Array.isArray(o) || (it = _unsupported_iterable_to_array(o)) || allowArrayLike && o && typeof o.length === "number") {
390
368
  if (it) o = it;
369
+
391
370
  var i = 0;
392
- return function () {
371
+
372
+ return function() {
393
373
  if (i >= o.length) return { done: true };
374
+
394
375
  return { done: false, value: o[i++] };
395
- }
376
+ };
396
377
  }
397
- throw new TypeError("Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
378
+
379
+ throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
398
380
  }
399
381
 
400
382
  /**
@@ -436,16 +418,16 @@ function _createForOfIteratorHelperLoose(o, allowArrayLike) {
436
418
  var buffer = buffers[bufferView.buffer];
437
419
  var _bufferView_byteOffset;
438
420
  var bufferData = new Uint8Array(buffer, (_bufferView_byteOffset = bufferView.byteOffset) != null ? _bufferView_byteOffset : 0, bufferView.byteLength);
439
- return GLTFUtil.loadImageBuffer(bufferData, textureRestoreInfo.mimeType).then(function(image) {
421
+ return GLTFUtils.loadImageBuffer(bufferData, textureRestoreInfo.mimeType).then(function(image) {
440
422
  textureRestoreInfo.texture.setImageSource(image);
441
423
  textureRestoreInfo.texture.generateMipmaps();
442
424
  });
443
425
  })).then(function() {
444
426
  // Restore mesh
445
- for(var _iterator = _createForOfIteratorHelperLoose(_this.meshes), _step; !(_step = _iterator()).done;){
427
+ for(var _iterator = _create_for_of_iterator_helper_loose(_this.meshes), _step; !(_step = _iterator()).done;){
446
428
  var meshInfo = _step.value;
447
429
  var mesh = meshInfo.mesh;
448
- for(var _iterator1 = _createForOfIteratorHelperLoose(meshInfo.vertexBuffers), _step1; !(_step1 = _iterator1()).done;){
430
+ for(var _iterator1 = _create_for_of_iterator_helper_loose(meshInfo.vertexBuffers), _step1; !(_step1 = _iterator1()).done;){
449
431
  var bufferRestoreInfo = _step1.value;
450
432
  var vertexData = _this._getBufferData(buffers, bufferRestoreInfo.data);
451
433
  bufferRestoreInfo.buffer.setData(vertexData);
@@ -454,18 +436,18 @@ function _createForOfIteratorHelperLoose(o, allowArrayLike) {
454
436
  var indexData = _this._getBufferData(buffers, meshInfo.indexBuffer);
455
437
  mesh.setIndices(indexData);
456
438
  }
457
- for(var _iterator2 = _createForOfIteratorHelperLoose(meshInfo.blendShapes), _step2; !(_step2 = _iterator2()).done;){
439
+ for(var _iterator2 = _create_for_of_iterator_helper_loose(meshInfo.blendShapes), _step2; !(_step2 = _iterator2()).done;){
458
440
  var restoreInfo = _step2.value;
459
441
  var frame = restoreInfo.blendShape.frames[0];
460
442
  var positionData = _this._getBufferData(buffers, restoreInfo.position);
461
- frame.deltaPositions = GLTFUtil.floatBufferToVector3Array(positionData);
443
+ frame.deltaPositions = GLTFUtils.floatBufferToVector3Array(positionData);
462
444
  if (restoreInfo.normal) {
463
445
  var normalData = _this._getBufferData(buffers, restoreInfo.normal);
464
- frame.deltaNormals = GLTFUtil.floatBufferToVector3Array(normalData);
446
+ frame.deltaNormals = GLTFUtils.floatBufferToVector3Array(normalData);
465
447
  }
466
448
  if (restoreInfo.tangent) {
467
449
  var tangentData = _this._getBufferData(buffers, restoreInfo.tangent);
468
- frame.deltaTangents = GLTFUtil.floatBufferToVector3Array(tangentData);
450
+ frame.deltaTangents = GLTFUtils.floatBufferToVector3Array(tangentData);
469
451
  }
470
452
  }
471
453
  mesh.uploadData(true);
@@ -747,9 +729,9 @@ var TextureWrapMode;
747
729
 
748
730
  /**
749
731
  * @internal
750
- */ var GLTFUtil = /*#__PURE__*/ function() {
751
- function GLTFUtil() {}
752
- GLTFUtil.floatBufferToVector2Array = function floatBufferToVector2Array(buffer) {
732
+ */ var GLTFUtils = /*#__PURE__*/ function() {
733
+ function GLTFUtils() {}
734
+ GLTFUtils.floatBufferToVector2Array = function floatBufferToVector2Array(buffer) {
753
735
  var bufferLen = buffer.length;
754
736
  var array = new Array(bufferLen / 2);
755
737
  for(var i = 0; i < bufferLen; i += 2){
@@ -757,7 +739,7 @@ var TextureWrapMode;
757
739
  }
758
740
  return array;
759
741
  };
760
- GLTFUtil.floatBufferToVector3Array = function floatBufferToVector3Array(buffer) {
742
+ GLTFUtils.floatBufferToVector3Array = function floatBufferToVector3Array(buffer) {
761
743
  var bufferLen = buffer.length;
762
744
  var array = new Array(bufferLen / 3);
763
745
  for(var i = 0; i < bufferLen; i += 3){
@@ -765,7 +747,7 @@ var TextureWrapMode;
765
747
  }
766
748
  return array;
767
749
  };
768
- GLTFUtil.floatBufferToVector4Array = function floatBufferToVector4Array(buffer) {
750
+ GLTFUtils.floatBufferToVector4Array = function floatBufferToVector4Array(buffer) {
769
751
  var bufferLen = buffer.length;
770
752
  var array = new Array(bufferLen / 4);
771
753
  for(var i = 0; i < bufferLen; i += 4){
@@ -773,7 +755,7 @@ var TextureWrapMode;
773
755
  }
774
756
  return array;
775
757
  };
776
- GLTFUtil.floatBufferToColorArray = function floatBufferToColorArray(buffer, isColor3) {
758
+ GLTFUtils.floatBufferToColorArray = function floatBufferToColorArray(buffer, isColor3) {
777
759
  var bufferLen = buffer.length;
778
760
  var colors = new Array(bufferLen / (isColor3 ? 3 : 4));
779
761
  if (isColor3) {
@@ -788,21 +770,8 @@ var TextureWrapMode;
788
770
  return colors;
789
771
  };
790
772
  /**
791
- * Parse binary text for glb loader.
792
- */ GLTFUtil.decodeText = function decodeText(array) {
793
- if (typeof TextDecoder !== "undefined") {
794
- return new TextDecoder().decode(array);
795
- }
796
- // TextDecoder polyfill
797
- var s = "";
798
- for(var i = 0, il = array.length; i < il; i++){
799
- s += String.fromCharCode(array[i]);
800
- }
801
- return decodeURIComponent(encodeURIComponent(s));
802
- };
803
- /**
804
773
  * Get the number of bytes occupied by accessor type.
805
- */ GLTFUtil.getAccessorTypeSize = function getAccessorTypeSize(accessorType) {
774
+ */ GLTFUtils.getAccessorTypeSize = function getAccessorTypeSize(accessorType) {
806
775
  switch(accessorType){
807
776
  case AccessorType.SCALAR:
808
777
  return 1;
@@ -822,7 +791,7 @@ var TextureWrapMode;
822
791
  };
823
792
  /**
824
793
  * Get the TypedArray corresponding to the component type.
825
- */ GLTFUtil.getComponentType = function getComponentType(componentType) {
794
+ */ GLTFUtils.getComponentType = function getComponentType(componentType) {
826
795
  switch(componentType){
827
796
  case AccessorComponentType.BYTE:
828
797
  return Int8Array;
@@ -838,7 +807,7 @@ var TextureWrapMode;
838
807
  return Float32Array;
839
808
  }
840
809
  };
841
- GLTFUtil.getNormalizedComponentScale = function getNormalizedComponentScale(componentType) {
810
+ GLTFUtils.getNormalizedComponentScale = function getNormalizedComponentScale(componentType) {
842
811
  // Reference: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization#encoding-quantized-data
843
812
  switch(componentType){
844
813
  case AccessorComponentType.BYTE:
@@ -853,7 +822,7 @@ var TextureWrapMode;
853
822
  throw new Error("Galacean.GLTFLoader: Unsupported normalized accessor component type.");
854
823
  }
855
824
  };
856
- GLTFUtil.getAccessorBuffer = function getAccessorBuffer(context, bufferViews, accessor) {
825
+ GLTFUtils.getAccessorBuffer = function getAccessorBuffer(context, bufferViews, accessor) {
857
826
  var buffers = context.buffers;
858
827
  var componentType = accessor.componentType;
859
828
  var bufferView = bufferViews[accessor.bufferView];
@@ -861,8 +830,8 @@ var TextureWrapMode;
861
830
  var buffer = buffers[bufferIndex];
862
831
  var bufferByteOffset = bufferView.byteOffset || 0;
863
832
  var byteOffset = accessor.byteOffset || 0;
864
- var TypedArray = GLTFUtil.getComponentType(componentType);
865
- var dataElementSize = GLTFUtil.getAccessorTypeSize(accessor.type);
833
+ var TypedArray = GLTFUtils.getComponentType(componentType);
834
+ var dataElementSize = GLTFUtils.getAccessorTypeSize(accessor.type);
866
835
  var dataElementBytes = TypedArray.BYTES_PER_ELEMENT;
867
836
  var elementStride = dataElementSize * dataElementBytes;
868
837
  var accessorCount = accessor.count;
@@ -889,25 +858,25 @@ var TextureWrapMode;
889
858
  bufferInfo.restoreInfo = new BufferDataRestoreInfo(new RestoreDataAccessor(bufferIndex, TypedArray, offset1, count1));
890
859
  }
891
860
  if (accessor.sparse) {
892
- GLTFUtil.processingSparseData(bufferViews, accessor, buffers, bufferInfo);
861
+ GLTFUtils.processingSparseData(bufferViews, accessor, buffers, bufferInfo);
893
862
  }
894
863
  return bufferInfo;
895
864
  };
896
865
  /**
897
866
  * @deprecated
898
867
  * Get accessor data.
899
- */ GLTFUtil.getAccessorData = function getAccessorData(glTF, accessor, buffers) {
868
+ */ GLTFUtils.getAccessorData = function getAccessorData(glTF, accessor, buffers) {
900
869
  var bufferViews = glTF.bufferViews;
901
870
  var bufferView = bufferViews[accessor.bufferView];
902
871
  var arrayBuffer = buffers[bufferView.buffer];
903
872
  var accessorByteOffset = accessor.hasOwnProperty("byteOffset") ? accessor.byteOffset : 0;
904
873
  var bufferViewByteOffset = bufferView.hasOwnProperty("byteOffset") ? bufferView.byteOffset : 0;
905
874
  var byteOffset = accessorByteOffset + bufferViewByteOffset;
906
- var accessorTypeSize = GLTFUtil.getAccessorTypeSize(accessor.type);
875
+ var accessorTypeSize = GLTFUtils.getAccessorTypeSize(accessor.type);
907
876
  var length = accessorTypeSize * accessor.count;
908
877
  var _bufferView_byteStride;
909
878
  var byteStride = (_bufferView_byteStride = bufferView.byteStride) != null ? _bufferView_byteStride : 0;
910
- var arrayType = GLTFUtil.getComponentType(accessor.componentType);
879
+ var arrayType = GLTFUtils.getComponentType(accessor.componentType);
911
880
  var uint8Array;
912
881
  if (byteStride) {
913
882
  var accessorByteSize = accessorTypeSize * arrayType.BYTES_PER_ELEMENT;
@@ -934,7 +903,7 @@ var TextureWrapMode;
934
903
  var _values_byteOffset, _valuesBufferView_byteOffset;
935
904
  var valuesByteOffset = ((_values_byteOffset = values.byteOffset) != null ? _values_byteOffset : 0) + ((_valuesBufferView_byteOffset = valuesBufferView.byteOffset) != null ? _valuesBufferView_byteOffset : 0);
936
905
  var valuesByteLength = valuesBufferView.byteLength;
937
- var indicesType = GLTFUtil.getComponentType(indices.componentType);
906
+ var indicesType = GLTFUtils.getComponentType(indices.componentType);
938
907
  var indicesArray = new indicesType(indicesArrayBuffer, indicesByteOffset, indicesByteLength / indicesType.BYTES_PER_ELEMENT);
939
908
  var valuesArray = new arrayType(valuesArrayBuffer, valuesByteOffset, valuesByteLength / arrayType.BYTES_PER_ELEMENT);
940
909
  for(var i1 = 0; i1 < count; i1++){
@@ -946,17 +915,17 @@ var TextureWrapMode;
946
915
  }
947
916
  return typedArray;
948
917
  };
949
- GLTFUtil.getBufferViewData = function getBufferViewData(bufferView, buffers) {
918
+ GLTFUtils.getBufferViewData = function getBufferViewData(bufferView, buffers) {
950
919
  var _bufferView_byteOffset = bufferView.byteOffset, byteOffset = _bufferView_byteOffset === void 0 ? 0 : _bufferView_byteOffset;
951
920
  var arrayBuffer = buffers[bufferView.buffer];
952
921
  return arrayBuffer.slice(byteOffset, byteOffset + bufferView.byteLength);
953
922
  };
954
923
  /**
955
924
  * Get accessor data.
956
- */ GLTFUtil.processingSparseData = function processingSparseData(bufferViews, accessor, buffers, bufferInfo) {
925
+ */ GLTFUtils.processingSparseData = function processingSparseData(bufferViews, accessor, buffers, bufferInfo) {
957
926
  var restoreInfo = bufferInfo.restoreInfo;
958
- var accessorTypeSize = GLTFUtil.getAccessorTypeSize(accessor.type);
959
- var TypedArray = GLTFUtil.getComponentType(accessor.componentType);
927
+ var accessorTypeSize = GLTFUtils.getAccessorTypeSize(accessor.type);
928
+ var TypedArray = GLTFUtils.getComponentType(accessor.componentType);
960
929
  var data = bufferInfo.data.slice();
961
930
  var _accessor_sparse = accessor.sparse, count = _accessor_sparse.count, indices = _accessor_sparse.indices, values = _accessor_sparse.values;
962
931
  var indicesBufferView = bufferViews[indices.bufferView];
@@ -973,7 +942,7 @@ var TextureWrapMode;
973
942
  var valuesByteLength = valuesBufferView.byteLength;
974
943
  restoreInfo.typeSize = accessorTypeSize;
975
944
  restoreInfo.sparseCount = count;
976
- var IndexTypeArray = GLTFUtil.getComponentType(indices.componentType);
945
+ var IndexTypeArray = GLTFUtils.getComponentType(indices.componentType);
977
946
  var indexLength = indicesByteLength / IndexTypeArray.BYTES_PER_ELEMENT;
978
947
  var indicesArray = new IndexTypeArray(indicesArrayBuffer, indicesByteOffset, indexLength);
979
948
  restoreInfo.sparseIndices = new RestoreDataAccessor(indicesBufferIndex, IndexTypeArray, indicesByteOffset, indexLength);
@@ -988,7 +957,7 @@ var TextureWrapMode;
988
957
  }
989
958
  bufferInfo.data = data;
990
959
  };
991
- GLTFUtil.getIndexFormat = function getIndexFormat(type) {
960
+ GLTFUtils.getIndexFormat = function getIndexFormat(type) {
992
961
  switch(type){
993
962
  case AccessorComponentType.UNSIGNED_BYTE:
994
963
  return IndexFormat.UInt8;
@@ -998,7 +967,7 @@ var TextureWrapMode;
998
967
  return IndexFormat.UInt32;
999
968
  }
1000
969
  };
1001
- GLTFUtil.getElementFormat = function getElementFormat(type, size, normalized) {
970
+ GLTFUtils.getElementFormat = function getElementFormat(type, size, normalized) {
1002
971
  if (normalized === void 0) normalized = false;
1003
972
  if (type == AccessorComponentType.FLOAT) {
1004
973
  switch(size){
@@ -1049,7 +1018,7 @@ var TextureWrapMode;
1049
1018
  };
1050
1019
  /**
1051
1020
  * Load image buffer
1052
- */ GLTFUtil.loadImageBuffer = function loadImageBuffer(imageBuffer, type) {
1021
+ */ GLTFUtils.loadImageBuffer = function loadImageBuffer(imageBuffer, type) {
1053
1022
  return new Promise(function(resolve, reject) {
1054
1023
  var blob = new window.Blob([
1055
1024
  imageBuffer
@@ -1073,18 +1042,9 @@ var TextureWrapMode;
1073
1042
  img.src = URL.createObjectURL(blob);
1074
1043
  });
1075
1044
  };
1076
- GLTFUtil.isAbsoluteUrl = function isAbsoluteUrl(url) {
1077
- return /^(?:http|blob|data:|\/)/.test(url);
1078
- };
1079
- GLTFUtil.parseRelativeUrl = function parseRelativeUrl(baseUrl, relativeUrl) {
1080
- if (GLTFUtil.isAbsoluteUrl(relativeUrl)) {
1081
- return relativeUrl;
1082
- }
1083
- return baseUrl.substring(0, baseUrl.lastIndexOf("/") + 1) + GLTFUtil._formatRelativePath(relativeUrl);
1084
- };
1085
1045
  /**
1086
1046
  * Parse the glb format.
1087
- */ GLTFUtil.parseGLB = function parseGLB(context, glb) {
1047
+ */ GLTFUtils.parseGLB = function parseGLB(context, glb) {
1088
1048
  var UINT32_LENGTH = 4;
1089
1049
  var GLB_HEADER_MAGIC = 0x46546c67; // 'glTF'
1090
1050
  var GLB_HEADER_LENGTH = 12;
@@ -1112,7 +1072,7 @@ var TextureWrapMode;
1112
1072
  return null;
1113
1073
  }
1114
1074
  var glTFData = new Uint8Array(glb, GLB_HEADER_LENGTH + 2 * UINT32_LENGTH, chunkLength);
1115
- var glTF = JSON.parse(GLTFUtil.decodeText(glTFData));
1075
+ var glTF = JSON.parse(Utils.decodeText(glTFData));
1116
1076
  // read all buffers
1117
1077
  var buffers = [];
1118
1078
  var byteOffset = GLB_HEADER_LENGTH + 2 * UINT32_LENGTH + chunkLength;
@@ -1135,7 +1095,7 @@ var TextureWrapMode;
1135
1095
  buffers: buffers
1136
1096
  };
1137
1097
  };
1138
- GLTFUtil._formatRelativePath = function _formatRelativePath(path) {
1098
+ GLTFUtils._formatRelativePath = function _formatRelativePath(path) {
1139
1099
  // For example input is "a/b", "/a/b", "./a/b", "./a/./b", "./a/../a/b", output is "a/b"
1140
1100
  return path.split("/").filter(Boolean).reduce(function(acc, cur) {
1141
1101
  if (cur === "..") acc.pop();
@@ -1143,23 +1103,25 @@ var TextureWrapMode;
1143
1103
  return acc;
1144
1104
  }, []).join("/");
1145
1105
  };
1146
- return GLTFUtil;
1106
+ return GLTFUtils;
1147
1107
  }();
1148
1108
 
1149
- function _arrayWithoutHoles(arr) {
1150
- if (Array.isArray(arr)) return _arrayLikeToArray(arr);
1109
+ function _array_without_holes(arr) {
1110
+ if (Array.isArray(arr)) return _array_like_to_array(arr);
1151
1111
  }
1152
1112
 
1153
- function _iterableToArray(iter) {
1154
- if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
1113
+ function _iterable_to_array(iter) {
1114
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) {
1115
+ return Array.from(iter);
1116
+ }
1155
1117
  }
1156
1118
 
1157
- function _nonIterableSpread() {
1158
- throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
1119
+ function _non_iterable_spread() {
1120
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
1159
1121
  }
1160
1122
 
1161
- function _toConsumableArray(arr) {
1162
- return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
1123
+ function _to_consumable_array(arr) {
1124
+ return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
1163
1125
  }
1164
1126
 
1165
1127
  /**
@@ -1249,7 +1211,7 @@ var GLTFExtensionMode;
1249
1211
  context,
1250
1212
  extensionSchema,
1251
1213
  ownerSchema
1252
- ].concat(_toConsumableArray(extra)));
1214
+ ].concat(_to_consumable_array(extra)));
1253
1215
  if (resource) {
1254
1216
  return resource;
1255
1217
  }
@@ -1275,7 +1237,7 @@ var GLTFExtensionMode;
1275
1237
  parseResource,
1276
1238
  extensionSchema,
1277
1239
  ownerSchema
1278
- ].concat(_toConsumableArray(extra)));
1240
+ ].concat(_to_consumable_array(extra)));
1279
1241
  }
1280
1242
  };
1281
1243
  /**
@@ -1323,7 +1285,7 @@ var GLTFExtensionMode;
1323
1285
  context,
1324
1286
  extensionSchema,
1325
1287
  ownerSchema
1326
- ].concat(_toConsumableArray(extra)));
1288
+ ].concat(_to_consumable_array(extra)));
1327
1289
  }
1328
1290
  };
1329
1291
  GLTFParser._additiveParse = function _additiveParse(extensionName, context, parseResource, extensionSchema, ownerSchema) {
@@ -1338,12 +1300,14 @@ var GLTFExtensionMode;
1338
1300
  parseResource,
1339
1301
  extensionSchema,
1340
1302
  ownerSchema
1341
- ].concat(_toConsumableArray(extra)));
1303
+ ].concat(_to_consumable_array(extra)));
1342
1304
  }
1343
1305
  };
1344
1306
  return GLTFParser;
1345
1307
  }();
1346
- GLTFParser._extensionParsers = {};
1308
+ (function() {
1309
+ GLTFParser._extensionParsers = {};
1310
+ })();
1347
1311
  /**
1348
1312
  * Declare ExtensionParser's decorator.
1349
1313
  * @param extensionName - Extension name
@@ -1405,10 +1369,10 @@ var GLTFAnimationParser = /*#__PURE__*/ function(GLTFParser1) {
1405
1369
  var gltfSampler = samplers[j];
1406
1370
  var inputAccessor = accessors[gltfSampler.input];
1407
1371
  var outputAccessor = accessors[gltfSampler.output];
1408
- var input = GLTFUtil.getAccessorBuffer(context, bufferViews, inputAccessor).data;
1409
- var output = GLTFUtil.getAccessorBuffer(context, bufferViews, outputAccessor).data;
1372
+ var input = GLTFUtils.getAccessorBuffer(context, bufferViews, inputAccessor).data;
1373
+ var output = GLTFUtils.getAccessorBuffer(context, bufferViews, outputAccessor).data;
1410
1374
  if (outputAccessor.normalized) {
1411
- var scale = GLTFUtil.getNormalizedComponentScale(outputAccessor.componentType);
1375
+ var scale = GLTFUtils.getNormalizedComponentScale(outputAccessor.componentType);
1412
1376
  var scaled = new Float32Array(output.length);
1413
1377
  for(var k = 0, v = output.length; k < v; k++){
1414
1378
  scaled[k] = output[k] * scale;
@@ -1562,7 +1526,7 @@ var GLTFBufferParser = /*#__PURE__*/ function(GLTFParser) {
1562
1526
  if (isGLB) {
1563
1527
  return request(url, requestConfig).then(function(glb) {
1564
1528
  restoreBufferRequests.push(new BufferRequestInfo(url, requestConfig));
1565
- return GLTFUtil.parseGLB(context, glb);
1529
+ return GLTFUtils.parseGLB(context, glb);
1566
1530
  }).then(function(param) {
1567
1531
  var glTF = param.glTF, buffers = param.buffers;
1568
1532
  context.glTF = glTF;
@@ -1574,7 +1538,7 @@ var GLTFBufferParser = /*#__PURE__*/ function(GLTFParser) {
1574
1538
  }).then(function(glTF) {
1575
1539
  context.glTF = glTF;
1576
1540
  return Promise.all(glTF.buffers.map(function(buffer) {
1577
- var absoluteUrl = GLTFUtil.parseRelativeUrl(url, buffer.uri);
1541
+ var absoluteUrl = Utils.resolveAbsoluteUrl(url, buffer.uri);
1578
1542
  restoreBufferRequests.push(new BufferRequestInfo(absoluteUrl, requestConfig));
1579
1543
  return request(absoluteUrl, requestConfig);
1580
1544
  })).then(function(buffers) {
@@ -1664,7 +1628,9 @@ var GLTFEntityParser = /*#__PURE__*/ function(GLTFParser) {
1664
1628
  };
1665
1629
  return GLTFEntityParser;
1666
1630
  }(GLTFParser);
1667
- /** @internal */ GLTFEntityParser._defaultName = "_GLTF_ENTITY_";
1631
+ (function() {
1632
+ /** @internal */ GLTFEntityParser._defaultName = "_GLTF_ENTITY_";
1633
+ })();
1668
1634
 
1669
1635
  var GLTFMaterialParser = /*#__PURE__*/ function(GLTFParser1) {
1670
1636
  _inherits(GLTFMaterialParser, GLTFParser1);
@@ -1779,11 +1745,9 @@ var GLTFMaterialParser = /*#__PURE__*/ function(GLTFParser1) {
1779
1745
  }(GLTFParser);
1780
1746
 
1781
1747
  function _instanceof(left, right) {
1782
- if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
1783
- return !!right[Symbol.hasInstance](left);
1784
- } else {
1785
- return left instanceof right;
1786
- }
1748
+ if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
1749
+ return !!right[Symbol.hasInstance](left);
1750
+ } else return left instanceof right;
1787
1751
  }
1788
1752
 
1789
1753
  var GLTFMeshParser = /*#__PURE__*/ function(GLTFParser1) {
@@ -1818,13 +1782,13 @@ var GLTFMeshParser = /*#__PURE__*/ function(GLTFParser1) {
1818
1782
  var attributeAccessorIdx = shapeAccessorIdx[attributeName];
1819
1783
  if (attributeAccessorIdx) {
1820
1784
  var accessor = glTF.accessors[attributeAccessorIdx];
1821
- return GLTFUtil.getAccessorBuffer(context, context.glTF.bufferViews, accessor);
1785
+ return GLTFUtils.getAccessorBuffer(context, context.glTF.bufferViews, accessor);
1822
1786
  } else {
1823
1787
  return null;
1824
1788
  }
1825
1789
  }, function() {
1826
1790
  var indexAccessor = glTF.accessors[gltfPrimitive.indices];
1827
- return GLTFUtil.getAccessorData(glTF, indexAccessor, buffers);
1791
+ return GLTFUtils.getAccessorData(glTF, indexAccessor, buffers);
1828
1792
  }, context.keepMeshData).then(resolve);
1829
1793
  }
1830
1794
  });
@@ -1856,16 +1820,18 @@ var GLTFMeshParser = /*#__PURE__*/ function(GLTFParser1) {
1856
1820
  var vertexElements = new Array();
1857
1821
  var vertexCount;
1858
1822
  var bufferBindIndex = 0;
1823
+ var positions;
1824
+ keepMeshData && (positions = new Array(vertexCount));
1859
1825
  for(var attribute in attributes){
1860
1826
  var accessor = accessors[attributes[attribute]];
1861
- var accessorBuffer = GLTFUtil.getAccessorBuffer(context, gltf.bufferViews, accessor);
1862
- var dataElementSize = GLTFUtil.getAccessorTypeSize(accessor.type);
1827
+ var accessorBuffer = GLTFUtils.getAccessorBuffer(context, gltf.bufferViews, accessor);
1828
+ var dataElementSize = GLTFUtils.getAccessorTypeSize(accessor.type);
1863
1829
  var attributeCount = accessor.count;
1864
1830
  var vertices = accessorBuffer.data;
1865
1831
  var vertexElement = void 0;
1866
1832
  var meshId = mesh.instanceId;
1867
1833
  var vertexBindingInfos = accessorBuffer.vertexBindingInfos;
1868
- var elementFormat = GLTFUtil.getElementFormat(accessor.componentType, dataElementSize, accessor.normalized);
1834
+ var elementFormat = GLTFUtils.getElementFormat(accessor.componentType, dataElementSize, accessor.normalized);
1869
1835
  if (accessorBuffer.interleaved) {
1870
1836
  var byteOffset = accessor.byteOffset || 0;
1871
1837
  var stride = accessorBuffer.stride;
@@ -1899,20 +1865,27 @@ var GLTFMeshParser = /*#__PURE__*/ function(GLTFParser1) {
1899
1865
  if (accessor.min && accessor.max) {
1900
1866
  min.copyFromArray(accessor.min);
1901
1867
  max.copyFromArray(accessor.max);
1868
+ if (keepMeshData) {
1869
+ var stride1 = vertices.length / attributeCount;
1870
+ for(var j = 0; j < attributeCount; j++){
1871
+ var offset = j * stride1;
1872
+ positions[j] = new Vector3(vertices[offset], vertices[offset + 1], vertices[offset + 2]);
1873
+ }
1874
+ }
1902
1875
  } else {
1903
1876
  var position = GLTFMeshParser._tempVector3;
1904
1877
  min.set(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
1905
1878
  max.set(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
1906
- var stride1 = vertices.length / attributeCount;
1907
- for(var j = 0; j < attributeCount; j++){
1908
- var offset = j * stride1;
1909
- position.copyFromArray(vertices, offset);
1879
+ var stride2 = vertices.length / attributeCount;
1880
+ for(var j1 = 0; j1 < attributeCount; j1++){
1881
+ var offset1 = j1 * stride2;
1882
+ position.copyFromArray(vertices, offset1);
1910
1883
  Vector3.min(min, position, min);
1911
1884
  Vector3.max(max, position, max);
1912
1885
  }
1913
1886
  }
1914
1887
  if (accessor.normalized) {
1915
- var scaleFactor = GLTFUtil.getNormalizedComponentScale(accessor.componentType);
1888
+ var scaleFactor = GLTFUtils.getNormalizedComponentScale(accessor.componentType);
1916
1889
  min.scale(scaleFactor);
1917
1890
  max.scale(scaleFactor);
1918
1891
  }
@@ -1922,7 +1895,7 @@ var GLTFMeshParser = /*#__PURE__*/ function(GLTFParser1) {
1922
1895
  // Indices
1923
1896
  if (indices !== undefined) {
1924
1897
  var indexAccessor = gltf.accessors[indices];
1925
- var accessorBuffer1 = GLTFUtil.getAccessorBuffer(context, gltf.bufferViews, indexAccessor);
1898
+ var accessorBuffer1 = GLTFUtils.getAccessorBuffer(context, gltf.bufferViews, indexAccessor);
1926
1899
  mesh.setIndices(accessorBuffer1.data);
1927
1900
  mesh.addSubMesh(0, indexAccessor.count, mode);
1928
1901
  meshRestoreInfo.indexBuffer = accessorBuffer1.restoreInfo;
@@ -1932,6 +1905,8 @@ var GLTFMeshParser = /*#__PURE__*/ function(GLTFParser1) {
1932
1905
  // BlendShapes
1933
1906
  targets && GLTFMeshParser._createBlendShape(mesh, meshRestoreInfo, gltfMesh, targets, getBlendShapeData);
1934
1907
  mesh.uploadData(!keepMeshData);
1908
+ //@ts-ignore
1909
+ mesh._positions = positions;
1935
1910
  return Promise.resolve(mesh);
1936
1911
  };
1937
1912
  /**
@@ -1943,9 +1918,9 @@ var GLTFMeshParser = /*#__PURE__*/ function(GLTFParser1) {
1943
1918
  var deltaPosBufferInfo = getBlendShapeData("POSITION", i);
1944
1919
  var deltaNorBufferInfo = getBlendShapeData("NORMAL", i);
1945
1920
  var deltaTanBufferInfo = getBlendShapeData("TANGENT", i);
1946
- var deltaPositions = deltaPosBufferInfo.data ? GLTFUtil.floatBufferToVector3Array(deltaPosBufferInfo.data) : null;
1947
- var deltaNormals = (deltaNorBufferInfo == null ? void 0 : deltaNorBufferInfo.data) ? GLTFUtil.floatBufferToVector3Array(deltaNorBufferInfo == null ? void 0 : deltaNorBufferInfo.data) : null;
1948
- var deltaTangents = (deltaTanBufferInfo == null ? void 0 : deltaTanBufferInfo.data) ? GLTFUtil.floatBufferToVector3Array(deltaTanBufferInfo == null ? void 0 : deltaTanBufferInfo.data) : null;
1921
+ var deltaPositions = deltaPosBufferInfo.data ? GLTFUtils.floatBufferToVector3Array(deltaPosBufferInfo.data) : null;
1922
+ var deltaNormals = (deltaNorBufferInfo == null ? void 0 : deltaNorBufferInfo.data) ? GLTFUtils.floatBufferToVector3Array(deltaNorBufferInfo == null ? void 0 : deltaNorBufferInfo.data) : null;
1923
+ var deltaTangents = (deltaTanBufferInfo == null ? void 0 : deltaTanBufferInfo.data) ? GLTFUtils.floatBufferToVector3Array(deltaTanBufferInfo == null ? void 0 : deltaTanBufferInfo.data) : null;
1949
1924
  var blendShape = new BlendShape(name);
1950
1925
  blendShape.addFrame(1.0, deltaPositions, deltaNormals, deltaTangents);
1951
1926
  mesh.addBlendShape(blendShape);
@@ -1954,7 +1929,9 @@ var GLTFMeshParser = /*#__PURE__*/ function(GLTFParser1) {
1954
1929
  };
1955
1930
  return GLTFMeshParser;
1956
1931
  }(GLTFParser);
1957
- GLTFMeshParser._tempVector3 = new Vector3();
1932
+ (function() {
1933
+ GLTFMeshParser._tempVector3 = new Vector3();
1934
+ })();
1958
1935
 
1959
1936
  var GLTFSceneParser = /*#__PURE__*/ function(GLTFParser1) {
1960
1937
  _inherits(GLTFSceneParser, GLTFParser1);
@@ -2106,7 +2083,7 @@ var GLTFSkinParser = /*#__PURE__*/ function(GLTFParser) {
2106
2083
  skin.inverseBindMatrices.length = jointCount;
2107
2084
  // parse IBM
2108
2085
  var accessor = glTF.accessors[inverseBindMatrices];
2109
- var buffer = GLTFUtil.getAccessorBuffer(context, glTF.bufferViews, accessor).data;
2086
+ var buffer = GLTFUtils.getAccessorBuffer(context, glTF.bufferViews, accessor).data;
2110
2087
  for(var i1 = 0; i1 < jointCount; i1++){
2111
2088
  var inverseBindMatrix = new Matrix();
2112
2089
  inverseBindMatrix.copyFromArray(buffer, i1 * 16);
@@ -2141,7 +2118,7 @@ var GLTFSkinParser = /*#__PURE__*/ function(GLTFParser) {
2141
2118
  };
2142
2119
  _proto._findSkeletonRootBone = function _findSkeletonRootBone(joints, entities) {
2143
2120
  var paths = {};
2144
- for(var _iterator = _createForOfIteratorHelperLoose(joints), _step; !(_step = _iterator()).done;){
2121
+ for(var _iterator = _create_for_of_iterator_helper_loose(joints), _step; !(_step = _iterator()).done;){
2145
2122
  var index = _step.value;
2146
2123
  var path = new Array();
2147
2124
  var entity = entities[index];
@@ -2191,7 +2168,7 @@ var GLTFTextureParser = /*#__PURE__*/ function(GLTFParser) {
2191
2168
  var ext = uri.substring(index1 + 1);
2192
2169
  var type = ext.startsWith("ktx") ? AssetType.KTX : AssetType.Texture2D;
2193
2170
  return engine.resourceManager.load({
2194
- url: GLTFUtil.parseRelativeUrl(url, uri),
2171
+ url: Utils.resolveAbsoluteUrl(url, uri),
2195
2172
  type: type
2196
2173
  }).then(function(texture) {
2197
2174
  if (!texture.name) {
@@ -2206,7 +2183,7 @@ var GLTFTextureParser = /*#__PURE__*/ function(GLTFParser) {
2206
2183
  var bufferView = glTF.bufferViews[bufferViewIndex];
2207
2184
  var buffer = buffers[bufferView.buffer];
2208
2185
  var imageBuffer = new Uint8Array(buffer, bufferView.byteOffset, bufferView.byteLength);
2209
- return GLTFUtil.loadImageBuffer(imageBuffer, mimeType).then(function(image) {
2186
+ return GLTFUtils.loadImageBuffer(imageBuffer, mimeType).then(function(image) {
2210
2187
  var texture = new Texture2D(engine, image.width, image.height);
2211
2188
  texture.setImageSource(image);
2212
2189
  texture.generateMipmaps();
@@ -2246,8 +2223,10 @@ var GLTFTextureParser = /*#__PURE__*/ function(GLTFParser) {
2246
2223
  };
2247
2224
  return GLTFTextureParser;
2248
2225
  }(GLTFParser);
2249
- var _obj;
2250
- GLTFTextureParser._wrapMap = (_obj = {}, _obj[TextureWrapMode.CLAMP_TO_EDGE] = TextureWrapMode$1.Clamp, _obj[TextureWrapMode.MIRRORED_REPEAT] = TextureWrapMode$1.Mirror, _obj[TextureWrapMode.REPEAT] = TextureWrapMode$1.Repeat, _obj);
2226
+ (function() {
2227
+ var _obj;
2228
+ GLTFTextureParser._wrapMap = (_obj = {}, _obj[TextureWrapMode.CLAMP_TO_EDGE] = TextureWrapMode$1.Clamp, _obj[TextureWrapMode.MIRRORED_REPEAT] = TextureWrapMode$1.Mirror, _obj[TextureWrapMode.REPEAT] = TextureWrapMode$1.Repeat, _obj);
2229
+ })();
2251
2230
 
2252
2231
  var GLTFValidator = /*#__PURE__*/ function(GLTFParser1) {
2253
2232
  _inherits(GLTFValidator, GLTFParser1);
@@ -2329,9 +2308,11 @@ var GLTFValidator = /*#__PURE__*/ function(GLTFParser1) {
2329
2308
  };
2330
2309
  return GLTFPipeline;
2331
2310
  }();
2332
- /**
2311
+ (function() {
2312
+ /**
2333
2313
  * Default pipeline.
2334
2314
  */ GLTFPipeline.defaultPipeline = new GLTFPipeline(GLTFBufferParser, GLTFValidator, GLTFTextureParser, GLTFMaterialParser, GLTFMeshParser, GLTFEntityParser, GLTFSkinParser, GLTFAnimationParser, GLTFSceneParser);
2315
+ })();
2335
2316
 
2336
2317
  /**
2337
2318
  * Product after glTF parser, usually, `defaultSceneRoot` is only needed to use.
@@ -2384,7 +2365,7 @@ var GLTFLoader = /*#__PURE__*/ function(Loader) {
2384
2365
  context.keepMeshData = (_params_keepMeshData = params == null ? void 0 : params.keepMeshData) != null ? _params_keepMeshData : false;
2385
2366
  masterPromiseInfo.onCancel(function() {
2386
2367
  var chainPromises = context.chainPromises;
2387
- for(var _iterator = _createForOfIteratorHelperLoose(chainPromises), _step; !(_step = _iterator()).done;){
2368
+ for(var _iterator = _create_for_of_iterator_helper_loose(chainPromises), _step; !(_step = _iterator()).done;){
2388
2369
  var promise = _step.value;
2389
2370
  promise.cancel();
2390
2371
  }
@@ -2487,7 +2468,7 @@ var HDRLoader = (_HDRLoader = /*#__PURE__*/ function(Loader) {
2487
2468
  return textureArray;
2488
2469
  };
2489
2470
  HDRLoader1._calcProjectionSpherical = function _calcProjectionSpherical(vDir, pixels, inputWidth, inputHeight) {
2490
- var theta = Math.atan2(vDir.z, -vDir.x);
2471
+ var theta = Math.atan2(vDir.z, vDir.x);
2491
2472
  var phi = Math.acos(vDir.y);
2492
2473
  while(theta < -PI){
2493
2474
  theta += 2 * PI;
@@ -2648,37 +2629,75 @@ var HDRLoader = (_HDRLoader = /*#__PURE__*/ function(Loader) {
2648
2629
  color.a *= M;
2649
2630
  };
2650
2631
  return HDRLoader1;
2651
- }(Loader), _HDRLoader._rightBottomBack = new Vector3(1.0, -1.0, -1.0), _HDRLoader._rightBottomFront = new Vector3(1.0, -1.0, 1.0), _HDRLoader._rightUpBack = new Vector3(1.0, 1.0, -1.0), _HDRLoader._rightUpFront = new Vector3(1.0, 1.0, 1.0), _HDRLoader._leftBottomBack = new Vector3(-1.0, -1.0, -1.0), _HDRLoader._leftBottomFront = new Vector3(-1.0, -1.0, 1.0), _HDRLoader._leftUpBack = new Vector3(-1.0, 1.0, -1.0), _HDRLoader._leftUpFront = new Vector3(-1.0, 1.0, 1.0), _HDRLoader._faceRight = [
2652
- _HDRLoader._rightBottomBack,
2653
- _HDRLoader._rightBottomFront,
2654
- _HDRLoader._rightUpBack,
2655
- _HDRLoader._rightUpFront
2656
- ], _HDRLoader._faceLeft = [
2657
- _HDRLoader._leftBottomFront,
2658
- _HDRLoader._leftBottomBack,
2659
- _HDRLoader._leftUpFront,
2660
- _HDRLoader._leftUpBack
2661
- ], _HDRLoader._faceUp = [
2662
- _HDRLoader._leftBottomFront,
2663
- _HDRLoader._rightBottomFront,
2664
- _HDRLoader._leftBottomBack,
2665
- _HDRLoader._rightBottomBack
2666
- ], _HDRLoader._faceBottom = [
2667
- _HDRLoader._leftUpBack,
2668
- _HDRLoader._rightUpBack,
2669
- _HDRLoader._leftUpFront,
2670
- _HDRLoader._rightUpFront
2671
- ], _HDRLoader._faceFront = [
2672
- _HDRLoader._leftBottomBack,
2673
- _HDRLoader._rightBottomBack,
2674
- _HDRLoader._leftUpBack,
2675
- _HDRLoader._rightUpBack
2676
- ], _HDRLoader._faceBack = [
2677
- _HDRLoader._rightBottomFront,
2678
- _HDRLoader._leftBottomFront,
2679
- _HDRLoader._rightUpFront,
2680
- _HDRLoader._leftUpFront
2681
- ], _HDRLoader._tempVector3 = new Vector3(), _HDRLoader._temp2Vector3 = new Vector3(), _HDRLoader._temp3Vector3 = new Vector3(), _HDRLoader._temp4Vector3 = new Vector3(), _HDRLoader._temp5Vector3 = new Vector3(), _HDRLoader);
2632
+ }(Loader), function() {
2633
+ _HDRLoader._rightBottomBack = new Vector3(1.0, -1.0, -1.0);
2634
+ }(), function() {
2635
+ _HDRLoader._rightBottomFront = new Vector3(1.0, -1.0, 1.0);
2636
+ }(), function() {
2637
+ _HDRLoader._rightUpBack = new Vector3(1.0, 1.0, -1.0);
2638
+ }(), function() {
2639
+ _HDRLoader._rightUpFront = new Vector3(1.0, 1.0, 1.0);
2640
+ }(), function() {
2641
+ _HDRLoader._leftBottomBack = new Vector3(-1.0, -1.0, -1.0);
2642
+ }(), function() {
2643
+ _HDRLoader._leftBottomFront = new Vector3(-1.0, -1.0, 1.0);
2644
+ }(), function() {
2645
+ _HDRLoader._leftUpBack = new Vector3(-1.0, 1.0, -1.0);
2646
+ }(), function() {
2647
+ _HDRLoader._leftUpFront = new Vector3(-1.0, 1.0, 1.0);
2648
+ }(), function() {
2649
+ _HDRLoader._faceRight = [
2650
+ _HDRLoader._rightBottomBack,
2651
+ _HDRLoader._rightBottomFront,
2652
+ _HDRLoader._rightUpBack,
2653
+ _HDRLoader._rightUpFront
2654
+ ];
2655
+ }(), function() {
2656
+ _HDRLoader._faceLeft = [
2657
+ _HDRLoader._leftBottomFront,
2658
+ _HDRLoader._leftBottomBack,
2659
+ _HDRLoader._leftUpFront,
2660
+ _HDRLoader._leftUpBack
2661
+ ];
2662
+ }(), function() {
2663
+ _HDRLoader._faceUp = [
2664
+ _HDRLoader._leftBottomFront,
2665
+ _HDRLoader._rightBottomFront,
2666
+ _HDRLoader._leftBottomBack,
2667
+ _HDRLoader._rightBottomBack
2668
+ ];
2669
+ }(), function() {
2670
+ _HDRLoader._faceBottom = [
2671
+ _HDRLoader._leftUpBack,
2672
+ _HDRLoader._rightUpBack,
2673
+ _HDRLoader._leftUpFront,
2674
+ _HDRLoader._rightUpFront
2675
+ ];
2676
+ }(), function() {
2677
+ _HDRLoader._faceFront = [
2678
+ _HDRLoader._leftBottomBack,
2679
+ _HDRLoader._rightBottomBack,
2680
+ _HDRLoader._leftUpBack,
2681
+ _HDRLoader._rightUpBack
2682
+ ];
2683
+ }(), function() {
2684
+ _HDRLoader._faceBack = [
2685
+ _HDRLoader._rightBottomFront,
2686
+ _HDRLoader._leftBottomFront,
2687
+ _HDRLoader._rightUpFront,
2688
+ _HDRLoader._leftUpFront
2689
+ ];
2690
+ }(), function() {
2691
+ _HDRLoader._tempVector3 = new Vector3();
2692
+ }(), function() {
2693
+ _HDRLoader._temp2Vector3 = new Vector3();
2694
+ }(), function() {
2695
+ _HDRLoader._temp3Vector3 = new Vector3();
2696
+ }(), function() {
2697
+ _HDRLoader._temp4Vector3 = new Vector3();
2698
+ }(), function() {
2699
+ _HDRLoader._temp5Vector3 = new Vector3();
2700
+ }(), _HDRLoader);
2682
2701
  HDRLoader = __decorate([
2683
2702
  resourceLoader(AssetType.HDR, [
2684
2703
  "hdr"
@@ -3048,19 +3067,21 @@ MaterialLoader = __decorate([
3048
3067
  ], MaterialLoader);
3049
3068
 
3050
3069
  function _defineProperties(target, props) {
3051
- for (var i = 0; i < props.length; i++) {
3052
- var descriptor = props[i];
3053
- descriptor.enumerable = descriptor.enumerable || false;
3054
- descriptor.configurable = true;
3055
- if ("value" in descriptor) descriptor.writable = true;
3056
- Object.defineProperty(target, descriptor.key, descriptor);
3057
- }
3070
+ for (var i = 0; i < props.length; i++) {
3071
+ var descriptor = props[i];
3072
+ descriptor.enumerable = descriptor.enumerable || false;
3073
+ descriptor.configurable = true;
3074
+
3075
+ if ("value" in descriptor) descriptor.writable = true;
3076
+
3077
+ Object.defineProperty(target, descriptor.key, descriptor);
3078
+ }
3058
3079
  }
3080
+ function _create_class(Constructor, protoProps, staticProps) {
3081
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
3082
+ if (staticProps) _defineProperties(Constructor, staticProps);
3059
3083
 
3060
- function _createClass(Constructor, protoProps, staticProps) {
3061
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
3062
- if (staticProps) _defineProperties(Constructor, staticProps);
3063
- return Constructor;
3084
+ return Constructor;
3064
3085
  }
3065
3086
 
3066
3087
  var BufferReader = /*#__PURE__*/ function() {
@@ -3130,7 +3151,7 @@ var BufferReader = /*#__PURE__*/ function() {
3130
3151
  var strByteLength = this.nextUint16();
3131
3152
  var uint8Array = new Uint8Array(this.buffer, this._offset, strByteLength);
3132
3153
  this._offset += strByteLength;
3133
- return GLTFUtil.decodeText(uint8Array);
3154
+ return Utils.decodeText(uint8Array);
3134
3155
  };
3135
3156
  /**
3136
3157
  * image data 放在最后
@@ -3169,7 +3190,7 @@ var BufferReader = /*#__PURE__*/ function() {
3169
3190
  if (byteLength < maxByteLength) this._offset++;
3170
3191
  return new Uint8Array(this._dataView.buffer, this._dataView.byteOffset + byteOffset, byteLength);
3171
3192
  };
3172
- _createClass(BufferReader, [
3193
+ _create_class(BufferReader, [
3173
3194
  {
3174
3195
  key: "offset",
3175
3196
  get: function get() {
@@ -3179,12 +3200,14 @@ var BufferReader = /*#__PURE__*/ function() {
3179
3200
  ]);
3180
3201
  return BufferReader;
3181
3202
  }();
3182
- BufferReader.imageMapping = {
3183
- 0: "image/png",
3184
- 1: "image/jpg",
3185
- 2: "image/webp",
3186
- 3: "ktx"
3187
- };
3203
+ (function() {
3204
+ BufferReader.imageMapping = {
3205
+ 0: "image/png",
3206
+ 1: "image/jpg",
3207
+ 2: "image/webp",
3208
+ 3: "ktx"
3209
+ };
3210
+ })();
3188
3211
 
3189
3212
  var decoderMap = {};
3190
3213
  /**
@@ -3213,8 +3236,8 @@ var FileHeader = /*#__PURE__*/ function() {
3213
3236
  var typeUint8Array = new Uint8Array(arrayBuffer, 7, typeLen);
3214
3237
  var nameLen = dataView.getUint16(7 + typeLen, true);
3215
3238
  var nameUint8Array = new Uint8Array(arrayBuffer, 9 + typeLen, nameLen);
3216
- var name = GLTFUtil.decodeText(nameUint8Array);
3217
- var type = GLTFUtil.decodeText(typeUint8Array);
3239
+ var name = Utils.decodeText(nameUint8Array);
3240
+ var type = Utils.decodeText(typeUint8Array);
3218
3241
  var header = new FileHeader();
3219
3242
  header.totalLength = totalLen;
3220
3243
  header.name = name;
@@ -3223,7 +3246,7 @@ var FileHeader = /*#__PURE__*/ function() {
3223
3246
  header.headerLength = nameUint8Array.byteLength + typeUint8Array.byteLength + 9;
3224
3247
  return header;
3225
3248
  };
3226
- _createClass(FileHeader, [
3249
+ _create_class(FileHeader, [
3227
3250
  {
3228
3251
  key: "dataLength",
3229
3252
  get: function get() {
@@ -3442,38 +3465,36 @@ Texture2DDecoder = __decorate([
3442
3465
  decoder("Texture2D")
3443
3466
  ], Texture2DDecoder);
3444
3467
 
3445
- function isNativeReflectConstruct() {
3446
- if (typeof Reflect === "undefined" || !Reflect.construct) return false;
3447
- if (Reflect.construct.sham) return false;
3448
- if (typeof Proxy === "function") return true;
3468
+ function _is_native_reflect_construct() {
3469
+ if (typeof Reflect === "undefined" || !Reflect.construct) return false;
3470
+ if (Reflect.construct.sham) return false;
3471
+ if (typeof Proxy === "function") return true;
3449
3472
 
3450
- try {
3451
- Date.prototype.toString.call(Reflect.construct(Date, [], function () { }));
3452
- return true;
3453
- } catch (e) {
3454
- return false;
3455
- }
3456
- }
3473
+ try {
3474
+ Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
3457
3475
 
3458
- function construct(Parent, args, Class) {
3459
- if (isNativeReflectConstruct()) {
3460
- construct = Reflect.construct;
3461
- } else {
3462
- construct = function construct(Parent, args, Class) {
3463
- var a = [null];
3464
- a.push.apply(a, args);
3465
- var Constructor = Function.bind.apply(Parent, a);
3466
- var instance = new Constructor();
3467
- if (Class) _setPrototypeOf(instance, Class.prototype);
3468
- return instance;
3469
- };
3470
- }
3471
-
3472
- return construct.apply(null, arguments);
3476
+ return true;
3477
+ } catch (e) {
3478
+ return false;
3479
+ }
3473
3480
  }
3474
3481
 
3475
3482
  function _construct(Parent, args, Class) {
3476
- return construct.apply(null, arguments);
3483
+ if (_is_native_reflect_construct()) _construct = Reflect.construct;
3484
+ else {
3485
+ _construct = function construct(Parent, args, Class) {
3486
+ var a = [null];
3487
+ a.push.apply(a, args);
3488
+ var Constructor = Function.bind.apply(Parent, a);
3489
+ var instance = new Constructor();
3490
+
3491
+ if (Class) _set_prototype_of(instance, Class.prototype);
3492
+
3493
+ return instance;
3494
+ };
3495
+ }
3496
+
3497
+ return _construct.apply(null, arguments);
3477
3498
  }
3478
3499
 
3479
3500
  var ReflectionParser = /*#__PURE__*/ function() {
@@ -3588,7 +3609,9 @@ var ReflectionParser = /*#__PURE__*/ function() {
3588
3609
  };
3589
3610
  return ReflectionParser;
3590
3611
  }();
3591
- ReflectionParser.customParseComponentHandles = new Map();
3612
+ (function() {
3613
+ ReflectionParser.customParseComponentHandles = new Map();
3614
+ })();
3592
3615
 
3593
3616
  var PrefabParser = /*#__PURE__*/ function() {
3594
3617
  function PrefabParser() {}
@@ -3842,7 +3865,7 @@ var SceneParserContext = /*#__PURE__*/ function() {
3842
3865
  };
3843
3866
  _proto._organizeEntities = function _organizeEntities() {
3844
3867
  var _this_context = this.context, entityConfigMap = _this_context.entityConfigMap, entityMap = _this_context.entityMap, scene = _this_context.scene, rootIds = _this_context.rootIds;
3845
- for(var _iterator = _createForOfIteratorHelperLoose(rootIds), _step; !(_step = _iterator()).done;){
3868
+ for(var _iterator = _create_for_of_iterator_helper_loose(rootIds), _step; !(_step = _iterator()).done;){
3846
3869
  var rootId = _step.value;
3847
3870
  PrefabParser.parseChildren(entityConfigMap, entityMap, rootId);
3848
3871
  }
@@ -4006,7 +4029,7 @@ var SourceFontLoader = /*#__PURE__*/ function(Loader) {
4006
4029
  });
4007
4030
  };
4008
4031
  _proto._registerFont = function _registerFont(fontName, fontUrl) {
4009
- return _asyncToGenerator(function() {
4032
+ return _async_to_generator(function() {
4010
4033
  var fontFace;
4011
4034
  return __generator(this, function(_state) {
4012
4035
  switch(_state.label){
@@ -4043,6 +4066,7 @@ var SpriteAtlasLoader = /*#__PURE__*/ function(Loader) {
4043
4066
  _this = Loader.apply(this, arguments) || this;
4044
4067
  _this._tempRect = new Rect();
4045
4068
  _this._tempVec2 = new Vector2();
4069
+ _this._tempVec4 = new Vector4();
4046
4070
  return _this;
4047
4071
  }
4048
4072
  var _proto = SpriteAtlasLoader.prototype;
@@ -4060,57 +4084,65 @@ var SpriteAtlasLoader = /*#__PURE__*/ function(Loader) {
4060
4084
  }));
4061
4085
  chainPromises.push(configPromise);
4062
4086
  configPromise.then(function(atlasData) {
4063
- var atlasItems = atlasData.atlasItems, format = atlasData.format;
4064
- var atlasItemsLen = atlasItems.length;
4065
- var imagePromises = AssetPromise.all(atlasItems.map(function(param) {
4066
- var img = param.img;
4067
- return _this.request(GLTFUtil.parseRelativeUrl(item.url, img), _extends({}, item, {
4068
- type: "image"
4069
- }));
4070
- }));
4071
- chainPromises.push(imagePromises);
4072
- return imagePromises.then(function(imgs) {
4073
- var engine = resourceManager.engine;
4074
- // Generate a SpriteAtlas object.
4075
- var tempRect = _this._tempRect, tempVec2 = _this._tempVec2;
4076
- var spriteAtlas = new SpriteAtlas(engine);
4077
- for(var i = 0; i < atlasItemsLen; i++){
4078
- // Generate Texture2D according to configuration.
4079
- var originalImg = imgs[i];
4080
- var width = originalImg.width, height = originalImg.height;
4081
- var texture = new Texture2D(engine, width, height, format);
4082
- texture.setImageSource(originalImg);
4083
- texture.generateMipmaps();
4084
- // Generate all the sprites on this texture.
4085
- var atlasItem = atlasItems[i];
4086
- var sprites = atlasItem.sprites;
4087
- var sourceWidthReciprocal = 1.0 / width;
4088
- var sourceHeightReciprocal = 1.0 / height;
4089
- for(var j = sprites.length - 1; j >= 0; j--){
4090
- var atlasSprite = sprites[j];
4091
- var region = atlasSprite.region, atlasRegionOffset = atlasSprite.atlasRegionOffset, atlasRegion = atlasSprite.atlasRegion, id = atlasSprite.id, pivot = atlasSprite.pivot;
4092
- var sprite = new Sprite(engine, texture, region ? tempRect.set(region.x, region.y, region.w, region.h) : undefined, pivot ? tempVec2.set(pivot.x, pivot.y) : undefined, undefined, atlasSprite.name);
4093
- sprite.atlasRegion.set(atlasRegion.x * sourceWidthReciprocal, atlasRegion.y * sourceHeightReciprocal, atlasRegion.w * sourceWidthReciprocal, atlasRegion.h * sourceHeightReciprocal);
4094
- atlasSprite.atlasRotated && (sprite.atlasRotated = true);
4095
- if (atlasRegionOffset) {
4096
- var offsetLeft = atlasRegionOffset.x, offsetTop = atlasRegionOffset.y, offsetRight = atlasRegionOffset.z, offsetBottom = atlasRegionOffset.w;
4097
- sprite.atlasRegionOffset.set(offsetLeft * sourceWidthReciprocal, offsetTop * sourceHeightReciprocal, offsetRight * sourceWidthReciprocal, offsetBottom * sourceHeightReciprocal);
4087
+ var _loop = function(i) {
4088
+ var atlasItem = atlasItems[i];
4089
+ if (atlasItem.img) {
4090
+ chainPromises.push(resourceManager.load({
4091
+ url: atlasItem.img,
4092
+ type: AssetType.Texture2D,
4093
+ params: {
4094
+ format: format,
4095
+ mipmap: mipmap
4098
4096
  }
4099
- if (id !== undefined) {
4097
+ }).then(function(texture) {
4098
+ anisoLevel && (texture.anisoLevel = anisoLevel);
4099
+ filterMode !== undefined && (texture.filterMode = filterMode);
4100
+ wrapModeU !== undefined && (texture.wrapModeU = wrapModeU);
4101
+ wrapModeV !== undefined && (texture.wrapModeV = wrapModeV);
4102
+ for(var i = 0; i < atlasItem.sprites.length; i++){
4100
4103
  // @ts-ignore
4101
- sprite._assetID = id;
4104
+ spriteAtlas._addSprite(_this._makeSprite(engine, atlasItem.sprites[i], texture));
4102
4105
  }
4106
+ }).catch(reject));
4107
+ } else {
4108
+ for(var i1 = 0; i1 < atlasItem.sprites.length; i1++){
4103
4109
  // @ts-ignore
4104
- spriteAtlas._addSprite(sprite);
4110
+ spriteAtlas._addSprite(_this._makeSprite(engine, atlasItem.sprites[i1]));
4105
4111
  }
4106
4112
  }
4113
+ };
4114
+ var atlasItems = atlasData.atlasItems, mipmap = atlasData.mipmap, anisoLevel = atlasData.anisoLevel, filterMode = atlasData.filterMode, wrapModeU = atlasData.wrapModeU, wrapModeV = atlasData.wrapModeV, format = atlasData.format;
4115
+ var atlasItemsLen = atlasItems ? atlasItems.length : 0;
4116
+ var engine = resourceManager.engine;
4117
+ var spriteAtlas = new SpriteAtlas(engine);
4118
+ if (atlasItemsLen < 0) {
4107
4119
  resolve(spriteAtlas);
4108
- });
4109
- }).catch(function(e) {
4110
- reject(e);
4111
- });
4120
+ return;
4121
+ }
4122
+ chainPromises.length = 0;
4123
+ for(var i = 0; i < atlasItems.length; i++)_loop(i);
4124
+ AssetPromise.all(chainPromises).then(function() {
4125
+ resolve(spriteAtlas);
4126
+ }).catch(reject);
4127
+ }).catch(reject);
4112
4128
  });
4113
4129
  };
4130
+ _proto._makeSprite = function _makeSprite(engine, config, texture) {
4131
+ // Generate a SpriteAtlas object.
4132
+ var region = config.region, atlasRegionOffset = config.atlasRegionOffset, atlasRegion = config.atlasRegion, pivot = config.pivot, border = config.border;
4133
+ var sprite = new Sprite(engine, texture, region ? this._tempRect.set(region.x, region.y, region.w, region.h) : undefined, pivot ? this._tempVec2.set(pivot.x, pivot.y) : undefined, border ? this._tempVec4.set(border.x, border.y, border.z, border.w) : undefined, config.name);
4134
+ if (texture) {
4135
+ var invW = 1 / texture.width;
4136
+ var invH = 1 / texture.height;
4137
+ sprite.atlasRegion.set(atlasRegion.x * invW, atlasRegion.y * invH, atlasRegion.w * invW, atlasRegion.h * invH);
4138
+ if (atlasRegionOffset) {
4139
+ var offsetLeft = atlasRegionOffset.x, offsetTop = atlasRegionOffset.y, offsetRight = atlasRegionOffset.z, offsetBottom = atlasRegionOffset.w;
4140
+ sprite.atlasRegionOffset.set(offsetLeft * invW, offsetTop * invH, offsetRight * invW, offsetBottom * invH);
4141
+ }
4142
+ config.atlasRotated && (sprite.atlasRotated = true);
4143
+ }
4144
+ return sprite;
4145
+ };
4114
4146
  return SpriteAtlasLoader;
4115
4147
  }(Loader);
4116
4148
  SpriteAtlasLoader = __decorate([
@@ -4131,13 +4163,19 @@ var SpriteLoader = /*#__PURE__*/ function(Loader) {
4131
4163
  _this.request(item.url, _extends({}, item, {
4132
4164
  type: "json"
4133
4165
  })).then(function(data) {
4134
- // @ts-ignore
4135
- resourceManager.getResourceByRef(data.texture).then(function(texture) {
4136
- var sprite = new Sprite(resourceManager.engine, texture);
4137
- sprite.region = data.region;
4138
- sprite.pivot = data.pivot;
4139
- resolve(sprite);
4140
- });
4166
+ if (data.belongToAtlas) {
4167
+ resourceManager// @ts-ignore
4168
+ .getResourceByRef(data.belongToAtlas).then(function(atlas) {
4169
+ resolve(atlas.getSprite(data.fullPath));
4170
+ }).catch(reject);
4171
+ } else if (data.texture) {
4172
+ resourceManager// @ts-ignore
4173
+ .getResourceByRef(data.texture).then(function(texture) {
4174
+ resolve(new Sprite(resourceManager.engine, texture, data.region, data.pivot, data.border));
4175
+ }).catch(reject);
4176
+ } else {
4177
+ resolve(new Sprite(resourceManager.engine, null, data.region, data.pivot, data.border));
4178
+ }
4141
4179
  }).catch(reject);
4142
4180
  });
4143
4181
  };
@@ -4362,7 +4400,7 @@ var SceneLoader = /*#__PURE__*/ function(Loader) {
4362
4400
  backgroundPromise = resourceManager.getResourceByRef(background.sky).then(function(light) {
4363
4401
  var sky = scene.background.sky;
4364
4402
  var skyMaterial = new SkyBoxMaterial(engine);
4365
- skyMaterial.textureCubeMap = light.specularTexture;
4403
+ skyMaterial.texture = light.specularTexture;
4366
4404
  skyMaterial.textureDecodeRGBM = true;
4367
4405
  sky.material = skyMaterial;
4368
4406
  sky.mesh = PrimitiveMesh.createCuboid(engine, 1, 1, 1);
@@ -4403,7 +4441,7 @@ SceneLoader = __decorate([
4403
4441
  "prefab"
4404
4442
  ], true)
4405
4443
  ], SceneLoader);
4406
- ReflectionParser.registerCustomParseComponent("TextRenderer", /*#__PURE__*/ _asyncToGenerator(function(instance, item, engine) {
4444
+ ReflectionParser.registerCustomParseComponent("TextRenderer", /*#__PURE__*/ _async_to_generator(function(instance, item, engine) {
4407
4445
  var props;
4408
4446
  return __generator(this, function(_state) {
4409
4447
  props = item.props;
@@ -4447,18 +4485,18 @@ var KHR_draco_mesh_compression = (_KHR_draco_mesh_compression = /*#__PURE__*/ fu
4447
4485
  for(var attributeName1 in glTFPrimitive.attributes){
4448
4486
  if (gltfAttributeMap[attributeName1] !== undefined) {
4449
4487
  var accessorDef = accessors[glTFPrimitive.attributes[attributeName1]];
4450
- attributeTypeMap[attributeName1] = GLTFUtil.getComponentType(accessorDef.componentType).name;
4488
+ attributeTypeMap[attributeName1] = GLTFUtils.getComponentType(accessorDef.componentType).name;
4451
4489
  }
4452
4490
  }
4453
4491
  var indexAccessor = accessors[glTFPrimitive.indices];
4454
- var indexType = GLTFUtil.getComponentType(indexAccessor.componentType).name;
4492
+ var indexType = GLTFUtils.getComponentType(indexAccessor.componentType).name;
4455
4493
  var taskConfig = {
4456
4494
  attributeIDs: attributeMap,
4457
4495
  attributeTypes: attributeTypeMap,
4458
4496
  useUniqueIDs: true,
4459
4497
  indexType: indexType
4460
4498
  };
4461
- var buffer = GLTFUtil.getBufferViewData(bufferViews[bufferViewIndex], buffers);
4499
+ var buffer = GLTFUtils.getBufferViewData(bufferViews[bufferViewIndex], buffers);
4462
4500
  return KHR_draco_mesh_compression._decoder.decode(buffer, taskConfig).then(function(decodedGeometry) {
4463
4501
  var mesh = new ModelMesh(engine, glTFMesh.name);
4464
4502
  return _this._parseMeshFromGLTFPrimitiveDraco(mesh, glTFMesh, glTFPrimitive, glTF, function(attributeSemantic) {
@@ -4481,7 +4519,7 @@ var KHR_draco_mesh_compression = (_KHR_draco_mesh_compression = /*#__PURE__*/ fu
4481
4519
  var accessors = gltf.accessors;
4482
4520
  var accessor = accessors[attributes["POSITION"]];
4483
4521
  var positionBuffer = getVertexBufferData("POSITION");
4484
- var positions = GLTFUtil.floatBufferToVector3Array(positionBuffer);
4522
+ var positions = GLTFUtils.floatBufferToVector3Array(positionBuffer);
4485
4523
  mesh.setPositions(positions);
4486
4524
  var bounds = mesh.bounds;
4487
4525
  vertexCount = accessor.count;
@@ -4508,55 +4546,55 @@ var KHR_draco_mesh_compression = (_KHR_draco_mesh_compression = /*#__PURE__*/ fu
4508
4546
  var bufferData = getVertexBufferData(attributeSemantic);
4509
4547
  switch(attributeSemantic){
4510
4548
  case "NORMAL":
4511
- var normals = GLTFUtil.floatBufferToVector3Array(bufferData);
4549
+ var normals = GLTFUtils.floatBufferToVector3Array(bufferData);
4512
4550
  mesh.setNormals(normals);
4513
4551
  break;
4514
4552
  case "TEXCOORD_0":
4515
- var texturecoords = GLTFUtil.floatBufferToVector2Array(bufferData);
4553
+ var texturecoords = GLTFUtils.floatBufferToVector2Array(bufferData);
4516
4554
  mesh.setUVs(texturecoords, 0);
4517
4555
  break;
4518
4556
  case "TEXCOORD_1":
4519
- var texturecoords1 = GLTFUtil.floatBufferToVector2Array(bufferData);
4557
+ var texturecoords1 = GLTFUtils.floatBufferToVector2Array(bufferData);
4520
4558
  mesh.setUVs(texturecoords1, 1);
4521
4559
  break;
4522
4560
  case "TEXCOORD_2":
4523
- var texturecoords2 = GLTFUtil.floatBufferToVector2Array(bufferData);
4561
+ var texturecoords2 = GLTFUtils.floatBufferToVector2Array(bufferData);
4524
4562
  mesh.setUVs(texturecoords2, 2);
4525
4563
  break;
4526
4564
  case "TEXCOORD_3":
4527
- var texturecoords3 = GLTFUtil.floatBufferToVector2Array(bufferData);
4565
+ var texturecoords3 = GLTFUtils.floatBufferToVector2Array(bufferData);
4528
4566
  mesh.setUVs(texturecoords3, 3);
4529
4567
  break;
4530
4568
  case "TEXCOORD_4":
4531
- var texturecoords4 = GLTFUtil.floatBufferToVector2Array(bufferData);
4569
+ var texturecoords4 = GLTFUtils.floatBufferToVector2Array(bufferData);
4532
4570
  mesh.setUVs(texturecoords4, 4);
4533
4571
  break;
4534
4572
  case "TEXCOORD_5":
4535
- var texturecoords5 = GLTFUtil.floatBufferToVector2Array(bufferData);
4573
+ var texturecoords5 = GLTFUtils.floatBufferToVector2Array(bufferData);
4536
4574
  mesh.setUVs(texturecoords5, 5);
4537
4575
  break;
4538
4576
  case "TEXCOORD_6":
4539
- var texturecoords6 = GLTFUtil.floatBufferToVector2Array(bufferData);
4577
+ var texturecoords6 = GLTFUtils.floatBufferToVector2Array(bufferData);
4540
4578
  mesh.setUVs(texturecoords6, 6);
4541
4579
  break;
4542
4580
  case "TEXCOORD_7":
4543
- var texturecoords7 = GLTFUtil.floatBufferToVector2Array(bufferData);
4581
+ var texturecoords7 = GLTFUtils.floatBufferToVector2Array(bufferData);
4544
4582
  mesh.setUVs(texturecoords7, 7);
4545
4583
  break;
4546
4584
  case "COLOR_0":
4547
- var colors = GLTFUtil.floatBufferToColorArray(bufferData, accessors[attributes["COLOR_0"]].type === AccessorType.VEC3);
4585
+ var colors = GLTFUtils.floatBufferToColorArray(bufferData, accessors[attributes["COLOR_0"]].type === AccessorType.VEC3);
4548
4586
  mesh.setColors(colors);
4549
4587
  break;
4550
4588
  case "TANGENT":
4551
- var tangents = GLTFUtil.floatBufferToVector4Array(bufferData);
4589
+ var tangents = GLTFUtils.floatBufferToVector4Array(bufferData);
4552
4590
  mesh.setTangents(tangents);
4553
4591
  break;
4554
4592
  case "JOINTS_0":
4555
- var joints = GLTFUtil.floatBufferToVector4Array(bufferData);
4593
+ var joints = GLTFUtils.floatBufferToVector4Array(bufferData);
4556
4594
  mesh.setBoneIndices(joints);
4557
4595
  break;
4558
4596
  case "WEIGHTS_0":
4559
- var weights = GLTFUtil.floatBufferToVector4Array(bufferData);
4597
+ var weights = GLTFUtils.floatBufferToVector4Array(bufferData);
4560
4598
  mesh.setBoneWeights(weights);
4561
4599
  break;
4562
4600
  }
@@ -4576,7 +4614,9 @@ var KHR_draco_mesh_compression = (_KHR_draco_mesh_compression = /*#__PURE__*/ fu
4576
4614
  return Promise.resolve(mesh);
4577
4615
  };
4578
4616
  return KHR_draco_mesh_compression1;
4579
- }(GLTFExtensionParser), _KHR_draco_mesh_compression._tempVector3 = new Vector3(), _KHR_draco_mesh_compression);
4617
+ }(GLTFExtensionParser), function() {
4618
+ _KHR_draco_mesh_compression._tempVector3 = new Vector3();
4619
+ }(), _KHR_draco_mesh_compression);
4580
4620
  KHR_draco_mesh_compression = __decorate([
4581
4621
  registerGLTFExtension("KHR_draco_mesh_compression", GLTFExtensionMode.CreateAndParse)
4582
4622
  ], KHR_draco_mesh_compression);
@@ -4757,12 +4797,12 @@ KHR_texture_transform = __decorate([
4757
4797
  registerGLTFExtension("KHR_texture_transform", GLTFExtensionMode.AdditiveParse)
4758
4798
  ], KHR_texture_transform);
4759
4799
 
4760
- var GalaceanMaterialsRemap = /*#__PURE__*/ function(GLTFExtensionParser) {
4761
- _inherits(GalaceanMaterialsRemap, GLTFExtensionParser);
4762
- function GalaceanMaterialsRemap() {
4800
+ var GALACEAN_materials_remap = /*#__PURE__*/ function(GLTFExtensionParser) {
4801
+ _inherits(GALACEAN_materials_remap, GLTFExtensionParser);
4802
+ function GALACEAN_materials_remap() {
4763
4803
  return GLTFExtensionParser.apply(this, arguments);
4764
4804
  }
4765
- var _proto = GalaceanMaterialsRemap.prototype;
4805
+ var _proto = GALACEAN_materials_remap.prototype;
4766
4806
  /**
4767
4807
  * @override
4768
4808
  */ _proto.createAndParse = function createAndParse(context, schema) {
@@ -4770,18 +4810,18 @@ var GalaceanMaterialsRemap = /*#__PURE__*/ function(GLTFExtensionParser) {
4770
4810
  // @ts-ignore
4771
4811
  return engine.resourceManager.getResourceByRef(schema);
4772
4812
  };
4773
- return GalaceanMaterialsRemap;
4813
+ return GALACEAN_materials_remap;
4774
4814
  }(GLTFExtensionParser);
4775
- GalaceanMaterialsRemap = __decorate([
4776
- registerGLTFExtension("OASIS_materials_remap", GLTFExtensionMode.CreateAndParse)
4777
- ], GalaceanMaterialsRemap);
4815
+ GALACEAN_materials_remap = __decorate([
4816
+ registerGLTFExtension("GALACEAN_materials_remap", GLTFExtensionMode.CreateAndParse)
4817
+ ], GALACEAN_materials_remap);
4778
4818
 
4779
- var OASIS_animation_event = /*#__PURE__*/ function(GLTFExtensionParser) {
4780
- _inherits(OASIS_animation_event, GLTFExtensionParser);
4781
- function OASIS_animation_event() {
4819
+ var GALACEAN_animation_event = /*#__PURE__*/ function(GLTFExtensionParser) {
4820
+ _inherits(GALACEAN_animation_event, GLTFExtensionParser);
4821
+ function GALACEAN_animation_event() {
4782
4822
  return GLTFExtensionParser.apply(this, arguments);
4783
4823
  }
4784
- var _proto = OASIS_animation_event.prototype;
4824
+ var _proto = GALACEAN_animation_event.prototype;
4785
4825
  /**
4786
4826
  * @override
4787
4827
  */ _proto.additiveParse = function additiveParse(context, animationClip, schema) {
@@ -4795,11 +4835,11 @@ var OASIS_animation_event = /*#__PURE__*/ function(GLTFExtensionParser) {
4795
4835
  animationClip.addEvent(event);
4796
4836
  });
4797
4837
  };
4798
- return OASIS_animation_event;
4838
+ return GALACEAN_animation_event;
4799
4839
  }(GLTFExtensionParser);
4800
- OASIS_animation_event = __decorate([
4801
- registerGLTFExtension("OASIS_animation_event", GLTFExtensionMode.AdditiveParse)
4802
- ], OASIS_animation_event);
4840
+ GALACEAN_animation_event = __decorate([
4841
+ registerGLTFExtension("GALACEAN_animation_event", GLTFExtensionMode.AdditiveParse)
4842
+ ], GALACEAN_animation_event);
4803
4843
 
4804
- export { AnimationClipDecoder, ComponentMap, EditorTextureLoader, GLTFAnimationParser, GLTFBufferParser, GLTFEntityParser, GLTFExtensionMode, GLTFExtensionParser, GLTFMaterialParser, GLTFMeshParser, GLTFParser, GLTFParserContext, GLTFPipeline, GLTFResource, GLTFSceneParser, GLTFSkinParser, GLTFTextureParser, GLTFUtil, GLTFValidator, InterpolableValueType, MeshDecoder, MeshLoader$1 as MeshLoader, PrefabParser, ReflectionParser, SceneParser, Texture2DDecoder, decode, parseSingleKTX, registerGLTFExtension };
4844
+ export { AnimationClipDecoder, ComponentMap, EditorTextureLoader, GLTFAnimationParser, GLTFBufferParser, GLTFEntityParser, GLTFExtensionMode, GLTFExtensionParser, GLTFMaterialParser, GLTFMeshParser, GLTFParser, GLTFParserContext, GLTFPipeline, GLTFResource, GLTFSceneParser, GLTFSkinParser, GLTFTextureParser, GLTFUtils, GLTFValidator, InterpolableValueType, MeshDecoder, MeshLoader$1 as MeshLoader, PrefabParser, ReflectionParser, SceneParser, Texture2DDecoder, decode, parseSingleKTX, registerGLTFExtension };
4805
4845
  //# sourceMappingURL=module.js.map