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

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