@galacean/engine-loader 0.0.0-experimental-renderSort.3 → 0.0.0-experimental-shaderlab.2

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 (45) hide show
  1. package/LICENSE +2 -2
  2. package/dist/main.js +1310 -706
  3. package/dist/main.js.map +1 -1
  4. package/dist/miniprogram.js +1309 -706
  5. package/dist/module.js +1298 -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/PrimitiveMeshLoader.d.ts +1 -0
  11. package/types/ShaderChunkLoader.d.ts +1 -0
  12. package/types/ShaderLoader.d.ts +1 -0
  13. package/types/gltf/GLTFResource.d.ts +50 -16
  14. package/types/gltf/GLTFSchema.d.ts +1 -1
  15. package/types/gltf/GLTFUtils.d.ts +6 -10
  16. package/types/gltf/extensions/EXT_meshopt_compression.d.ts +13 -0
  17. package/types/gltf/extensions/GLTFExtensionParser.d.ts +1 -1
  18. package/types/gltf/extensions/GLTFExtensionSchema.d.ts +18 -10
  19. package/types/gltf/extensions/KHR_materials_anisotropy.d.ts +1 -0
  20. package/types/gltf/extensions/MeshoptDecoder.d.ts +8 -0
  21. package/types/gltf/extensions/index.d.ts +2 -1
  22. package/types/gltf/index.d.ts +2 -1
  23. package/types/gltf/parser/GLTFBufferViewParser.d.ts +5 -0
  24. package/types/gltf/parser/GLTFJSONParser.d.ts +7 -0
  25. package/types/gltf/parser/GLTFMeshParser.d.ts +7 -6
  26. package/types/gltf/parser/GLTFParser.d.ts +1 -1
  27. package/types/gltf/parser/GLTFParserContext.d.ts +20 -6
  28. package/types/gltf/parser/GLTFSchemaParser.d.ts +0 -1
  29. package/types/gltf/parser/index.d.ts +2 -1
  30. package/types/index.d.ts +5 -1
  31. package/types/ktx2/KTX2Loader.d.ts +4 -3
  32. package/types/resource-deserialize/index.d.ts +2 -1
  33. package/types/resource-deserialize/resources/animationClip/AnimationClipDecoder.d.ts +0 -1
  34. package/types/resource-deserialize/resources/parser/HierarchyParser.d.ts +36 -0
  35. package/types/resource-deserialize/resources/parser/ParserContext.d.ts +29 -0
  36. package/types/resource-deserialize/resources/parser/ReflectionParser.d.ts +4 -4
  37. package/types/resource-deserialize/resources/prefab/PrefabDesign.d.ts +70 -0
  38. package/types/resource-deserialize/resources/prefab/PrefabParser.d.ts +14 -0
  39. package/types/resource-deserialize/resources/prefab/PrefabParserContext.d.ts +5 -0
  40. package/types/resource-deserialize/resources/prefab/ReflectionParser.d.ts +14 -0
  41. package/types/resource-deserialize/resources/scene/SceneParser.d.ts +3 -17
  42. package/types/resource-deserialize/resources/scene/SceneParserContext.d.ts +6 -12
  43. package/types/resource-deserialize/resources/schema/BasicSchema.d.ts +27 -1
  44. package/types/resource-deserialize/resources/schema/MaterialSchema.d.ts +2 -1
  45. package/types/resource-deserialize/resources/schema/SceneSchema.d.ts +9 -1
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,28 @@ 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 = {};
1579
1889
  this._resourceCache = new Map();
1890
+ this._progress = {
1891
+ taskDetail: {},
1892
+ taskComplete: {
1893
+ loaded: 0,
1894
+ total: 0
1895
+ }
1896
+ };
1897
+ this./**
1898
+ * @internal
1899
+ */ _onTaskDetail = function(url, loaded, total) {
1900
+ var _this__progress_taskDetail, _url;
1901
+ var detail = (_this__progress_taskDetail = _this._progress.taskDetail)[_url = url] || (_this__progress_taskDetail[_url] = {});
1902
+ detail.loaded = loaded;
1903
+ detail.total = total;
1904
+ _this._setTaskDetailProgress(url, loaded, total);
1905
+ };
1580
1906
  this.contentRestorer = new GLTFContentRestorer(glTFResource);
1581
1907
  }
1582
1908
  var _proto = GLTFParserContext.prototype;
@@ -1599,7 +1925,7 @@ var TextureWrapMode;
1599
1925
  var glTFItems = this.glTF[glTFSchemaMap[type]];
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);
@@ -1617,15 +1943,15 @@ var TextureWrapMode;
1617
1943
  };
1618
1944
  _proto.parse = function parse() {
1619
1945
  var _this = this;
1620
- return this.get(0).then(function(json) {
1946
+ var promise = this.get(0).then(function(json) {
1621
1947
  _this.glTF = json;
1622
1948
  return Promise.all([
1623
1949
  _this.get(1),
1624
- _this.get(4),
1625
1950
  _this.get(5),
1626
1951
  _this.get(6),
1627
- _this.get(8),
1952
+ _this.get(7),
1628
1953
  _this.get(9),
1954
+ _this.get(10),
1629
1955
  _this.get(2)
1630
1956
  ]).then(function() {
1631
1957
  var glTFResource = _this.glTFResource;
@@ -1636,6 +1962,18 @@ var TextureWrapMode;
1636
1962
  return glTFResource;
1637
1963
  });
1638
1964
  });
1965
+ this._addTaskCompletePromise(promise);
1966
+ return promise;
1967
+ };
1968
+ /**
1969
+ * @internal
1970
+ */ _proto._addTaskCompletePromise = function _addTaskCompletePromise(taskPromise) {
1971
+ var _this = this;
1972
+ var task = this._progress.taskComplete;
1973
+ task.total += 1;
1974
+ taskPromise.then(function() {
1975
+ _this._setTaskCompleteProgress(++task.loaded, task.total);
1976
+ });
1639
1977
  };
1640
1978
  _proto._createAnimator = function _createAnimator(context, animations) {
1641
1979
  var defaultSceneRoot = context.glTFResource.defaultSceneRoot;
@@ -1663,7 +2001,7 @@ var TextureWrapMode;
1663
2001
  var _this = this;
1664
2002
  var glTFResourceKey = glTFResourceMap[type];
1665
2003
  if (!glTFResourceKey) return;
1666
- if (type === 7) {
2004
+ if (type === 8) {
1667
2005
  var _this_glTFResource, _glTFResourceKey;
1668
2006
  ((_this_glTFResource = this.glTFResource)[_glTFResourceKey = glTFResourceKey] || (_this_glTFResource[_glTFResourceKey] = []))[index] = resource;
1669
2007
  } else {
@@ -1671,7 +2009,7 @@ var TextureWrapMode;
1671
2009
  resource.then(function(item) {
1672
2010
  var _this_glTFResource, _glTFResourceKey;
1673
2011
  ((_this_glTFResource = _this.glTFResource)[_glTFResourceKey = glTFResourceKey] || (_this_glTFResource[_glTFResourceKey] = []))[index] = item;
1674
- if (type === 6) {
2012
+ if (type === 7) {
1675
2013
  for(var i = 0, length = item.length; i < length; i++){
1676
2014
  var mesh = item[i];
1677
2015
  // @ts-ignore
@@ -1711,17 +2049,18 @@ exports.GLTFParserType = void 0;
1711
2049
  GLTFParserType[GLTFParserType["Validator"] = 1] = "Validator";
1712
2050
  GLTFParserType[GLTFParserType["Scene"] = 2] = "Scene";
1713
2051
  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";
2052
+ GLTFParserType[GLTFParserType["BufferView"] = 4] = "BufferView";
2053
+ GLTFParserType[GLTFParserType["Texture"] = 5] = "Texture";
2054
+ GLTFParserType[GLTFParserType["Material"] = 6] = "Material";
2055
+ GLTFParserType[GLTFParserType["Mesh"] = 7] = "Mesh";
2056
+ GLTFParserType[GLTFParserType["Entity"] = 8] = "Entity";
2057
+ GLTFParserType[GLTFParserType["Skin"] = 9] = "Skin";
2058
+ GLTFParserType[GLTFParserType["Animation"] = 10] = "Animation";
1720
2059
  })(exports.GLTFParserType || (exports.GLTFParserType = {}));
1721
2060
  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);
2061
+ 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
2062
  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);
2063
+ 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);
1725
2064
  function registerGLTFParser(pipeline) {
1726
2065
  return function(Parser) {
1727
2066
  var parser = new Parser();
@@ -1775,19 +2114,19 @@ function registerGLTFParser(pipeline) {
1775
2114
  * Get the number of bytes occupied by accessor type.
1776
2115
  */ GLTFUtils.getAccessorTypeSize = function getAccessorTypeSize(accessorType) {
1777
2116
  switch(accessorType){
1778
- case AccessorType.SCALAR:
2117
+ case exports.AccessorType.SCALAR:
1779
2118
  return 1;
1780
- case AccessorType.VEC2:
2119
+ case exports.AccessorType.VEC2:
1781
2120
  return 2;
1782
- case AccessorType.VEC3:
2121
+ case exports.AccessorType.VEC3:
1783
2122
  return 3;
1784
- case AccessorType.VEC4:
2123
+ case exports.AccessorType.VEC4:
1785
2124
  return 4;
1786
- case AccessorType.MAT2:
2125
+ case exports.AccessorType.MAT2:
1787
2126
  return 4;
1788
- case AccessorType.MAT3:
2127
+ case exports.AccessorType.MAT3:
1789
2128
  return 9;
1790
- case AccessorType.MAT4:
2129
+ case exports.AccessorType.MAT4:
1791
2130
  return 16;
1792
2131
  }
1793
2132
  };
@@ -1826,110 +2165,68 @@ function registerGLTFParser(pipeline) {
1826
2165
  };
1827
2166
  GLTFUtils.getAccessorBuffer = function getAccessorBuffer(context, bufferViews, accessor) {
1828
2167
  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));
2168
+ var TypedArray = GLTFUtils.getComponentType(componentType);
2169
+ var dataElementSize = GLTFUtils.getAccessorTypeSize(accessor.type);
2170
+ var dataElementBytes = TypedArray.BYTES_PER_ELEMENT;
2171
+ var elementStride = dataElementSize * dataElementBytes;
2172
+ var accessorCount = accessor.count;
2173
+ var promise;
2174
+ if (accessor.bufferView !== undefined) {
2175
+ var bufferViewIndex = accessor.bufferView;
2176
+ var bufferView = bufferViews[bufferViewIndex];
2177
+ promise = context.get(exports.GLTFParserType.BufferView, accessor.bufferView).then(function(bufferViewData) {
2178
+ var bufferIndex = bufferView.buffer;
2179
+ var _bufferViewData_byteOffset;
2180
+ var bufferByteOffset = (_bufferViewData_byteOffset = bufferViewData.byteOffset) != null ? _bufferViewData_byteOffset : 0;
2181
+ var _accessor_byteOffset;
2182
+ var byteOffset = (_accessor_byteOffset = accessor.byteOffset) != null ? _accessor_byteOffset : 0;
2183
+ var bufferStride = bufferView.byteStride;
2184
+ var bufferInfo;
2185
+ // According to the glTF official documentation only byteStride not undefined is allowed
2186
+ if (bufferStride !== undefined && bufferStride !== elementStride) {
2187
+ var bufferSlice = Math.floor(byteOffset / bufferStride);
2188
+ var bufferCacheKey = bufferViewIndex + ":" + componentType + ":" + bufferSlice + ":" + accessorCount;
2189
+ var accessorBufferCache = context.accessorBufferCache;
2190
+ bufferInfo = accessorBufferCache[bufferCacheKey];
2191
+ if (!bufferInfo) {
2192
+ var offset = bufferByteOffset + bufferSlice * bufferStride;
2193
+ var count = accessorCount * (bufferStride / dataElementBytes);
2194
+ var data = new TypedArray(bufferViewData.buffer, offset, count);
2195
+ accessorBufferCache[bufferCacheKey] = bufferInfo = new BufferInfo(data, true, bufferStride);
2196
+ bufferInfo.restoreInfo = new BufferDataRestoreInfo(new RestoreDataAccessor(bufferIndex, TypedArray, offset, count));
2197
+ }
2198
+ } else {
2199
+ var offset1 = bufferByteOffset + byteOffset;
2200
+ var count1 = accessorCount * dataElementSize;
2201
+ var data1 = new TypedArray(bufferViewData.buffer, offset1, count1);
2202
+ bufferInfo = new BufferInfo(data1, false, elementStride);
2203
+ bufferInfo.restoreInfo = new BufferDataRestoreInfo(new RestoreDataAccessor(bufferIndex, TypedArray, offset1, count1));
1856
2204
  }
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
- });
2205
+ return bufferInfo;
2206
+ });
2207
+ } else {
2208
+ var count = accessorCount * dataElementSize;
2209
+ var data = new TypedArray(count);
2210
+ var bufferInfo = new BufferInfo(data, false, elementStride);
2211
+ bufferInfo.restoreInfo = new BufferDataRestoreInfo(new RestoreDataAccessor(undefined, TypedArray, undefined, count));
2212
+ promise = Promise.resolve(bufferInfo);
2213
+ }
2214
+ return accessor.sparse ? promise.then(function(bufferInfo) {
2215
+ return GLTFUtils.processingSparseData(context, accessor, bufferInfo).then(function() {
2216
+ return bufferInfo;
2217
+ });
2218
+ }) : promise;
1869
2219
  };
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);
2220
+ GLTFUtils.bufferToVector3Array = function bufferToVector3Array(buffer, byteOffset, count, normalized, componentType) {
2221
+ var baseOffset = byteOffset / buffer.BYTES_PER_ELEMENT;
2222
+ var stride = buffer.length / count;
2223
+ var vertices = new Array(count);
2224
+ var factor = normalized ? GLTFUtils.getNormalizedComponentScale(componentType) : 1;
1875
2225
  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]);
2226
+ var index = baseOffset + i * stride;
2227
+ vertices[i] = new engineMath.Vector3(buffer[index] * factor, buffer[index + 1] * factor, buffer[index + 2] * factor);
1878
2228
  }
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
- }
1931
- }
1932
- return typedArray;
2229
+ return vertices;
1933
2230
  };
1934
2231
  GLTFUtils.getBufferViewData = function getBufferViewData(bufferView, buffers) {
1935
2232
  var _bufferView_byteOffset = bufferView.byteOffset, byteOffset = _bufferView_byteOffset === void 0 ? 0 : _bufferView_byteOffset;
@@ -1938,40 +2235,43 @@ function registerGLTFParser(pipeline) {
1938
2235
  };
1939
2236
  /**
1940
2237
  * Get accessor data.
1941
- */ GLTFUtils.processingSparseData = function processingSparseData(bufferViews, accessor, buffers, bufferInfo) {
2238
+ */ GLTFUtils.processingSparseData = function processingSparseData(context, accessor, bufferInfo) {
1942
2239
  var restoreInfo = bufferInfo.restoreInfo;
2240
+ var bufferViews = context.glTF.bufferViews;
1943
2241
  var accessorTypeSize = GLTFUtils.getAccessorTypeSize(accessor.type);
1944
2242
  var TypedArray = GLTFUtils.getComponentType(accessor.componentType);
1945
2243
  var data = bufferInfo.data.slice();
1946
2244
  var _accessor_sparse = accessor.sparse, count = _accessor_sparse.count, indices = _accessor_sparse.indices, values = _accessor_sparse.values;
1947
2245
  var indicesBufferView = bufferViews[indices.bufferView];
1948
2246
  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];
2247
+ return Promise.all([
2248
+ context.get(exports.GLTFParserType.BufferView, indices.bufferView),
2249
+ context.get(exports.GLTFParserType.BufferView, values.bufferView)
2250
+ ]).then(function(param) {
2251
+ var indicesUint8Array = param[0], valuesUin8Array = param[1];
2252
+ var _indices_byteOffset, _indicesUint8Array_byteOffset;
2253
+ var indicesByteOffset = ((_indices_byteOffset = indices.byteOffset) != null ? _indices_byteOffset : 0) + ((_indicesUint8Array_byteOffset = indicesUint8Array.byteOffset) != null ? _indicesUint8Array_byteOffset : 0);
2254
+ var indicesByteLength = indicesUint8Array.byteLength;
2255
+ var _values_byteOffset, _valuesUin8Array_byteOffset;
2256
+ var valuesByteOffset = ((_values_byteOffset = values.byteOffset) != null ? _values_byteOffset : 0) + ((_valuesUin8Array_byteOffset = valuesUin8Array.byteOffset) != null ? _valuesUin8Array_byteOffset : 0);
2257
+ var valuesByteLength = valuesUin8Array.byteLength;
2258
+ restoreInfo.typeSize = accessorTypeSize;
2259
+ restoreInfo.sparseCount = count;
2260
+ var IndexTypeArray = GLTFUtils.getComponentType(indices.componentType);
2261
+ var indexLength = indicesByteLength / IndexTypeArray.BYTES_PER_ELEMENT;
2262
+ var indicesArray = new IndexTypeArray(indicesUint8Array.buffer, indicesByteOffset, indexLength);
2263
+ restoreInfo.sparseIndices = new RestoreDataAccessor(indicesBufferView.buffer, IndexTypeArray, indicesByteOffset, indexLength);
2264
+ var valueLength = valuesByteLength / TypedArray.BYTES_PER_ELEMENT;
2265
+ var valuesArray = new TypedArray(valuesUin8Array.buffer, valuesByteOffset, valueLength);
2266
+ restoreInfo.sparseValues = new RestoreDataAccessor(valuesBufferView.buffer, TypedArray, valuesByteOffset, valueLength);
2267
+ for(var i = 0; i < count; i++){
2268
+ var replaceIndex = indicesArray[i];
2269
+ for(var j = 0; j < accessorTypeSize; j++){
2270
+ data[replaceIndex * accessorTypeSize + j] = valuesArray[i * accessorTypeSize + j];
2271
+ }
1972
2272
  }
1973
- }
1974
- bufferInfo.data = data;
2273
+ bufferInfo.data = data;
2274
+ });
1975
2275
  };
1976
2276
  GLTFUtils.getIndexFormat = function getIndexFormat(type) {
1977
2277
  switch(type){
@@ -2060,7 +2360,7 @@ function registerGLTFParser(pipeline) {
2060
2360
  };
2061
2361
  /**
2062
2362
  * Parse the glb format.
2063
- */ GLTFUtils.parseGLB = function parseGLB(context, glb) {
2363
+ */ GLTFUtils.parseGLB = function parseGLB(context, originBuffer) {
2064
2364
  var UINT32_LENGTH = 4;
2065
2365
  var GLB_HEADER_MAGIC = 0x46546c67; // 'glTF'
2066
2366
  var GLB_HEADER_LENGTH = 12;
@@ -2068,7 +2368,7 @@ function registerGLTFParser(pipeline) {
2068
2368
  JSON: 0x4e4f534a,
2069
2369
  BIN: 0x004e4942
2070
2370
  };
2071
- var dataView = new DataView(glb);
2371
+ var dataView = new DataView(originBuffer);
2072
2372
  // read header
2073
2373
  var header = {
2074
2374
  magic: dataView.getUint32(0, true),
@@ -2076,8 +2376,9 @@ function registerGLTFParser(pipeline) {
2076
2376
  length: dataView.getUint32(2 * UINT32_LENGTH, true)
2077
2377
  };
2078
2378
  if (header.magic !== GLB_HEADER_MAGIC) {
2079
- console.error("Invalid glb magic number. Expected 0x46546C67, found 0x" + header.magic.toString(16));
2080
- return null;
2379
+ return {
2380
+ originBuffer: originBuffer
2381
+ };
2081
2382
  }
2082
2383
  // read main data
2083
2384
  var chunkLength = dataView.getUint32(GLB_HEADER_LENGTH, true);
@@ -2087,7 +2388,7 @@ function registerGLTFParser(pipeline) {
2087
2388
  console.error("Invalid glb chunk type. Expected 0x4E4F534A, found 0x" + chunkType.toString(16));
2088
2389
  return null;
2089
2390
  }
2090
- var glTFData = new Uint8Array(glb, GLB_HEADER_LENGTH + 2 * UINT32_LENGTH, chunkLength);
2391
+ var glTFData = new Uint8Array(originBuffer, GLB_HEADER_LENGTH + 2 * UINT32_LENGTH, chunkLength);
2091
2392
  var glTF = JSON.parse(engineCore.Utils.decodeText(glTFData));
2092
2393
  // read all buffers
2093
2394
  var buffers = [];
@@ -2101,7 +2402,7 @@ function registerGLTFParser(pipeline) {
2101
2402
  return null;
2102
2403
  }
2103
2404
  var currentOffset = byteOffset + 2 * UINT32_LENGTH;
2104
- var buffer = glb.slice(currentOffset, currentOffset + chunkLength);
2405
+ var buffer = originBuffer.slice(currentOffset, currentOffset + chunkLength);
2105
2406
  buffers.push(buffer);
2106
2407
  restoreGLBBufferSlice.push(new engineMath.Vector2(currentOffset, chunkLength));
2107
2408
  byteOffset += chunkLength + 2 * UINT32_LENGTH;
@@ -2980,18 +3281,22 @@ exports.KTX2Loader = (_KTX2Loader = /*#__PURE__*/ function(Loader1) {
2980
3281
  /**
2981
3282
  * @internal
2982
3283
  */ _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
- });
3284
+ var _this = this;
3285
+ return new engineCore.AssetPromise(function(resolve, reject, setTaskCompleteProgress, setTaskDetailProgress) {
3286
+ _this.request(item.url, {
3287
+ type: "arraybuffer"
3288
+ }).onProgress(setTaskCompleteProgress, setTaskDetailProgress).then(function(buffer) {
3289
+ return exports.KTX2Loader._parseBuffer(new Uint8Array(buffer), resourceManager.engine, item.params).then(function(param) {
3290
+ var engine = param.engine, result = param.result, targetFormat = param.targetFormat, params = param.params;
3291
+ return exports.KTX2Loader._createTextureByBuffer(engine, result, targetFormat, params);
3292
+ });
3293
+ }).then(resolve).catch(reject);
2990
3294
  });
2991
3295
  };
2992
3296
  /**
2993
- * Destroy ktx2 transcoder worker.
2994
- */ KTX2Loader1.destroy = function destroy() {
3297
+ * Release ktx2 transcoder worker.
3298
+ * @remarks If use loader after releasing, we should release again.
3299
+ */ KTX2Loader1.release = function release() {
2995
3300
  if (this._binomialLLCTranscoder) this._binomialLLCTranscoder.destroy();
2996
3301
  if (this._khronosTranscoder) this._khronosTranscoder.destroy();
2997
3302
  this._binomialLLCTranscoder = null;
@@ -3236,16 +3541,16 @@ exports.KTX2Transcoder = void 0;
3236
3541
  var frame = restoreInfo.blendShape.frames[0];
3237
3542
  var position = restoreInfo.position;
3238
3543
  var positionData = _this._getBufferData(buffers, position.buffer);
3239
- frame.deltaPositions = GLTFUtils.bufferToVector3Array(positionData, position.stride, position.byteOffset, position.count);
3544
+ frame.deltaPositions = GLTFUtils.bufferToVector3Array(positionData, position.byteOffset, position.count, position.normalized, position.componentType);
3240
3545
  if (restoreInfo.normal) {
3241
3546
  var normal = restoreInfo.normal;
3242
3547
  var normalData = _this._getBufferData(buffers, normal.buffer);
3243
- frame.deltaNormals = GLTFUtils.bufferToVector3Array(normalData, normal.stride, normal.byteOffset, normal.count);
3548
+ frame.deltaNormals = GLTFUtils.bufferToVector3Array(normalData, normal.byteOffset, normal.count, normal.normalized, normal.componentType);
3244
3549
  }
3245
3550
  if (restoreInfo.tangent) {
3246
3551
  var tangent = restoreInfo.tangent;
3247
3552
  var tangentData = _this._getBufferData(buffers, tangent.buffer);
3248
- frame.deltaTangents = GLTFUtils.bufferToVector3Array(tangentData, tangent.stride, tangent.byteOffset, tangent.count);
3553
+ frame.deltaTangents = GLTFUtils.bufferToVector3Array(tangentData, tangent.byteOffset, tangent.count, tangent.normalized, tangent.componentType);
3249
3554
  }
3250
3555
  }
3251
3556
  mesh.uploadData(true);
@@ -3257,8 +3562,13 @@ exports.KTX2Transcoder = void 0;
3257
3562
  };
3258
3563
  _proto._getBufferData = function _getBufferData(buffers, restoreInfo) {
3259
3564
  var main = restoreInfo.main;
3260
- var buffer = buffers[main.bufferIndex];
3261
- var data = new main.TypedArray(buffer, main.byteOffset, main.length);
3565
+ var data;
3566
+ if (main) {
3567
+ var buffer = buffers[main.bufferIndex];
3568
+ data = new main.TypedArray(buffer, main.byteOffset, main.length);
3569
+ } else {
3570
+ data = new main.TypedArray(main.length);
3571
+ }
3262
3572
  var sparseCount = restoreInfo.sparseCount;
3263
3573
  if (sparseCount) {
3264
3574
  var sparseIndex = restoreInfo.sparseIndices;
@@ -3331,11 +3641,12 @@ exports.KTX2Transcoder = void 0;
3331
3641
  };
3332
3642
  /**
3333
3643
  * @internal
3334
- */ var BlendShapeDataRestoreInfo = function BlendShapeDataRestoreInfo(buffer, stride, byteOffset, count) {
3644
+ */ var BlendShapeDataRestoreInfo = function BlendShapeDataRestoreInfo(buffer, byteOffset, count, normalized, componentType) {
3335
3645
  this.buffer = buffer;
3336
- this.stride = stride;
3337
3646
  this.byteOffset = byteOffset;
3338
3647
  this.count = count;
3648
+ this.normalized = normalized;
3649
+ this.componentType = componentType;
3339
3650
  };
3340
3651
 
3341
3652
  /**
@@ -3511,23 +3822,20 @@ exports.GLTFSchemaParser = /*#__PURE__*/ function(GLTFParser1) {
3511
3822
  var requestConfig = {
3512
3823
  type: "arraybuffer"
3513
3824
  };
3514
- var isGLB = this._isGLB(url);
3515
- contentRestorer.isGLB = isGLB;
3516
- var promise = isGLB ? engineCore.request(url, requestConfig).then(function(glb) {
3825
+ return engineCore.request(url, requestConfig).onProgress(undefined, context._onTaskDetail).then(function(buffer) {
3517
3826
  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"
3827
+ return GLTFUtils.parseGLB(context, buffer);
3828
+ }).then(function(result) {
3829
+ var _result;
3830
+ if ((_result = result) == null ? void 0 : _result.glTF) {
3831
+ contentRestorer.isGLB = true;
3832
+ context.buffers = result.buffers;
3833
+ return result.glTF;
3834
+ } else {
3835
+ contentRestorer.isGLB = false;
3836
+ return JSON.parse(engineCore.Utils.decodeText(new Uint8Array(result.originBuffer)));
3837
+ }
3525
3838
  });
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
3839
  };
3532
3840
  return GLTFSchemaParser;
3533
3841
  }(GLTFParser);
@@ -3554,9 +3862,9 @@ exports.GLTFAnimationParser = /*#__PURE__*/ function(GLTFParser1) {
3554
3862
  * @internal
3555
3863
  */ GLTFAnimationParser1._parseStandardProperty = function _parseStandardProperty(context, animationClip, animationInfo) {
3556
3864
  var _loop = function(j, m) {
3557
- var gltfSampler = samplers[j];
3558
- var inputAccessor = accessors[gltfSampler.input];
3559
- var outputAccessor = accessors[gltfSampler.output];
3865
+ var glTFSampler = samplers[j];
3866
+ var inputAccessor = accessors[glTFSampler.input];
3867
+ var outputAccessor = accessors[glTFSampler.output];
3560
3868
  var promise = Promise.all([
3561
3869
  GLTFUtils.getAccessorBuffer(context, bufferViews, inputAccessor),
3562
3870
  GLTFUtils.getAccessorBuffer(context, bufferViews, outputAccessor)
@@ -3572,8 +3880,8 @@ exports.GLTFAnimationParser = /*#__PURE__*/ function(GLTFParser1) {
3572
3880
  output = scaled;
3573
3881
  }
3574
3882
  var outputStride = output.length / input.length;
3575
- var _gltfSampler_interpolation;
3576
- var interpolation = (_gltfSampler_interpolation = gltfSampler.interpolation) != null ? _gltfSampler_interpolation : AnimationSamplerInterpolation.Linear;
3883
+ var _glTFSampler_interpolation;
3884
+ var interpolation = (_glTFSampler_interpolation = glTFSampler.interpolation) != null ? _glTFSampler_interpolation : AnimationSamplerInterpolation.Linear;
3577
3885
  var samplerInterpolation;
3578
3886
  switch(interpolation){
3579
3887
  case AnimationSamplerInterpolation.CubicSpine:
@@ -3587,13 +3895,13 @@ exports.GLTFAnimationParser = /*#__PURE__*/ function(GLTFParser1) {
3587
3895
  break;
3588
3896
  }
3589
3897
  input[input.length - 1];
3590
- sampleDataCollection.push({
3898
+ sampleDataCollection[j] = {
3591
3899
  type: outputAccessor.type,
3592
3900
  interpolation: samplerInterpolation,
3593
3901
  input: input,
3594
3902
  output: output,
3595
3903
  outputSize: outputStride
3596
- });
3904
+ };
3597
3905
  });
3598
3906
  promises.push(promise);
3599
3907
  };
@@ -3601,16 +3909,17 @@ exports.GLTFAnimationParser = /*#__PURE__*/ function(GLTFParser1) {
3601
3909
  var glTF = context.glTF;
3602
3910
  var accessors = glTF.accessors, bufferViews = glTF.bufferViews;
3603
3911
  var channels = animationInfo.channels, samplers = animationInfo.samplers;
3604
- var sampleDataCollection = new Array();
3912
+ var len = samplers.length;
3913
+ var sampleDataCollection = new Array(len);
3605
3914
  var entities = context.get(exports.GLTFParserType.Entity);
3606
3915
  var promises = new Array();
3607
3916
  // parse samplers
3608
- for(var j = 0, m = samplers.length; j < m; j++)_loop(j);
3917
+ for(var j = 0, m = len; j < m; j++)_loop(j);
3609
3918
  promises.push(context.get(exports.GLTFParserType.Scene));
3610
3919
  return Promise.all(promises).then(function() {
3611
3920
  for(var j = 0, m = channels.length; j < m; j++){
3612
- var gltfChannel = channels[j];
3613
- var target = gltfChannel.target;
3921
+ var glTFChannel = channels[j];
3922
+ var target = glTFChannel.target;
3614
3923
  var channelTargetEntity = entities[target.node];
3615
3924
  var relativePath = "";
3616
3925
  var entity = channelTargetEntity;
@@ -3642,14 +3951,21 @@ exports.GLTFAnimationParser = /*#__PURE__*/ function(GLTFParser1) {
3642
3951
  propertyName = "blendShapeWeights";
3643
3952
  break;
3644
3953
  }
3645
- var curve = _this._addCurve(target.path, gltfChannel, sampleDataCollection);
3646
- animationClip.addCurveBinding(relativePath, ComponentType, propertyName, curve);
3954
+ var curve = _this._addCurve(target.path, glTFChannel, sampleDataCollection);
3955
+ if (target.path === AnimationChannelTargetPath.WEIGHTS) {
3956
+ var mesh = glTF.nodes[target.node].mesh;
3957
+ for(var i = 0, n = glTF.meshes[mesh].primitives.length; i < n; i++){
3958
+ animationClip.addCurveBinding(relativePath, ComponentType, i, propertyName, curve);
3959
+ }
3960
+ } else {
3961
+ animationClip.addCurveBinding(relativePath, ComponentType, propertyName, curve);
3962
+ }
3647
3963
  }
3648
3964
  return animationClip;
3649
3965
  });
3650
3966
  };
3651
- GLTFAnimationParser1._addCurve = function _addCurve(animationChannelTargetPath, gltfChannel, sampleDataCollection) {
3652
- var sampleData = sampleDataCollection[gltfChannel.sampler];
3967
+ GLTFAnimationParser1._addCurve = function _addCurve(animationChannelTargetPath, glTFChannel, sampleDataCollection) {
3968
+ var sampleData = sampleDataCollection[glTFChannel.sampler];
3653
3969
  var input = sampleData.input, output = sampleData.output, outputSize = sampleData.outputSize;
3654
3970
  switch(animationChannelTargetPath){
3655
3971
  case AnimationChannelTargetPath.TRANSLATION:
@@ -3741,7 +4057,9 @@ exports.GLTFBufferParser = /*#__PURE__*/ function(GLTFParser1) {
3741
4057
  };
3742
4058
  var absoluteUrl = engineCore.Utils.resolveAbsoluteUrl(url, bufferInfo.uri);
3743
4059
  restoreBufferRequests.push(new BufferRequestInfo(absoluteUrl, requestConfig));
3744
- return engineCore.request(absoluteUrl, requestConfig);
4060
+ var promise = engineCore.request(absoluteUrl, requestConfig).onProgress(undefined, context._onTaskDetail);
4061
+ context._addTaskCompletePromise(promise);
4062
+ return promise;
3745
4063
  };
3746
4064
  return GLTFBufferParser;
3747
4065
  }(GLTFParser);
@@ -3756,10 +4074,13 @@ exports.GLTFEntityParser = /*#__PURE__*/ function(GLTFParser1) {
3756
4074
  }
3757
4075
  var _proto = GLTFEntityParser.prototype;
3758
4076
  _proto.parse = function parse(context, index) {
4077
+ var glTFResource = context.glTFResource;
3759
4078
  var entityInfo = context.glTF.nodes[index];
3760
- var engine = context.glTFResource.engine;
4079
+ var engine = glTFResource.engine;
3761
4080
  var matrix = entityInfo.matrix, translation = entityInfo.translation, rotation = entityInfo.rotation, scale = entityInfo.scale, extensions = entityInfo.extensions;
3762
4081
  var entity = new engineCore.Entity(engine, entityInfo.name || "_GLTF_ENTITY_" + index);
4082
+ // @ts-ignore
4083
+ entity._markAsTemplate(glTFResource);
3763
4084
  var transform = entity.transform;
3764
4085
  if (matrix) {
3765
4086
  var localMatrix = transform.localMatrix;
@@ -3801,7 +4122,8 @@ exports.GLTFMaterialParser = /*#__PURE__*/ function(GLTFParser1) {
3801
4122
  var _proto = GLTFMaterialParser1.prototype;
3802
4123
  _proto.parse = function parse(context, index) {
3803
4124
  var materialInfo = context.glTF.materials[index];
3804
- var engine = context.glTFResource.engine;
4125
+ var glTFResource = context.glTFResource;
4126
+ var engine = glTFResource.engine;
3805
4127
  var material = GLTFParser.executeExtensionsCreateAndParse(materialInfo.extensions, context, materialInfo);
3806
4128
  if (!material) {
3807
4129
  material = new engineCore.PBRMaterial(engine);
@@ -3809,8 +4131,10 @@ exports.GLTFMaterialParser = /*#__PURE__*/ function(GLTFParser1) {
3809
4131
  exports.GLTFMaterialParser._parseStandardProperty(context, material, materialInfo);
3810
4132
  }
3811
4133
  return Promise.resolve(material).then(function(material) {
3812
- material || (material = exports.GLTFMaterialParser._getDefaultMaterial(context.glTFResource.engine));
4134
+ material || (material = exports.GLTFMaterialParser._getDefaultMaterial(engine));
3813
4135
  GLTFParser.executeExtensionsAdditiveAndParse(materialInfo.extensions, context, material, materialInfo);
4136
+ // @ts-ignore
4137
+ material._associationSuperResource(glTFResource);
3814
4138
  return material;
3815
4139
  });
3816
4140
  };
@@ -3931,46 +4255,37 @@ exports.GLTFMeshParser = (_GLTFMeshParser = /*#__PURE__*/ function(GLTFParser1)
3931
4255
  var mesh = GLTFParser.executeExtensionsCreateAndParse(gltfPrimitive.extensions, context, gltfPrimitive, meshInfo);
3932
4256
  if (mesh) {
3933
4257
  if (_instanceof(mesh, engineCore.ModelMesh)) {
4258
+ // @ts-ignore
4259
+ mesh._associationSuperResource(glTFResource);
3934
4260
  resolve(mesh);
3935
4261
  } else {
3936
4262
  mesh.then(function(mesh) {
3937
- return resolve(mesh);
4263
+ // @ts-ignore
4264
+ mesh._associationSuperResource(glTFResource);
4265
+ resolve(mesh);
3938
4266
  });
3939
4267
  }
3940
4268
  } else {
3941
4269
  var mesh1 = new engineCore.ModelMesh(engine, meshInfo.name || i + "");
4270
+ // @ts-ignore
4271
+ mesh1._associationSuperResource(glTFResource);
3942
4272
  var meshRestoreInfo = new ModelMeshRestoreInfo();
3943
4273
  meshRestoreInfo.mesh = mesh1;
3944
4274
  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);
4275
+ exports.GLTFMeshParser._parseMeshFromGLTFPrimitive(context, mesh1, meshRestoreInfo, meshInfo, gltfPrimitive, glTF, context.params.keepMeshData).then(resolve);
3962
4276
  }
3963
4277
  });
3964
4278
  };
3965
4279
  var meshInfo = context.glTF.meshes[index];
3966
- var glTF = context.glTF, engine = context.glTFResource.engine;
4280
+ var glTF = context.glTF, glTFResource = context.glTFResource;
4281
+ var engine = glTFResource.engine;
3967
4282
  var primitivePromises = new Array();
3968
4283
  for(var i = 0, length = meshInfo.primitives.length; i < length; i++)_loop(i);
3969
4284
  return Promise.all(primitivePromises);
3970
4285
  };
3971
4286
  /**
3972
4287
  * @internal
3973
- */ GLTFMeshParser1._parseMeshFromGLTFPrimitive = function _parseMeshFromGLTFPrimitive(context, mesh, meshRestoreInfo, gltfMesh, gltfPrimitive, gltf, getVertexBufferData, getBlendShapeData, getIndexBufferData, keepMeshData) {
4288
+ */ GLTFMeshParser1._parseMeshFromGLTFPrimitive = function _parseMeshFromGLTFPrimitive(context, mesh, meshRestoreInfo, gltfMesh, gltfPrimitive, gltf, keepMeshData) {
3974
4289
  var _loop = function(attribute) {
3975
4290
  var accessor = accessors[attributes[attribute]];
3976
4291
  var promise = GLTFUtils.getAccessorBuffer(context, gltf.bufferViews, accessor).then(function(accessorBuffer) {
@@ -4065,61 +4380,68 @@ exports.GLTFMeshParser = (_GLTFMeshParser = /*#__PURE__*/ function(GLTFParser1)
4065
4380
  }
4066
4381
  // BlendShapes
4067
4382
  if (targets) {
4068
- promises.push(exports.GLTFMeshParser._createBlendShape(mesh, meshRestoreInfo, gltfMesh, accessors, targets, getBlendShapeData));
4383
+ promises.push(exports.GLTFMeshParser._createBlendShape(context, mesh, meshRestoreInfo, gltfMesh, gltfPrimitive, targets));
4069
4384
  }
4070
4385
  return Promise.all(promises).then(function() {
4071
4386
  mesh.uploadData(!keepMeshData);
4072
- return Promise.resolve(mesh);
4387
+ return mesh;
4073
4388
  });
4074
4389
  });
4075
4390
  };
4391
+ GLTFMeshParser1._getBlendShapeData = function _getBlendShapeData(context, glTF, accessor) {
4392
+ return GLTFUtils.getAccessorBuffer(context, glTF.bufferViews, accessor).then(function(bufferInfo) {
4393
+ var buffer = bufferInfo.data;
4394
+ var _accessor_byteOffset;
4395
+ var byteOffset = bufferInfo.interleaved ? ((_accessor_byteOffset = accessor.byteOffset) != null ? _accessor_byteOffset : 0) % bufferInfo.stride : 0;
4396
+ var count = accessor.count, normalized = accessor.normalized, componentType = accessor.componentType;
4397
+ var vertices = GLTFUtils.bufferToVector3Array(buffer, byteOffset, count, normalized, componentType);
4398
+ var restoreInfo = new BlendShapeDataRestoreInfo(bufferInfo.restoreInfo, byteOffset, count, normalized, componentType);
4399
+ return {
4400
+ vertices: vertices,
4401
+ restoreInfo: restoreInfo
4402
+ };
4403
+ });
4404
+ };
4076
4405
  /**
4077
4406
  * @internal
4078
- */ GLTFMeshParser1._createBlendShape = function _createBlendShape(mesh, meshRestoreInfo, glTFMesh, accessors, glTFTargets, getBlendShapeData) {
4079
- var _loop = function(i, n) {
4407
+ */ GLTFMeshParser1._createBlendShape = function _createBlendShape(context, mesh, meshRestoreInfo, glTFMesh, gltfPrimitive, glTFTargets) {
4408
+ var _this = this, _loop = function(i) {
4409
+ var blendShapeData = {};
4410
+ blendShapeCollection[i] = blendShapeData;
4080
4411
  var name = blendShapeNames ? blendShapeNames[i] : "blendShape" + i;
4412
+ var targets = gltfPrimitive.targets[i];
4413
+ var normalTarget = targets["NORMAL"];
4414
+ var tangentTarget = targets["TANGENT"];
4415
+ var hasNormal = normalTarget !== undefined;
4416
+ var hasTangent = tangentTarget !== undefined;
4081
4417
  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
- }
4418
+ _this._getBlendShapeData(context, glTF, accessors[targets["POSITION"]]),
4419
+ hasNormal ? _this._getBlendShapeData(context, glTF, accessors[normalTarget]) : null,
4420
+ hasTangent ? _this._getBlendShapeData(context, glTF, accessors[tangentTarget]) : null
4421
+ ]).then(function(vertices) {
4422
+ var _tangentData;
4423
+ var positionData = vertices[0], normalData = vertices[1], tangentData = vertices[2];
4111
4424
  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));
4425
+ blendShape.addFrame(1.0, positionData.vertices, hasNormal ? normalData.vertices : null, hasTangent ? tangentData.vertices : null);
4426
+ blendShapeData.blendShape = blendShape;
4427
+ blendShapeData.restoreInfo = new BlendShapeRestoreInfo(blendShape, positionData.restoreInfo, hasNormal ? normalData.restoreInfo : null, hasTangent ? (_tangentData = tangentData) == null ? void 0 : _tangentData.restoreInfo : null);
4116
4428
  });
4117
4429
  promises.push(promise);
4118
4430
  };
4431
+ var glTF = context.glTF;
4432
+ var accessors = glTF.accessors;
4119
4433
  var blendShapeNames = glTFMesh.extras ? glTFMesh.extras.targetNames : null;
4120
4434
  var promises = new Array();
4121
- for(var i = 0, n = glTFTargets.length; i < n; i++)_loop(i);
4122
- return Promise.all(promises);
4435
+ var blendShapeCount = glTFTargets.length;
4436
+ var blendShapeCollection = new Array(blendShapeCount);
4437
+ for(var i = 0; i < blendShapeCount; i++)_loop(i);
4438
+ return Promise.all(promises).then(function() {
4439
+ for(var _iterator = _create_for_of_iterator_helper_loose(blendShapeCollection), _step; !(_step = _iterator()).done;){
4440
+ var blendShape = _step.value;
4441
+ mesh.addBlendShape(blendShape.blendShape);
4442
+ meshRestoreInfo.blendShapes.push(blendShape.restoreInfo);
4443
+ }
4444
+ });
4123
4445
  };
4124
4446
  return GLTFMeshParser1;
4125
4447
  }(GLTFParser), function() {
@@ -4152,12 +4474,8 @@ exports.GLTFSceneParser = /*#__PURE__*/ function(GLTFParser1) {
4152
4474
  sceneRoot.addChild(childEntity);
4153
4475
  }
4154
4476
  }
4155
- // @ts-ignore
4156
- sceneRoot._hookResource = glTFResource;
4157
- // @ts-ignore
4158
- glTFResource._addReferCount(1);
4159
4477
  if (isDefaultScene) {
4160
- glTFResource.defaultSceneRoot = sceneRoot;
4478
+ glTFResource._defaultSceneRoot = sceneRoot;
4161
4479
  }
4162
4480
  var promises = new Array();
4163
4481
  for(var i1 = 0; i1 < sceneNodes.length; i1++){
@@ -4424,11 +4742,12 @@ exports.GLTFTextureParser = (_GLTFTextureParser = /*#__PURE__*/ function(GLTFPar
4424
4742
  params: {
4425
4743
  mipmap: (_samplerInfo = samplerInfo) == null ? void 0 : _samplerInfo.mipmap
4426
4744
  }
4427
- }).then(function(texture) {
4745
+ }).onProgress(undefined, context._onTaskDetail).then(function(texture) {
4428
4746
  texture.name = textureName || imageName || texture.name || "texture_" + index;
4429
4747
  useSampler && GLTFUtils.parseSampler(texture, samplerInfo);
4430
4748
  return texture;
4431
4749
  });
4750
+ context._addTaskCompletePromise(texture);
4432
4751
  } else {
4433
4752
  var bufferView = glTF.bufferViews[bufferViewIndex];
4434
4753
  texture = context.get(exports.GLTFParserType.Buffer).then(function(buffers) {
@@ -4450,6 +4769,8 @@ exports.GLTFTextureParser = (_GLTFTextureParser = /*#__PURE__*/ function(GLTFPar
4450
4769
  }
4451
4770
  return Promise.resolve(texture).then(function(texture) {
4452
4771
  GLTFParser.executeExtensionsAdditiveAndParse(extensions, context, texture, textureInfo);
4772
+ // @ts-ignore
4773
+ texture._associationSuperResource(glTFResource);
4453
4774
  return texture;
4454
4775
  });
4455
4776
  };
@@ -4500,12 +4821,232 @@ exports.GLTFValidator = __decorate([
4500
4821
  registerGLTFParser(exports.GLTFParserType.Validator)
4501
4822
  ], exports.GLTFValidator);
4502
4823
 
4503
- var GLTFLoader = /*#__PURE__*/ function(Loader1) {
4824
+ exports.GLTFBufferViewParser = /*#__PURE__*/ function(GLTFParser1) {
4825
+ _inherits(GLTFBufferViewParser, GLTFParser1);
4826
+ function GLTFBufferViewParser() {
4827
+ return GLTFParser1.apply(this, arguments);
4828
+ }
4829
+ var _proto = GLTFBufferViewParser.prototype;
4830
+ _proto.parse = function parse(context, index) {
4831
+ var bufferView = context.glTF.bufferViews[index];
4832
+ var extensions = bufferView.extensions, _bufferView_byteOffset = bufferView.byteOffset, byteOffset = _bufferView_byteOffset === void 0 ? 0 : _bufferView_byteOffset, byteLength = bufferView.byteLength, bufferIndex = bufferView.buffer;
4833
+ return extensions ? GLTFParser.executeExtensionsCreateAndParse(extensions, context, bufferView) : context.get(exports.GLTFParserType.Buffer, bufferIndex).then(function(buffer) {
4834
+ return new Uint8Array(buffer, byteOffset, byteLength);
4835
+ });
4836
+ };
4837
+ return GLTFBufferViewParser;
4838
+ }(GLTFParser);
4839
+ exports.GLTFBufferViewParser = __decorate([
4840
+ registerGLTFParser(exports.GLTFParserType.BufferView)
4841
+ ], exports.GLTFBufferViewParser);
4842
+
4843
+ // Source: https://github.com/zeux/meshoptimizer/blob/master/js/meshopt_decoder.js
4844
+ var MeshoptDecoder = function() {
4845
+ var unpack = function unpack(data) {
4846
+ var result = new Uint8Array(data.length);
4847
+ for(var i = 0; i < data.length; ++i){
4848
+ var ch = data.charCodeAt(i);
4849
+ result[i] = ch > 96 ? ch - 97 : ch > 64 ? ch - 39 : ch + 4;
4850
+ }
4851
+ var write = 0;
4852
+ for(var i1 = 0; i1 < data.length; ++i1){
4853
+ result[write++] = result[i1] < 60 ? wasmpack[result[i1]] : (result[i1] - 60) * 64 + result[++i1];
4854
+ }
4855
+ return result.buffer.slice(0, write);
4856
+ };
4857
+ var decode = function decode(fun, target, count, size, source, filter) {
4858
+ var sbrk = instance.exports.sbrk;
4859
+ var count4 = count + 3 & ~3;
4860
+ var tp = sbrk(count4 * size);
4861
+ var sp = sbrk(source.length);
4862
+ var heap = new Uint8Array(instance.exports.memory.buffer);
4863
+ heap.set(source, sp);
4864
+ var res = fun(tp, count, size, sp, source.length);
4865
+ if (res == 0 && filter) {
4866
+ filter(tp, count4, size);
4867
+ }
4868
+ target.set(heap.subarray(tp, tp + count * size));
4869
+ sbrk(tp - sbrk(0));
4870
+ if (res != 0) {
4871
+ throw new Error("Malformed buffer data: " + res);
4872
+ }
4873
+ };
4874
+ var createWorker = function createWorker(url) {
4875
+ var worker = {
4876
+ object: new Worker(url),
4877
+ pending: 0,
4878
+ requests: {}
4879
+ };
4880
+ worker.object.onmessage = function(event) {
4881
+ var data = event.data;
4882
+ worker.pending -= data.count;
4883
+ worker.requests[data.id][data.action](data.value);
4884
+ delete worker.requests[data.id];
4885
+ };
4886
+ return worker;
4887
+ };
4888
+ var initWorkers = function initWorkers(count) {
4889
+ 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 }';
4890
+ var blob = new Blob([
4891
+ source
4892
+ ], {
4893
+ type: "text/javascript"
4894
+ });
4895
+ var url = URL.createObjectURL(blob);
4896
+ for(var i = 0; i < count; ++i){
4897
+ workers[i] = createWorker(url);
4898
+ }
4899
+ URL.revokeObjectURL(url);
4900
+ };
4901
+ var decodeWorker = function decodeWorker(count, size, source, mode, filter) {
4902
+ var worker = workers[0];
4903
+ for(var i = 1; i < workers.length; ++i){
4904
+ if (workers[i].pending < worker.pending) {
4905
+ worker = workers[i];
4906
+ }
4907
+ }
4908
+ return new Promise(function(resolve, reject) {
4909
+ var data = new Uint8Array(source);
4910
+ var id = requestId++;
4911
+ worker.pending += count;
4912
+ worker.requests[id] = {
4913
+ resolve: resolve,
4914
+ reject: reject
4915
+ };
4916
+ worker.object.postMessage({
4917
+ id: id,
4918
+ count: count,
4919
+ size: size,
4920
+ source: data,
4921
+ mode: mode,
4922
+ filter: filter
4923
+ }, [
4924
+ data.buffer
4925
+ ]);
4926
+ });
4927
+ };
4928
+ 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";
4929
+ 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";
4930
+ var wasmpack = new Uint8Array([
4931
+ 32,
4932
+ 0,
4933
+ 65,
4934
+ 2,
4935
+ 1,
4936
+ 106,
4937
+ 34,
4938
+ 33,
4939
+ 3,
4940
+ 128,
4941
+ 11,
4942
+ 4,
4943
+ 13,
4944
+ 64,
4945
+ 6,
4946
+ 253,
4947
+ 10,
4948
+ 7,
4949
+ 15,
4950
+ 116,
4951
+ 127,
4952
+ 5,
4953
+ 8,
4954
+ 12,
4955
+ 40,
4956
+ 16,
4957
+ 19,
4958
+ 54,
4959
+ 20,
4960
+ 9,
4961
+ 27,
4962
+ 255,
4963
+ 113,
4964
+ 17,
4965
+ 42,
4966
+ 67,
4967
+ 24,
4968
+ 23,
4969
+ 146,
4970
+ 148,
4971
+ 18,
4972
+ 14,
4973
+ 22,
4974
+ 45,
4975
+ 70,
4976
+ 69,
4977
+ 56,
4978
+ 114,
4979
+ 101,
4980
+ 21,
4981
+ 25,
4982
+ 63,
4983
+ 75,
4984
+ 136,
4985
+ 108,
4986
+ 28,
4987
+ 118,
4988
+ 29,
4989
+ 73,
4990
+ 115
4991
+ ]);
4992
+ // @ts-ignore
4993
+ var wasm = engineCore.SystemInfo._detectSIMDSupported() ? wasm_simd : wasm_base;
4994
+ var instance;
4995
+ var ready = WebAssembly.instantiate(unpack(wasm), {}).then(function(result) {
4996
+ instance = result.instance;
4997
+ instance.exports.__wasm_call_ctors();
4998
+ });
4999
+ var filters = {
5000
+ NONE: "",
5001
+ OCTAHEDRAL: "meshopt_decodeFilterOct",
5002
+ QUATERNION: "meshopt_decodeFilterQuat",
5003
+ EXPONENTIAL: "meshopt_decodeFilterExp"
5004
+ };
5005
+ var decoders = {
5006
+ ATTRIBUTES: "meshopt_decodeVertexBuffer",
5007
+ TRIANGLES: "meshopt_decodeIndexBuffer",
5008
+ INDICES: "meshopt_decodeIndexSequence"
5009
+ };
5010
+ var workers = [];
5011
+ var requestId = 0;
5012
+ return {
5013
+ workerCount: 4,
5014
+ ready: ready,
5015
+ useWorkers: function useWorkers() {
5016
+ initWorkers(this.workerCount);
5017
+ },
5018
+ decodeGltfBuffer: function decodeGltfBuffer(count, stride, source, mode, filter) {
5019
+ if (this.workerCount > 0 && workers.length === 0) this.useWorkers();
5020
+ if (workers.length > 0) return decodeWorker(count, stride, source, decoders[mode], filters[filter]);
5021
+ return ready.then(function() {
5022
+ var target = new Uint8Array(count * stride);
5023
+ decode(instance.exports[decoders[mode]], target, count, stride, source, instance.exports[filters[filter]]);
5024
+ return target;
5025
+ });
5026
+ },
5027
+ release: function release() {
5028
+ for(var i = 0; i < workers.length; i++){
5029
+ workers[i].object.terminate();
5030
+ }
5031
+ }
5032
+ };
5033
+ }();
5034
+
5035
+ exports.GLTFLoader = /*#__PURE__*/ function(Loader1) {
4504
5036
  _inherits(GLTFLoader, Loader1);
4505
5037
  function GLTFLoader() {
4506
5038
  return Loader1.apply(this, arguments);
4507
5039
  }
4508
5040
  var _proto = GLTFLoader.prototype;
5041
+ _proto.initialize = function initialize(_, configuration) {
5042
+ var _configuration_glTF;
5043
+ var meshOptOptions = (_configuration_glTF = configuration.glTF) == null ? void 0 : _configuration_glTF.meshOpt;
5044
+ if (meshOptOptions) {
5045
+ MeshoptDecoder.workerCount = meshOptOptions.workerCount;
5046
+ MeshoptDecoder.useWorkers();
5047
+ }
5048
+ return Promise.resolve();
5049
+ };
4509
5050
  _proto.load = function load(item, resourceManager) {
4510
5051
  var url = item.url;
4511
5052
  var params = item.params;
@@ -4513,16 +5054,26 @@ var GLTFLoader = /*#__PURE__*/ function(Loader1) {
4513
5054
  var context = new GLTFParserContext(glTFResource, resourceManager, _extends({
4514
5055
  keepMeshData: false
4515
5056
  }, params));
4516
- return context.parse();
5057
+ return new engineCore.AssetPromise(function(resolve, reject, setTaskCompleteProgress, setTaskDetailProgress) {
5058
+ context._setTaskCompleteProgress = setTaskCompleteProgress;
5059
+ context._setTaskDetailProgress = setTaskDetailProgress;
5060
+ context.parse().then(resolve).catch(reject);
5061
+ });
5062
+ };
5063
+ /**
5064
+ * Release glTF loader memory(includes meshopt workers).
5065
+ * @remarks If use loader after releasing, we should release again.
5066
+ */ GLTFLoader.release = function release() {
5067
+ MeshoptDecoder.release();
4517
5068
  };
4518
5069
  return GLTFLoader;
4519
5070
  }(engineCore.Loader);
4520
- GLTFLoader = __decorate([
5071
+ exports.GLTFLoader = __decorate([
4521
5072
  engineCore.resourceLoader(engineCore.AssetType.GLTF, [
4522
5073
  "gltf",
4523
5074
  "glb"
4524
5075
  ])
4525
- ], GLTFLoader);
5076
+ ], exports.GLTFLoader);
4526
5077
 
4527
5078
  var _HDRLoader;
4528
5079
  var PI = Math.PI;
@@ -5136,60 +5687,73 @@ var MaterialLoader = /*#__PURE__*/ function(Loader1) {
5136
5687
  _this.request(item.url, _extends({}, item, {
5137
5688
  type: "json"
5138
5689
  })).then(function(materialSchema) {
5139
- var _loop = function(key) {
5140
- var _shaderData_key = shaderData[key], type = _shaderData_key.type, value = _shaderData_key.value;
5141
- switch(type){
5142
- case "Vector2":
5143
- materialShaderData.setVector2(key, new engineMath.Vector2(value.x, value.y));
5144
- break;
5145
- case "Vector3":
5146
- materialShaderData.setVector3(key, new engineMath.Vector3(value.x, value.y, value.z));
5147
- break;
5148
- case "Vector4":
5149
- materialShaderData.setVector4(key, new engineMath.Vector4(value.x, value.y, value.z, value.w));
5150
- break;
5151
- case "Color":
5152
- materialShaderData.setColor(key, new engineMath.Color(value.r, value.g, value.b, value.a));
5153
- break;
5154
- case "Float":
5155
- materialShaderData.setFloat(key, value);
5156
- break;
5157
- case "Texture":
5158
- texturePromises.push(// @ts-ignore
5159
- resourceManager.getResourceByRef(value).then(function(texture) {
5160
- materialShaderData.setTexture(key, texture);
5161
- }));
5162
- break;
5163
- case "Boolean":
5164
- materialShaderData.setInt(key, value ? 1 : 0);
5165
- break;
5166
- case "Integer":
5167
- materialShaderData.setInt(key, Number(value));
5168
- break;
5169
- }
5170
- };
5171
5690
  var engine = resourceManager.engine;
5172
- var name = materialSchema.name, shader = materialSchema.shader, shaderData = materialSchema.shaderData, macros = materialSchema.macros, renderState = materialSchema.renderState;
5173
- var material = new engineCore.Material(engine, engineCore.Shader.find(shader));
5174
- material.name = name;
5175
- var texturePromises = new Array();
5176
- var materialShaderData = material.shaderData;
5177
- for(var key in shaderData)_loop(key);
5178
- for(var i = 0, length = macros.length; i < length; i++){
5179
- var _macros_i = macros[i], name1 = _macros_i.name, value = _macros_i.value;
5180
- if (value == undefined) {
5181
- materialShaderData.enableMacro(name1);
5182
- } else {
5183
- materialShaderData.enableMacro(name1, value);
5184
- }
5691
+ var shaderRef = materialSchema.shaderRef, shader = materialSchema.shader;
5692
+ if (shaderRef) {
5693
+ resolve(resourceManager// @ts-ignore
5694
+ .getResourceByRef(shaderRef).then(function(shaderObject) {
5695
+ return _this.getMaterialByShader(materialSchema, shaderObject, engine);
5696
+ }));
5697
+ } else {
5698
+ // compatible with 1.2-pre version material schema
5699
+ var shaderObject = engineCore.Shader.find(shader);
5700
+ resolve(_this.getMaterialByShader(materialSchema, shaderObject, engine));
5185
5701
  }
5186
- parseProperty(material, "renderState", renderState);
5187
- return Promise.all(texturePromises).then(function() {
5188
- resolve(material);
5189
- });
5190
5702
  }).catch(reject);
5191
5703
  });
5192
5704
  };
5705
+ _proto.getMaterialByShader = function getMaterialByShader(materialSchema, shader, engine) {
5706
+ var _loop = function(key) {
5707
+ var _shaderData_key = shaderData[key], type = _shaderData_key.type, value = _shaderData_key.value;
5708
+ switch(type){
5709
+ case "Vector2":
5710
+ materialShaderData.setVector2(key, new engineMath.Vector2(value.x, value.y));
5711
+ break;
5712
+ case "Vector3":
5713
+ materialShaderData.setVector3(key, new engineMath.Vector3(value.x, value.y, value.z));
5714
+ break;
5715
+ case "Vector4":
5716
+ materialShaderData.setVector4(key, new engineMath.Vector4(value.x, value.y, value.z, value.w));
5717
+ break;
5718
+ case "Color":
5719
+ materialShaderData.setColor(key, new engineMath.Color(value.r, value.g, value.b, value.a));
5720
+ break;
5721
+ case "Float":
5722
+ materialShaderData.setFloat(key, value);
5723
+ break;
5724
+ case "Texture":
5725
+ texturePromises.push(// @ts-ignore
5726
+ engine.resourceManager.getResourceByRef(value).then(function(texture) {
5727
+ materialShaderData.setTexture(key, texture);
5728
+ }));
5729
+ break;
5730
+ case "Boolean":
5731
+ materialShaderData.setInt(key, value ? 1 : 0);
5732
+ break;
5733
+ case "Integer":
5734
+ materialShaderData.setInt(key, Number(value));
5735
+ break;
5736
+ }
5737
+ };
5738
+ var name = materialSchema.name, shaderData = materialSchema.shaderData, macros = materialSchema.macros, renderState = materialSchema.renderState;
5739
+ var material = new engineCore.Material(engine, shader);
5740
+ material.name = name;
5741
+ var texturePromises = new Array();
5742
+ var materialShaderData = material.shaderData;
5743
+ for(var key in shaderData)_loop(key);
5744
+ for(var i = 0, length = macros.length; i < length; i++){
5745
+ var _macros_i = macros[i], name1 = _macros_i.name, value = _macros_i.value;
5746
+ if (value == undefined) {
5747
+ materialShaderData.enableMacro(name1);
5748
+ } else {
5749
+ materialShaderData.enableMacro(name1, value);
5750
+ }
5751
+ }
5752
+ parseProperty(material, "renderState", renderState);
5753
+ return Promise.all(texturePromises).then(function() {
5754
+ return material;
5755
+ });
5756
+ };
5193
5757
  return MaterialLoader;
5194
5758
  }(engineCore.Loader);
5195
5759
  MaterialLoader = __decorate([
@@ -5224,6 +5788,86 @@ MeshLoader = __decorate([
5224
5788
  ])
5225
5789
  ], MeshLoader);
5226
5790
 
5791
+ var PrimitiveMeshLoader = /*#__PURE__*/ function(Loader1) {
5792
+ _inherits(PrimitiveMeshLoader, Loader1);
5793
+ function PrimitiveMeshLoader() {
5794
+ return Loader1.apply(this, arguments);
5795
+ }
5796
+ var _proto = PrimitiveMeshLoader.prototype;
5797
+ _proto.load = function load(item, param) {
5798
+ var engine = param.engine;
5799
+ return this.request(item.url, _extends({}, item, {
5800
+ type: "json"
5801
+ })).then(function(data) {
5802
+ switch(data.type){
5803
+ case "sphere":
5804
+ return engineCore.PrimitiveMesh.createSubdivisionSurfaceSphere(engine, data.sphereRadius, data.sphereStep);
5805
+ case "capsule":
5806
+ return engineCore.PrimitiveMesh.createCapsule(engine, data.capsuleRadius, data.capsuleHeight, data.capsuleRadialSegments, data.capsuleHeightSegments);
5807
+ case "cone":
5808
+ return engineCore.PrimitiveMesh.createCone(engine, data.coneRadius, data.coneHeight, data.coneRadialSegment, data.coneHeightSegment);
5809
+ case "cuboid":
5810
+ return engineCore.PrimitiveMesh.createCuboid(engine, data.cuboidWidth, data.cuboidHeight, data.cuboidDepth);
5811
+ case "cylinder":
5812
+ return engineCore.PrimitiveMesh.createCylinder(engine, data.cylinderRadiusTop, data.cylinderRadiusBottom, data.cylinderHeight, data.cylinderRadialSegment, data.cylinderHeightSegment);
5813
+ case "plane":
5814
+ return engineCore.PrimitiveMesh.createPlane(engine, data.planeWidth, data.planeHeight, data.planeHorizontalSegments, data.planeVerticalSegments);
5815
+ case "torus":
5816
+ return engineCore.PrimitiveMesh.createTorus(engine, data.torusRadius, data.torusTubeRadius, data.torusRadialSegments, data.torusTubularSegments, data.torusArc);
5817
+ }
5818
+ });
5819
+ };
5820
+ return PrimitiveMeshLoader;
5821
+ }(engineCore.Loader);
5822
+ PrimitiveMeshLoader = __decorate([
5823
+ engineCore.resourceLoader(engineCore.AssetType.PrimitiveMesh, [
5824
+ "mesh"
5825
+ ], false)
5826
+ ], PrimitiveMeshLoader);
5827
+ var /** @internal */ PrimitiveMeshType;
5828
+ (function(PrimitiveMeshType) {
5829
+ PrimitiveMeshType["Sphere"] = "sphere";
5830
+ PrimitiveMeshType["Cuboid"] = "cuboid";
5831
+ PrimitiveMeshType["Plane"] = "plane";
5832
+ PrimitiveMeshType["Cylinder"] = "cylinder";
5833
+ PrimitiveMeshType["Torus"] = "torus";
5834
+ PrimitiveMeshType["Cone"] = "cone";
5835
+ PrimitiveMeshType["Capsule"] = "capsule";
5836
+ })(PrimitiveMeshType || (PrimitiveMeshType = {}));
5837
+
5838
+ var ProjectLoader = /*#__PURE__*/ function(Loader1) {
5839
+ _inherits(ProjectLoader, Loader1);
5840
+ function ProjectLoader() {
5841
+ return Loader1.apply(this, arguments);
5842
+ }
5843
+ var _proto = ProjectLoader.prototype;
5844
+ _proto.load = function load(item, resourceManager) {
5845
+ var _this = this;
5846
+ var engine = resourceManager.engine;
5847
+ return new engineCore.AssetPromise(function(resolve, reject) {
5848
+ _this.request(item.url, {
5849
+ type: "json"
5850
+ }).then(function(data) {
5851
+ // @ts-ignore
5852
+ engine.resourceManager.initVirtualResources(data.files);
5853
+ return resourceManager.load({
5854
+ type: engineCore.AssetType.Scene,
5855
+ url: data.scene
5856
+ }).then(function(scene) {
5857
+ engine.sceneManager.activeScene = scene;
5858
+ resolve();
5859
+ });
5860
+ }).catch(reject);
5861
+ });
5862
+ };
5863
+ return ProjectLoader;
5864
+ }(engineCore.Loader);
5865
+ ProjectLoader = __decorate([
5866
+ engineCore.resourceLoader(engineCore.AssetType.Project, [
5867
+ "proj"
5868
+ ], false)
5869
+ ], ProjectLoader);
5870
+
5227
5871
  var SourceFontLoader = /*#__PURE__*/ function(Loader1) {
5228
5872
  _inherits(SourceFontLoader, Loader1);
5229
5873
  function SourceFontLoader() {
@@ -5286,7 +5930,7 @@ var SpriteAtlasLoader = /*#__PURE__*/ function(Loader1) {
5286
5930
  var _proto = SpriteAtlasLoader.prototype;
5287
5931
  _proto.load = function load(item, resourceManager) {
5288
5932
  var _this = this;
5289
- return new engineCore.AssetPromise(function(resolve, reject, _, onCancel) {
5933
+ return new engineCore.AssetPromise(function(resolve, reject, _, __, onCancel) {
5290
5934
  var chainPromises = [];
5291
5935
  onCancel(function() {
5292
5936
  for(var i = 0; i < chainPromises.length; i++){
@@ -5449,12 +6093,12 @@ var Texture2DLoader = /*#__PURE__*/ function(Loader1) {
5449
6093
  var _proto = Texture2DLoader.prototype;
5450
6094
  _proto.load = function load(item, resourceManager) {
5451
6095
  var _this = this;
5452
- return new engineCore.AssetPromise(function(resolve, reject) {
6096
+ return new engineCore.AssetPromise(function(resolve, reject, setTaskCompleteProgress, setTaskDetailProgress) {
5453
6097
  var url = item.url;
5454
6098
  var requestConfig = _extends({}, item, {
5455
6099
  type: "image"
5456
6100
  });
5457
- _this.request(url, requestConfig).then(function(image) {
6101
+ _this.request(url, requestConfig).onProgress(setTaskCompleteProgress, setTaskDetailProgress).then(function(image) {
5458
6102
  var _item_params;
5459
6103
  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
6104
  var texture = new engineCore.Texture2D(resourceManager.engine, image.width, image.height, format, mipmap);
@@ -5559,38 +6203,105 @@ TextureCubeLoader = __decorate([
5559
6203
  ])
5560
6204
  ], TextureCubeLoader);
5561
6205
 
5562
- var ProjectLoader = /*#__PURE__*/ function(Loader1) {
5563
- _inherits(ProjectLoader, Loader1);
5564
- function ProjectLoader() {
6206
+ var ShaderLoader = /*#__PURE__*/ function(Loader1) {
6207
+ _inherits(ShaderLoader, Loader1);
6208
+ function ShaderLoader() {
5565
6209
  return Loader1.apply(this, arguments);
5566
6210
  }
5567
- var _proto = ProjectLoader.prototype;
6211
+ var _proto = ShaderLoader.prototype;
5568
6212
  _proto.load = function load(item, resourceManager) {
5569
6213
  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);
6214
+ return this.request(item.url, _extends({}, item, {
6215
+ type: "text"
6216
+ })).then(function(code) {
6217
+ var builtinShader = _this.getBuiltinShader(code);
6218
+ if (builtinShader) {
6219
+ return engineCore.Shader.find(builtinShader);
6220
+ }
6221
+ var matches = code.matchAll(/^[ \t]*#include +"([^$\\"]+)"/gm);
6222
+ return Promise.all(Array.from(matches).map(function(m) {
6223
+ var path = m[1];
6224
+ if (path) {
6225
+ // @ts-ignore
6226
+ var resource = resourceManager._virtualPathMap[path];
6227
+ if (!resource) return;
6228
+ return resourceManager.load({
6229
+ type: engineCore.AssetType.ShaderChunk,
6230
+ url: resource,
6231
+ params: {
6232
+ includeKey: path
6233
+ }
6234
+ });
6235
+ }
6236
+ })).then(function() {
6237
+ return engineCore.Shader.create(code);
6238
+ });
5585
6239
  });
5586
6240
  };
5587
- return ProjectLoader;
6241
+ _proto.getBuiltinShader = function getBuiltinShader(code) {
6242
+ var match = code.match(/^\s*\/\/\s*@builtin\s+(\w+)/);
6243
+ if (match && match[1]) return match[1];
6244
+ };
6245
+ return ShaderLoader;
5588
6246
  }(engineCore.Loader);
5589
- ProjectLoader = __decorate([
5590
- engineCore.resourceLoader(engineCore.AssetType.Project, [
5591
- "proj"
6247
+ ShaderLoader = __decorate([
6248
+ engineCore.resourceLoader(engineCore.AssetType.Shader, [
6249
+ "gs",
6250
+ "gsl"
5592
6251
  ], false)
5593
- ], ProjectLoader);
6252
+ ], ShaderLoader);
6253
+
6254
+ var ShaderChunkLoader = /*#__PURE__*/ function(Loader1) {
6255
+ _inherits(ShaderChunkLoader, Loader1);
6256
+ function ShaderChunkLoader() {
6257
+ return Loader1.apply(this, arguments);
6258
+ }
6259
+ var _proto = ShaderChunkLoader.prototype;
6260
+ _proto.load = function load(item, resourceManager) {
6261
+ return this.request(item.url, _extends({}, item, {
6262
+ type: "text"
6263
+ })).then(/*#__PURE__*/ _async_to_generator(function(code) {
6264
+ var includeKey, matches;
6265
+ return __generator(this, function(_state) {
6266
+ switch(_state.label){
6267
+ case 0:
6268
+ includeKey = item.params.includeKey;
6269
+ engineCore.ShaderFactory.registerInclude(includeKey, code);
6270
+ matches = code.matchAll(/^[ \t]*#include +"([^$\\"]+)"/gm);
6271
+ return [
6272
+ 4,
6273
+ Promise.all(Array.from(matches).map(function(m) {
6274
+ var path = m[1];
6275
+ if (path) {
6276
+ // @ts-ignore
6277
+ var resource = resourceManager._virtualPathMap[path];
6278
+ if (!resource) return;
6279
+ return resourceManager.load({
6280
+ type: engineCore.AssetType.ShaderChunk,
6281
+ url: resource,
6282
+ params: {
6283
+ includeKey: path
6284
+ }
6285
+ });
6286
+ }
6287
+ }))
6288
+ ];
6289
+ case 1:
6290
+ _state.sent();
6291
+ return [
6292
+ 2
6293
+ ];
6294
+ }
6295
+ });
6296
+ }));
6297
+ };
6298
+ return ShaderChunkLoader;
6299
+ }(engineCore.Loader);
6300
+ ShaderChunkLoader = __decorate([
6301
+ engineCore.resourceLoader(engineCore.AssetType.ShaderChunk, [
6302
+ "glsl"
6303
+ ], false)
6304
+ ], ShaderChunkLoader);
5594
6305
 
5595
6306
  var SceneLoader = /*#__PURE__*/ function(Loader1) {
5596
6307
  _inherits(SceneLoader, Loader1);
@@ -5610,7 +6321,7 @@ var SceneLoader = /*#__PURE__*/ function(Loader1) {
5610
6321
  // parse ambient light
5611
6322
  var ambient = data.scene.ambient;
5612
6323
  if (ambient) {
5613
- var useCustomAmbient = ambient.specularMode === "Custom";
6324
+ var useCustomAmbient = ambient.specularMode === exports.SpecularMode.Custom;
5614
6325
  var useSH = ambient.diffuseMode === engineCore.DiffuseMode.SphericalHarmonics;
5615
6326
  scene.ambientLight.diffuseIntensity = ambient.diffuseIntensity;
5616
6327
  scene.ambientLight.specularIntensity = ambient.specularIntensity;
@@ -5638,6 +6349,7 @@ var SceneLoader = /*#__PURE__*/ function(Loader1) {
5638
6349
  }));
5639
6350
  }
5640
6351
  }
6352
+ // parse background
5641
6353
  var background = data.scene.background;
5642
6354
  scene.background.mode = background.mode;
5643
6355
  switch(scene.background.mode){
@@ -5681,6 +6393,17 @@ var SceneLoader = /*#__PURE__*/ function(Loader1) {
5681
6393
  var _shadow_shadowTwoCascadeSplits;
5682
6394
  scene.shadowTwoCascadeSplits = (_shadow_shadowTwoCascadeSplits = shadow.shadowTwoCascadeSplits) != null ? _shadow_shadowTwoCascadeSplits : scene.shadowTwoCascadeSplits;
5683
6395
  shadow.shadowFourCascadeSplits && scene.shadowFourCascadeSplits.copyFrom(shadow.shadowFourCascadeSplits);
6396
+ var _shadow_shadowFadeBorder;
6397
+ scene.shadowFadeBorder = (_shadow_shadowFadeBorder = shadow.shadowFadeBorder) != null ? _shadow_shadowFadeBorder : scene.shadowFadeBorder;
6398
+ }
6399
+ // parse fog
6400
+ var fog = data.scene.fog;
6401
+ if (fog) {
6402
+ if (fog.fogMode != undefined) scene.fogMode = fog.fogMode;
6403
+ if (fog.fogStart != undefined) scene.fogStart = fog.fogStart;
6404
+ if (fog.fogEnd != undefined) scene.fogEnd = fog.fogEnd;
6405
+ if (fog.fogDensity != undefined) scene.fogDensity = fog.fogDensity;
6406
+ if (fog.fogColor != undefined) scene.fogColor.copyFrom(fog.fogColor);
5684
6407
  }
5685
6408
  return Promise.all(promises).then(function() {
5686
6409
  resolve(scene);
@@ -5711,170 +6434,6 @@ ReflectionParser.registerCustomParseComponent("TextRenderer", /*#__PURE__*/ _asy
5711
6434
  });
5712
6435
  }));
5713
6436
 
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
6437
  var KHR_lights_punctual = /*#__PURE__*/ function(GLTFExtensionParser1) {
5879
6438
  _inherits(KHR_lights_punctual, GLTFExtensionParser1);
5880
6439
  function KHR_lights_punctual() {
@@ -6049,7 +6608,7 @@ var KHR_materials_variants = /*#__PURE__*/ function(GLTFExtensionParser1) {
6049
6608
  var _glTFResource;
6050
6609
  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
6610
  var mappings = schema.mappings;
6052
- (_glTFResource = glTFResource).extensionsData || (_glTFResource.extensionsData = {});
6611
+ (_glTFResource = glTFResource)._extensionsData || (_glTFResource._extensionsData = {});
6053
6612
  var extensionData = [];
6054
6613
  glTFResource.extensionsData.variants = extensionData;
6055
6614
  for(var i = 0; i < mappings.length; i++)_loop(i);
@@ -6079,7 +6638,7 @@ var KHR_texture_basisu = /*#__PURE__*/ function(GLTFExtensionParser1) {
6079
6638
  var _proto = KHR_texture_basisu.prototype;
6080
6639
  _proto.createAndParse = function createAndParse(context, schema, textureInfo) {
6081
6640
  return _async_to_generator(function() {
6082
- var glTF, glTFResource, engine, url, sampler, textureName, source, _glTF_images_source, uri, bufferViewIndex, mimeType, imageName, samplerInfo, index, bufferView;
6641
+ var glTF, glTFResource, engine, url, sampler, textureName, source, _glTF_images_source, uri, bufferViewIndex, mimeType, imageName, samplerInfo, index, promise, bufferView;
6083
6642
  return __generator(this, function(_state) {
6084
6643
  glTF = context.glTF, glTFResource = context.glTFResource;
6085
6644
  engine = glTFResource.engine, url = glTFResource.url;
@@ -6089,20 +6648,22 @@ var KHR_texture_basisu = /*#__PURE__*/ function(GLTFExtensionParser1) {
6089
6648
  samplerInfo = sampler !== undefined && GLTFUtils.getSamplerInfo(glTF.samplers[sampler]);
6090
6649
  if (uri) {
6091
6650
  index = uri.lastIndexOf(".");
6651
+ promise = engine.resourceManager.load({
6652
+ url: engineCore.Utils.resolveAbsoluteUrl(url, uri),
6653
+ type: engineCore.AssetType.KTX2
6654
+ }).onProgress(undefined, context._onTaskDetail).then(function(texture) {
6655
+ if (!texture.name) {
6656
+ texture.name = textureName || imageName || "texture_" + index;
6657
+ }
6658
+ if (sampler !== undefined) {
6659
+ GLTFUtils.parseSampler(texture, samplerInfo);
6660
+ }
6661
+ return texture;
6662
+ });
6663
+ context._addTaskCompletePromise(promise);
6092
6664
  return [
6093
6665
  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
- })
6666
+ promise
6106
6667
  ];
6107
6668
  } else {
6108
6669
  bufferView = glTF.bufferViews[bufferViewIndex];
@@ -6172,7 +6733,9 @@ var GALACEAN_materials_remap = /*#__PURE__*/ function(GLTFExtensionParser1) {
6172
6733
  _proto.createAndParse = function createAndParse(context, schema) {
6173
6734
  var engine = context.glTFResource.engine;
6174
6735
  // @ts-ignore
6175
- return engine.resourceManager.getResourceByRef(schema);
6736
+ var promise = engine.resourceManager.getResourceByRef(schema);
6737
+ context._addTaskCompletePromise(promise);
6738
+ return promise;
6176
6739
  };
6177
6740
  return GALACEAN_materials_remap;
6178
6741
  }(GLTFExtensionParser);
@@ -6203,12 +6766,53 @@ GALACEAN_animation_event = __decorate([
6203
6766
  registerGLTFExtension("GALACEAN_animation_event", exports.GLTFExtensionMode.AdditiveParse)
6204
6767
  ], GALACEAN_animation_event);
6205
6768
 
6206
- exports.ComponentMap = ComponentMap;
6769
+ var EXT_meshopt_compression = /*#__PURE__*/ function(GLTFExtensionParser1) {
6770
+ _inherits(EXT_meshopt_compression, GLTFExtensionParser1);
6771
+ function EXT_meshopt_compression() {
6772
+ return GLTFExtensionParser1.apply(this, arguments);
6773
+ }
6774
+ var _proto = EXT_meshopt_compression.prototype;
6775
+ _proto.createAndParse = function createAndParse(context, schema) {
6776
+ return context.get(exports.GLTFParserType.Buffer, schema.buffer).then(function(arrayBuffer) {
6777
+ return MeshoptDecoder.decodeGltfBuffer(schema.count, schema.byteStride, new Uint8Array(arrayBuffer, schema.byteOffset, schema.byteLength), schema.mode, schema.filter);
6778
+ });
6779
+ };
6780
+ return EXT_meshopt_compression;
6781
+ }(GLTFExtensionParser);
6782
+ EXT_meshopt_compression = __decorate([
6783
+ registerGLTFExtension("EXT_meshopt_compression", exports.GLTFExtensionMode.CreateAndParse)
6784
+ ], EXT_meshopt_compression);
6785
+
6786
+ var KHR_materials_anisotropy = /*#__PURE__*/ function(GLTFExtensionParser1) {
6787
+ _inherits(KHR_materials_anisotropy, GLTFExtensionParser1);
6788
+ function KHR_materials_anisotropy() {
6789
+ return GLTFExtensionParser1.apply(this, arguments);
6790
+ }
6791
+ var _proto = KHR_materials_anisotropy.prototype;
6792
+ _proto.additiveParse = function additiveParse(context, material, schema) {
6793
+ 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;
6794
+ material.anisotropy = anisotropyStrength;
6795
+ material.anisotropyRotation = anisotropyRotation;
6796
+ if (anisotropyTexture) {
6797
+ exports.GLTFMaterialParser._checkOtherTextureTransform(anisotropyTexture, "Anisotropy texture");
6798
+ context.get(exports.GLTFParserType.Texture, anisotropyTexture.index).then(function(texture) {
6799
+ material.anisotropyTexture = texture;
6800
+ });
6801
+ }
6802
+ };
6803
+ return KHR_materials_anisotropy;
6804
+ }(GLTFExtensionParser);
6805
+ KHR_materials_anisotropy = __decorate([
6806
+ registerGLTFExtension("KHR_materials_anisotropy", exports.GLTFExtensionMode.AdditiveParse)
6807
+ ], KHR_materials_anisotropy);
6808
+
6809
+ exports.BufferInfo = BufferInfo;
6207
6810
  exports.GLTFExtensionParser = GLTFExtensionParser;
6208
6811
  exports.GLTFParser = GLTFParser;
6209
6812
  exports.GLTFParserContext = GLTFParserContext;
6210
6813
  exports.GLTFResource = GLTFResource;
6211
6814
  exports.GLTFUtils = GLTFUtils;
6815
+ exports.ParserContext = ParserContext;
6212
6816
  exports.PrefabParser = PrefabParser;
6213
6817
  exports.ReflectionParser = ReflectionParser;
6214
6818
  exports.SceneParser = SceneParser;