@galacean/engine-loader 0.0.0-experimental-renderSort.4 → 0.0.0-experimental-stateMachine.0

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