@galacean/engine-loader 0.0.0-experimental-renderSort.4 → 0.0.0-experimental-stateMachine.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.
Files changed (43) hide show
  1. package/LICENSE +2 -2
  2. package/dist/main.js +1234 -706
  3. package/dist/main.js.map +1 -1
  4. package/dist/miniprogram.js +1233 -706
  5. package/dist/module.js +1222 -695
  6. package/dist/module.js.map +1 -1
  7. package/package.json +4 -5
  8. package/types/GLTFContentRestorer.d.ts +7 -6
  9. package/types/GLTFLoader.d.ts +7 -1
  10. package/types/gltf/GLTFResource.d.ts +58 -22
  11. package/types/gltf/GLTFSchema.d.ts +1 -1
  12. package/types/gltf/GLTFUtils.d.ts +6 -10
  13. package/types/gltf/extensions/EXT_meshopt_compression.d.ts +13 -0
  14. package/types/gltf/extensions/GLTFExtensionParser.d.ts +1 -1
  15. package/types/gltf/extensions/GLTFExtensionSchema.d.ts +18 -10
  16. package/types/gltf/extensions/KHR_materials_anisotropy.d.ts +1 -0
  17. package/types/gltf/extensions/MeshoptDecoder.d.ts +8 -0
  18. package/types/gltf/extensions/index.d.ts +2 -1
  19. package/types/gltf/index.d.ts +2 -1
  20. package/types/gltf/parser/GLTFAnimatorControllerParser.d.ts +7 -0
  21. package/types/gltf/parser/GLTFBufferViewParser.d.ts +5 -0
  22. package/types/gltf/parser/GLTFMeshParser.d.ts +7 -6
  23. package/types/gltf/parser/GLTFParser.d.ts +1 -1
  24. package/types/gltf/parser/GLTFParserContext.d.ts +23 -7
  25. package/types/gltf/parser/GLTFSchemaParser.d.ts +0 -1
  26. package/types/gltf/parser/index.d.ts +3 -1
  27. package/types/index.d.ts +3 -1
  28. package/types/ktx2/KTX2Loader.d.ts +4 -3
  29. package/types/resource-deserialize/index.d.ts +2 -1
  30. package/types/resource-deserialize/resources/animationClip/AnimationClipDecoder.d.ts +0 -1
  31. package/types/resource-deserialize/resources/parser/HierarchyParser.d.ts +36 -0
  32. package/types/resource-deserialize/resources/parser/ParserContext.d.ts +29 -0
  33. package/types/resource-deserialize/resources/parser/ReflectionParser.d.ts +4 -4
  34. package/types/resource-deserialize/resources/prefab/PrefabParser.d.ts +14 -0
  35. package/types/resource-deserialize/resources/prefab/PrefabParserContext.d.ts +5 -0
  36. package/types/resource-deserialize/resources/scene/SceneParser.d.ts +3 -17
  37. package/types/resource-deserialize/resources/scene/SceneParserContext.d.ts +6 -12
  38. package/types/resource-deserialize/resources/schema/BasicSchema.d.ts +24 -1
  39. package/types/resource-deserialize/resources/schema/SceneSchema.d.ts +9 -1
  40. package/types/gltf/GLTFPipeline.d.ts +0 -23
  41. package/types/resource-deserialize/resources/animationClip/ComponentMap.d.ts +0 -2
  42. package/types/resource-deserialize/resources/parser/PrefabParser.d.ts +0 -5
  43. /package/types/{gltf/extensions/KHR_draco_mesh_compression.d.ts → PrimitiveMeshLoader.d.ts} +0 -0
package/dist/main.js CHANGED
@@ -5,7 +5,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var engineCore = require('@galacean/engine-core');
6
6
  var engineMath = require('@galacean/engine-math');
7
7
  var engineRhiWebgl = require('@galacean/engine-rhi-webgl');
8
- var engineDraco = require('@galacean/engine-draco');
9
8
 
10
9
  function _extends() {
11
10
  _extends = Object.assign || function assign(target) {
@@ -641,8 +640,7 @@ var ReflectionParser = /*#__PURE__*/ function() {
641
640
  var assetRefId = entityConfig.assetRefId;
642
641
  var engine = this._context.engine;
643
642
  if (assetRefId) {
644
- return engine.resourceManager// @ts-ignore
645
- .getResourceByRef({
643
+ return engine.resourceManager.getResourceByRef({
646
644
  refId: assetRefId,
647
645
  key: entityConfig.key,
648
646
  isClone: entityConfig.isClone
@@ -673,37 +671,373 @@ var ReflectionParser = /*#__PURE__*/ function() {
673
671
  ReflectionParser.customParseComponentHandles = new Map();
674
672
  })();
675
673
 
676
- var PrefabParser = /*#__PURE__*/ function() {
677
- function PrefabParser() {}
678
- PrefabParser.parseChildren = function parseChildren(entitiesConfig, entities, parentId) {
679
- var children = entitiesConfig.get(parentId).children;
674
+ /**
675
+ * Parser context
676
+ * @export
677
+ * @abstract
678
+ * @class ParserContext
679
+ * @template T
680
+ * @template I
681
+ */ var ParserContext = /*#__PURE__*/ function() {
682
+ function ParserContext(originalData, engine, target) {
683
+ this.originalData = originalData;
684
+ this.engine = engine;
685
+ this.target = target;
686
+ this.entityMap = new Map();
687
+ this.components = new Map();
688
+ this.assets = new Map();
689
+ this.entityConfigMap = new Map();
690
+ this.rootIds = [];
691
+ this.strippedIds = [];
692
+ this.resourceManager = engine.resourceManager;
693
+ }
694
+ var _proto = ParserContext.prototype;
695
+ /**
696
+ * Destroy the context.
697
+ * @abstract
698
+ * @memberof ParserContext
699
+ */ _proto.destroy = function destroy() {
700
+ this.entityMap.clear();
701
+ this.components.clear();
702
+ this.assets.clear();
703
+ this.entityConfigMap.clear();
704
+ this.rootIds.length = 0;
705
+ };
706
+ return ParserContext;
707
+ }();
708
+
709
+ var PrefabParserContext = /*#__PURE__*/ function(ParserContext1) {
710
+ _inherits(PrefabParserContext, ParserContext1);
711
+ function PrefabParserContext() {
712
+ return ParserContext1.apply(this, arguments);
713
+ }
714
+ return PrefabParserContext;
715
+ }(ParserContext);
716
+
717
+ function _array_like_to_array(arr, len) {
718
+ if (len == null || len > arr.length) len = arr.length;
719
+
720
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
721
+
722
+ return arr2;
723
+ }
724
+
725
+ function _unsupported_iterable_to_array(o, minLen) {
726
+ if (!o) return;
727
+ if (typeof o === "string") return _array_like_to_array(o, minLen);
728
+
729
+ var n = Object.prototype.toString.call(o).slice(8, -1);
730
+
731
+ if (n === "Object" && o.constructor) n = o.constructor.name;
732
+ if (n === "Map" || n === "Set") return Array.from(n);
733
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
734
+ }
735
+
736
+ function _create_for_of_iterator_helper_loose(o, allowArrayLike) {
737
+ var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
738
+
739
+ if (it) return (it = it.call(o)).next.bind(it);
740
+ // Fallback for engines without symbol support
741
+ if (Array.isArray(o) || (it = _unsupported_iterable_to_array(o)) || allowArrayLike && o && typeof o.length === "number") {
742
+ if (it) o = it;
743
+
744
+ var i = 0;
745
+
746
+ return function() {
747
+ if (i >= o.length) return { done: true };
748
+
749
+ return { done: false, value: o[i++] };
750
+ };
751
+ }
752
+
753
+ throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
754
+ }
755
+
756
+ var HierarchyParser = /*#__PURE__*/ function() {
757
+ function HierarchyParser(context) {
758
+ var _this = this;
759
+ this.context = context;
760
+ this.prefabContextMap = new WeakMap();
761
+ this.prefabPromiseMap = new Map();
762
+ this._engine = this.context.engine;
763
+ this._organizeEntities = this._organizeEntities.bind(this);
764
+ this._parseComponents = this._parseComponents.bind(this);
765
+ this._parsePrefabModification = this._parsePrefabModification.bind(this);
766
+ this._parsePrefabRemovedEntities = this._parsePrefabRemovedEntities.bind(this);
767
+ this._parsePrefabRemovedComponents = this._parsePrefabRemovedComponents.bind(this);
768
+ this._clearAndResolve = this._clearAndResolve.bind(this);
769
+ this.promise = new Promise(function(resolve, reject) {
770
+ _this._reject = reject;
771
+ _this._resolve = resolve;
772
+ });
773
+ this._reflectionParser = new ReflectionParser(context);
774
+ }
775
+ var _proto = HierarchyParser.prototype;
776
+ /** start parse the scene or prefab or others */ _proto.start = function start() {
777
+ this._parseEntities().then(this._organizeEntities).then(this._parseComponents).then(this._parsePrefabModification).then(this._parsePrefabRemovedEntities).then(this._parsePrefabRemovedComponents).then(this._clearAndResolve).then(this._resolve).catch(this._reject);
778
+ };
779
+ _proto._parseEntities = function _parseEntities() {
780
+ var _this = this;
781
+ var entitiesConfig = this.context.originalData.entities;
782
+ var entityConfigMap = this.context.entityConfigMap;
783
+ var entityMap = this.context.entityMap;
784
+ var engine = this._engine;
785
+ var promises = entitiesConfig.map(function(entityConfig) {
786
+ var _entityConfig_strippedId;
787
+ var id = (_entityConfig_strippedId = entityConfig.strippedId) != null ? _entityConfig_strippedId : entityConfig.id;
788
+ entityConfig.id = id;
789
+ entityConfigMap.set(id, entityConfig);
790
+ return _this._getEntityByConfig(entityConfig, engine);
791
+ });
792
+ return Promise.all(promises).then(function(entities) {
793
+ for(var i = 0, l = entities.length; i < l; i++){
794
+ entityMap.set(entitiesConfig[i].id, entities[i]);
795
+ }
796
+ return entities;
797
+ });
798
+ };
799
+ _proto._parseComponents = function _parseComponents() {
800
+ var entitiesConfig = this.context.originalData.entities;
801
+ var entityMap = this.context.entityMap;
802
+ var components = this.context.components;
803
+ var promises = [];
804
+ for(var i = 0, l = entitiesConfig.length; i < l; i++){
805
+ var entityConfig = entitiesConfig[i];
806
+ var entity = entityMap.get(entityConfig.id);
807
+ for(var i1 = 0; i1 < entityConfig.components.length; i1++){
808
+ var componentConfig = entityConfig.components[i1];
809
+ var key = !componentConfig.refId ? componentConfig.class : componentConfig.refId;
810
+ var component = entity.addComponent(engineCore.Loader.getClass(key));
811
+ components.set(componentConfig.id, component);
812
+ var promise = this._reflectionParser.parsePropsAndMethods(component, componentConfig);
813
+ promises.push(promise);
814
+ }
815
+ }
816
+ return Promise.all(promises);
817
+ };
818
+ _proto._parsePrefabModification = function _parsePrefabModification() {
819
+ var _loop = function(i, l) {
820
+ var _modifications;
821
+ var entityConfig = entitiesConfig[i];
822
+ var id = entityConfig.id, modifications = entityConfig.modifications;
823
+ if ((_modifications = modifications) == null ? void 0 : _modifications.length) {
824
+ var _promises;
825
+ var rootEntity = entityMap.get(id);
826
+ (_promises = promises).push.apply(_promises, [].concat(modifications.map(function(modification) {
827
+ var target = modification.target, props = modification.props, methods = modification.methods;
828
+ var entityId = target.entityId, componentId = target.componentId;
829
+ var context = _this.prefabContextMap.get(rootEntity);
830
+ var targetEntity = context.entityMap.get(entityId);
831
+ var targetComponent = context.components.get(componentId);
832
+ if (targetComponent) {
833
+ return _this._reflectionParser.parsePropsAndMethods(targetComponent, {
834
+ props: props,
835
+ methods: methods
836
+ });
837
+ } else if (targetEntity) {
838
+ return Promise.resolve(_this._applyEntityData(targetEntity, props));
839
+ }
840
+ })));
841
+ }
842
+ };
843
+ var _this = this;
844
+ var entitiesConfig = this.context.originalData.entities;
845
+ var entityMap = this.context.entityMap;
846
+ var promises = [];
847
+ for(var i = 0, l = entitiesConfig.length; i < l; i++)_loop(i);
848
+ return Promise.all(promises);
849
+ };
850
+ _proto._parsePrefabRemovedEntities = function _parsePrefabRemovedEntities() {
851
+ var _loop = function(i, l) {
852
+ var _removedEntities;
853
+ var entityConfig = entitiesConfig[i];
854
+ var id = entityConfig.id, removedEntities = entityConfig.removedEntities;
855
+ if ((_removedEntities = removedEntities) == null ? void 0 : _removedEntities.length) {
856
+ var _promises;
857
+ var rootEntity = entityMap.get(id);
858
+ (_promises = promises).push.apply(_promises, [].concat(removedEntities.map(function(target) {
859
+ var entityId = target.entityId;
860
+ var context = _this.prefabContextMap.get(rootEntity);
861
+ var targetEntity = context.entityMap.get(entityId);
862
+ if (targetEntity) {
863
+ targetEntity.destroy();
864
+ }
865
+ })));
866
+ }
867
+ };
868
+ var _this = this;
869
+ var entitiesConfig = this.context.originalData.entities;
870
+ var entityMap = this.context.entityMap;
871
+ var promises = [];
872
+ for(var i = 0, l = entitiesConfig.length; i < l; i++)_loop(i);
873
+ return Promise.all(promises);
874
+ };
875
+ _proto._parsePrefabRemovedComponents = function _parsePrefabRemovedComponents() {
876
+ var _loop = function(i, l) {
877
+ var _removedComponents;
878
+ var entityConfig = entitiesConfig[i];
879
+ var id = entityConfig.id, removedComponents = entityConfig.removedComponents;
880
+ if ((_removedComponents = removedComponents) == null ? void 0 : _removedComponents.length) {
881
+ var _promises;
882
+ var rootEntity = entityMap.get(id);
883
+ (_promises = promises).concat.apply(_promises, [].concat(removedComponents.map(function(target) {
884
+ var componentId = target.componentId;
885
+ var context = _this.prefabContextMap.get(rootEntity);
886
+ var targetComponent = context.components.get(componentId);
887
+ if (targetComponent) {
888
+ targetComponent.destroy();
889
+ }
890
+ })));
891
+ }
892
+ };
893
+ var _this = this;
894
+ var entitiesConfig = this.context.originalData.entities;
895
+ var entityMap = this.context.entityMap;
896
+ var promises = [];
897
+ for(var i = 0, l = entitiesConfig.length; i < l; i++)_loop(i);
898
+ return Promise.all(promises);
899
+ };
900
+ _proto._clearAndResolve = function _clearAndResolve() {
901
+ var target = this.context.target;
902
+ return target;
903
+ };
904
+ _proto._organizeEntities = function _organizeEntities() {
905
+ var _this_context = this.context, rootIds = _this_context.rootIds, strippedIds = _this_context.strippedIds;
906
+ var parentIds = rootIds.concat(strippedIds);
907
+ for(var _iterator = _create_for_of_iterator_helper_loose(parentIds), _step; !(_step = _iterator()).done;){
908
+ var parentId = _step.value;
909
+ this._parseChildren(parentId);
910
+ }
911
+ for(var i = 0; i < rootIds.length; i++){
912
+ this.handleRootEntity(rootIds[i]);
913
+ }
914
+ };
915
+ _proto._getEntityByConfig = function _getEntityByConfig(entityConfig, engine) {
916
+ var _this = this;
917
+ var entityPromise;
918
+ if (entityConfig.assetRefId) {
919
+ entityPromise = this._parseGLTF(entityConfig, engine);
920
+ } else if (entityConfig.strippedId) {
921
+ entityPromise = this._parseStrippedEntity(entityConfig);
922
+ } else {
923
+ entityPromise = this._parseEntity(entityConfig, engine);
924
+ }
925
+ return entityPromise.then(function(entity) {
926
+ return _this._applyEntityData(entity, entityConfig);
927
+ });
928
+ };
929
+ _proto._parseEntity = function _parseEntity(entityConfig, engine) {
930
+ var entity = new engineCore.Entity(engine, entityConfig.name);
931
+ if (!entityConfig.parent) this.context.rootIds.push(entityConfig.id);
932
+ return Promise.resolve(entity);
933
+ };
934
+ _proto._parseGLTF = function _parseGLTF(entityConfig, engine) {
935
+ var _this = this;
936
+ var assetRefId = entityConfig.assetRefId;
937
+ var context = new ParserContext(null, engine);
938
+ return engine.resourceManager// @ts-ignore
939
+ .getResourceByRef({
940
+ refId: assetRefId
941
+ }).then(function(glTFResource) {
942
+ var entity = glTFResource.instantiateSceneRoot();
943
+ if (!entityConfig.parent) _this.context.rootIds.push(entityConfig.id);
944
+ _this._traverseAddEntityToMap(entity, context, "");
945
+ _this.prefabContextMap.set(entity, context);
946
+ var cbArray = _this.prefabPromiseMap.get(entityConfig.id);
947
+ cbArray && cbArray.forEach(function(cb) {
948
+ cb.resolve(context);
949
+ });
950
+ return entity;
951
+ });
952
+ };
953
+ _proto._parseStrippedEntity = function _parseStrippedEntity(entityConfig) {
954
+ var _this = this;
955
+ this.context.strippedIds.push(entityConfig.id);
956
+ return new Promise(function(resolve, reject) {
957
+ var _this_prefabPromiseMap_get;
958
+ var cbArray = (_this_prefabPromiseMap_get = _this.prefabPromiseMap.get(entityConfig.prefabInstanceId)) != null ? _this_prefabPromiseMap_get : [];
959
+ cbArray.push({
960
+ resolve: resolve,
961
+ reject: reject
962
+ });
963
+ _this.prefabPromiseMap.set(entityConfig.prefabInstanceId, cbArray);
964
+ }).then(function(context) {
965
+ var entityId = entityConfig.prefabSource.entityId;
966
+ return context.entityMap.get(entityId);
967
+ });
968
+ };
969
+ _proto._parseChildren = function _parseChildren(parentId) {
970
+ var _this_context = this.context, entityConfigMap = _this_context.entityConfigMap, entityMap = _this_context.entityMap;
971
+ var children = entityConfigMap.get(parentId).children;
680
972
  if (children && children.length > 0) {
681
- var parent = entities.get(parentId);
973
+ var parent = entityMap.get(parentId);
682
974
  for(var i = 0; i < children.length; i++){
683
975
  var childId = children[i];
684
- var entity = entities.get(childId);
976
+ var entity = entityMap.get(childId);
685
977
  parent.addChild(entity);
686
- this.parseChildren(entitiesConfig, entities, childId);
978
+ this._parseChildren(childId);
687
979
  }
688
980
  }
689
981
  };
690
- return PrefabParser;
982
+ _proto._applyEntityData = function _applyEntityData(entity, entityConfig) {
983
+ if (entityConfig === void 0) entityConfig = {};
984
+ var _entityConfig_isActive;
985
+ entity.isActive = (_entityConfig_isActive = entityConfig.isActive) != null ? _entityConfig_isActive : entity.isActive;
986
+ var _entityConfig_name;
987
+ entity.name = (_entityConfig_name = entityConfig.name) != null ? _entityConfig_name : entity.name;
988
+ var position = entityConfig.position, rotation = entityConfig.rotation, scale = entityConfig.scale, layer = entityConfig.layer;
989
+ if (position) entity.transform.position.copyFrom(position);
990
+ if (rotation) entity.transform.rotation.copyFrom(rotation);
991
+ if (scale) entity.transform.scale.copyFrom(scale);
992
+ if (layer) entity.layer = layer;
993
+ return entity;
994
+ };
995
+ _proto._traverseAddEntityToMap = function _traverseAddEntityToMap(entity, context, path) {
996
+ var entityMap = context.entityMap, components = context.components;
997
+ var componentsMap = {};
998
+ var componentIndexMap = {};
999
+ entityMap.set(path, entity);
1000
+ // @ts-ignore
1001
+ entity._components.forEach(function(component) {
1002
+ // @ts-ignore
1003
+ var name = engineCore.Loader.getClassName(component.constructor);
1004
+ if (!componentsMap[name]) {
1005
+ componentsMap[name] = entity.getComponents(component.constructor, []);
1006
+ componentIndexMap[name] = 0;
1007
+ }
1008
+ components.set(path + ":" + name + "/" + componentIndexMap[name]++, component);
1009
+ });
1010
+ for(var i = 0, n = entity.children.length; i < n; i++){
1011
+ var child = entity.children[i];
1012
+ var childPath = path ? path + "/" + i : "" + i;
1013
+ this._traverseAddEntityToMap(child, context, childPath);
1014
+ }
1015
+ };
1016
+ return HierarchyParser;
691
1017
  }();
692
1018
 
693
- var ComponentMap = {
694
- Transform: engineCore.Transform,
695
- Animator: engineCore.Animator,
696
- DirectLight: engineCore.DirectLight,
697
- Camera: engineCore.Camera,
698
- MeshRenderer: engineCore.MeshRenderer,
699
- ParticleRenderer: engineCore.ParticleRenderer,
700
- PointLight: engineCore.PointLight,
701
- SpotLight: engineCore.SpotLight,
702
- Script: engineCore.Script,
703
- SpriteMask: engineCore.SpriteMask,
704
- SpriteRenderer: engineCore.SpriteRenderer,
705
- TextRenderer: engineCore.TextRenderer
706
- };
1019
+ var PrefabParser = /*#__PURE__*/ function(HierarchyParser1) {
1020
+ _inherits(PrefabParser, HierarchyParser1);
1021
+ function PrefabParser() {
1022
+ return HierarchyParser1.apply(this, arguments);
1023
+ }
1024
+ var _proto = PrefabParser.prototype;
1025
+ _proto.handleRootEntity = function handleRootEntity(id) {
1026
+ this.context.target = this.context.entityMap.get(id);
1027
+ };
1028
+ /**
1029
+ * Parse prefab data.
1030
+ * @param engine - the engine of the parser context
1031
+ * @param prefabData - prefab data which is exported by editor
1032
+ * @returns a promise of prefab
1033
+ */ PrefabParser.parse = function parse(engine, prefabData) {
1034
+ var context = new PrefabParserContext(prefabData, engine);
1035
+ var parser = new PrefabParser(context);
1036
+ parser.start();
1037
+ return parser;
1038
+ };
1039
+ return PrefabParser;
1040
+ }(HierarchyParser);
707
1041
 
708
1042
  exports.InterpolableValueType = void 0;
709
1043
  (function(InterpolableValueType) {
@@ -737,8 +1071,9 @@ exports.AnimationClipDecoder = /*#__PURE__*/ function() {
737
1071
  for(var i1 = 0; i1 < curveBindingsLen; ++i1){
738
1072
  var relativePath = bufferReader.nextStr();
739
1073
  var componentStr = bufferReader.nextStr();
740
- var componentType = ComponentMap[componentStr];
1074
+ var componentType = engineCore.Loader.getClass(componentStr);
741
1075
  var property = bufferReader.nextStr();
1076
+ var getProperty = bufferReader.nextStr();
742
1077
  var curve = void 0;
743
1078
  var interpolation = bufferReader.nextUint8();
744
1079
  var keysLen = bufferReader.nextUint16();
@@ -863,13 +1198,42 @@ exports.AnimationClipDecoder = /*#__PURE__*/ function() {
863
1198
  for(var j7 = 0; j7 < keysLen; ++j7){
864
1199
  var keyframe8 = new engineCore.Keyframe();
865
1200
  keyframe8.time = bufferReader.nextFloat32();
866
- keyframe8.value = JSON.parse(bufferReader.nextStr());
1201
+ var str = bufferReader.nextStr();
1202
+ if (str) {
1203
+ keyframe8.value = JSON.parse(str);
1204
+ } else {
1205
+ keyframe8.value = null;
1206
+ }
867
1207
  curve.addKey(keyframe8);
868
1208
  }
869
1209
  break;
870
1210
  }
1211
+ case "AnimationBoolCurve":
1212
+ {
1213
+ curve = new engineCore.AnimationBoolCurve();
1214
+ curve.interpolation = interpolation;
1215
+ for(var j8 = 0; j8 < keysLen; ++j8){
1216
+ var keyframe9 = new engineCore.Keyframe();
1217
+ keyframe9.time = bufferReader.nextFloat32();
1218
+ keyframe9.value = bufferReader.nextUint8() === 1;
1219
+ curve.addKey(keyframe9);
1220
+ }
1221
+ break;
1222
+ }
1223
+ case "AnimationStringCurve":
1224
+ {
1225
+ curve = new engineCore.AnimationStringCurve();
1226
+ curve.interpolation = interpolation;
1227
+ for(var j9 = 0; j9 < keysLen; ++j9){
1228
+ var keyframe10 = new engineCore.Keyframe();
1229
+ keyframe10.time = bufferReader.nextFloat32();
1230
+ keyframe10.value = bufferReader.nextStr();
1231
+ curve.addKey(keyframe10);
1232
+ }
1233
+ break;
1234
+ }
871
1235
  }
872
- clip.addCurveBinding(relativePath, componentType, property, curve);
1236
+ clip.addCurveBinding(relativePath, componentType, property, getProperty, curve);
873
1237
  }
874
1238
  resolve(clip);
875
1239
  });
@@ -886,145 +1250,28 @@ exports.SpecularMode = void 0;
886
1250
  SpecularMode["Custom"] = "Custom";
887
1251
  })(exports.SpecularMode || (exports.SpecularMode = {}));
888
1252
 
889
- function _array_like_to_array(arr, len) {
890
- if (len == null || len > arr.length) len = arr.length;
891
-
892
- for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
893
-
894
- return arr2;
895
- }
896
-
897
- function _unsupported_iterable_to_array(o, minLen) {
898
- if (!o) return;
899
- if (typeof o === "string") return _array_like_to_array(o, minLen);
900
-
901
- var n = Object.prototype.toString.call(o).slice(8, -1);
902
-
903
- if (n === "Object" && o.constructor) n = o.constructor.name;
904
- if (n === "Map" || n === "Set") return Array.from(n);
905
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
906
- }
907
-
908
- function _create_for_of_iterator_helper_loose(o, allowArrayLike) {
909
- var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
910
-
911
- if (it) return (it = it.call(o)).next.bind(it);
912
- // Fallback for engines without symbol support
913
- if (Array.isArray(o) || (it = _unsupported_iterable_to_array(o)) || allowArrayLike && o && typeof o.length === "number") {
914
- if (it) o = it;
915
-
916
- var i = 0;
917
-
918
- return function() {
919
- if (i >= o.length) return { done: true };
920
-
921
- return { done: false, value: o[i++] };
922
- };
923
- }
924
-
925
- throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
926
- }
927
-
928
- var SceneParserContext = /*#__PURE__*/ function() {
929
- function SceneParserContext(originalData, scene) {
930
- this.originalData = originalData;
931
- this.scene = scene;
932
- this.entityMap = new Map();
933
- this.components = new Map();
934
- this.assets = new Map();
935
- this.entityConfigMap = new Map();
936
- this.rootIds = [];
937
- this.engine = scene.engine;
938
- this.resourceManager = scene.engine.resourceManager;
1253
+ var SceneParserContext = /*#__PURE__*/ function(ParserContext1) {
1254
+ _inherits(SceneParserContext, ParserContext1);
1255
+ function SceneParserContext(originalData, engine, scene) {
1256
+ var _this;
1257
+ _this = ParserContext1.call(this, originalData, engine, scene) || this;
1258
+ _this.originalData = originalData;
1259
+ _this.engine = engine;
1260
+ _this.scene = scene;
1261
+ return _this;
939
1262
  }
940
- var _proto = SceneParserContext.prototype;
941
- _proto.destroy = function destroy() {
942
- this.entityMap.clear();
943
- this.components.clear();
944
- this.assets.clear();
945
- this.entityConfigMap.clear();
946
- this.rootIds.length = 0;
947
- };
948
1263
  return SceneParserContext;
949
- }();
1264
+ }(ParserContext);
950
1265
 
951
- /** @Internal */ var SceneParser = /*#__PURE__*/ function() {
952
- function SceneParser(context) {
953
- var _this = this;
954
- this.context = context;
955
- this._engine = context.scene.engine;
956
- this._organizeEntities = this._organizeEntities.bind(this);
957
- this._parseComponents = this._parseComponents.bind(this);
958
- this._clearAndResolveScene = this._clearAndResolveScene.bind(this);
959
- this.promise = new Promise(function(resolve, reject) {
960
- _this._reject = reject;
961
- _this._resolve = resolve;
962
- });
963
- this._reflectionParser = new ReflectionParser(context);
1266
+ /** @Internal */ var SceneParser = /*#__PURE__*/ function(HierarchyParser1) {
1267
+ _inherits(SceneParser, HierarchyParser1);
1268
+ function SceneParser() {
1269
+ return HierarchyParser1.apply(this, arguments);
964
1270
  }
965
1271
  var _proto = SceneParser.prototype;
966
- /** start parse the scene */ _proto.start = function start() {
967
- this._parseEntities().then(this._organizeEntities).then(this._parseComponents).then(this._clearAndResolveScene).then(this._resolve).catch(this._reject);
968
- };
969
- _proto._parseEntities = function _parseEntities() {
970
- var _this = this;
971
- var entitiesConfig = this.context.originalData.entities;
972
- var entityConfigMap = this.context.entityConfigMap;
973
- var entitiesMap = this.context.entityMap;
974
- var rootIds = this.context.rootIds;
975
- this._engine;
976
- var promises = entitiesConfig.map(function(entityConfig) {
977
- entityConfigMap.set(entityConfig.id, entityConfig);
978
- // record root entities
979
- if (!entityConfig.parent) rootIds.push(entityConfig.id);
980
- return _this._reflectionParser.parseEntity(entityConfig);
981
- });
982
- return Promise.all(promises).then(function(entities) {
983
- for(var i = 0, l = entities.length; i < l; i++){
984
- entitiesMap.set(entitiesConfig[i].id, entities[i]);
985
- }
986
- return entities;
987
- });
988
- };
989
- _proto._organizeEntities = function _organizeEntities() {
990
- var _this_context = this.context, entityConfigMap = _this_context.entityConfigMap, entityMap = _this_context.entityMap, scene = _this_context.scene, rootIds = _this_context.rootIds;
991
- for(var _iterator = _create_for_of_iterator_helper_loose(rootIds), _step; !(_step = _iterator()).done;){
992
- var rootId = _step.value;
993
- PrefabParser.parseChildren(entityConfigMap, entityMap, rootId);
994
- }
995
- var rootEntities = rootIds.map(function(id) {
996
- return entityMap.get(id);
997
- });
998
- for(var i = 0; i < rootEntities.length; i++){
999
- scene.addRootEntity(rootEntities[i]);
1000
- }
1001
- };
1002
- _proto._parseComponents = function _parseComponents() {
1003
- var entitiesConfig = this.context.originalData.entities;
1004
- var entityMap = this.context.entityMap;
1005
- var promises = [];
1006
- for(var i = 0, l = entitiesConfig.length; i < l; i++){
1007
- var entityConfig = entitiesConfig[i];
1008
- var entity = entityMap.get(entityConfig.id);
1009
- for(var i1 = 0; i1 < entityConfig.components.length; i1++){
1010
- var componentConfig = entityConfig.components[i1];
1011
- var key = !componentConfig.refId ? componentConfig.class : componentConfig.refId;
1012
- var component = void 0;
1013
- // TODO: remove hack code when support additional edit
1014
- if (key === "Animator") {
1015
- component = entity.getComponent(engineCore.Loader.getClass(key));
1016
- }
1017
- component = component || entity.addComponent(engineCore.Loader.getClass(key));
1018
- var promise = this._reflectionParser.parsePropsAndMethods(component, componentConfig);
1019
- promises.push(promise);
1020
- }
1021
- }
1022
- return Promise.all(promises);
1023
- };
1024
- _proto._clearAndResolveScene = function _clearAndResolveScene() {
1025
- var scene = this.context.scene;
1026
- this.context.destroy();
1027
- return scene;
1272
+ _proto.handleRootEntity = function handleRootEntity(id) {
1273
+ var _this_context = this.context, target = _this_context.target, entityMap = _this_context.entityMap;
1274
+ target.addRootEntity(entityMap.get(id));
1028
1275
  };
1029
1276
  /**
1030
1277
  * Parse scene data.
@@ -1033,13 +1280,13 @@ var SceneParserContext = /*#__PURE__*/ function() {
1033
1280
  * @returns a promise of scene
1034
1281
  */ SceneParser.parse = function parse(engine, sceneData) {
1035
1282
  var scene = new engineCore.Scene(engine);
1036
- var context = new SceneParserContext(sceneData, scene);
1283
+ var context = new SceneParserContext(sceneData, engine, scene);
1037
1284
  var parser = new SceneParser(context);
1038
1285
  parser.start();
1039
1286
  return parser.promise;
1040
1287
  };
1041
1288
  return SceneParser;
1042
- }();
1289
+ }(HierarchyParser);
1043
1290
 
1044
1291
  exports.MeshLoader = /*#__PURE__*/ function(Loader1) {
1045
1292
  _inherits(MeshLoader, Loader1);
@@ -1123,26 +1370,34 @@ var AnimationClipLoader = /*#__PURE__*/ function(Loader1) {
1123
1370
  var curveBindingPromises = clip.curveBindings.map(function(curveBinding) {
1124
1371
  var curve = curveBinding.curve;
1125
1372
  var promises = curve.keys.map(function(key) {
1126
- var value = key.value;
1127
- if (typeof value === "object" && value.refId) {
1128
- return new Promise(function(resolve) {
1129
- resourceManager// @ts-ignore
1130
- .getResourceByRef(value).then(function(asset) {
1131
- key.value = asset;
1132
- resolve(key);
1133
- }).catch(reject);
1134
- });
1135
- }
1373
+ return _this._parseKeyframeValue(key, resourceManager).then(function(actualValue) {
1374
+ key.value = actualValue;
1375
+ });
1136
1376
  });
1137
1377
  return Promise.all(promises);
1138
1378
  });
1139
1379
  return Promise.all(curveBindingPromises).then(function() {
1140
1380
  resolve(clip);
1141
1381
  });
1142
- });
1382
+ }).catch(reject);
1143
1383
  }).catch(reject);
1144
1384
  });
1145
1385
  };
1386
+ _proto._parseKeyframeValue = function _parseKeyframeValue(keyframe, resourceManager) {
1387
+ var _value;
1388
+ var value = keyframe.value;
1389
+ if (typeof value === "object" && ((_value = value) == null ? void 0 : _value.refId)) {
1390
+ return new Promise(function(resolve) {
1391
+ resourceManager// @ts-ignore
1392
+ .getResourceByRef(value).then(function(asset) {
1393
+ keyframe.value = asset;
1394
+ resolve(keyframe.value);
1395
+ });
1396
+ });
1397
+ } else {
1398
+ return Promise.resolve(keyframe.value);
1399
+ }
1400
+ };
1146
1401
  return AnimationClipLoader;
1147
1402
  }(engineCore.Loader);
1148
1403
  AnimationClipLoader = __decorate([
@@ -1418,6 +1673,60 @@ FontLoader = __decorate([
1418
1673
  _this.url = url;
1419
1674
  return _this;
1420
1675
  }
1676
+ var _proto = GLTFResource.prototype;
1677
+ /**
1678
+ * Instantiate scene root entity.
1679
+ * @param sceneIndex - Scene index
1680
+ * @returns Root entity
1681
+ */ _proto.instantiateSceneRoot = function instantiateSceneRoot(sceneIndex) {
1682
+ var sceneRoot = sceneIndex === undefined ? this._defaultSceneRoot : this._sceneRoots[sceneIndex];
1683
+ return sceneRoot.clone();
1684
+ };
1685
+ _proto._onDestroy = function _onDestroy() {
1686
+ ReferResource1.prototype._onDestroy.call(this);
1687
+ var _this = this, textures = _this.textures, materials = _this.materials, meshes = _this.meshes;
1688
+ textures && this._disassociationSuperResource(textures);
1689
+ materials && this._disassociationSuperResource(materials);
1690
+ if (meshes) {
1691
+ for(var i = 0, n = meshes.length; i < n; i++){
1692
+ this._disassociationSuperResource(meshes[i]);
1693
+ }
1694
+ }
1695
+ };
1696
+ _proto._disassociationSuperResource = function _disassociationSuperResource(resources) {
1697
+ for(var i = 0, n = resources.length; i < n; i++){
1698
+ // @ts-ignore
1699
+ resources[i]._disassociationSuperResource(this);
1700
+ }
1701
+ };
1702
+ _create_class(GLTFResource, [
1703
+ {
1704
+ key: "extensionsData",
1705
+ get: /**
1706
+ * Extensions data.
1707
+ */ function get() {
1708
+ return this._extensionsData;
1709
+ }
1710
+ },
1711
+ {
1712
+ key: "sceneRoots",
1713
+ get: /**
1714
+ * @deprecated Please use `instantiateSceneRoot` instead.
1715
+ * RootEntities after SceneParser.
1716
+ */ function get() {
1717
+ return this._sceneRoots;
1718
+ }
1719
+ },
1720
+ {
1721
+ key: "defaultSceneRoot",
1722
+ get: /**
1723
+ * @deprecated Please use `instantiateSceneRoot` instead.
1724
+ * RootEntity after SceneParser.
1725
+ */ function get() {
1726
+ return this._defaultSceneRoot;
1727
+ }
1728
+ }
1729
+ ]);
1421
1730
  return GLTFResource;
1422
1731
  }(engineCore.ReferResource);
1423
1732
 
@@ -1444,7 +1753,7 @@ FontLoader = __decorate([
1444
1753
  * Float
1445
1754
  */ "FLOAT"] = 5126] = "FLOAT";
1446
1755
  })(AccessorComponentType || (AccessorComponentType = {}));
1447
- var AccessorType;
1756
+ exports.AccessorType = void 0;
1448
1757
  (function(AccessorType) {
1449
1758
  AccessorType[/**
1450
1759
  * Scalar
@@ -1467,7 +1776,7 @@ var AccessorType;
1467
1776
  AccessorType[/**
1468
1777
  * Matrix4x4
1469
1778
  */ "MAT4"] = "MAT4";
1470
- })(AccessorType || (AccessorType = {}));
1779
+ })(exports.AccessorType || (exports.AccessorType = {}));
1471
1780
  var AnimationChannelTargetPath;
1472
1781
  (function(AnimationChannelTargetPath) {
1473
1782
  AnimationChannelTargetPath[/**
@@ -1572,11 +1881,29 @@ var TextureWrapMode;
1572
1881
  * @internal
1573
1882
  */ var GLTFParserContext = /*#__PURE__*/ function() {
1574
1883
  function GLTFParserContext(glTFResource, resourceManager, params) {
1884
+ var _this = this;
1575
1885
  this.glTFResource = glTFResource;
1576
1886
  this.resourceManager = resourceManager;
1577
1887
  this.params = params;
1578
1888
  this.accessorBufferCache = {};
1889
+ this.needAnimatorController = false;
1579
1890
  this._resourceCache = new Map();
1891
+ this._progress = {
1892
+ taskDetail: {},
1893
+ taskComplete: {
1894
+ loaded: 0,
1895
+ total: 0
1896
+ }
1897
+ };
1898
+ this./**
1899
+ * @internal
1900
+ */ _onTaskDetail = function(url, loaded, total) {
1901
+ var _this__progress_taskDetail, _url;
1902
+ var detail = (_this__progress_taskDetail = _this._progress.taskDetail)[_url = url] || (_this__progress_taskDetail[_url] = {});
1903
+ detail.loaded = loaded;
1904
+ detail.total = total;
1905
+ _this._setTaskDetailProgress(url, loaded, total);
1906
+ };
1580
1907
  this.contentRestorer = new GLTFContentRestorer(glTFResource);
1581
1908
  }
1582
1909
  var _proto = GLTFParserContext.prototype;
@@ -1587,91 +1914,90 @@ var TextureWrapMode;
1587
1914
  return Promise.resolve(null);
1588
1915
  }
1589
1916
  var cache = this._resourceCache;
1590
- var isOnlyOne = type === 0 || type === 1;
1591
- var cacheKey = isOnlyOne || index === undefined ? "" + type : type + ":" + index;
1917
+ var cacheKey = index === undefined ? "" + type : type + ":" + index;
1592
1918
  var resource = cache.get(cacheKey);
1593
1919
  if (resource) {
1594
1920
  return resource;
1595
1921
  }
1596
- if (isOnlyOne) {
1597
- resource = parser.parse(this);
1598
- } else {
1599
- var glTFItems = this.glTF[glTFSchemaMap[type]];
1922
+ var glTFSchemaKey = glTFSchemaMap[type];
1923
+ var isSubAsset = !!glTFResourceMap[type];
1924
+ if (glTFSchemaKey) {
1925
+ var glTFItems = this.glTF[glTFSchemaKey];
1600
1926
  if (glTFItems && (index === undefined || glTFItems[index])) {
1601
1927
  if (index === undefined) {
1602
- resource = type === 7 ? glTFItems.map(function(_, index) {
1928
+ resource = type === 8 ? glTFItems.map(function(_, index) {
1603
1929
  return _this.get(type, index);
1604
1930
  }) : Promise.all(glTFItems.map(function(_, index) {
1605
1931
  return _this.get(type, index);
1606
1932
  }));
1607
1933
  } else {
1608
1934
  resource = parser.parse(this, index);
1609
- this._handleSubAsset(resource, type, index);
1935
+ isSubAsset && this._handleSubAsset(resource, type, index);
1610
1936
  }
1611
1937
  } else {
1612
1938
  resource = Promise.resolve(null);
1613
1939
  }
1940
+ } else {
1941
+ resource = parser.parse(this, index);
1942
+ isSubAsset && this._handleSubAsset(resource, type, index);
1614
1943
  }
1615
1944
  cache.set(cacheKey, resource);
1616
1945
  return resource;
1617
1946
  };
1618
1947
  _proto.parse = function parse() {
1619
1948
  var _this = this;
1620
- return this.get(0).then(function(json) {
1949
+ var promise = this.get(0).then(function(json) {
1621
1950
  _this.glTF = json;
1951
+ _this.needAnimatorController = !!(json.skins || json.animations);
1622
1952
  return Promise.all([
1623
1953
  _this.get(1),
1624
- _this.get(4),
1625
1954
  _this.get(5),
1626
1955
  _this.get(6),
1627
- _this.get(8),
1956
+ _this.get(7),
1628
1957
  _this.get(9),
1958
+ _this.get(10),
1959
+ _this.get(11),
1629
1960
  _this.get(2)
1630
1961
  ]).then(function() {
1631
1962
  var glTFResource = _this.glTFResource;
1632
- if (glTFResource.skins || glTFResource.animations) {
1633
- _this._createAnimator(_this, glTFResource.animations);
1963
+ var animatorController = glTFResource.animatorController;
1964
+ if (animatorController) {
1965
+ var animator = glTFResource._defaultSceneRoot.addComponent(engineCore.Animator);
1966
+ animator.animatorController = animatorController;
1634
1967
  }
1635
1968
  _this.resourceManager.addContentRestorer(_this.contentRestorer);
1636
1969
  return glTFResource;
1637
1970
  });
1638
1971
  });
1972
+ this._addTaskCompletePromise(promise);
1973
+ return promise;
1639
1974
  };
1640
- _proto._createAnimator = function _createAnimator(context, animations) {
1641
- var defaultSceneRoot = context.glTFResource.defaultSceneRoot;
1642
- var animator = defaultSceneRoot.addComponent(engineCore.Animator);
1643
- var animatorController = new engineCore.AnimatorController();
1644
- var layer = new engineCore.AnimatorControllerLayer("layer");
1645
- var animatorStateMachine = new engineCore.AnimatorStateMachine();
1646
- animatorController.addLayer(layer);
1647
- animator.animatorController = animatorController;
1648
- layer.stateMachine = animatorStateMachine;
1649
- if (animations) {
1650
- for(var i = 0; i < animations.length; i++){
1651
- var animationClip = animations[i];
1652
- var name = animationClip.name;
1653
- var uniqueName = animatorStateMachine.makeUniqueStateName(name);
1654
- if (uniqueName !== name) {
1655
- console.warn("AnimatorState name is existed, name: " + name + " reset to " + uniqueName);
1656
- }
1657
- var animatorState = animatorStateMachine.addState(uniqueName);
1658
- animatorState.clip = animationClip;
1659
- }
1660
- }
1975
+ /**
1976
+ * @internal
1977
+ */ _proto._addTaskCompletePromise = function _addTaskCompletePromise(taskPromise) {
1978
+ var _this = this;
1979
+ var task = this._progress.taskComplete;
1980
+ task.total += 1;
1981
+ taskPromise.then(function() {
1982
+ _this._setTaskCompleteProgress(++task.loaded, task.total);
1983
+ });
1661
1984
  };
1662
1985
  _proto._handleSubAsset = function _handleSubAsset(resource, type, index) {
1663
1986
  var _this = this;
1664
1987
  var glTFResourceKey = glTFResourceMap[type];
1665
- if (!glTFResourceKey) return;
1666
- if (type === 7) {
1988
+ if (type === 8) {
1667
1989
  var _this_glTFResource, _glTFResourceKey;
1668
1990
  ((_this_glTFResource = this.glTFResource)[_glTFResourceKey = glTFResourceKey] || (_this_glTFResource[_glTFResourceKey] = []))[index] = resource;
1669
1991
  } else {
1670
1992
  var url = this.glTFResource.url;
1671
1993
  resource.then(function(item) {
1672
- var _this_glTFResource, _glTFResourceKey;
1673
- ((_this_glTFResource = _this.glTFResource)[_glTFResourceKey = glTFResourceKey] || (_this_glTFResource[_glTFResourceKey] = []))[index] = item;
1674
- if (type === 6) {
1994
+ if (index == undefined) {
1995
+ _this.glTFResource[glTFResourceKey] = item;
1996
+ } else {
1997
+ var _this_glTFResource, _glTFResourceKey;
1998
+ ((_this_glTFResource = _this.glTFResource)[_glTFResourceKey = glTFResourceKey] || (_this_glTFResource[_glTFResourceKey] = []))[index] = item;
1999
+ }
2000
+ if (type === 7) {
1675
2001
  for(var i = 0, length = item.length; i < length; i++){
1676
2002
  var mesh = item[i];
1677
2003
  // @ts-ignore
@@ -1711,17 +2037,19 @@ exports.GLTFParserType = void 0;
1711
2037
  GLTFParserType[GLTFParserType["Validator"] = 1] = "Validator";
1712
2038
  GLTFParserType[GLTFParserType["Scene"] = 2] = "Scene";
1713
2039
  GLTFParserType[GLTFParserType["Buffer"] = 3] = "Buffer";
1714
- GLTFParserType[GLTFParserType["Texture"] = 4] = "Texture";
1715
- GLTFParserType[GLTFParserType["Material"] = 5] = "Material";
1716
- GLTFParserType[GLTFParserType["Mesh"] = 6] = "Mesh";
1717
- GLTFParserType[GLTFParserType["Entity"] = 7] = "Entity";
1718
- GLTFParserType[GLTFParserType["Skin"] = 8] = "Skin";
1719
- GLTFParserType[GLTFParserType["Animation"] = 9] = "Animation";
2040
+ GLTFParserType[GLTFParserType["BufferView"] = 4] = "BufferView";
2041
+ GLTFParserType[GLTFParserType["Texture"] = 5] = "Texture";
2042
+ GLTFParserType[GLTFParserType["Material"] = 6] = "Material";
2043
+ GLTFParserType[GLTFParserType["Mesh"] = 7] = "Mesh";
2044
+ GLTFParserType[GLTFParserType["Entity"] = 8] = "Entity";
2045
+ GLTFParserType[GLTFParserType["Skin"] = 9] = "Skin";
2046
+ GLTFParserType[GLTFParserType["Animation"] = 10] = "Animation";
2047
+ GLTFParserType[GLTFParserType["AnimatorController"] = 11] = "AnimatorController";
1720
2048
  })(exports.GLTFParserType || (exports.GLTFParserType = {}));
1721
2049
  var _obj;
1722
- var glTFSchemaMap = (_obj = {}, _obj[2] = "scenes", _obj[3] = "buffers", _obj[4] = "textures", _obj[5] = "materials", _obj[6] = "meshes", _obj[7] = "nodes", _obj[8] = "skins", _obj[9] = "animations", _obj);
2050
+ var glTFSchemaMap = (_obj = {}, _obj[2] = "scenes", _obj[3] = "buffers", _obj[5] = "textures", _obj[6] = "materials", _obj[7] = "meshes", _obj[8] = "nodes", _obj[9] = "skins", _obj[10] = "animations", _obj[4] = "bufferViews", _obj);
1723
2051
  var _obj1;
1724
- var glTFResourceMap = (_obj1 = {}, _obj1[2] = "sceneRoots", _obj1[4] = "textures", _obj1[5] = "materials", _obj1[6] = "meshes", _obj1[7] = "entities", _obj1[8] = "skins", _obj1[9] = "animations", _obj1);
2052
+ var glTFResourceMap = (_obj1 = {}, _obj1[2] = "_sceneRoots", _obj1[5] = "textures", _obj1[6] = "materials", _obj1[7] = "meshes", _obj1[8] = "entities", _obj1[9] = "skins", _obj1[10] = "animations", _obj1[11] = "animatorController", _obj1);
1725
2053
  function registerGLTFParser(pipeline) {
1726
2054
  return function(Parser) {
1727
2055
  var parser = new Parser();
@@ -1775,19 +2103,19 @@ function registerGLTFParser(pipeline) {
1775
2103
  * Get the number of bytes occupied by accessor type.
1776
2104
  */ GLTFUtils.getAccessorTypeSize = function getAccessorTypeSize(accessorType) {
1777
2105
  switch(accessorType){
1778
- case AccessorType.SCALAR:
2106
+ case exports.AccessorType.SCALAR:
1779
2107
  return 1;
1780
- case AccessorType.VEC2:
2108
+ case exports.AccessorType.VEC2:
1781
2109
  return 2;
1782
- case AccessorType.VEC3:
2110
+ case exports.AccessorType.VEC3:
1783
2111
  return 3;
1784
- case AccessorType.VEC4:
2112
+ case exports.AccessorType.VEC4:
1785
2113
  return 4;
1786
- case AccessorType.MAT2:
2114
+ case exports.AccessorType.MAT2:
1787
2115
  return 4;
1788
- case AccessorType.MAT3:
2116
+ case exports.AccessorType.MAT3:
1789
2117
  return 9;
1790
- case AccessorType.MAT4:
2118
+ case exports.AccessorType.MAT4:
1791
2119
  return 16;
1792
2120
  }
1793
2121
  };
@@ -1826,110 +2154,68 @@ function registerGLTFParser(pipeline) {
1826
2154
  };
1827
2155
  GLTFUtils.getAccessorBuffer = function getAccessorBuffer(context, bufferViews, accessor) {
1828
2156
  var componentType = accessor.componentType;
1829
- var bufferView = bufferViews[accessor.bufferView];
1830
- return context.get(exports.GLTFParserType.Buffer).then(function(buffers) {
1831
- var bufferIndex = bufferView.buffer;
1832
- var buffer = buffers[bufferIndex];
1833
- var _bufferView_byteOffset;
1834
- var bufferByteOffset = (_bufferView_byteOffset = bufferView.byteOffset) != null ? _bufferView_byteOffset : 0;
1835
- var _accessor_byteOffset;
1836
- var byteOffset = (_accessor_byteOffset = accessor.byteOffset) != null ? _accessor_byteOffset : 0;
1837
- var TypedArray = GLTFUtils.getComponentType(componentType);
1838
- var dataElementSize = GLTFUtils.getAccessorTypeSize(accessor.type);
1839
- var dataElementBytes = TypedArray.BYTES_PER_ELEMENT;
1840
- var elementStride = dataElementSize * dataElementBytes;
1841
- var accessorCount = accessor.count;
1842
- var bufferStride = bufferView.byteStride;
1843
- var bufferInfo;
1844
- // According to the glTF official documentation only byteStride not undefined is allowed
1845
- if (bufferStride !== undefined && bufferStride !== elementStride) {
1846
- var bufferSlice = Math.floor(byteOffset / bufferStride);
1847
- var bufferCacheKey = accessor.bufferView + ":" + componentType + ":" + bufferSlice + ":" + accessorCount;
1848
- var accessorBufferCache = context.accessorBufferCache;
1849
- bufferInfo = accessorBufferCache[bufferCacheKey];
1850
- if (!bufferInfo) {
1851
- var offset = bufferByteOffset + bufferSlice * bufferStride;
1852
- var count = accessorCount * (bufferStride / dataElementBytes);
1853
- var data = new TypedArray(buffer, offset, count);
1854
- accessorBufferCache[bufferCacheKey] = bufferInfo = new BufferInfo(data, true, bufferStride);
1855
- bufferInfo.restoreInfo = new BufferDataRestoreInfo(new RestoreDataAccessor(bufferIndex, TypedArray, offset, count));
2157
+ var TypedArray = GLTFUtils.getComponentType(componentType);
2158
+ var dataElementSize = GLTFUtils.getAccessorTypeSize(accessor.type);
2159
+ var dataElementBytes = TypedArray.BYTES_PER_ELEMENT;
2160
+ var elementStride = dataElementSize * dataElementBytes;
2161
+ var accessorCount = accessor.count;
2162
+ var promise;
2163
+ if (accessor.bufferView !== undefined) {
2164
+ var bufferViewIndex = accessor.bufferView;
2165
+ var bufferView = bufferViews[bufferViewIndex];
2166
+ promise = context.get(exports.GLTFParserType.BufferView, accessor.bufferView).then(function(bufferViewData) {
2167
+ var bufferIndex = bufferView.buffer;
2168
+ var _bufferViewData_byteOffset;
2169
+ var bufferByteOffset = (_bufferViewData_byteOffset = bufferViewData.byteOffset) != null ? _bufferViewData_byteOffset : 0;
2170
+ var _accessor_byteOffset;
2171
+ var byteOffset = (_accessor_byteOffset = accessor.byteOffset) != null ? _accessor_byteOffset : 0;
2172
+ var bufferStride = bufferView.byteStride;
2173
+ var bufferInfo;
2174
+ // According to the glTF official documentation only byteStride not undefined is allowed
2175
+ if (bufferStride !== undefined && bufferStride !== elementStride) {
2176
+ var bufferSlice = Math.floor(byteOffset / bufferStride);
2177
+ var bufferCacheKey = bufferViewIndex + ":" + componentType + ":" + bufferSlice + ":" + accessorCount;
2178
+ var accessorBufferCache = context.accessorBufferCache;
2179
+ bufferInfo = accessorBufferCache[bufferCacheKey];
2180
+ if (!bufferInfo) {
2181
+ var offset = bufferByteOffset + bufferSlice * bufferStride;
2182
+ var count = accessorCount * (bufferStride / dataElementBytes);
2183
+ var data = new TypedArray(bufferViewData.buffer, offset, count);
2184
+ accessorBufferCache[bufferCacheKey] = bufferInfo = new BufferInfo(data, true, bufferStride);
2185
+ bufferInfo.restoreInfo = new BufferDataRestoreInfo(new RestoreDataAccessor(bufferIndex, TypedArray, offset, count));
2186
+ }
2187
+ } else {
2188
+ var offset1 = bufferByteOffset + byteOffset;
2189
+ var count1 = accessorCount * dataElementSize;
2190
+ var data1 = new TypedArray(bufferViewData.buffer, offset1, count1);
2191
+ bufferInfo = new BufferInfo(data1, false, elementStride);
2192
+ bufferInfo.restoreInfo = new BufferDataRestoreInfo(new RestoreDataAccessor(bufferIndex, TypedArray, offset1, count1));
1856
2193
  }
1857
- } else {
1858
- var offset1 = bufferByteOffset + byteOffset;
1859
- var count1 = accessorCount * dataElementSize;
1860
- var data1 = new TypedArray(buffer, offset1, count1);
1861
- bufferInfo = new BufferInfo(data1, false, elementStride);
1862
- bufferInfo.restoreInfo = new BufferDataRestoreInfo(new RestoreDataAccessor(bufferIndex, TypedArray, offset1, count1));
1863
- }
1864
- if (accessor.sparse) {
1865
- GLTFUtils.processingSparseData(bufferViews, accessor, buffers, bufferInfo);
1866
- }
1867
- return bufferInfo;
1868
- });
2194
+ return bufferInfo;
2195
+ });
2196
+ } else {
2197
+ var count = accessorCount * dataElementSize;
2198
+ var data = new TypedArray(count);
2199
+ var bufferInfo = new BufferInfo(data, false, elementStride);
2200
+ bufferInfo.restoreInfo = new BufferDataRestoreInfo(new RestoreDataAccessor(undefined, TypedArray, undefined, count));
2201
+ promise = Promise.resolve(bufferInfo);
2202
+ }
2203
+ return accessor.sparse ? promise.then(function(bufferInfo) {
2204
+ return GLTFUtils.processingSparseData(context, accessor, bufferInfo).then(function() {
2205
+ return bufferInfo;
2206
+ });
2207
+ }) : promise;
1869
2208
  };
1870
- GLTFUtils.bufferToVector3Array = function bufferToVector3Array(data, byteStride, accessorByteOffset, count) {
1871
- var bytesPerElement = data.BYTES_PER_ELEMENT;
1872
- var offset = accessorByteOffset % byteStride / bytesPerElement;
1873
- var stride = byteStride / bytesPerElement;
1874
- var vector3s = new Array(count);
2209
+ GLTFUtils.bufferToVector3Array = function bufferToVector3Array(buffer, byteOffset, count, normalized, componentType) {
2210
+ var baseOffset = byteOffset / buffer.BYTES_PER_ELEMENT;
2211
+ var stride = buffer.length / count;
2212
+ var vertices = new Array(count);
2213
+ var factor = normalized ? GLTFUtils.getNormalizedComponentScale(componentType) : 1;
1875
2214
  for(var i = 0; i < count; i++){
1876
- var index = offset + i * stride;
1877
- vector3s[i] = new engineMath.Vector3(data[index], data[index + 1], data[index + 2]);
1878
- }
1879
- return vector3s;
1880
- };
1881
- /**
1882
- * @deprecated
1883
- * Get accessor data.
1884
- */ GLTFUtils.getAccessorData = function getAccessorData(glTF, accessor, buffers) {
1885
- var bufferViews = glTF.bufferViews;
1886
- var bufferView = bufferViews[accessor.bufferView];
1887
- var arrayBuffer = buffers[bufferView.buffer];
1888
- var accessorByteOffset = accessor.hasOwnProperty("byteOffset") ? accessor.byteOffset : 0;
1889
- var bufferViewByteOffset = bufferView.hasOwnProperty("byteOffset") ? bufferView.byteOffset : 0;
1890
- var byteOffset = accessorByteOffset + bufferViewByteOffset;
1891
- var accessorTypeSize = GLTFUtils.getAccessorTypeSize(accessor.type);
1892
- var length = accessorTypeSize * accessor.count;
1893
- var _bufferView_byteStride;
1894
- var byteStride = (_bufferView_byteStride = bufferView.byteStride) != null ? _bufferView_byteStride : 0;
1895
- var arrayType = GLTFUtils.getComponentType(accessor.componentType);
1896
- var uint8Array;
1897
- if (byteStride) {
1898
- var accessorByteSize = accessorTypeSize * arrayType.BYTES_PER_ELEMENT;
1899
- uint8Array = new Uint8Array(accessor.count * accessorByteSize);
1900
- var originalBufferView = new Uint8Array(arrayBuffer, bufferViewByteOffset, bufferView.byteLength);
1901
- for(var i = 0; i < accessor.count; i++){
1902
- for(var j = 0; j < accessorByteSize; j++){
1903
- uint8Array[i * accessorByteSize + j] = originalBufferView[i * byteStride + accessorByteOffset + j];
1904
- }
1905
- }
1906
- } else {
1907
- uint8Array = new Uint8Array(arrayBuffer.slice(byteOffset, byteOffset + length * arrayType.BYTES_PER_ELEMENT));
1908
- }
1909
- var typedArray = new arrayType(uint8Array.buffer);
1910
- if (accessor.sparse) {
1911
- var _accessor_sparse = accessor.sparse, count = _accessor_sparse.count, indices = _accessor_sparse.indices, values = _accessor_sparse.values;
1912
- var indicesBufferView = bufferViews[indices.bufferView];
1913
- var valuesBufferView = bufferViews[values.bufferView];
1914
- var indicesArrayBuffer = buffers[indicesBufferView.buffer];
1915
- var valuesArrayBuffer = buffers[valuesBufferView.buffer];
1916
- var _indices_byteOffset, _indicesBufferView_byteOffset;
1917
- var indicesByteOffset = ((_indices_byteOffset = indices.byteOffset) != null ? _indices_byteOffset : 0) + ((_indicesBufferView_byteOffset = indicesBufferView.byteOffset) != null ? _indicesBufferView_byteOffset : 0);
1918
- var indicesByteLength = indicesBufferView.byteLength;
1919
- var _values_byteOffset, _valuesBufferView_byteOffset;
1920
- var valuesByteOffset = ((_values_byteOffset = values.byteOffset) != null ? _values_byteOffset : 0) + ((_valuesBufferView_byteOffset = valuesBufferView.byteOffset) != null ? _valuesBufferView_byteOffset : 0);
1921
- var valuesByteLength = valuesBufferView.byteLength;
1922
- var indicesType = GLTFUtils.getComponentType(indices.componentType);
1923
- var indicesArray = new indicesType(indicesArrayBuffer, indicesByteOffset, indicesByteLength / indicesType.BYTES_PER_ELEMENT);
1924
- var valuesArray = new arrayType(valuesArrayBuffer, valuesByteOffset, valuesByteLength / arrayType.BYTES_PER_ELEMENT);
1925
- for(var i1 = 0; i1 < count; i1++){
1926
- var replaceIndex = indicesArray[i1];
1927
- for(var j1 = 0; j1 < accessorTypeSize; j1++){
1928
- typedArray[replaceIndex * accessorTypeSize + j1] = valuesArray[i1 * accessorTypeSize + j1];
1929
- }
1930
- }
2215
+ var index = baseOffset + i * stride;
2216
+ vertices[i] = new engineMath.Vector3(buffer[index] * factor, buffer[index + 1] * factor, buffer[index + 2] * factor);
1931
2217
  }
1932
- return typedArray;
2218
+ return vertices;
1933
2219
  };
1934
2220
  GLTFUtils.getBufferViewData = function getBufferViewData(bufferView, buffers) {
1935
2221
  var _bufferView_byteOffset = bufferView.byteOffset, byteOffset = _bufferView_byteOffset === void 0 ? 0 : _bufferView_byteOffset;
@@ -1938,40 +2224,43 @@ function registerGLTFParser(pipeline) {
1938
2224
  };
1939
2225
  /**
1940
2226
  * Get accessor data.
1941
- */ GLTFUtils.processingSparseData = function processingSparseData(bufferViews, accessor, buffers, bufferInfo) {
2227
+ */ GLTFUtils.processingSparseData = function processingSparseData(context, accessor, bufferInfo) {
1942
2228
  var restoreInfo = bufferInfo.restoreInfo;
2229
+ var bufferViews = context.glTF.bufferViews;
1943
2230
  var accessorTypeSize = GLTFUtils.getAccessorTypeSize(accessor.type);
1944
2231
  var TypedArray = GLTFUtils.getComponentType(accessor.componentType);
1945
2232
  var data = bufferInfo.data.slice();
1946
2233
  var _accessor_sparse = accessor.sparse, count = _accessor_sparse.count, indices = _accessor_sparse.indices, values = _accessor_sparse.values;
1947
2234
  var indicesBufferView = bufferViews[indices.bufferView];
1948
2235
  var valuesBufferView = bufferViews[values.bufferView];
1949
- var indicesBufferIndex = indicesBufferView.buffer;
1950
- var valuesBufferIndex = valuesBufferView.buffer;
1951
- var indicesArrayBuffer = buffers[indicesBufferIndex];
1952
- var valuesArrayBuffer = buffers[valuesBufferIndex];
1953
- var _indices_byteOffset, _indicesBufferView_byteOffset;
1954
- var indicesByteOffset = ((_indices_byteOffset = indices.byteOffset) != null ? _indices_byteOffset : 0) + ((_indicesBufferView_byteOffset = indicesBufferView.byteOffset) != null ? _indicesBufferView_byteOffset : 0);
1955
- var indicesByteLength = indicesBufferView.byteLength;
1956
- var _values_byteOffset, _valuesBufferView_byteOffset;
1957
- var valuesByteOffset = ((_values_byteOffset = values.byteOffset) != null ? _values_byteOffset : 0) + ((_valuesBufferView_byteOffset = valuesBufferView.byteOffset) != null ? _valuesBufferView_byteOffset : 0);
1958
- var valuesByteLength = valuesBufferView.byteLength;
1959
- restoreInfo.typeSize = accessorTypeSize;
1960
- restoreInfo.sparseCount = count;
1961
- var IndexTypeArray = GLTFUtils.getComponentType(indices.componentType);
1962
- var indexLength = indicesByteLength / IndexTypeArray.BYTES_PER_ELEMENT;
1963
- var indicesArray = new IndexTypeArray(indicesArrayBuffer, indicesByteOffset, indexLength);
1964
- restoreInfo.sparseIndices = new RestoreDataAccessor(indicesBufferIndex, IndexTypeArray, indicesByteOffset, indexLength);
1965
- var valueLength = valuesByteLength / TypedArray.BYTES_PER_ELEMENT;
1966
- var valuesArray = new TypedArray(valuesArrayBuffer, valuesByteOffset, valueLength);
1967
- restoreInfo.sparseValues = new RestoreDataAccessor(valuesBufferIndex, TypedArray, valuesByteOffset, valueLength);
1968
- for(var i = 0; i < count; i++){
1969
- var replaceIndex = indicesArray[i];
1970
- for(var j = 0; j < accessorTypeSize; j++){
1971
- data[replaceIndex * accessorTypeSize + j] = valuesArray[i * accessorTypeSize + j];
2236
+ return Promise.all([
2237
+ context.get(exports.GLTFParserType.BufferView, indices.bufferView),
2238
+ context.get(exports.GLTFParserType.BufferView, values.bufferView)
2239
+ ]).then(function(param) {
2240
+ var indicesUint8Array = param[0], valuesUin8Array = param[1];
2241
+ var _indices_byteOffset, _indicesUint8Array_byteOffset;
2242
+ var indicesByteOffset = ((_indices_byteOffset = indices.byteOffset) != null ? _indices_byteOffset : 0) + ((_indicesUint8Array_byteOffset = indicesUint8Array.byteOffset) != null ? _indicesUint8Array_byteOffset : 0);
2243
+ var indicesByteLength = indicesUint8Array.byteLength;
2244
+ var _values_byteOffset, _valuesUin8Array_byteOffset;
2245
+ var valuesByteOffset = ((_values_byteOffset = values.byteOffset) != null ? _values_byteOffset : 0) + ((_valuesUin8Array_byteOffset = valuesUin8Array.byteOffset) != null ? _valuesUin8Array_byteOffset : 0);
2246
+ var valuesByteLength = valuesUin8Array.byteLength;
2247
+ restoreInfo.typeSize = accessorTypeSize;
2248
+ restoreInfo.sparseCount = count;
2249
+ var IndexTypeArray = GLTFUtils.getComponentType(indices.componentType);
2250
+ var indexLength = indicesByteLength / IndexTypeArray.BYTES_PER_ELEMENT;
2251
+ var indicesArray = new IndexTypeArray(indicesUint8Array.buffer, indicesByteOffset, indexLength);
2252
+ restoreInfo.sparseIndices = new RestoreDataAccessor(indicesBufferView.buffer, IndexTypeArray, indicesByteOffset, indexLength);
2253
+ var valueLength = valuesByteLength / TypedArray.BYTES_PER_ELEMENT;
2254
+ var valuesArray = new TypedArray(valuesUin8Array.buffer, valuesByteOffset, valueLength);
2255
+ restoreInfo.sparseValues = new RestoreDataAccessor(valuesBufferView.buffer, TypedArray, valuesByteOffset, valueLength);
2256
+ for(var i = 0; i < count; i++){
2257
+ var replaceIndex = indicesArray[i];
2258
+ for(var j = 0; j < accessorTypeSize; j++){
2259
+ data[replaceIndex * accessorTypeSize + j] = valuesArray[i * accessorTypeSize + j];
2260
+ }
1972
2261
  }
1973
- }
1974
- bufferInfo.data = data;
2262
+ bufferInfo.data = data;
2263
+ });
1975
2264
  };
1976
2265
  GLTFUtils.getIndexFormat = function getIndexFormat(type) {
1977
2266
  switch(type){
@@ -2060,7 +2349,7 @@ function registerGLTFParser(pipeline) {
2060
2349
  };
2061
2350
  /**
2062
2351
  * Parse the glb format.
2063
- */ GLTFUtils.parseGLB = function parseGLB(context, glb) {
2352
+ */ GLTFUtils.parseGLB = function parseGLB(context, originBuffer) {
2064
2353
  var UINT32_LENGTH = 4;
2065
2354
  var GLB_HEADER_MAGIC = 0x46546c67; // 'glTF'
2066
2355
  var GLB_HEADER_LENGTH = 12;
@@ -2068,7 +2357,7 @@ function registerGLTFParser(pipeline) {
2068
2357
  JSON: 0x4e4f534a,
2069
2358
  BIN: 0x004e4942
2070
2359
  };
2071
- var dataView = new DataView(glb);
2360
+ var dataView = new DataView(originBuffer);
2072
2361
  // read header
2073
2362
  var header = {
2074
2363
  magic: dataView.getUint32(0, true),
@@ -2076,8 +2365,9 @@ function registerGLTFParser(pipeline) {
2076
2365
  length: dataView.getUint32(2 * UINT32_LENGTH, true)
2077
2366
  };
2078
2367
  if (header.magic !== GLB_HEADER_MAGIC) {
2079
- console.error("Invalid glb magic number. Expected 0x46546C67, found 0x" + header.magic.toString(16));
2080
- return null;
2368
+ return {
2369
+ originBuffer: originBuffer
2370
+ };
2081
2371
  }
2082
2372
  // read main data
2083
2373
  var chunkLength = dataView.getUint32(GLB_HEADER_LENGTH, true);
@@ -2087,7 +2377,7 @@ function registerGLTFParser(pipeline) {
2087
2377
  console.error("Invalid glb chunk type. Expected 0x4E4F534A, found 0x" + chunkType.toString(16));
2088
2378
  return null;
2089
2379
  }
2090
- var glTFData = new Uint8Array(glb, GLB_HEADER_LENGTH + 2 * UINT32_LENGTH, chunkLength);
2380
+ var glTFData = new Uint8Array(originBuffer, GLB_HEADER_LENGTH + 2 * UINT32_LENGTH, chunkLength);
2091
2381
  var glTF = JSON.parse(engineCore.Utils.decodeText(glTFData));
2092
2382
  // read all buffers
2093
2383
  var buffers = [];
@@ -2101,7 +2391,7 @@ function registerGLTFParser(pipeline) {
2101
2391
  return null;
2102
2392
  }
2103
2393
  var currentOffset = byteOffset + 2 * UINT32_LENGTH;
2104
- var buffer = glb.slice(currentOffset, currentOffset + chunkLength);
2394
+ var buffer = originBuffer.slice(currentOffset, currentOffset + chunkLength);
2105
2395
  buffers.push(buffer);
2106
2396
  restoreGLBBufferSlice.push(new engineMath.Vector2(currentOffset, chunkLength));
2107
2397
  byteOffset += chunkLength + 2 * UINT32_LENGTH;
@@ -2980,18 +3270,22 @@ exports.KTX2Loader = (_KTX2Loader = /*#__PURE__*/ function(Loader1) {
2980
3270
  /**
2981
3271
  * @internal
2982
3272
  */ _proto.load = function load(item, resourceManager) {
2983
- return this.request(item.url, {
2984
- type: "arraybuffer"
2985
- }).then(function(buffer) {
2986
- return exports.KTX2Loader._parseBuffer(new Uint8Array(buffer), resourceManager.engine, item.params).then(function(param) {
2987
- var engine = param.engine, result = param.result, targetFormat = param.targetFormat, params = param.params;
2988
- return exports.KTX2Loader._createTextureByBuffer(engine, result, targetFormat, params);
2989
- });
3273
+ var _this = this;
3274
+ return new engineCore.AssetPromise(function(resolve, reject, setTaskCompleteProgress, setTaskDetailProgress) {
3275
+ _this.request(item.url, {
3276
+ type: "arraybuffer"
3277
+ }).onProgress(setTaskCompleteProgress, setTaskDetailProgress).then(function(buffer) {
3278
+ return exports.KTX2Loader._parseBuffer(new Uint8Array(buffer), resourceManager.engine, item.params).then(function(param) {
3279
+ var engine = param.engine, result = param.result, targetFormat = param.targetFormat, params = param.params;
3280
+ return exports.KTX2Loader._createTextureByBuffer(engine, result, targetFormat, params);
3281
+ });
3282
+ }).then(resolve).catch(reject);
2990
3283
  });
2991
3284
  };
2992
3285
  /**
2993
- * Destroy ktx2 transcoder worker.
2994
- */ KTX2Loader1.destroy = function destroy() {
3286
+ * Release ktx2 transcoder worker.
3287
+ * @remarks If use loader after releasing, we should release again.
3288
+ */ KTX2Loader1.release = function release() {
2995
3289
  if (this._binomialLLCTranscoder) this._binomialLLCTranscoder.destroy();
2996
3290
  if (this._khronosTranscoder) this._khronosTranscoder.destroy();
2997
3291
  this._binomialLLCTranscoder = null;
@@ -3236,16 +3530,16 @@ exports.KTX2Transcoder = void 0;
3236
3530
  var frame = restoreInfo.blendShape.frames[0];
3237
3531
  var position = restoreInfo.position;
3238
3532
  var positionData = _this._getBufferData(buffers, position.buffer);
3239
- frame.deltaPositions = GLTFUtils.bufferToVector3Array(positionData, position.stride, position.byteOffset, position.count);
3533
+ frame.deltaPositions = GLTFUtils.bufferToVector3Array(positionData, position.byteOffset, position.count, position.normalized, position.componentType);
3240
3534
  if (restoreInfo.normal) {
3241
3535
  var normal = restoreInfo.normal;
3242
3536
  var normalData = _this._getBufferData(buffers, normal.buffer);
3243
- frame.deltaNormals = GLTFUtils.bufferToVector3Array(normalData, normal.stride, normal.byteOffset, normal.count);
3537
+ frame.deltaNormals = GLTFUtils.bufferToVector3Array(normalData, normal.byteOffset, normal.count, normal.normalized, normal.componentType);
3244
3538
  }
3245
3539
  if (restoreInfo.tangent) {
3246
3540
  var tangent = restoreInfo.tangent;
3247
3541
  var tangentData = _this._getBufferData(buffers, tangent.buffer);
3248
- frame.deltaTangents = GLTFUtils.bufferToVector3Array(tangentData, tangent.stride, tangent.byteOffset, tangent.count);
3542
+ frame.deltaTangents = GLTFUtils.bufferToVector3Array(tangentData, tangent.byteOffset, tangent.count, tangent.normalized, tangent.componentType);
3249
3543
  }
3250
3544
  }
3251
3545
  mesh.uploadData(true);
@@ -3257,8 +3551,13 @@ exports.KTX2Transcoder = void 0;
3257
3551
  };
3258
3552
  _proto._getBufferData = function _getBufferData(buffers, restoreInfo) {
3259
3553
  var main = restoreInfo.main;
3260
- var buffer = buffers[main.bufferIndex];
3261
- var data = new main.TypedArray(buffer, main.byteOffset, main.length);
3554
+ var data;
3555
+ if (main) {
3556
+ var buffer = buffers[main.bufferIndex];
3557
+ data = new main.TypedArray(buffer, main.byteOffset, main.length);
3558
+ } else {
3559
+ data = new main.TypedArray(main.length);
3560
+ }
3262
3561
  var sparseCount = restoreInfo.sparseCount;
3263
3562
  if (sparseCount) {
3264
3563
  var sparseIndex = restoreInfo.sparseIndices;
@@ -3331,11 +3630,12 @@ exports.KTX2Transcoder = void 0;
3331
3630
  };
3332
3631
  /**
3333
3632
  * @internal
3334
- */ var BlendShapeDataRestoreInfo = function BlendShapeDataRestoreInfo(buffer, stride, byteOffset, count) {
3633
+ */ var BlendShapeDataRestoreInfo = function BlendShapeDataRestoreInfo(buffer, byteOffset, count, normalized, componentType) {
3335
3634
  this.buffer = buffer;
3336
- this.stride = stride;
3337
3635
  this.byteOffset = byteOffset;
3338
3636
  this.count = count;
3637
+ this.normalized = normalized;
3638
+ this.componentType = componentType;
3339
3639
  };
3340
3640
 
3341
3641
  /**
@@ -3511,23 +3811,20 @@ exports.GLTFSchemaParser = /*#__PURE__*/ function(GLTFParser1) {
3511
3811
  var requestConfig = {
3512
3812
  type: "arraybuffer"
3513
3813
  };
3514
- var isGLB = this._isGLB(url);
3515
- contentRestorer.isGLB = isGLB;
3516
- var promise = isGLB ? engineCore.request(url, requestConfig).then(function(glb) {
3814
+ return engineCore.request(url, requestConfig).onProgress(undefined, context._onTaskDetail).then(function(buffer) {
3517
3815
  restoreBufferRequests.push(new BufferRequestInfo(url, requestConfig));
3518
- return GLTFUtils.parseGLB(context, glb);
3519
- }).then(function(param) {
3520
- var glTF = param.glTF, buffers = param.buffers;
3521
- context.buffers = buffers;
3522
- return glTF;
3523
- }) : engineCore.request(url, {
3524
- type: "json"
3816
+ return GLTFUtils.parseGLB(context, buffer);
3817
+ }).then(function(result) {
3818
+ var _result;
3819
+ if ((_result = result) == null ? void 0 : _result.glTF) {
3820
+ contentRestorer.isGLB = true;
3821
+ context.buffers = result.buffers;
3822
+ return result.glTF;
3823
+ } else {
3824
+ contentRestorer.isGLB = false;
3825
+ return JSON.parse(engineCore.Utils.decodeText(new Uint8Array(result.originBuffer)));
3826
+ }
3525
3827
  });
3526
- return promise;
3527
- };
3528
- _proto._isGLB = function _isGLB(url) {
3529
- var index = url.lastIndexOf(".");
3530
- return url.substring(index + 1, index + 4) === "glb";
3531
3828
  };
3532
3829
  return GLTFSchemaParser;
3533
3830
  }(GLTFParser);
@@ -3554,9 +3851,9 @@ exports.GLTFAnimationParser = /*#__PURE__*/ function(GLTFParser1) {
3554
3851
  * @internal
3555
3852
  */ GLTFAnimationParser1._parseStandardProperty = function _parseStandardProperty(context, animationClip, animationInfo) {
3556
3853
  var _loop = function(j, m) {
3557
- var gltfSampler = samplers[j];
3558
- var inputAccessor = accessors[gltfSampler.input];
3559
- var outputAccessor = accessors[gltfSampler.output];
3854
+ var glTFSampler = samplers[j];
3855
+ var inputAccessor = accessors[glTFSampler.input];
3856
+ var outputAccessor = accessors[glTFSampler.output];
3560
3857
  var promise = Promise.all([
3561
3858
  GLTFUtils.getAccessorBuffer(context, bufferViews, inputAccessor),
3562
3859
  GLTFUtils.getAccessorBuffer(context, bufferViews, outputAccessor)
@@ -3572,8 +3869,8 @@ exports.GLTFAnimationParser = /*#__PURE__*/ function(GLTFParser1) {
3572
3869
  output = scaled;
3573
3870
  }
3574
3871
  var outputStride = output.length / input.length;
3575
- var _gltfSampler_interpolation;
3576
- var interpolation = (_gltfSampler_interpolation = gltfSampler.interpolation) != null ? _gltfSampler_interpolation : AnimationSamplerInterpolation.Linear;
3872
+ var _glTFSampler_interpolation;
3873
+ var interpolation = (_glTFSampler_interpolation = glTFSampler.interpolation) != null ? _glTFSampler_interpolation : AnimationSamplerInterpolation.Linear;
3577
3874
  var samplerInterpolation;
3578
3875
  switch(interpolation){
3579
3876
  case AnimationSamplerInterpolation.CubicSpine:
@@ -3587,13 +3884,13 @@ exports.GLTFAnimationParser = /*#__PURE__*/ function(GLTFParser1) {
3587
3884
  break;
3588
3885
  }
3589
3886
  input[input.length - 1];
3590
- sampleDataCollection.push({
3887
+ sampleDataCollection[j] = {
3591
3888
  type: outputAccessor.type,
3592
3889
  interpolation: samplerInterpolation,
3593
3890
  input: input,
3594
3891
  output: output,
3595
3892
  outputSize: outputStride
3596
- });
3893
+ };
3597
3894
  });
3598
3895
  promises.push(promise);
3599
3896
  };
@@ -3601,16 +3898,17 @@ exports.GLTFAnimationParser = /*#__PURE__*/ function(GLTFParser1) {
3601
3898
  var glTF = context.glTF;
3602
3899
  var accessors = glTF.accessors, bufferViews = glTF.bufferViews;
3603
3900
  var channels = animationInfo.channels, samplers = animationInfo.samplers;
3604
- var sampleDataCollection = new Array();
3901
+ var len = samplers.length;
3902
+ var sampleDataCollection = new Array(len);
3605
3903
  var entities = context.get(exports.GLTFParserType.Entity);
3606
3904
  var promises = new Array();
3607
3905
  // parse samplers
3608
- for(var j = 0, m = samplers.length; j < m; j++)_loop(j);
3906
+ for(var j = 0, m = len; j < m; j++)_loop(j);
3609
3907
  promises.push(context.get(exports.GLTFParserType.Scene));
3610
3908
  return Promise.all(promises).then(function() {
3611
3909
  for(var j = 0, m = channels.length; j < m; j++){
3612
- var gltfChannel = channels[j];
3613
- var target = gltfChannel.target;
3910
+ var glTFChannel = channels[j];
3911
+ var target = glTFChannel.target;
3614
3912
  var channelTargetEntity = entities[target.node];
3615
3913
  var relativePath = "";
3616
3914
  var entity = channelTargetEntity;
@@ -3642,14 +3940,21 @@ exports.GLTFAnimationParser = /*#__PURE__*/ function(GLTFParser1) {
3642
3940
  propertyName = "blendShapeWeights";
3643
3941
  break;
3644
3942
  }
3645
- var curve = _this._addCurve(target.path, gltfChannel, sampleDataCollection);
3646
- animationClip.addCurveBinding(relativePath, ComponentType, propertyName, curve);
3943
+ var curve = _this._addCurve(target.path, glTFChannel, sampleDataCollection);
3944
+ if (target.path === AnimationChannelTargetPath.WEIGHTS) {
3945
+ var mesh = glTF.nodes[target.node].mesh;
3946
+ for(var i = 0, n = glTF.meshes[mesh].primitives.length; i < n; i++){
3947
+ animationClip.addCurveBinding(relativePath, ComponentType, i, propertyName, curve);
3948
+ }
3949
+ } else {
3950
+ animationClip.addCurveBinding(relativePath, ComponentType, propertyName, curve);
3951
+ }
3647
3952
  }
3648
3953
  return animationClip;
3649
3954
  });
3650
3955
  };
3651
- GLTFAnimationParser1._addCurve = function _addCurve(animationChannelTargetPath, gltfChannel, sampleDataCollection) {
3652
- var sampleData = sampleDataCollection[gltfChannel.sampler];
3956
+ GLTFAnimationParser1._addCurve = function _addCurve(animationChannelTargetPath, glTFChannel, sampleDataCollection) {
3957
+ var sampleData = sampleDataCollection[glTFChannel.sampler];
3653
3958
  var input = sampleData.input, output = sampleData.output, outputSize = sampleData.outputSize;
3654
3959
  switch(animationChannelTargetPath){
3655
3960
  case AnimationChannelTargetPath.TRANSLATION:
@@ -3741,7 +4046,9 @@ exports.GLTFBufferParser = /*#__PURE__*/ function(GLTFParser1) {
3741
4046
  };
3742
4047
  var absoluteUrl = engineCore.Utils.resolveAbsoluteUrl(url, bufferInfo.uri);
3743
4048
  restoreBufferRequests.push(new BufferRequestInfo(absoluteUrl, requestConfig));
3744
- return engineCore.request(absoluteUrl, requestConfig);
4049
+ var promise = engineCore.request(absoluteUrl, requestConfig).onProgress(undefined, context._onTaskDetail);
4050
+ context._addTaskCompletePromise(promise);
4051
+ return promise;
3745
4052
  };
3746
4053
  return GLTFBufferParser;
3747
4054
  }(GLTFParser);
@@ -3756,10 +4063,13 @@ exports.GLTFEntityParser = /*#__PURE__*/ function(GLTFParser1) {
3756
4063
  }
3757
4064
  var _proto = GLTFEntityParser.prototype;
3758
4065
  _proto.parse = function parse(context, index) {
4066
+ var glTFResource = context.glTFResource;
3759
4067
  var entityInfo = context.glTF.nodes[index];
3760
- var engine = context.glTFResource.engine;
4068
+ var engine = glTFResource.engine;
3761
4069
  var matrix = entityInfo.matrix, translation = entityInfo.translation, rotation = entityInfo.rotation, scale = entityInfo.scale, extensions = entityInfo.extensions;
3762
4070
  var entity = new engineCore.Entity(engine, entityInfo.name || "_GLTF_ENTITY_" + index);
4071
+ // @ts-ignore
4072
+ entity._markAsTemplate(glTFResource);
3763
4073
  var transform = entity.transform;
3764
4074
  if (matrix) {
3765
4075
  var localMatrix = transform.localMatrix;
@@ -3801,7 +4111,8 @@ exports.GLTFMaterialParser = /*#__PURE__*/ function(GLTFParser1) {
3801
4111
  var _proto = GLTFMaterialParser1.prototype;
3802
4112
  _proto.parse = function parse(context, index) {
3803
4113
  var materialInfo = context.glTF.materials[index];
3804
- var engine = context.glTFResource.engine;
4114
+ var glTFResource = context.glTFResource;
4115
+ var engine = glTFResource.engine;
3805
4116
  var material = GLTFParser.executeExtensionsCreateAndParse(materialInfo.extensions, context, materialInfo);
3806
4117
  if (!material) {
3807
4118
  material = new engineCore.PBRMaterial(engine);
@@ -3809,8 +4120,10 @@ exports.GLTFMaterialParser = /*#__PURE__*/ function(GLTFParser1) {
3809
4120
  exports.GLTFMaterialParser._parseStandardProperty(context, material, materialInfo);
3810
4121
  }
3811
4122
  return Promise.resolve(material).then(function(material) {
3812
- material || (material = exports.GLTFMaterialParser._getDefaultMaterial(context.glTFResource.engine));
4123
+ material || (material = exports.GLTFMaterialParser._getDefaultMaterial(engine));
3813
4124
  GLTFParser.executeExtensionsAdditiveAndParse(materialInfo.extensions, context, material, materialInfo);
4125
+ // @ts-ignore
4126
+ material._associationSuperResource(glTFResource);
3814
4127
  return material;
3815
4128
  });
3816
4129
  };
@@ -3931,46 +4244,37 @@ exports.GLTFMeshParser = (_GLTFMeshParser = /*#__PURE__*/ function(GLTFParser1)
3931
4244
  var mesh = GLTFParser.executeExtensionsCreateAndParse(gltfPrimitive.extensions, context, gltfPrimitive, meshInfo);
3932
4245
  if (mesh) {
3933
4246
  if (_instanceof(mesh, engineCore.ModelMesh)) {
4247
+ // @ts-ignore
4248
+ mesh._associationSuperResource(glTFResource);
3934
4249
  resolve(mesh);
3935
4250
  } else {
3936
4251
  mesh.then(function(mesh) {
3937
- return resolve(mesh);
4252
+ // @ts-ignore
4253
+ mesh._associationSuperResource(glTFResource);
4254
+ resolve(mesh);
3938
4255
  });
3939
4256
  }
3940
4257
  } else {
3941
4258
  var mesh1 = new engineCore.ModelMesh(engine, meshInfo.name || i + "");
4259
+ // @ts-ignore
4260
+ mesh1._associationSuperResource(glTFResource);
3942
4261
  var meshRestoreInfo = new ModelMeshRestoreInfo();
3943
4262
  meshRestoreInfo.mesh = mesh1;
3944
4263
  context.contentRestorer.meshes.push(meshRestoreInfo);
3945
- exports.GLTFMeshParser._parseMeshFromGLTFPrimitive(context, mesh1, meshRestoreInfo, meshInfo, gltfPrimitive, glTF, function(attributeSemantic) {
3946
- return null;
3947
- }, function(attributeName, shapeIndex) {
3948
- var shapeAccessorIdx = gltfPrimitive.targets[shapeIndex];
3949
- var attributeAccessorIdx = shapeAccessorIdx[attributeName];
3950
- if (attributeAccessorIdx) {
3951
- var accessor = glTF.accessors[attributeAccessorIdx];
3952
- return GLTFUtils.getAccessorBuffer(context, context.glTF.bufferViews, accessor);
3953
- } else {
3954
- return null;
3955
- }
3956
- }, function() {
3957
- var indexAccessor = glTF.accessors[gltfPrimitive.indices];
3958
- return context.get(exports.GLTFParserType.Buffer).then(function(buffers) {
3959
- return GLTFUtils.getAccessorData(glTF, indexAccessor, buffers);
3960
- });
3961
- }, context.params.keepMeshData).then(resolve);
4264
+ exports.GLTFMeshParser._parseMeshFromGLTFPrimitive(context, mesh1, meshRestoreInfo, meshInfo, gltfPrimitive, glTF, context.params.keepMeshData).then(resolve);
3962
4265
  }
3963
4266
  });
3964
4267
  };
3965
4268
  var meshInfo = context.glTF.meshes[index];
3966
- var glTF = context.glTF, engine = context.glTFResource.engine;
4269
+ var glTF = context.glTF, glTFResource = context.glTFResource;
4270
+ var engine = glTFResource.engine;
3967
4271
  var primitivePromises = new Array();
3968
4272
  for(var i = 0, length = meshInfo.primitives.length; i < length; i++)_loop(i);
3969
4273
  return Promise.all(primitivePromises);
3970
4274
  };
3971
4275
  /**
3972
4276
  * @internal
3973
- */ GLTFMeshParser1._parseMeshFromGLTFPrimitive = function _parseMeshFromGLTFPrimitive(context, mesh, meshRestoreInfo, gltfMesh, gltfPrimitive, gltf, getVertexBufferData, getBlendShapeData, getIndexBufferData, keepMeshData) {
4277
+ */ GLTFMeshParser1._parseMeshFromGLTFPrimitive = function _parseMeshFromGLTFPrimitive(context, mesh, meshRestoreInfo, gltfMesh, gltfPrimitive, gltf, keepMeshData) {
3974
4278
  var _loop = function(attribute) {
3975
4279
  var accessor = accessors[attributes[attribute]];
3976
4280
  var promise = GLTFUtils.getAccessorBuffer(context, gltf.bufferViews, accessor).then(function(accessorBuffer) {
@@ -4065,61 +4369,68 @@ exports.GLTFMeshParser = (_GLTFMeshParser = /*#__PURE__*/ function(GLTFParser1)
4065
4369
  }
4066
4370
  // BlendShapes
4067
4371
  if (targets) {
4068
- promises.push(exports.GLTFMeshParser._createBlendShape(mesh, meshRestoreInfo, gltfMesh, accessors, targets, getBlendShapeData));
4372
+ promises.push(exports.GLTFMeshParser._createBlendShape(context, mesh, meshRestoreInfo, gltfMesh, gltfPrimitive, targets));
4069
4373
  }
4070
4374
  return Promise.all(promises).then(function() {
4071
4375
  mesh.uploadData(!keepMeshData);
4072
- return Promise.resolve(mesh);
4376
+ return mesh;
4073
4377
  });
4074
4378
  });
4075
4379
  };
4380
+ GLTFMeshParser1._getBlendShapeData = function _getBlendShapeData(context, glTF, accessor) {
4381
+ return GLTFUtils.getAccessorBuffer(context, glTF.bufferViews, accessor).then(function(bufferInfo) {
4382
+ var buffer = bufferInfo.data;
4383
+ var _accessor_byteOffset;
4384
+ var byteOffset = bufferInfo.interleaved ? ((_accessor_byteOffset = accessor.byteOffset) != null ? _accessor_byteOffset : 0) % bufferInfo.stride : 0;
4385
+ var count = accessor.count, normalized = accessor.normalized, componentType = accessor.componentType;
4386
+ var vertices = GLTFUtils.bufferToVector3Array(buffer, byteOffset, count, normalized, componentType);
4387
+ var restoreInfo = new BlendShapeDataRestoreInfo(bufferInfo.restoreInfo, byteOffset, count, normalized, componentType);
4388
+ return {
4389
+ vertices: vertices,
4390
+ restoreInfo: restoreInfo
4391
+ };
4392
+ });
4393
+ };
4076
4394
  /**
4077
4395
  * @internal
4078
- */ GLTFMeshParser1._createBlendShape = function _createBlendShape(mesh, meshRestoreInfo, glTFMesh, accessors, glTFTargets, getBlendShapeData) {
4079
- var _loop = function(i, n) {
4396
+ */ GLTFMeshParser1._createBlendShape = function _createBlendShape(context, mesh, meshRestoreInfo, glTFMesh, gltfPrimitive, glTFTargets) {
4397
+ var _this = this, _loop = function(i) {
4398
+ var blendShapeData = {};
4399
+ blendShapeCollection[i] = blendShapeData;
4080
4400
  var name = blendShapeNames ? blendShapeNames[i] : "blendShape" + i;
4401
+ var targets = gltfPrimitive.targets[i];
4402
+ var normalTarget = targets["NORMAL"];
4403
+ var tangentTarget = targets["TANGENT"];
4404
+ var hasNormal = normalTarget !== undefined;
4405
+ var hasTangent = tangentTarget !== undefined;
4081
4406
  var promise = Promise.all([
4082
- getBlendShapeData("POSITION", i),
4083
- getBlendShapeData("NORMAL", i),
4084
- getBlendShapeData("TANGENT", i)
4085
- ]).then(function(infos) {
4086
- var posBufferInfo = infos[0];
4087
- var norBufferInfo = infos[1];
4088
- var tanBufferInfo = infos[2];
4089
- var target = glTFTargets[i];
4090
- var posAccessor;
4091
- var norAccessor;
4092
- var tanAccessor;
4093
- var positions = null;
4094
- if (posBufferInfo) {
4095
- posAccessor = accessors[target["POSITION"]];
4096
- var _posAccessor_byteOffset;
4097
- positions = GLTFUtils.bufferToVector3Array(posBufferInfo.data, posBufferInfo.stride, (_posAccessor_byteOffset = posAccessor.byteOffset) != null ? _posAccessor_byteOffset : 0, posAccessor.count);
4098
- }
4099
- var normals = null;
4100
- if (norBufferInfo) {
4101
- norAccessor = accessors[target["NORMAL"]];
4102
- var _norAccessor_byteOffset;
4103
- normals = GLTFUtils.bufferToVector3Array(norBufferInfo.data, norBufferInfo.stride, (_norAccessor_byteOffset = norAccessor.byteOffset) != null ? _norAccessor_byteOffset : 0, norAccessor.count);
4104
- }
4105
- var tangents = null;
4106
- if (tanBufferInfo) {
4107
- tanAccessor = accessors[target["NORMAL"]];
4108
- var _tanAccessor_byteOffset;
4109
- tangents = GLTFUtils.bufferToVector3Array(tanBufferInfo.data, tanBufferInfo.stride, (_tanAccessor_byteOffset = tanAccessor.byteOffset) != null ? _tanAccessor_byteOffset : 0, tanAccessor.count);
4110
- }
4407
+ _this._getBlendShapeData(context, glTF, accessors[targets["POSITION"]]),
4408
+ hasNormal ? _this._getBlendShapeData(context, glTF, accessors[normalTarget]) : null,
4409
+ hasTangent ? _this._getBlendShapeData(context, glTF, accessors[tangentTarget]) : null
4410
+ ]).then(function(vertices) {
4411
+ var _tangentData;
4412
+ var positionData = vertices[0], normalData = vertices[1], tangentData = vertices[2];
4111
4413
  var blendShape = new engineCore.BlendShape(name);
4112
- blendShape.addFrame(1.0, positions, normals, tangents);
4113
- mesh.addBlendShape(blendShape);
4114
- var _posAccessor_byteOffset1, _norAccessor_byteOffset1, _tanAccessor_byteOffset1;
4115
- meshRestoreInfo.blendShapes.push(new BlendShapeRestoreInfo(blendShape, new BlendShapeDataRestoreInfo(posBufferInfo.restoreInfo, posBufferInfo.stride, (_posAccessor_byteOffset1 = posAccessor.byteOffset) != null ? _posAccessor_byteOffset1 : 0, posAccessor.count), norBufferInfo ? new BlendShapeDataRestoreInfo(norBufferInfo.restoreInfo, norBufferInfo.stride, (_norAccessor_byteOffset1 = norAccessor.byteOffset) != null ? _norAccessor_byteOffset1 : 0, norAccessor.count) : null, tanBufferInfo ? new BlendShapeDataRestoreInfo(tanBufferInfo.restoreInfo, tanBufferInfo.stride, (_tanAccessor_byteOffset1 = tanAccessor.byteOffset) != null ? _tanAccessor_byteOffset1 : 0, tanAccessor.count) : null));
4414
+ blendShape.addFrame(1.0, positionData.vertices, hasNormal ? normalData.vertices : null, hasTangent ? tangentData.vertices : null);
4415
+ blendShapeData.blendShape = blendShape;
4416
+ blendShapeData.restoreInfo = new BlendShapeRestoreInfo(blendShape, positionData.restoreInfo, hasNormal ? normalData.restoreInfo : null, hasTangent ? (_tangentData = tangentData) == null ? void 0 : _tangentData.restoreInfo : null);
4116
4417
  });
4117
4418
  promises.push(promise);
4118
4419
  };
4420
+ var glTF = context.glTF;
4421
+ var accessors = glTF.accessors;
4119
4422
  var blendShapeNames = glTFMesh.extras ? glTFMesh.extras.targetNames : null;
4120
4423
  var promises = new Array();
4121
- for(var i = 0, n = glTFTargets.length; i < n; i++)_loop(i);
4122
- return Promise.all(promises);
4424
+ var blendShapeCount = glTFTargets.length;
4425
+ var blendShapeCollection = new Array(blendShapeCount);
4426
+ for(var i = 0; i < blendShapeCount; i++)_loop(i);
4427
+ return Promise.all(promises).then(function() {
4428
+ for(var _iterator = _create_for_of_iterator_helper_loose(blendShapeCollection), _step; !(_step = _iterator()).done;){
4429
+ var blendShape = _step.value;
4430
+ mesh.addBlendShape(blendShape.blendShape);
4431
+ meshRestoreInfo.blendShapes.push(blendShape.restoreInfo);
4432
+ }
4433
+ });
4123
4434
  };
4124
4435
  return GLTFMeshParser1;
4125
4436
  }(GLTFParser), function() {
@@ -4152,12 +4463,8 @@ exports.GLTFSceneParser = /*#__PURE__*/ function(GLTFParser1) {
4152
4463
  sceneRoot.addChild(childEntity);
4153
4464
  }
4154
4465
  }
4155
- // @ts-ignore
4156
- sceneRoot._hookResource = glTFResource;
4157
- // @ts-ignore
4158
- glTFResource._addReferCount(1);
4159
4466
  if (isDefaultScene) {
4160
- glTFResource.defaultSceneRoot = sceneRoot;
4467
+ glTFResource._defaultSceneRoot = sceneRoot;
4161
4468
  }
4162
4469
  var promises = new Array();
4163
4470
  for(var i1 = 0; i1 < sceneNodes.length; i1++){
@@ -4424,11 +4731,12 @@ exports.GLTFTextureParser = (_GLTFTextureParser = /*#__PURE__*/ function(GLTFPar
4424
4731
  params: {
4425
4732
  mipmap: (_samplerInfo = samplerInfo) == null ? void 0 : _samplerInfo.mipmap
4426
4733
  }
4427
- }).then(function(texture) {
4734
+ }).onProgress(undefined, context._onTaskDetail).then(function(texture) {
4428
4735
  texture.name = textureName || imageName || texture.name || "texture_" + index;
4429
4736
  useSampler && GLTFUtils.parseSampler(texture, samplerInfo);
4430
4737
  return texture;
4431
4738
  });
4739
+ context._addTaskCompletePromise(texture);
4432
4740
  } else {
4433
4741
  var bufferView = glTF.bufferViews[bufferViewIndex];
4434
4742
  texture = context.get(exports.GLTFParserType.Buffer).then(function(buffers) {
@@ -4450,6 +4758,8 @@ exports.GLTFTextureParser = (_GLTFTextureParser = /*#__PURE__*/ function(GLTFPar
4450
4758
  }
4451
4759
  return Promise.resolve(texture).then(function(texture) {
4452
4760
  GLTFParser.executeExtensionsAdditiveAndParse(extensions, context, texture, textureInfo);
4761
+ // @ts-ignore
4762
+ texture._associationSuperResource(glTFResource);
4453
4763
  return texture;
4454
4764
  });
4455
4765
  };
@@ -4500,12 +4810,274 @@ exports.GLTFValidator = __decorate([
4500
4810
  registerGLTFParser(exports.GLTFParserType.Validator)
4501
4811
  ], exports.GLTFValidator);
4502
4812
 
4503
- var GLTFLoader = /*#__PURE__*/ function(Loader1) {
4813
+ exports.GLTFBufferViewParser = /*#__PURE__*/ function(GLTFParser1) {
4814
+ _inherits(GLTFBufferViewParser, GLTFParser1);
4815
+ function GLTFBufferViewParser() {
4816
+ return GLTFParser1.apply(this, arguments);
4817
+ }
4818
+ var _proto = GLTFBufferViewParser.prototype;
4819
+ _proto.parse = function parse(context, index) {
4820
+ var bufferView = context.glTF.bufferViews[index];
4821
+ var extensions = bufferView.extensions, _bufferView_byteOffset = bufferView.byteOffset, byteOffset = _bufferView_byteOffset === void 0 ? 0 : _bufferView_byteOffset, byteLength = bufferView.byteLength, bufferIndex = bufferView.buffer;
4822
+ return extensions ? GLTFParser.executeExtensionsCreateAndParse(extensions, context, bufferView) : context.get(exports.GLTFParserType.Buffer, bufferIndex).then(function(buffer) {
4823
+ return new Uint8Array(buffer, byteOffset, byteLength);
4824
+ });
4825
+ };
4826
+ return GLTFBufferViewParser;
4827
+ }(GLTFParser);
4828
+ exports.GLTFBufferViewParser = __decorate([
4829
+ registerGLTFParser(exports.GLTFParserType.BufferView)
4830
+ ], exports.GLTFBufferViewParser);
4831
+
4832
+ exports.GLTFAnimatorControllerParser = /*#__PURE__*/ function(GLTFParser1) {
4833
+ _inherits(GLTFAnimatorControllerParser, GLTFParser1);
4834
+ function GLTFAnimatorControllerParser() {
4835
+ return GLTFParser1.apply(this, arguments);
4836
+ }
4837
+ var _proto = GLTFAnimatorControllerParser.prototype;
4838
+ _proto.parse = function parse(context) {
4839
+ var _this = this;
4840
+ if (!context.needAnimatorController) {
4841
+ return Promise.resolve(null);
4842
+ }
4843
+ return context.get(exports.GLTFParserType.Animation).then(function(animations) {
4844
+ var animatorController = _this._createAnimatorController(animations);
4845
+ return Promise.resolve(animatorController);
4846
+ });
4847
+ };
4848
+ _proto._createAnimatorController = function _createAnimatorController(animations) {
4849
+ var animatorController = new engineCore.AnimatorController();
4850
+ var layer = new engineCore.AnimatorControllerLayer("layer");
4851
+ var animatorStateMachine = new engineCore.AnimatorStateMachine();
4852
+ animatorController.addLayer(layer);
4853
+ layer.stateMachine = animatorStateMachine;
4854
+ if (animations) {
4855
+ for(var i = 0; i < animations.length; i++){
4856
+ var animationClip = animations[i];
4857
+ var name = animationClip.name;
4858
+ var uniqueName = animatorStateMachine.makeUniqueStateName(name);
4859
+ if (uniqueName !== name) {
4860
+ console.warn("AnimatorState name is existed, name: " + name + " reset to " + uniqueName);
4861
+ }
4862
+ var animatorState = animatorStateMachine.addState(uniqueName);
4863
+ animatorState.clip = animationClip;
4864
+ }
4865
+ }
4866
+ return animatorController;
4867
+ };
4868
+ return GLTFAnimatorControllerParser;
4869
+ }(GLTFParser);
4870
+ exports.GLTFAnimatorControllerParser = __decorate([
4871
+ registerGLTFParser(exports.GLTFParserType.AnimatorController)
4872
+ ], exports.GLTFAnimatorControllerParser);
4873
+
4874
+ // Source: https://github.com/zeux/meshoptimizer/blob/master/js/meshopt_decoder.js
4875
+ var MeshoptDecoder = function() {
4876
+ var unpack = function unpack(data) {
4877
+ var result = new Uint8Array(data.length);
4878
+ for(var i = 0; i < data.length; ++i){
4879
+ var ch = data.charCodeAt(i);
4880
+ result[i] = ch > 96 ? ch - 97 : ch > 64 ? ch - 39 : ch + 4;
4881
+ }
4882
+ var write = 0;
4883
+ for(var i1 = 0; i1 < data.length; ++i1){
4884
+ result[write++] = result[i1] < 60 ? wasmpack[result[i1]] : (result[i1] - 60) * 64 + result[++i1];
4885
+ }
4886
+ return result.buffer.slice(0, write);
4887
+ };
4888
+ var decode = function decode(fun, target, count, size, source, filter) {
4889
+ var sbrk = instance.exports.sbrk;
4890
+ var count4 = count + 3 & ~3;
4891
+ var tp = sbrk(count4 * size);
4892
+ var sp = sbrk(source.length);
4893
+ var heap = new Uint8Array(instance.exports.memory.buffer);
4894
+ heap.set(source, sp);
4895
+ var res = fun(tp, count, size, sp, source.length);
4896
+ if (res == 0 && filter) {
4897
+ filter(tp, count4, size);
4898
+ }
4899
+ target.set(heap.subarray(tp, tp + count * size));
4900
+ sbrk(tp - sbrk(0));
4901
+ if (res != 0) {
4902
+ throw new Error("Malformed buffer data: " + res);
4903
+ }
4904
+ };
4905
+ var createWorker = function createWorker(url) {
4906
+ var worker = {
4907
+ object: new Worker(url),
4908
+ pending: 0,
4909
+ requests: {}
4910
+ };
4911
+ worker.object.onmessage = function(event) {
4912
+ var data = event.data;
4913
+ worker.pending -= data.count;
4914
+ worker.requests[data.id][data.action](data.value);
4915
+ delete worker.requests[data.id];
4916
+ };
4917
+ return worker;
4918
+ };
4919
+ var initWorkers = function initWorkers(count) {
4920
+ var source = "var instance; var ready = WebAssembly.instantiate(new Uint8Array([" + new Uint8Array(unpack(wasm)) + "]), {})" + ".then(function(result) {instance = result.instance; instance.exports.__wasm_call_ctors();});\n" + "self.onmessage = workerProcess;\n" + 'function decode(fun, target, count, size, source, filter) {\n const sbrk = instance.exports.sbrk;\n const count4 = (count + 3) & ~3;\n const tp = sbrk(count4 * size);\n const sp = sbrk(source.length);\n const heap = new Uint8Array(instance.exports.memory.buffer);\n heap.set(source, sp);\n const res = fun(tp, count, size, sp, source.length);\n if (res == 0 && filter) {\n filter(tp, count4, size);\n }\n target.set(heap.subarray(tp, tp + count * size));\n sbrk(tp - sbrk(0));\n if (res != 0) {\n throw new Error("Malformed buffer data: " + res);\n }\n }\n' + 'function workerProcess(event) {\n ready.then(function () {\n const data = event.data;\n try {\n const target = new Uint8Array(data.count * data.size);\n decode(instance.exports[data.mode], target, data.count, data.size, data.source, instance.exports[data.filter]);\n self.postMessage({ id: data.id, count: data.count, action: "resolve", value: target }, [target.buffer]);\n } catch (error) {\n self.postMessage({\n id: data.id,\n count: data.count,\n action: "reject",\n value: error\n });\n }\n });\n }';
4921
+ var blob = new Blob([
4922
+ source
4923
+ ], {
4924
+ type: "text/javascript"
4925
+ });
4926
+ var url = URL.createObjectURL(blob);
4927
+ for(var i = 0; i < count; ++i){
4928
+ workers[i] = createWorker(url);
4929
+ }
4930
+ URL.revokeObjectURL(url);
4931
+ };
4932
+ var decodeWorker = function decodeWorker(count, size, source, mode, filter) {
4933
+ var worker = workers[0];
4934
+ for(var i = 1; i < workers.length; ++i){
4935
+ if (workers[i].pending < worker.pending) {
4936
+ worker = workers[i];
4937
+ }
4938
+ }
4939
+ return new Promise(function(resolve, reject) {
4940
+ var data = new Uint8Array(source);
4941
+ var id = requestId++;
4942
+ worker.pending += count;
4943
+ worker.requests[id] = {
4944
+ resolve: resolve,
4945
+ reject: reject
4946
+ };
4947
+ worker.object.postMessage({
4948
+ id: id,
4949
+ count: count,
4950
+ size: size,
4951
+ source: data,
4952
+ mode: mode,
4953
+ filter: filter
4954
+ }, [
4955
+ data.buffer
4956
+ ]);
4957
+ });
4958
+ };
4959
+ var wasm_base = "b9H79Tebbbe8Fv9Gbb9Gvuuuuueu9Giuuub9Geueu9Giuuueuikqbeeedddillviebeoweuec:q;iekr;leDo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbeY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVbdE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbiL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtblK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949Wbol79IV9Rbrq:P8Yqdbk;3sezu8Jjjjjbcj;eb9Rgv8Kjjjjbc9:hodnadcefal0mbcuhoaiRbbc:Ge9hmbavaialfgrad9Radz1jjjbhwcj;abad9UhoaicefhldnadTmbaoc;WFbGgocjdaocjd6EhDcbhqinaqae9pmeaDaeaq9RaqaDfae6Egkcsfgocl4cifcd4hxdndndndnaoc9WGgmTmbcbhPcehsawcjdfhzalhHinaraH9Rax6midnaraHaxfgl9RcK6mbczhoinawcj;cbfaogifgoc9WfhOdndndndndnaHaic9WfgAco4fRbbaAci4coG4ciGPlbedibkaO9cb83ibaOcwf9cb83ibxikaOalRblalRbbgAco4gCaCciSgCE86bbaocGfalclfaCfgORbbaAcl4ciGgCaCciSgCE86bbaocVfaOaCfgORbbaAcd4ciGgCaCciSgCE86bbaoc7faOaCfgORbbaAciGgAaAciSgAE86bbaoctfaOaAfgARbbalRbegOco4gCaCciSgCE86bbaoc91faAaCfgARbbaOcl4ciGgCaCciSgCE86bbaoc4faAaCfgARbbaOcd4ciGgCaCciSgCE86bbaoc93faAaCfgARbbaOciGgOaOciSgOE86bbaoc94faAaOfgARbbalRbdgOco4gCaCciSgCE86bbaoc95faAaCfgARbbaOcl4ciGgCaCciSgCE86bbaoc96faAaCfgARbbaOcd4ciGgCaCciSgCE86bbaoc97faAaCfgARbbaOciGgOaOciSgOE86bbaoc98faAaOfgORbbalRbiglco4gAaAciSgAE86bbaoc99faOaAfgORbbalcl4ciGgAaAciSgAE86bbaoc9:faOaAfgORbbalcd4ciGgAaAciSgAE86bbaocufaOaAfgoRbbalciGglalciSglE86bbaoalfhlxdkaOalRbwalRbbgAcl4gCaCcsSgCE86bbaocGfalcwfaCfgORbbaAcsGgAaAcsSgAE86bbaocVfaOaAfgORbbalRbegAcl4gCaCcsSgCE86bbaoc7faOaCfgORbbaAcsGgAaAcsSgAE86bbaoctfaOaAfgORbbalRbdgAcl4gCaCcsSgCE86bbaoc91faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc4faOaAfgORbbalRbigAcl4gCaCcsSgCE86bbaoc93faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc94faOaAfgORbbalRblgAcl4gCaCcsSgCE86bbaoc95faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc96faOaAfgORbbalRbvgAcl4gCaCcsSgCE86bbaoc97faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc98faOaAfgORbbalRbogAcl4gCaCcsSgCE86bbaoc99faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc9:faOaAfgORbbalRbrglcl4gAaAcsSgAE86bbaocufaOaAfgoRbbalcsGglalcsSglE86bbaoalfhlxekaOal8Pbb83bbaOcwfalcwf8Pbb83bbalczfhlkdnaiam9pmbaiczfhoaral9RcL0mekkaiam6mialTmidnakTmbawaPfRbbhOcbhoazhiinaiawcj;cbfaofRbbgAce4cbaAceG9R7aOfgO86bbaiadfhiaocefgoak9hmbkkazcefhzaPcefgPad6hsalhHaPad9hmexvkkcbhlasceGmdxikalaxad2fhCdnakTmbcbhHcehsawcjdfhminaral9Rax6mialTmdalaxfhlawaHfRbbhOcbhoamhiinaiawcj;cbfaofRbbgAce4cbaAceG9R7aOfgO86bbaiadfhiaocefgoak9hmbkamcefhmaHcefgHad6hsaHad9hmbkaChlxikcbhocehsinaral9Rax6mdalTmealaxfhlaocefgoad6hsadao9hmbkaChlxdkcbhlasceGTmekc9:hoxikabaqad2fawcjdfakad2z1jjjb8Aawawcjdfakcufad2fadz1jjjb8Aakaqfhqalmbkc9:hoxekcbc99aral9Radcaadca0ESEhokavcj;ebf8Kjjjjbaok;yzeHu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnaeci9UgrcHfal0mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgDce0mbavc;abfcFecjez:jjjjb8AavcUf9cu83ibavc8Wf9cu83ibavcyf9cu83ibavcaf9cu83ibavcKf9cu83ibavczf9cu83ibav9cu83iwav9cu83ibaialfc9WfhqaicefgwarfhodnaeTmbcmcsaDceSEhkcbhxcbhmcbhDcbhicbhlindnaoaq9nmbc9:hoxikdndnawRbbgrc;Ve0mbavc;abfalarcl4cu7fcsGcitfgPydlhsaPydbhzdnarcsGgPak9pmbavaiarcu7fcsGcdtfydbaxaPEhraPThPdndnadcd9hmbabaDcetfgHaz87ebaHcdfas87ebaHclfar87ebxekabaDcdtfgHazBdbaHclfasBdbaHcwfarBdbkaxaPfhxavc;abfalcitfgHarBdbaHasBdlavaicdtfarBdbavc;abfalcefcsGglcitfgHazBdbaHarBdlaiaPfhialcefhlxdkdndnaPcsSmbamaPfaPc987fcefhmxekaocefhrao8SbbgPcFeGhHdndnaPcu9mmbarhoxekaocvfhoaHcFbGhHcrhPdninar8SbbgOcFbGaPtaHVhHaOcu9kmearcefhraPcrfgPc8J9hmbxdkkarcefhokaHce4cbaHceG9R7amfhmkdndnadcd9hmbabaDcetfgraz87ebarcdfas87ebarclfam87ebxekabaDcdtfgrazBdbarclfasBdbarcwfamBdbkavc;abfalcitfgramBdbarasBdlavaicdtfamBdbavc;abfalcefcsGglcitfgrazBdbaramBdlaicefhialcefhlxekdnarcpe0mbaxcefgOavaiaqarcsGfRbbgPcl49RcsGcdtfydbaPcz6gHEhravaiaP9RcsGcdtfydbaOaHfgsaPcsGgOEhPaOThOdndnadcd9hmbabaDcetfgzax87ebazcdfar87ebazclfaP87ebxekabaDcdtfgzaxBdbazclfarBdbazcwfaPBdbkavaicdtfaxBdbavc;abfalcitfgzarBdbazaxBdlavaicefgicsGcdtfarBdbavc;abfalcefcsGcitfgzaPBdbazarBdlavaiaHfcsGgicdtfaPBdbavc;abfalcdfcsGglcitfgraxBdbaraPBdlalcefhlaiaOfhiasaOfhxxekaxcbaoRbbgzEgAarc;:eSgrfhsazcsGhCazcl4hXdndnazcs0mbascefhOxekashOavaiaX9RcsGcdtfydbhskdndnaCmbaOcefhxxekaOhxavaiaz9RcsGcdtfydbhOkdndnarTmbaocefhrxekaocdfhrao8SbegHcFeGhPdnaHcu9kmbaocofhAaPcFbGhPcrhodninar8SbbgHcFbGaotaPVhPaHcu9kmearcefhraocrfgoc8J9hmbkaAhrxekarcefhrkaPce4cbaPceG9R7amfgmhAkdndnaXcsSmbarhPxekarcefhPar8SbbgocFeGhHdnaocu9kmbarcvfhsaHcFbGhHcrhodninaP8SbbgrcFbGaotaHVhHarcu9kmeaPcefhPaocrfgoc8J9hmbkashPxekaPcefhPkaHce4cbaHceG9R7amfgmhskdndnaCcsSmbaPhoxekaPcefhoaP8SbbgrcFeGhHdnarcu9kmbaPcvfhOaHcFbGhHcrhrdninao8SbbgPcFbGartaHVhHaPcu9kmeaocefhoarcrfgrc8J9hmbkaOhoxekaocefhokaHce4cbaHceG9R7amfgmhOkdndnadcd9hmbabaDcetfgraA87ebarcdfas87ebarclfaO87ebxekabaDcdtfgraABdbarclfasBdbarcwfaOBdbkavc;abfalcitfgrasBdbaraABdlavaicdtfaABdbavc;abfalcefcsGcitfgraOBdbarasBdlavaicefgicsGcdtfasBdbavc;abfalcdfcsGcitfgraABdbaraOBdlavaiazcz6aXcsSVfgicsGcdtfaOBdbaiaCTaCcsSVfhialcifhlkawcefhwalcsGhlaicsGhiaDcifgDae6mbkkcbc99aoaqSEhokavc;aef8Kjjjjbaok:llevu8Jjjjjbcz9Rhvc9:hodnaecvfal0mbcuhoaiRbbc;:eGc;qe9hmbav9cb83iwaicefhraialfc98fhwdnaeTmbdnadcdSmbcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcdtfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfglBdbaoalBdbaDcefgDae9hmbxdkkcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcetfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfgl87ebaoalBdbaDcefgDae9hmbkkcbc99arawSEhokaok:Lvoeue99dud99eud99dndnadcl9hmbaeTmeindndnabcdfgd8Sbb:Yab8Sbbgi:Ygl:l:tabcefgv8Sbbgo:Ygr:l:tgwJbb;:9cawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai86bbdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad86bbdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad86bbabclfhbaecufgembxdkkaeTmbindndnabclfgd8Ueb:Yab8Uebgi:Ygl:l:tabcdfgv8Uebgo:Ygr:l:tgwJb;:FSawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai87ebdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad87ebdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad87ebabcwfhbaecufgembkkk;siliui99iue99dnaeTmbcbhiabhlindndnJ;Zl81Zalcof8UebgvciV:Y:vgoal8Ueb:YNgrJb;:FSNJbbbZJbbb:;arJbbbb9GEMgw:lJbbb9p9DTmbaw:OhDxekcjjjj94hDkalclf8Uebhqalcdf8UebhkabavcefciGaiVcetfaD87ebdndnaoak:YNgwJb;:FSNJbbbZJbbb:;awJbbbb9GEMgx:lJbbb9p9DTmbax:Ohkxekcjjjj94hkkabavcdfciGaiVcetfak87ebdndnaoaq:YNgoJb;:FSNJbbbZJbbb:;aoJbbbb9GEMgx:lJbbb9p9DTmbax:Ohqxekcjjjj94hqkabavcufciGaiVcetfaq87ebdndnJbbjZararN:tawawN:taoaoN:tgrJbbbbarJbbbb9GE:rJb;:FSNJbbbZMgr:lJbbb9p9DTmbar:Ohqxekcjjjj94hqkabavciGaiVcetfaq87ebalcwfhlaiclfhiaecufgembkkk9mbdnadcd4ae2geTmbinababydbgdcwtcw91:Yadce91cjjj;8ifcjjj98G::NUdbabclfhbaecufgembkkk9teiucbcbydj1jjbgeabcifc98GfgbBdj1jjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaik;LeeeudndnaeabVciGTmbabhixekdndnadcz9pmbabhixekabhiinaiaeydbBdbaiclfaeclfydbBdbaicwfaecwfydbBdbaicxfaecxfydbBdbaiczfhiaeczfheadc9Wfgdcs0mbkkadcl6mbinaiaeydbBdbaeclfheaiclfhiadc98fgdci0mbkkdnadTmbinaiaeRbb86bbaicefhiaecefheadcufgdmbkkabk;aeedudndnabciGTmbabhixekaecFeGc:b:c:ew2hldndnadcz9pmbabhixekabhiinaialBdbaicxfalBdbaicwfalBdbaiclfalBdbaiczfhiadc9Wfgdcs0mbkkadcl6mbinaialBdbaiclfhiadc98fgdci0mbkkdnadTmbinaiae86bbaicefhiadcufgdmbkkabkkkebcjwklz9Kbb";
4960
+ var wasm_simd = "b9H79TebbbeKl9Gbb9Gvuuuuueu9Giuuub9Geueuikqbbebeedddilve9Weeeviebeoweuec:q;Aekr;leDo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbdY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVblE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtboK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbrL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949Wbwl79IV9RbDq;t9tqlbzik9:evu8Jjjjjbcz9Rhbcbheincbhdcbhiinabcwfadfaicjuaead4ceGglE86bbaialfhiadcefgdcw9hmbkaec:q:yjjbfai86bbaecitc:q1jjbfab8Piw83ibaecefgecjd9hmbkk;h8JlHud97euo978Jjjjjbcj;kb9Rgv8Kjjjjbc9:hodnadcefal0mbcuhoaiRbbc:Ge9hmbavaialfgrad9Rad;8qbbcj;abad9UhoaicefhldnadTmbaoc;WFbGgocjdaocjd6EhwcbhDinaDae9pmeawaeaD9RaDawfae6Egqcsfgoc9WGgkci2hxakcethmaocl4cifcd4hPabaDad2fhscbhzdnincehHalhOcbhAdninaraO9RaP6miavcj;cbfaAak2fhCaOaPfhlcbhidnakc;ab6mbaral9Rc;Gb6mbcbhoinaCaofhidndndndndnaOaoco4fRbbgXciGPlbedibkaipxbbbbbbbbbbbbbbbbpklbxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaialpbbbpklbalczfhlkdndndndndnaXcd4ciGPlbedibkaipxbbbbbbbbbbbbbbbbpklzxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklzalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklzalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaialpbbbpklzalczfhlkdndndndndnaXcl4ciGPlbedibkaipxbbbbbbbbbbbbbbbbpklaxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklaalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklaalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaialpbbbpklaalczfhlkdndndndndnaXco4Plbedibkaipxbbbbbbbbbbbbbbbbpkl8WxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibaXc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spkl8WalclfaYpQbfaXc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibaXc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spkl8WalcwfaYpQbfaXc:q:yjjbfRbbfhlxekaialpbbbpkl8Walczfhlkaoc;abfhiaocjefak0meaihoaral9Rc;Fb0mbkkdndnaiak9pmbaici4hoinaral9RcK6mdaCaifhXdndndndndnaOaico4fRbbaocoG4ciGPlbedibkaXpxbbbbbbbbbbbbbbbbpklbxikaXalpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaXalpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaXalpbbbpklbalczfhlkaocdfhoaiczfgiak6mbkkalTmbaAci6hHalhOaAcefgohAaoclSmdxekkcbhlaHceGmdkdnakTmbavcjdfazfhiavazfpbdbhYcbhXinaiavcj;cbfaXfgopblbgLcep9TaLpxeeeeeeeeeeeeeeeegQp9op9Hp9rgLaoakfpblbg8Acep9Ta8AaQp9op9Hp9rg8ApmbzeHdOiAlCvXoQrLgEaoamfpblbg3cep9Ta3aQp9op9Hp9rg3aoaxfpblbg5cep9Ta5aQp9op9Hp9rg5pmbzeHdOiAlCvXoQrLg8EpmbezHdiOAlvCXorQLgQaQpmbedibedibedibediaYp9UgYp9AdbbaiadfgoaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaoadfgoaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaoadfgoaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaoadfgoaYaEa8EpmwDKYqk8AExm35Ps8E8FgQaQpmbedibedibedibedip9UgYp9AdbbaoadfgoaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaoadfgoaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaoadfgoaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaoadfgoaYaLa8ApmwKDYq8AkEx3m5P8Es8FgLa3a5pmwKDYq8AkEx3m5P8Es8Fg8ApmbezHdiOAlvCXorQLgQaQpmbedibedibedibedip9UgYp9AdbbaoadfgoaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaoadfgoaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaoadfgoaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaoadfgoaYaLa8ApmwDKYqk8AExm35Ps8E8FgQaQpmbedibedibedibedip9UgYp9AdbbaoadfgoaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaoadfgoaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaoadfgoaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaoadfhiaXczfgXak6mbkkazclfgzad6mbkasavcjdfaqad2;8qbbavavcjdfaqcufad2fad;8qbbaqaDfhDc9:hoalmexikkc9:hoxekcbc99aral9Radcaadca0ESEhokavcj;kbf8Kjjjjbaokwbz:bjjjbk;uzeHu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnaeci9UgrcHfal0mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgDce0mbavc;abfcFecje;8kbavcUf9cu83ibavc8Wf9cu83ibavcyf9cu83ibavcaf9cu83ibavcKf9cu83ibavczf9cu83ibav9cu83iwav9cu83ibaialfc9WfhqaicefgwarfhodnaeTmbcmcsaDceSEhkcbhxcbhmcbhDcbhicbhlindnaoaq9nmbc9:hoxikdndnawRbbgrc;Ve0mbavc;abfalarcl4cu7fcsGcitfgPydlhsaPydbhzdnarcsGgPak9pmbavaiarcu7fcsGcdtfydbaxaPEhraPThPdndnadcd9hmbabaDcetfgHaz87ebaHcdfas87ebaHclfar87ebxekabaDcdtfgHazBdbaHclfasBdbaHcwfarBdbkaxaPfhxavc;abfalcitfgHarBdbaHasBdlavaicdtfarBdbavc;abfalcefcsGglcitfgHazBdbaHarBdlaiaPfhialcefhlxdkdndnaPcsSmbamaPfaPc987fcefhmxekaocefhrao8SbbgPcFeGhHdndnaPcu9mmbarhoxekaocvfhoaHcFbGhHcrhPdninar8SbbgOcFbGaPtaHVhHaOcu9kmearcefhraPcrfgPc8J9hmbxdkkarcefhokaHce4cbaHceG9R7amfhmkdndnadcd9hmbabaDcetfgraz87ebarcdfas87ebarclfam87ebxekabaDcdtfgrazBdbarclfasBdbarcwfamBdbkavc;abfalcitfgramBdbarasBdlavaicdtfamBdbavc;abfalcefcsGglcitfgrazBdbaramBdlaicefhialcefhlxekdnarcpe0mbaxcefgOavaiaqarcsGfRbbgPcl49RcsGcdtfydbaPcz6gHEhravaiaP9RcsGcdtfydbaOaHfgsaPcsGgOEhPaOThOdndnadcd9hmbabaDcetfgzax87ebazcdfar87ebazclfaP87ebxekabaDcdtfgzaxBdbazclfarBdbazcwfaPBdbkavaicdtfaxBdbavc;abfalcitfgzarBdbazaxBdlavaicefgicsGcdtfarBdbavc;abfalcefcsGcitfgzaPBdbazarBdlavaiaHfcsGgicdtfaPBdbavc;abfalcdfcsGglcitfgraxBdbaraPBdlalcefhlaiaOfhiasaOfhxxekaxcbaoRbbgzEgAarc;:eSgrfhsazcsGhCazcl4hXdndnazcs0mbascefhOxekashOavaiaX9RcsGcdtfydbhskdndnaCmbaOcefhxxekaOhxavaiaz9RcsGcdtfydbhOkdndnarTmbaocefhrxekaocdfhrao8SbegHcFeGhPdnaHcu9kmbaocofhAaPcFbGhPcrhodninar8SbbgHcFbGaotaPVhPaHcu9kmearcefhraocrfgoc8J9hmbkaAhrxekarcefhrkaPce4cbaPceG9R7amfgmhAkdndnaXcsSmbarhPxekarcefhPar8SbbgocFeGhHdnaocu9kmbarcvfhsaHcFbGhHcrhodninaP8SbbgrcFbGaotaHVhHarcu9kmeaPcefhPaocrfgoc8J9hmbkashPxekaPcefhPkaHce4cbaHceG9R7amfgmhskdndnaCcsSmbaPhoxekaPcefhoaP8SbbgrcFeGhHdnarcu9kmbaPcvfhOaHcFbGhHcrhrdninao8SbbgPcFbGartaHVhHaPcu9kmeaocefhoarcrfgrc8J9hmbkaOhoxekaocefhokaHce4cbaHceG9R7amfgmhOkdndnadcd9hmbabaDcetfgraA87ebarcdfas87ebarclfaO87ebxekabaDcdtfgraABdbarclfasBdbarcwfaOBdbkavc;abfalcitfgrasBdbaraABdlavaicdtfaABdbavc;abfalcefcsGcitfgraOBdbarasBdlavaicefgicsGcdtfasBdbavc;abfalcdfcsGcitfgraABdbaraOBdlavaiazcz6aXcsSVfgicsGcdtfaOBdbaiaCTaCcsSVfhialcifhlkawcefhwalcsGhlaicsGhiaDcifgDae6mbkkcbc99aoaqSEhokavc;aef8Kjjjjbaok:llevu8Jjjjjbcz9Rhvc9:hodnaecvfal0mbcuhoaiRbbc;:eGc;qe9hmbav9cb83iwaicefhraialfc98fhwdnaeTmbdnadcdSmbcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcdtfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfglBdbaoalBdbaDcefgDae9hmbxdkkcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcetfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfgl87ebaoalBdbaDcefgDae9hmbkkcbc99arawSEhokaok:EPliuo97eue978Jjjjjbca9Rhidndnadcl9hmbdnaec98GglTmbcbhvabhdinadadpbbbgocKp:RecKp:Sep;6egraocwp:RecKp:Sep;6earp;Geaoczp:RecKp:Sep;6egwp;Gep;Kep;LegDpxbbbbbbbbbbbbbbbbp:2egqarpxbbbjbbbjbbbjbbbjgkp9op9rp;Kegrpxbb;:9cbb;:9cbb;:9cbb;:9cararp;MeaDaDp;Meawaqawakp9op9rp;Kegrarp;Mep;Kep;Kep;Jep;Negwp;Mepxbbn0bbn0bbn0bbn0gqp;KepxFbbbFbbbFbbbFbbbp9oaopxbbbFbbbFbbbFbbbFp9op9qarawp;Meaqp;Kecwp:RepxbFbbbFbbbFbbbFbbp9op9qaDawp;Meaqp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qpkbbadczfhdavclfgval6mbkkalae9pmeaiaeciGgvcdtgdVcbczad9R;8kbaiabalcdtfglad;8qbbdnavTmbaiaipblbgocKp:RecKp:Sep;6egraocwp:RecKp:Sep;6earp;Geaoczp:RecKp:Sep;6egwp;Gep;Kep;LegDpxbbbbbbbbbbbbbbbbp:2egqarpxbbbjbbbjbbbjbbbjgkp9op9rp;Kegrpxbb;:9cbb;:9cbb;:9cbb;:9cararp;MeaDaDp;Meawaqawakp9op9rp;Kegrarp;Mep;Kep;Kep;Jep;Negwp;Mepxbbn0bbn0bbn0bbn0gqp;KepxFbbbFbbbFbbbFbbbp9oaopxbbbFbbbFbbbFbbbFp9op9qarawp;Meaqp;Kecwp:RepxbFbbbFbbbFbbbFbbp9op9qaDawp;Meaqp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qpklbkalaiad;8qbbskdnaec98GgxTmbcbhvabhdinadczfglalpbbbgopxbbbbbbFFbbbbbbFFgkp9oadpbbbgDaopmlvorxmPsCXQL358E8FpxFubbFubbFubbFubbp9op;6eaDaopmbediwDqkzHOAKY8AEgoczp:Sep;6egrp;Geaoczp:Reczp:Sep;6egwp;Gep;Kep;Legopxb;:FSb;:FSb;:FSb;:FSawaopxbbbbbbbbbbbbbbbbp:2egqawpxbbbjbbbjbbbjbbbjgmp9op9rp;Kegwawp;Meaoaop;Mearaqaramp9op9rp;Kegoaop;Mep;Kep;Kep;Jep;Negrp;Mepxbbn0bbn0bbn0bbn0gqp;Keczp:Reawarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9op9qgwaoarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9ogopmwDKYqk8AExm35Ps8E8Fp9qpkbbadaDakp9oawaopmbezHdiOAlvCXorQLp9qpkbbadcafhdavclfgvax6mbkkaxae9pmbaiaeciGgvcitgdfcbcaad9R;8kbaiabaxcitfglad;8qbbdnavTmbaiaipblzgopxbbbbbbFFbbbbbbFFgkp9oaipblbgDaopmlvorxmPsCXQL358E8FpxFubbFubbFubbFubbp9op;6eaDaopmbediwDqkzHOAKY8AEgoczp:Sep;6egrp;Geaoczp:Reczp:Sep;6egwp;Gep;Kep;Legopxb;:FSb;:FSb;:FSb;:FSawaopxbbbbbbbbbbbbbbbbp:2egqawpxbbbjbbbjbbbjbbbjgmp9op9rp;Kegwawp;Meaoaop;Mearaqaramp9op9rp;Kegoaop;Mep;Kep;Kep;Jep;Negrp;Mepxbbn0bbn0bbn0bbn0gqp;Keczp:Reawarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9op9qgwaoarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9ogopmwDKYqk8AExm35Ps8E8Fp9qpklzaiaDakp9oawaopmbezHdiOAlvCXorQLp9qpklbkalaiad;8qbbkk;4wllue97euv978Jjjjjbc8W9Rhidnaec98GglTmbcbhvabhoinaiaopbbbgraoczfgwpbbbgDpmlvorxmPsCXQL358E8Fgqczp:Segkclp:RepklbaopxbbjZbbjZbbjZbbjZpx;Zl81Z;Zl81Z;Zl81Z;Zl81Zakpxibbbibbbibbbibbbp9qp;6ep;NegkaraDpmbediwDqkzHOAKY8AEgrczp:Reczp:Sep;6ep;MegDaDp;Meakarczp:Sep;6ep;Megxaxp;Meakaqczp:Reczp:Sep;6ep;Megqaqp;Mep;Kep;Kep;Lepxbbbbbbbbbbbbbbbbp:4ep;Jepxb;:FSb;:FSb;:FSb;:FSgkp;Mepxbbn0bbn0bbn0bbn0grp;KepxFFbbFFbbFFbbFFbbgmp9oaxakp;Mearp;Keczp:Rep9qgxaqakp;Mearp;Keczp:ReaDakp;Mearp;Keamp9op9qgkpmbezHdiOAlvCXorQLgrp5baipblbpEb:T:j83ibaocwfarp5eaipblbpEe:T:j83ibawaxakpmwDKYqk8AExm35Ps8E8Fgkp5baipblbpEd:T:j83ibaocKfakp5eaipblbpEi:T:j83ibaocafhoavclfgval6mbkkdnalae9pmbaiaeciGgvcitgofcbcaao9R;8kbaiabalcitfgwao;8qbbdnavTmbaiaipblbgraipblzgDpmlvorxmPsCXQL358E8Fgqczp:Segkclp:RepklaaipxbbjZbbjZbbjZbbjZpx;Zl81Z;Zl81Z;Zl81Z;Zl81Zakpxibbbibbbibbbibbbp9qp;6ep;NegkaraDpmbediwDqkzHOAKY8AEgrczp:Reczp:Sep;6ep;MegDaDp;Meakarczp:Sep;6ep;Megxaxp;Meakaqczp:Reczp:Sep;6ep;Megqaqp;Mep;Kep;Kep;Lepxbbbbbbbbbbbbbbbbp:4ep;Jepxb;:FSb;:FSb;:FSb;:FSgkp;Mepxbbn0bbn0bbn0bbn0grp;KepxFFbbFFbbFFbbFFbbgmp9oaxakp;Mearp;Keczp:Rep9qgxaqakp;Mearp;Keczp:ReaDakp;Mearp;Keamp9op9qgkpmbezHdiOAlvCXorQLgrp5baipblapEb:T:j83ibaiarp5eaipblapEe:T:j83iwaiaxakpmwDKYqk8AExm35Ps8E8Fgkp5baipblapEd:T:j83izaiakp5eaipblapEi:T:j83iKkawaiao;8qbbkk:Pddiue978Jjjjjbc;ab9Rhidnadcd4ae2glc98GgvTmbcbhdabheinaeaepbbbgocwp:Recwp:Sep;6eaocep:SepxbbjZbbjZbbjZbbjZp:UepxbbjFbbjFbbjFbbjFp9op;Mepkbbaeczfheadclfgdav6mbkkdnaval9pmbaialciGgdcdtgeVcbc;abae9R;8kbaiabavcdtfgvae;8qbbdnadTmbaiaipblbgocwp:Recwp:Sep;6eaocep:SepxbbjZbbjZbbjZbbjZp:UepxbbjFbbjFbbjFbbjFp9op;Mepklbkavaiae;8qbbkk9teiucbcbydj1jjbgeabcifc98GfgbBdj1jjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaikkkebcjwklz9Tbb";
4961
+ var wasmpack = new Uint8Array([
4962
+ 32,
4963
+ 0,
4964
+ 65,
4965
+ 2,
4966
+ 1,
4967
+ 106,
4968
+ 34,
4969
+ 33,
4970
+ 3,
4971
+ 128,
4972
+ 11,
4973
+ 4,
4974
+ 13,
4975
+ 64,
4976
+ 6,
4977
+ 253,
4978
+ 10,
4979
+ 7,
4980
+ 15,
4981
+ 116,
4982
+ 127,
4983
+ 5,
4984
+ 8,
4985
+ 12,
4986
+ 40,
4987
+ 16,
4988
+ 19,
4989
+ 54,
4990
+ 20,
4991
+ 9,
4992
+ 27,
4993
+ 255,
4994
+ 113,
4995
+ 17,
4996
+ 42,
4997
+ 67,
4998
+ 24,
4999
+ 23,
5000
+ 146,
5001
+ 148,
5002
+ 18,
5003
+ 14,
5004
+ 22,
5005
+ 45,
5006
+ 70,
5007
+ 69,
5008
+ 56,
5009
+ 114,
5010
+ 101,
5011
+ 21,
5012
+ 25,
5013
+ 63,
5014
+ 75,
5015
+ 136,
5016
+ 108,
5017
+ 28,
5018
+ 118,
5019
+ 29,
5020
+ 73,
5021
+ 115
5022
+ ]);
5023
+ // @ts-ignore
5024
+ var wasm = engineCore.SystemInfo._detectSIMDSupported() ? wasm_simd : wasm_base;
5025
+ var instance;
5026
+ var ready = WebAssembly.instantiate(unpack(wasm), {}).then(function(result) {
5027
+ instance = result.instance;
5028
+ instance.exports.__wasm_call_ctors();
5029
+ });
5030
+ var filters = {
5031
+ NONE: "",
5032
+ OCTAHEDRAL: "meshopt_decodeFilterOct",
5033
+ QUATERNION: "meshopt_decodeFilterQuat",
5034
+ EXPONENTIAL: "meshopt_decodeFilterExp"
5035
+ };
5036
+ var decoders = {
5037
+ ATTRIBUTES: "meshopt_decodeVertexBuffer",
5038
+ TRIANGLES: "meshopt_decodeIndexBuffer",
5039
+ INDICES: "meshopt_decodeIndexSequence"
5040
+ };
5041
+ var workers = [];
5042
+ var requestId = 0;
5043
+ return {
5044
+ workerCount: 4,
5045
+ ready: ready,
5046
+ useWorkers: function useWorkers() {
5047
+ initWorkers(this.workerCount);
5048
+ },
5049
+ decodeGltfBuffer: function decodeGltfBuffer(count, stride, source, mode, filter) {
5050
+ if (this.workerCount > 0 && workers.length === 0) this.useWorkers();
5051
+ if (workers.length > 0) return decodeWorker(count, stride, source, decoders[mode], filters[filter]);
5052
+ return ready.then(function() {
5053
+ var target = new Uint8Array(count * stride);
5054
+ decode(instance.exports[decoders[mode]], target, count, stride, source, instance.exports[filters[filter]]);
5055
+ return target;
5056
+ });
5057
+ },
5058
+ release: function release() {
5059
+ for(var i = 0; i < workers.length; i++){
5060
+ workers[i].object.terminate();
5061
+ }
5062
+ }
5063
+ };
5064
+ }();
5065
+
5066
+ exports.GLTFLoader = /*#__PURE__*/ function(Loader1) {
4504
5067
  _inherits(GLTFLoader, Loader1);
4505
5068
  function GLTFLoader() {
4506
5069
  return Loader1.apply(this, arguments);
4507
5070
  }
4508
5071
  var _proto = GLTFLoader.prototype;
5072
+ _proto.initialize = function initialize(_, configuration) {
5073
+ var _configuration_glTF;
5074
+ var meshOptOptions = (_configuration_glTF = configuration.glTF) == null ? void 0 : _configuration_glTF.meshOpt;
5075
+ if (meshOptOptions) {
5076
+ MeshoptDecoder.workerCount = meshOptOptions.workerCount;
5077
+ MeshoptDecoder.useWorkers();
5078
+ }
5079
+ return Promise.resolve();
5080
+ };
4509
5081
  _proto.load = function load(item, resourceManager) {
4510
5082
  var url = item.url;
4511
5083
  var params = item.params;
@@ -4513,20 +5085,31 @@ var GLTFLoader = /*#__PURE__*/ function(Loader1) {
4513
5085
  var context = new GLTFParserContext(glTFResource, resourceManager, _extends({
4514
5086
  keepMeshData: false
4515
5087
  }, params));
4516
- return context.parse();
5088
+ return new engineCore.AssetPromise(function(resolve, reject, setTaskCompleteProgress, setTaskDetailProgress) {
5089
+ context._setTaskCompleteProgress = setTaskCompleteProgress;
5090
+ context._setTaskDetailProgress = setTaskDetailProgress;
5091
+ context.parse().then(resolve).catch(reject);
5092
+ });
5093
+ };
5094
+ /**
5095
+ * Release glTF loader memory(includes meshopt workers).
5096
+ * @remarks If use loader after releasing, we should release again.
5097
+ */ GLTFLoader.release = function release() {
5098
+ MeshoptDecoder.release();
4517
5099
  };
4518
5100
  return GLTFLoader;
4519
5101
  }(engineCore.Loader);
4520
- GLTFLoader = __decorate([
5102
+ exports.GLTFLoader = __decorate([
4521
5103
  engineCore.resourceLoader(engineCore.AssetType.GLTF, [
4522
5104
  "gltf",
4523
5105
  "glb"
4524
5106
  ])
4525
- ], GLTFLoader);
5107
+ ], exports.GLTFLoader);
4526
5108
 
4527
5109
  var _HDRLoader;
4528
5110
  var PI = Math.PI;
4529
- var HDRLoader = (_HDRLoader = /*#__PURE__*/ function(Loader1) {
5111
+ var HDRLoader = (_HDRLoader = // referenece: https://www.flipcode.com/archives/HDR_Image_Reader.shtml
5112
+ /*#__PURE__*/ function(Loader1) {
4530
5113
  _inherits(HDRLoader1, Loader1);
4531
5114
  function HDRLoader1() {
4532
5115
  return Loader1.apply(this, arguments);
@@ -4696,15 +5279,20 @@ var HDRLoader = (_HDRLoader = /*#__PURE__*/ function(Loader1) {
4696
5279
  var dataRGBA = new Uint8Array(4 * width * height);
4697
5280
  var offset = 0, pos = 0;
4698
5281
  var ptrEnd = 4 * scanLineWidth;
4699
- var rgbeStart = new Uint8Array(4);
4700
5282
  var scanLineBuffer = new Uint8Array(ptrEnd);
4701
5283
  var numScanLines = height; // read in each successive scanLine
4702
5284
  while(numScanLines > 0 && pos < byteLength){
4703
- rgbeStart[0] = buffer[pos++];
4704
- rgbeStart[1] = buffer[pos++];
4705
- rgbeStart[2] = buffer[pos++];
4706
- rgbeStart[3] = buffer[pos++];
4707
- if (2 != rgbeStart[0] || 2 != rgbeStart[1] || (rgbeStart[2] << 8 | rgbeStart[3]) != scanLineWidth) {
5285
+ var a = buffer[pos++];
5286
+ var b = buffer[pos++];
5287
+ var c = buffer[pos++];
5288
+ var d = buffer[pos++];
5289
+ if (a != 2 || b != 2 || c & 0x80 || width < 8 || width > 32767) {
5290
+ // this file is not run length encoded
5291
+ // read values sequentially
5292
+ return buffer;
5293
+ }
5294
+ if ((c << 8 | d) != scanLineWidth) {
5295
+ // eslint-disable-next-line no-throw-literal
4708
5296
  throw "HDR Bad header format, wrong scan line width";
4709
5297
  }
4710
5298
  // read each of the four channels for the scanline into the buffer
@@ -5224,6 +5812,86 @@ MeshLoader = __decorate([
5224
5812
  ])
5225
5813
  ], MeshLoader);
5226
5814
 
5815
+ var PrimitiveMeshLoader = /*#__PURE__*/ function(Loader1) {
5816
+ _inherits(PrimitiveMeshLoader, Loader1);
5817
+ function PrimitiveMeshLoader() {
5818
+ return Loader1.apply(this, arguments);
5819
+ }
5820
+ var _proto = PrimitiveMeshLoader.prototype;
5821
+ _proto.load = function load(item, param) {
5822
+ var engine = param.engine;
5823
+ return this.request(item.url, _extends({}, item, {
5824
+ type: "json"
5825
+ })).then(function(data) {
5826
+ switch(data.type){
5827
+ case "sphere":
5828
+ return engineCore.PrimitiveMesh.createSubdivisionSurfaceSphere(engine, data.sphereRadius, data.sphereStep);
5829
+ case "capsule":
5830
+ return engineCore.PrimitiveMesh.createCapsule(engine, data.capsuleRadius, data.capsuleHeight, data.capsuleRadialSegments, data.capsuleHeightSegments);
5831
+ case "cone":
5832
+ return engineCore.PrimitiveMesh.createCone(engine, data.coneRadius, data.coneHeight, data.coneRadialSegment, data.coneHeightSegment);
5833
+ case "cuboid":
5834
+ return engineCore.PrimitiveMesh.createCuboid(engine, data.cuboidWidth, data.cuboidHeight, data.cuboidDepth);
5835
+ case "cylinder":
5836
+ return engineCore.PrimitiveMesh.createCylinder(engine, data.cylinderRadiusTop, data.cylinderRadiusBottom, data.cylinderHeight, data.cylinderRadialSegment, data.cylinderHeightSegment);
5837
+ case "plane":
5838
+ return engineCore.PrimitiveMesh.createPlane(engine, data.planeWidth, data.planeHeight, data.planeHorizontalSegments, data.planeVerticalSegments);
5839
+ case "torus":
5840
+ return engineCore.PrimitiveMesh.createTorus(engine, data.torusRadius, data.torusTubeRadius, data.torusRadialSegments, data.torusTubularSegments, data.torusArc);
5841
+ }
5842
+ });
5843
+ };
5844
+ return PrimitiveMeshLoader;
5845
+ }(engineCore.Loader);
5846
+ PrimitiveMeshLoader = __decorate([
5847
+ engineCore.resourceLoader(engineCore.AssetType.PrimitiveMesh, [
5848
+ "mesh"
5849
+ ], false)
5850
+ ], PrimitiveMeshLoader);
5851
+ var /** @internal */ PrimitiveMeshType;
5852
+ (function(PrimitiveMeshType) {
5853
+ PrimitiveMeshType["Sphere"] = "sphere";
5854
+ PrimitiveMeshType["Cuboid"] = "cuboid";
5855
+ PrimitiveMeshType["Plane"] = "plane";
5856
+ PrimitiveMeshType["Cylinder"] = "cylinder";
5857
+ PrimitiveMeshType["Torus"] = "torus";
5858
+ PrimitiveMeshType["Cone"] = "cone";
5859
+ PrimitiveMeshType["Capsule"] = "capsule";
5860
+ })(PrimitiveMeshType || (PrimitiveMeshType = {}));
5861
+
5862
+ var ProjectLoader = /*#__PURE__*/ function(Loader1) {
5863
+ _inherits(ProjectLoader, Loader1);
5864
+ function ProjectLoader() {
5865
+ return Loader1.apply(this, arguments);
5866
+ }
5867
+ var _proto = ProjectLoader.prototype;
5868
+ _proto.load = function load(item, resourceManager) {
5869
+ var _this = this;
5870
+ var engine = resourceManager.engine;
5871
+ return new engineCore.AssetPromise(function(resolve, reject) {
5872
+ _this.request(item.url, {
5873
+ type: "json"
5874
+ }).then(function(data) {
5875
+ // @ts-ignore
5876
+ engine.resourceManager.initVirtualResources(data.files);
5877
+ return resourceManager.load({
5878
+ type: engineCore.AssetType.Scene,
5879
+ url: data.scene
5880
+ }).then(function(scene) {
5881
+ engine.sceneManager.activeScene = scene;
5882
+ resolve();
5883
+ });
5884
+ }).catch(reject);
5885
+ });
5886
+ };
5887
+ return ProjectLoader;
5888
+ }(engineCore.Loader);
5889
+ ProjectLoader = __decorate([
5890
+ engineCore.resourceLoader(engineCore.AssetType.Project, [
5891
+ "proj"
5892
+ ], false)
5893
+ ], ProjectLoader);
5894
+
5227
5895
  var SourceFontLoader = /*#__PURE__*/ function(Loader1) {
5228
5896
  _inherits(SourceFontLoader, Loader1);
5229
5897
  function SourceFontLoader() {
@@ -5286,7 +5954,7 @@ var SpriteAtlasLoader = /*#__PURE__*/ function(Loader1) {
5286
5954
  var _proto = SpriteAtlasLoader.prototype;
5287
5955
  _proto.load = function load(item, resourceManager) {
5288
5956
  var _this = this;
5289
- return new engineCore.AssetPromise(function(resolve, reject, _, onCancel) {
5957
+ return new engineCore.AssetPromise(function(resolve, reject, _, __, onCancel) {
5290
5958
  var chainPromises = [];
5291
5959
  onCancel(function() {
5292
5960
  for(var i = 0; i < chainPromises.length; i++){
@@ -5449,12 +6117,12 @@ var Texture2DLoader = /*#__PURE__*/ function(Loader1) {
5449
6117
  var _proto = Texture2DLoader.prototype;
5450
6118
  _proto.load = function load(item, resourceManager) {
5451
6119
  var _this = this;
5452
- return new engineCore.AssetPromise(function(resolve, reject) {
6120
+ return new engineCore.AssetPromise(function(resolve, reject, setTaskCompleteProgress, setTaskDetailProgress) {
5453
6121
  var url = item.url;
5454
6122
  var requestConfig = _extends({}, item, {
5455
6123
  type: "image"
5456
6124
  });
5457
- _this.request(url, requestConfig).then(function(image) {
6125
+ _this.request(url, requestConfig).onProgress(setTaskCompleteProgress, setTaskDetailProgress).then(function(image) {
5458
6126
  var _item_params;
5459
6127
  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;
5460
6128
  var texture = new engineCore.Texture2D(resourceManager.engine, image.width, image.height, format, mipmap);
@@ -5559,39 +6227,6 @@ TextureCubeLoader = __decorate([
5559
6227
  ])
5560
6228
  ], TextureCubeLoader);
5561
6229
 
5562
- var ProjectLoader = /*#__PURE__*/ function(Loader1) {
5563
- _inherits(ProjectLoader, Loader1);
5564
- function ProjectLoader() {
5565
- return Loader1.apply(this, arguments);
5566
- }
5567
- var _proto = ProjectLoader.prototype;
5568
- _proto.load = function load(item, resourceManager) {
5569
- var _this = this;
5570
- var engine = resourceManager.engine;
5571
- return new engineCore.AssetPromise(function(resolve, reject) {
5572
- _this.request(item.url, {
5573
- type: "json"
5574
- }).then(function(data) {
5575
- // @ts-ignore
5576
- engine.resourceManager.initVirtualResources(data.files);
5577
- return resourceManager.load({
5578
- type: engineCore.AssetType.Scene,
5579
- url: data.scene
5580
- }).then(function(scene) {
5581
- engine.sceneManager.activeScene = scene;
5582
- resolve();
5583
- });
5584
- }).catch(reject);
5585
- });
5586
- };
5587
- return ProjectLoader;
5588
- }(engineCore.Loader);
5589
- ProjectLoader = __decorate([
5590
- engineCore.resourceLoader(engineCore.AssetType.Project, [
5591
- "proj"
5592
- ], false)
5593
- ], ProjectLoader);
5594
-
5595
6230
  var SceneLoader = /*#__PURE__*/ function(Loader1) {
5596
6231
  _inherits(SceneLoader, Loader1);
5597
6232
  function SceneLoader() {
@@ -5610,7 +6245,7 @@ var SceneLoader = /*#__PURE__*/ function(Loader1) {
5610
6245
  // parse ambient light
5611
6246
  var ambient = data.scene.ambient;
5612
6247
  if (ambient) {
5613
- var useCustomAmbient = ambient.specularMode === "Custom";
6248
+ var useCustomAmbient = ambient.specularMode === exports.SpecularMode.Custom;
5614
6249
  var useSH = ambient.diffuseMode === engineCore.DiffuseMode.SphericalHarmonics;
5615
6250
  scene.ambientLight.diffuseIntensity = ambient.diffuseIntensity;
5616
6251
  scene.ambientLight.specularIntensity = ambient.specularIntensity;
@@ -5638,6 +6273,7 @@ var SceneLoader = /*#__PURE__*/ function(Loader1) {
5638
6273
  }));
5639
6274
  }
5640
6275
  }
6276
+ // parse background
5641
6277
  var background = data.scene.background;
5642
6278
  scene.background.mode = background.mode;
5643
6279
  switch(scene.background.mode){
@@ -5681,6 +6317,17 @@ var SceneLoader = /*#__PURE__*/ function(Loader1) {
5681
6317
  var _shadow_shadowTwoCascadeSplits;
5682
6318
  scene.shadowTwoCascadeSplits = (_shadow_shadowTwoCascadeSplits = shadow.shadowTwoCascadeSplits) != null ? _shadow_shadowTwoCascadeSplits : scene.shadowTwoCascadeSplits;
5683
6319
  shadow.shadowFourCascadeSplits && scene.shadowFourCascadeSplits.copyFrom(shadow.shadowFourCascadeSplits);
6320
+ var _shadow_shadowFadeBorder;
6321
+ scene.shadowFadeBorder = (_shadow_shadowFadeBorder = shadow.shadowFadeBorder) != null ? _shadow_shadowFadeBorder : scene.shadowFadeBorder;
6322
+ }
6323
+ // parse fog
6324
+ var fog = data.scene.fog;
6325
+ if (fog) {
6326
+ if (fog.fogMode != undefined) scene.fogMode = fog.fogMode;
6327
+ if (fog.fogStart != undefined) scene.fogStart = fog.fogStart;
6328
+ if (fog.fogEnd != undefined) scene.fogEnd = fog.fogEnd;
6329
+ if (fog.fogDensity != undefined) scene.fogDensity = fog.fogDensity;
6330
+ if (fog.fogColor != undefined) scene.fogColor.copyFrom(fog.fogColor);
5684
6331
  }
5685
6332
  return Promise.all(promises).then(function() {
5686
6333
  resolve(scene);
@@ -5711,170 +6358,6 @@ ReflectionParser.registerCustomParseComponent("TextRenderer", /*#__PURE__*/ _asy
5711
6358
  });
5712
6359
  }));
5713
6360
 
5714
- var _KHR_draco_mesh_compression;
5715
- var KHR_draco_mesh_compression = (_KHR_draco_mesh_compression = /*#__PURE__*/ function(GLTFExtensionParser1) {
5716
- _inherits(KHR_draco_mesh_compression1, GLTFExtensionParser1);
5717
- function KHR_draco_mesh_compression1() {
5718
- return GLTFExtensionParser1.apply(this, arguments);
5719
- }
5720
- var _proto = KHR_draco_mesh_compression1.prototype;
5721
- _proto.createAndParse = function createAndParse(context, schema, glTFPrimitive, glTFMesh) {
5722
- var _this = this;
5723
- this._initialize();
5724
- var glTF = context.glTF, engine = context.glTFResource.engine;
5725
- var bufferViews = glTF.bufferViews, accessors = glTF.accessors;
5726
- var bufferViewIndex = schema.bufferView, gltfAttributeMap = schema.attributes;
5727
- var attributeMap = {};
5728
- var attributeTypeMap = {};
5729
- for(var attributeName in gltfAttributeMap){
5730
- attributeMap[attributeName] = gltfAttributeMap[attributeName];
5731
- }
5732
- for(var attributeName1 in glTFPrimitive.attributes){
5733
- if (gltfAttributeMap[attributeName1] !== undefined) {
5734
- var accessorDef = accessors[glTFPrimitive.attributes[attributeName1]];
5735
- attributeTypeMap[attributeName1] = GLTFUtils.getComponentType(accessorDef.componentType).name;
5736
- }
5737
- }
5738
- var indexAccessor = accessors[glTFPrimitive.indices];
5739
- var indexType = GLTFUtils.getComponentType(indexAccessor.componentType).name;
5740
- var taskConfig = {
5741
- attributeIDs: attributeMap,
5742
- attributeTypes: attributeTypeMap,
5743
- useUniqueIDs: true,
5744
- indexType: indexType
5745
- };
5746
- return context.get(exports.GLTFParserType.Buffer).then(function(buffers) {
5747
- var buffer = GLTFUtils.getBufferViewData(bufferViews[bufferViewIndex], buffers);
5748
- return KHR_draco_mesh_compression._decoder.decode(buffer, taskConfig).then(function(decodedGeometry) {
5749
- var mesh = new engineCore.ModelMesh(engine, glTFMesh.name);
5750
- return _this._parseMeshFromGLTFPrimitiveDraco(mesh, glTFMesh, glTFPrimitive, glTF, function(attributeSemantic) {
5751
- for(var j = 0; j < decodedGeometry.attributes.length; j++){
5752
- if (decodedGeometry.attributes[j].name === attributeSemantic) {
5753
- return decodedGeometry.attributes[j].array;
5754
- }
5755
- }
5756
- return null;
5757
- }, function(attributeSemantic, shapeIndex) {
5758
- throw "BlendShape animation is not supported when using draco.";
5759
- }, function() {
5760
- return decodedGeometry.index.array;
5761
- }, context.params.keepMeshData);
5762
- });
5763
- });
5764
- };
5765
- _proto._initialize = function _initialize() {
5766
- if (!KHR_draco_mesh_compression._decoder) {
5767
- KHR_draco_mesh_compression._decoder = new engineDraco.DRACODecoder();
5768
- }
5769
- };
5770
- _proto._parseMeshFromGLTFPrimitiveDraco = function _parseMeshFromGLTFPrimitiveDraco(mesh, gltfMesh, gltfPrimitive, gltf, getVertexBufferData, getBlendShapeData, getIndexBufferData, keepMeshData) {
5771
- var attributes = gltfPrimitive.attributes, targets = gltfPrimitive.targets, indices = gltfPrimitive.indices, mode = gltfPrimitive.mode;
5772
- var vertexCount;
5773
- var accessors = gltf.accessors;
5774
- var accessor = accessors[attributes["POSITION"]];
5775
- var positionBuffer = getVertexBufferData("POSITION");
5776
- var positions = GLTFUtils.floatBufferToVector3Array(positionBuffer);
5777
- mesh.setPositions(positions);
5778
- var bounds = mesh.bounds;
5779
- vertexCount = accessor.count;
5780
- if (accessor.min && accessor.max) {
5781
- bounds.min.copyFromArray(accessor.min);
5782
- bounds.max.copyFromArray(accessor.max);
5783
- } else {
5784
- var position = KHR_draco_mesh_compression._tempVector3;
5785
- var min = bounds.min, max = bounds.max;
5786
- min.set(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
5787
- max.set(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
5788
- var stride = positionBuffer.length / vertexCount;
5789
- for(var j = 0; j < vertexCount; j++){
5790
- var offset = j * stride;
5791
- position.copyFromArray(positionBuffer, offset);
5792
- engineMath.Vector3.min(min, position, min);
5793
- engineMath.Vector3.max(max, position, max);
5794
- }
5795
- }
5796
- for(var attributeSemantic in attributes){
5797
- if (attributeSemantic === "POSITION") {
5798
- continue;
5799
- }
5800
- var bufferData = getVertexBufferData(attributeSemantic);
5801
- switch(attributeSemantic){
5802
- case "NORMAL":
5803
- var normals = GLTFUtils.floatBufferToVector3Array(bufferData);
5804
- mesh.setNormals(normals);
5805
- break;
5806
- case "TEXCOORD_0":
5807
- var texturecoords = GLTFUtils.floatBufferToVector2Array(bufferData);
5808
- mesh.setUVs(texturecoords, 0);
5809
- break;
5810
- case "TEXCOORD_1":
5811
- var texturecoords1 = GLTFUtils.floatBufferToVector2Array(bufferData);
5812
- mesh.setUVs(texturecoords1, 1);
5813
- break;
5814
- case "TEXCOORD_2":
5815
- var texturecoords2 = GLTFUtils.floatBufferToVector2Array(bufferData);
5816
- mesh.setUVs(texturecoords2, 2);
5817
- break;
5818
- case "TEXCOORD_3":
5819
- var texturecoords3 = GLTFUtils.floatBufferToVector2Array(bufferData);
5820
- mesh.setUVs(texturecoords3, 3);
5821
- break;
5822
- case "TEXCOORD_4":
5823
- var texturecoords4 = GLTFUtils.floatBufferToVector2Array(bufferData);
5824
- mesh.setUVs(texturecoords4, 4);
5825
- break;
5826
- case "TEXCOORD_5":
5827
- var texturecoords5 = GLTFUtils.floatBufferToVector2Array(bufferData);
5828
- mesh.setUVs(texturecoords5, 5);
5829
- break;
5830
- case "TEXCOORD_6":
5831
- var texturecoords6 = GLTFUtils.floatBufferToVector2Array(bufferData);
5832
- mesh.setUVs(texturecoords6, 6);
5833
- break;
5834
- case "TEXCOORD_7":
5835
- var texturecoords7 = GLTFUtils.floatBufferToVector2Array(bufferData);
5836
- mesh.setUVs(texturecoords7, 7);
5837
- break;
5838
- case "COLOR_0":
5839
- var colors = GLTFUtils.floatBufferToColorArray(bufferData, accessors[attributes["COLOR_0"]].type === AccessorType.VEC3);
5840
- mesh.setColors(colors);
5841
- break;
5842
- case "TANGENT":
5843
- var tangents = GLTFUtils.floatBufferToVector4Array(bufferData);
5844
- mesh.setTangents(tangents);
5845
- break;
5846
- case "JOINTS_0":
5847
- var joints = GLTFUtils.floatBufferToVector4Array(bufferData);
5848
- mesh.setBoneIndices(joints);
5849
- break;
5850
- case "WEIGHTS_0":
5851
- var weights = GLTFUtils.floatBufferToVector4Array(bufferData);
5852
- mesh.setBoneWeights(weights);
5853
- break;
5854
- }
5855
- }
5856
- // Indices
5857
- if (indices !== undefined) {
5858
- var indexAccessor = gltf.accessors[indices];
5859
- var indexData = getIndexBufferData();
5860
- mesh.setIndices(indexData);
5861
- mesh.addSubMesh(0, indexAccessor.count, mode);
5862
- } else {
5863
- mesh.addSubMesh(0, vertexCount, mode);
5864
- }
5865
- // BlendShapes
5866
- targets && exports.GLTFMeshParser._createBlendShape(mesh, null, gltfMesh, accessors, targets, getBlendShapeData);
5867
- mesh.uploadData(!keepMeshData);
5868
- return Promise.resolve(mesh);
5869
- };
5870
- return KHR_draco_mesh_compression1;
5871
- }(GLTFExtensionParser), function() {
5872
- _KHR_draco_mesh_compression._tempVector3 = new engineMath.Vector3();
5873
- }(), _KHR_draco_mesh_compression);
5874
- KHR_draco_mesh_compression = __decorate([
5875
- registerGLTFExtension("KHR_draco_mesh_compression", exports.GLTFExtensionMode.CreateAndParse)
5876
- ], KHR_draco_mesh_compression);
5877
-
5878
6361
  var KHR_lights_punctual = /*#__PURE__*/ function(GLTFExtensionParser1) {
5879
6362
  _inherits(KHR_lights_punctual, GLTFExtensionParser1);
5880
6363
  function KHR_lights_punctual() {
@@ -6049,7 +6532,7 @@ var KHR_materials_variants = /*#__PURE__*/ function(GLTFExtensionParser1) {
6049
6532
  var _glTFResource;
6050
6533
  var _context_glTF = context.glTF, _context_glTF_extensions = _context_glTF.extensions, _context_glTF_extensions_KHR_materials_variants = _context_glTF_extensions.KHR_materials_variants, variantNames = _context_glTF_extensions_KHR_materials_variants.variants, glTFResource = context.glTFResource;
6051
6534
  var mappings = schema.mappings;
6052
- (_glTFResource = glTFResource).extensionsData || (_glTFResource.extensionsData = {});
6535
+ (_glTFResource = glTFResource)._extensionsData || (_glTFResource._extensionsData = {});
6053
6536
  var extensionData = [];
6054
6537
  glTFResource.extensionsData.variants = extensionData;
6055
6538
  for(var i = 0; i < mappings.length; i++)_loop(i);
@@ -6079,7 +6562,7 @@ var KHR_texture_basisu = /*#__PURE__*/ function(GLTFExtensionParser1) {
6079
6562
  var _proto = KHR_texture_basisu.prototype;
6080
6563
  _proto.createAndParse = function createAndParse(context, schema, textureInfo) {
6081
6564
  return _async_to_generator(function() {
6082
- var glTF, glTFResource, engine, url, sampler, textureName, source, _glTF_images_source, uri, bufferViewIndex, mimeType, imageName, samplerInfo, index, bufferView;
6565
+ var glTF, glTFResource, engine, url, sampler, textureName, source, _glTF_images_source, uri, bufferViewIndex, mimeType, imageName, samplerInfo, index, promise, bufferView;
6083
6566
  return __generator(this, function(_state) {
6084
6567
  glTF = context.glTF, glTFResource = context.glTFResource;
6085
6568
  engine = glTFResource.engine, url = glTFResource.url;
@@ -6089,20 +6572,22 @@ var KHR_texture_basisu = /*#__PURE__*/ function(GLTFExtensionParser1) {
6089
6572
  samplerInfo = sampler !== undefined && GLTFUtils.getSamplerInfo(glTF.samplers[sampler]);
6090
6573
  if (uri) {
6091
6574
  index = uri.lastIndexOf(".");
6575
+ promise = engine.resourceManager.load({
6576
+ url: engineCore.Utils.resolveAbsoluteUrl(url, uri),
6577
+ type: engineCore.AssetType.KTX2
6578
+ }).onProgress(undefined, context._onTaskDetail).then(function(texture) {
6579
+ if (!texture.name) {
6580
+ texture.name = textureName || imageName || "texture_" + index;
6581
+ }
6582
+ if (sampler !== undefined) {
6583
+ GLTFUtils.parseSampler(texture, samplerInfo);
6584
+ }
6585
+ return texture;
6586
+ });
6587
+ context._addTaskCompletePromise(promise);
6092
6588
  return [
6093
6589
  2,
6094
- engine.resourceManager.load({
6095
- url: engineCore.Utils.resolveAbsoluteUrl(url, uri),
6096
- type: engineCore.AssetType.KTX2
6097
- }).then(function(texture) {
6098
- if (!texture.name) {
6099
- texture.name = textureName || imageName || "texture_" + index;
6100
- }
6101
- if (sampler !== undefined) {
6102
- GLTFUtils.parseSampler(texture, samplerInfo);
6103
- }
6104
- return texture;
6105
- })
6590
+ promise
6106
6591
  ];
6107
6592
  } else {
6108
6593
  bufferView = glTF.bufferViews[bufferViewIndex];
@@ -6172,7 +6657,9 @@ var GALACEAN_materials_remap = /*#__PURE__*/ function(GLTFExtensionParser1) {
6172
6657
  _proto.createAndParse = function createAndParse(context, schema) {
6173
6658
  var engine = context.glTFResource.engine;
6174
6659
  // @ts-ignore
6175
- return engine.resourceManager.getResourceByRef(schema);
6660
+ var promise = engine.resourceManager.getResourceByRef(schema);
6661
+ context._addTaskCompletePromise(promise);
6662
+ return promise;
6176
6663
  };
6177
6664
  return GALACEAN_materials_remap;
6178
6665
  }(GLTFExtensionParser);
@@ -6203,12 +6690,53 @@ GALACEAN_animation_event = __decorate([
6203
6690
  registerGLTFExtension("GALACEAN_animation_event", exports.GLTFExtensionMode.AdditiveParse)
6204
6691
  ], GALACEAN_animation_event);
6205
6692
 
6206
- exports.ComponentMap = ComponentMap;
6693
+ var EXT_meshopt_compression = /*#__PURE__*/ function(GLTFExtensionParser1) {
6694
+ _inherits(EXT_meshopt_compression, GLTFExtensionParser1);
6695
+ function EXT_meshopt_compression() {
6696
+ return GLTFExtensionParser1.apply(this, arguments);
6697
+ }
6698
+ var _proto = EXT_meshopt_compression.prototype;
6699
+ _proto.createAndParse = function createAndParse(context, schema) {
6700
+ return context.get(exports.GLTFParserType.Buffer, schema.buffer).then(function(arrayBuffer) {
6701
+ return MeshoptDecoder.decodeGltfBuffer(schema.count, schema.byteStride, new Uint8Array(arrayBuffer, schema.byteOffset, schema.byteLength), schema.mode, schema.filter);
6702
+ });
6703
+ };
6704
+ return EXT_meshopt_compression;
6705
+ }(GLTFExtensionParser);
6706
+ EXT_meshopt_compression = __decorate([
6707
+ registerGLTFExtension("EXT_meshopt_compression", exports.GLTFExtensionMode.CreateAndParse)
6708
+ ], EXT_meshopt_compression);
6709
+
6710
+ var KHR_materials_anisotropy = /*#__PURE__*/ function(GLTFExtensionParser1) {
6711
+ _inherits(KHR_materials_anisotropy, GLTFExtensionParser1);
6712
+ function KHR_materials_anisotropy() {
6713
+ return GLTFExtensionParser1.apply(this, arguments);
6714
+ }
6715
+ var _proto = KHR_materials_anisotropy.prototype;
6716
+ _proto.additiveParse = function additiveParse(context, material, schema) {
6717
+ var _schema_anisotropyStrength = schema.anisotropyStrength, anisotropyStrength = _schema_anisotropyStrength === void 0 ? 0 : _schema_anisotropyStrength, _schema_anisotropyRotation = schema.anisotropyRotation, anisotropyRotation = _schema_anisotropyRotation === void 0 ? 0 : _schema_anisotropyRotation, anisotropyTexture = schema.anisotropyTexture;
6718
+ material.anisotropy = anisotropyStrength;
6719
+ material.anisotropyRotation = anisotropyRotation;
6720
+ if (anisotropyTexture) {
6721
+ exports.GLTFMaterialParser._checkOtherTextureTransform(anisotropyTexture, "Anisotropy texture");
6722
+ context.get(exports.GLTFParserType.Texture, anisotropyTexture.index).then(function(texture) {
6723
+ material.anisotropyTexture = texture;
6724
+ });
6725
+ }
6726
+ };
6727
+ return KHR_materials_anisotropy;
6728
+ }(GLTFExtensionParser);
6729
+ KHR_materials_anisotropy = __decorate([
6730
+ registerGLTFExtension("KHR_materials_anisotropy", exports.GLTFExtensionMode.AdditiveParse)
6731
+ ], KHR_materials_anisotropy);
6732
+
6733
+ exports.BufferInfo = BufferInfo;
6207
6734
  exports.GLTFExtensionParser = GLTFExtensionParser;
6208
6735
  exports.GLTFParser = GLTFParser;
6209
6736
  exports.GLTFParserContext = GLTFParserContext;
6210
6737
  exports.GLTFResource = GLTFResource;
6211
6738
  exports.GLTFUtils = GLTFUtils;
6739
+ exports.ParserContext = ParserContext;
6212
6740
  exports.PrefabParser = PrefabParser;
6213
6741
  exports.ReflectionParser = ReflectionParser;
6214
6742
  exports.SceneParser = SceneParser;