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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/LICENSE +2 -2
  2. package/dist/main.js +1234 -706
  3. package/dist/main.js.map +1 -1
  4. package/dist/miniprogram.js +1233 -706
  5. package/dist/module.js +1222 -695
  6. package/dist/module.js.map +1 -1
  7. package/package.json +4 -5
  8. package/types/GLTFContentRestorer.d.ts +7 -6
  9. package/types/GLTFLoader.d.ts +7 -1
  10. package/types/gltf/GLTFResource.d.ts +58 -22
  11. package/types/gltf/GLTFSchema.d.ts +1 -1
  12. package/types/gltf/GLTFUtils.d.ts +6 -10
  13. package/types/gltf/extensions/EXT_meshopt_compression.d.ts +13 -0
  14. package/types/gltf/extensions/GLTFExtensionParser.d.ts +1 -1
  15. package/types/gltf/extensions/GLTFExtensionSchema.d.ts +18 -10
  16. package/types/gltf/extensions/KHR_materials_anisotropy.d.ts +1 -0
  17. package/types/gltf/extensions/MeshoptDecoder.d.ts +8 -0
  18. package/types/gltf/extensions/index.d.ts +2 -1
  19. package/types/gltf/index.d.ts +2 -1
  20. package/types/gltf/parser/GLTFAnimatorControllerParser.d.ts +7 -0
  21. package/types/gltf/parser/GLTFBufferViewParser.d.ts +5 -0
  22. package/types/gltf/parser/GLTFMeshParser.d.ts +7 -6
  23. package/types/gltf/parser/GLTFParser.d.ts +1 -1
  24. package/types/gltf/parser/GLTFParserContext.d.ts +23 -7
  25. package/types/gltf/parser/GLTFSchemaParser.d.ts +0 -1
  26. package/types/gltf/parser/index.d.ts +3 -1
  27. package/types/index.d.ts +3 -1
  28. package/types/ktx2/KTX2Loader.d.ts +4 -3
  29. package/types/resource-deserialize/index.d.ts +2 -1
  30. package/types/resource-deserialize/resources/animationClip/AnimationClipDecoder.d.ts +0 -1
  31. package/types/resource-deserialize/resources/parser/HierarchyParser.d.ts +36 -0
  32. package/types/resource-deserialize/resources/parser/ParserContext.d.ts +29 -0
  33. package/types/resource-deserialize/resources/parser/ReflectionParser.d.ts +4 -4
  34. package/types/resource-deserialize/resources/prefab/PrefabParser.d.ts +14 -0
  35. package/types/resource-deserialize/resources/prefab/PrefabParserContext.d.ts +5 -0
  36. package/types/resource-deserialize/resources/scene/SceneParser.d.ts +3 -17
  37. package/types/resource-deserialize/resources/scene/SceneParserContext.d.ts +6 -12
  38. package/types/resource-deserialize/resources/schema/BasicSchema.d.ts +24 -1
  39. package/types/resource-deserialize/resources/schema/SceneSchema.d.ts +9 -1
  40. package/types/gltf/GLTFPipeline.d.ts +0 -23
  41. package/types/resource-deserialize/resources/animationClip/ComponentMap.d.ts +0 -2
  42. package/types/resource-deserialize/resources/parser/PrefabParser.d.ts +0 -5
  43. /package/types/{gltf/extensions/KHR_draco_mesh_compression.d.ts → PrimitiveMeshLoader.d.ts} +0 -0
package/dist/module.js CHANGED
@@ -1,7 +1,6 @@
1
- import { Utils, ModelMesh, BlendShape, Texture2D, Loader, Entity, Transform, Animator, DirectLight, Camera, MeshRenderer, ParticleRenderer, PointLight, SpotLight, Script, SpriteMask, SpriteRenderer, TextRenderer, AnimationClip, AnimationEvent, AnimationRefCurve, Keyframe, AnimationQuaternionCurve, AnimationColorCurve, AnimationVector4Curve, AnimationVector3Curve, AnimationVector2Curve, AnimationFloatArrayCurve, AnimationArrayCurve, AnimationFloatCurve, Scene, resourceLoader, AssetPromise, AssetType, AnimatorController, AnimatorControllerLayer, AnimatorStateMachine, AnimatorStateTransition, TextureCube, TextureFilterMode, TextureCubeFace, AmbientLight, DiffuseMode, Font, ReferResource, IndexFormat, VertexElementFormat, GLCapabilityType, Logger, TextureFormat, request, ContentRestorer, InterpolationType, SkinnedMeshRenderer, PBRMaterial, BlinnPhongMaterial, PBRSpecularMaterial, TextureCoordinate, RenderFace, VertexElement, Buffer, BufferBindFlag, BufferUsage, Skin, TextureWrapMode as TextureWrapMode$1, Material, Shader, SpriteAtlas, Sprite, BackgroundMode, UnlitMaterial } from '@galacean/engine-core';
1
+ import { Utils, ModelMesh, BlendShape, Texture2D, Loader, Entity, AnimationClip, AnimationEvent, AnimationStringCurve, Keyframe, AnimationBoolCurve, AnimationRefCurve, AnimationQuaternionCurve, AnimationColorCurve, AnimationVector4Curve, AnimationVector3Curve, AnimationVector2Curve, AnimationFloatArrayCurve, AnimationArrayCurve, AnimationFloatCurve, Scene, resourceLoader, AssetPromise, AssetType, AnimatorController, AnimatorControllerLayer, AnimatorStateMachine, AnimatorStateTransition, TextureCube, TextureFilterMode, TextureCubeFace, AmbientLight, DiffuseMode, Font, ReferResource, Animator, IndexFormat, VertexElementFormat, GLCapabilityType, Logger, TextureFormat, request, ContentRestorer, InterpolationType, SkinnedMeshRenderer, Transform, PBRMaterial, BlinnPhongMaterial, PBRSpecularMaterial, TextureCoordinate, RenderFace, VertexElement, Buffer, BufferBindFlag, BufferUsage, Camera, MeshRenderer, Skin, TextureWrapMode as TextureWrapMode$1, SystemInfo, Material, Shader, PrimitiveMesh, SpriteAtlas, Sprite, BackgroundMode, DirectLight, PointLight, SpotLight, UnlitMaterial } from '@galacean/engine-core';
2
2
  import { Color, Vector4, Vector3, Vector2, Quaternion, SphericalHarmonics3, MathUtil, BoundingBox, Matrix, Rect } from '@galacean/engine-math';
3
3
  import { GLCompressedTextureInternalFormat } from '@galacean/engine-rhi-webgl';
4
- import { DRACODecoder } from '@galacean/engine-draco';
5
4
 
6
5
  function _extends() {
7
6
  _extends = Object.assign || function assign(target) {
@@ -637,8 +636,7 @@ var ReflectionParser = /*#__PURE__*/ function() {
637
636
  var assetRefId = entityConfig.assetRefId;
638
637
  var engine = this._context.engine;
639
638
  if (assetRefId) {
640
- return engine.resourceManager// @ts-ignore
641
- .getResourceByRef({
639
+ return engine.resourceManager.getResourceByRef({
642
640
  refId: assetRefId,
643
641
  key: entityConfig.key,
644
642
  isClone: entityConfig.isClone
@@ -669,37 +667,373 @@ var ReflectionParser = /*#__PURE__*/ function() {
669
667
  ReflectionParser.customParseComponentHandles = new Map();
670
668
  })();
671
669
 
672
- var PrefabParser = /*#__PURE__*/ function() {
673
- function PrefabParser() {}
674
- PrefabParser.parseChildren = function parseChildren(entitiesConfig, entities, parentId) {
675
- var children = entitiesConfig.get(parentId).children;
670
+ /**
671
+ * Parser context
672
+ * @export
673
+ * @abstract
674
+ * @class ParserContext
675
+ * @template T
676
+ * @template I
677
+ */ var ParserContext = /*#__PURE__*/ function() {
678
+ function ParserContext(originalData, engine, target) {
679
+ this.originalData = originalData;
680
+ this.engine = engine;
681
+ this.target = target;
682
+ this.entityMap = new Map();
683
+ this.components = new Map();
684
+ this.assets = new Map();
685
+ this.entityConfigMap = new Map();
686
+ this.rootIds = [];
687
+ this.strippedIds = [];
688
+ this.resourceManager = engine.resourceManager;
689
+ }
690
+ var _proto = ParserContext.prototype;
691
+ /**
692
+ * Destroy the context.
693
+ * @abstract
694
+ * @memberof ParserContext
695
+ */ _proto.destroy = function destroy() {
696
+ this.entityMap.clear();
697
+ this.components.clear();
698
+ this.assets.clear();
699
+ this.entityConfigMap.clear();
700
+ this.rootIds.length = 0;
701
+ };
702
+ return ParserContext;
703
+ }();
704
+
705
+ var PrefabParserContext = /*#__PURE__*/ function(ParserContext1) {
706
+ _inherits(PrefabParserContext, ParserContext1);
707
+ function PrefabParserContext() {
708
+ return ParserContext1.apply(this, arguments);
709
+ }
710
+ return PrefabParserContext;
711
+ }(ParserContext);
712
+
713
+ function _array_like_to_array(arr, len) {
714
+ if (len == null || len > arr.length) len = arr.length;
715
+
716
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
717
+
718
+ return arr2;
719
+ }
720
+
721
+ function _unsupported_iterable_to_array(o, minLen) {
722
+ if (!o) return;
723
+ if (typeof o === "string") return _array_like_to_array(o, minLen);
724
+
725
+ var n = Object.prototype.toString.call(o).slice(8, -1);
726
+
727
+ if (n === "Object" && o.constructor) n = o.constructor.name;
728
+ if (n === "Map" || n === "Set") return Array.from(n);
729
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
730
+ }
731
+
732
+ function _create_for_of_iterator_helper_loose(o, allowArrayLike) {
733
+ var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
734
+
735
+ if (it) return (it = it.call(o)).next.bind(it);
736
+ // Fallback for engines without symbol support
737
+ if (Array.isArray(o) || (it = _unsupported_iterable_to_array(o)) || allowArrayLike && o && typeof o.length === "number") {
738
+ if (it) o = it;
739
+
740
+ var i = 0;
741
+
742
+ return function() {
743
+ if (i >= o.length) return { done: true };
744
+
745
+ return { done: false, value: o[i++] };
746
+ };
747
+ }
748
+
749
+ throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
750
+ }
751
+
752
+ var HierarchyParser = /*#__PURE__*/ function() {
753
+ function HierarchyParser(context) {
754
+ var _this = this;
755
+ this.context = context;
756
+ this.prefabContextMap = new WeakMap();
757
+ this.prefabPromiseMap = new Map();
758
+ this._engine = this.context.engine;
759
+ this._organizeEntities = this._organizeEntities.bind(this);
760
+ this._parseComponents = this._parseComponents.bind(this);
761
+ this._parsePrefabModification = this._parsePrefabModification.bind(this);
762
+ this._parsePrefabRemovedEntities = this._parsePrefabRemovedEntities.bind(this);
763
+ this._parsePrefabRemovedComponents = this._parsePrefabRemovedComponents.bind(this);
764
+ this._clearAndResolve = this._clearAndResolve.bind(this);
765
+ this.promise = new Promise(function(resolve, reject) {
766
+ _this._reject = reject;
767
+ _this._resolve = resolve;
768
+ });
769
+ this._reflectionParser = new ReflectionParser(context);
770
+ }
771
+ var _proto = HierarchyParser.prototype;
772
+ /** start parse the scene or prefab or others */ _proto.start = function start() {
773
+ 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);
774
+ };
775
+ _proto._parseEntities = function _parseEntities() {
776
+ var _this = this;
777
+ var entitiesConfig = this.context.originalData.entities;
778
+ var entityConfigMap = this.context.entityConfigMap;
779
+ var entityMap = this.context.entityMap;
780
+ var engine = this._engine;
781
+ var promises = entitiesConfig.map(function(entityConfig) {
782
+ var _entityConfig_strippedId;
783
+ var id = (_entityConfig_strippedId = entityConfig.strippedId) != null ? _entityConfig_strippedId : entityConfig.id;
784
+ entityConfig.id = id;
785
+ entityConfigMap.set(id, entityConfig);
786
+ return _this._getEntityByConfig(entityConfig, engine);
787
+ });
788
+ return Promise.all(promises).then(function(entities) {
789
+ for(var i = 0, l = entities.length; i < l; i++){
790
+ entityMap.set(entitiesConfig[i].id, entities[i]);
791
+ }
792
+ return entities;
793
+ });
794
+ };
795
+ _proto._parseComponents = function _parseComponents() {
796
+ var entitiesConfig = this.context.originalData.entities;
797
+ var entityMap = this.context.entityMap;
798
+ var components = this.context.components;
799
+ var promises = [];
800
+ for(var i = 0, l = entitiesConfig.length; i < l; i++){
801
+ var entityConfig = entitiesConfig[i];
802
+ var entity = entityMap.get(entityConfig.id);
803
+ for(var i1 = 0; i1 < entityConfig.components.length; i1++){
804
+ var componentConfig = entityConfig.components[i1];
805
+ var key = !componentConfig.refId ? componentConfig.class : componentConfig.refId;
806
+ var component = entity.addComponent(Loader.getClass(key));
807
+ components.set(componentConfig.id, component);
808
+ var promise = this._reflectionParser.parsePropsAndMethods(component, componentConfig);
809
+ promises.push(promise);
810
+ }
811
+ }
812
+ return Promise.all(promises);
813
+ };
814
+ _proto._parsePrefabModification = function _parsePrefabModification() {
815
+ var _loop = function(i, l) {
816
+ var _modifications;
817
+ var entityConfig = entitiesConfig[i];
818
+ var id = entityConfig.id, modifications = entityConfig.modifications;
819
+ if ((_modifications = modifications) == null ? void 0 : _modifications.length) {
820
+ var _promises;
821
+ var rootEntity = entityMap.get(id);
822
+ (_promises = promises).push.apply(_promises, [].concat(modifications.map(function(modification) {
823
+ var target = modification.target, props = modification.props, methods = modification.methods;
824
+ var entityId = target.entityId, componentId = target.componentId;
825
+ var context = _this.prefabContextMap.get(rootEntity);
826
+ var targetEntity = context.entityMap.get(entityId);
827
+ var targetComponent = context.components.get(componentId);
828
+ if (targetComponent) {
829
+ return _this._reflectionParser.parsePropsAndMethods(targetComponent, {
830
+ props: props,
831
+ methods: methods
832
+ });
833
+ } else if (targetEntity) {
834
+ return Promise.resolve(_this._applyEntityData(targetEntity, props));
835
+ }
836
+ })));
837
+ }
838
+ };
839
+ var _this = this;
840
+ var entitiesConfig = this.context.originalData.entities;
841
+ var entityMap = this.context.entityMap;
842
+ var promises = [];
843
+ for(var i = 0, l = entitiesConfig.length; i < l; i++)_loop(i);
844
+ return Promise.all(promises);
845
+ };
846
+ _proto._parsePrefabRemovedEntities = function _parsePrefabRemovedEntities() {
847
+ var _loop = function(i, l) {
848
+ var _removedEntities;
849
+ var entityConfig = entitiesConfig[i];
850
+ var id = entityConfig.id, removedEntities = entityConfig.removedEntities;
851
+ if ((_removedEntities = removedEntities) == null ? void 0 : _removedEntities.length) {
852
+ var _promises;
853
+ var rootEntity = entityMap.get(id);
854
+ (_promises = promises).push.apply(_promises, [].concat(removedEntities.map(function(target) {
855
+ var entityId = target.entityId;
856
+ var context = _this.prefabContextMap.get(rootEntity);
857
+ var targetEntity = context.entityMap.get(entityId);
858
+ if (targetEntity) {
859
+ targetEntity.destroy();
860
+ }
861
+ })));
862
+ }
863
+ };
864
+ var _this = this;
865
+ var entitiesConfig = this.context.originalData.entities;
866
+ var entityMap = this.context.entityMap;
867
+ var promises = [];
868
+ for(var i = 0, l = entitiesConfig.length; i < l; i++)_loop(i);
869
+ return Promise.all(promises);
870
+ };
871
+ _proto._parsePrefabRemovedComponents = function _parsePrefabRemovedComponents() {
872
+ var _loop = function(i, l) {
873
+ var _removedComponents;
874
+ var entityConfig = entitiesConfig[i];
875
+ var id = entityConfig.id, removedComponents = entityConfig.removedComponents;
876
+ if ((_removedComponents = removedComponents) == null ? void 0 : _removedComponents.length) {
877
+ var _promises;
878
+ var rootEntity = entityMap.get(id);
879
+ (_promises = promises).concat.apply(_promises, [].concat(removedComponents.map(function(target) {
880
+ var componentId = target.componentId;
881
+ var context = _this.prefabContextMap.get(rootEntity);
882
+ var targetComponent = context.components.get(componentId);
883
+ if (targetComponent) {
884
+ targetComponent.destroy();
885
+ }
886
+ })));
887
+ }
888
+ };
889
+ var _this = this;
890
+ var entitiesConfig = this.context.originalData.entities;
891
+ var entityMap = this.context.entityMap;
892
+ var promises = [];
893
+ for(var i = 0, l = entitiesConfig.length; i < l; i++)_loop(i);
894
+ return Promise.all(promises);
895
+ };
896
+ _proto._clearAndResolve = function _clearAndResolve() {
897
+ var target = this.context.target;
898
+ return target;
899
+ };
900
+ _proto._organizeEntities = function _organizeEntities() {
901
+ var _this_context = this.context, rootIds = _this_context.rootIds, strippedIds = _this_context.strippedIds;
902
+ var parentIds = rootIds.concat(strippedIds);
903
+ for(var _iterator = _create_for_of_iterator_helper_loose(parentIds), _step; !(_step = _iterator()).done;){
904
+ var parentId = _step.value;
905
+ this._parseChildren(parentId);
906
+ }
907
+ for(var i = 0; i < rootIds.length; i++){
908
+ this.handleRootEntity(rootIds[i]);
909
+ }
910
+ };
911
+ _proto._getEntityByConfig = function _getEntityByConfig(entityConfig, engine) {
912
+ var _this = this;
913
+ var entityPromise;
914
+ if (entityConfig.assetRefId) {
915
+ entityPromise = this._parseGLTF(entityConfig, engine);
916
+ } else if (entityConfig.strippedId) {
917
+ entityPromise = this._parseStrippedEntity(entityConfig);
918
+ } else {
919
+ entityPromise = this._parseEntity(entityConfig, engine);
920
+ }
921
+ return entityPromise.then(function(entity) {
922
+ return _this._applyEntityData(entity, entityConfig);
923
+ });
924
+ };
925
+ _proto._parseEntity = function _parseEntity(entityConfig, engine) {
926
+ var entity = new Entity(engine, entityConfig.name);
927
+ if (!entityConfig.parent) this.context.rootIds.push(entityConfig.id);
928
+ return Promise.resolve(entity);
929
+ };
930
+ _proto._parseGLTF = function _parseGLTF(entityConfig, engine) {
931
+ var _this = this;
932
+ var assetRefId = entityConfig.assetRefId;
933
+ var context = new ParserContext(null, engine);
934
+ return engine.resourceManager// @ts-ignore
935
+ .getResourceByRef({
936
+ refId: assetRefId
937
+ }).then(function(glTFResource) {
938
+ var entity = glTFResource.instantiateSceneRoot();
939
+ if (!entityConfig.parent) _this.context.rootIds.push(entityConfig.id);
940
+ _this._traverseAddEntityToMap(entity, context, "");
941
+ _this.prefabContextMap.set(entity, context);
942
+ var cbArray = _this.prefabPromiseMap.get(entityConfig.id);
943
+ cbArray && cbArray.forEach(function(cb) {
944
+ cb.resolve(context);
945
+ });
946
+ return entity;
947
+ });
948
+ };
949
+ _proto._parseStrippedEntity = function _parseStrippedEntity(entityConfig) {
950
+ var _this = this;
951
+ this.context.strippedIds.push(entityConfig.id);
952
+ return new Promise(function(resolve, reject) {
953
+ var _this_prefabPromiseMap_get;
954
+ var cbArray = (_this_prefabPromiseMap_get = _this.prefabPromiseMap.get(entityConfig.prefabInstanceId)) != null ? _this_prefabPromiseMap_get : [];
955
+ cbArray.push({
956
+ resolve: resolve,
957
+ reject: reject
958
+ });
959
+ _this.prefabPromiseMap.set(entityConfig.prefabInstanceId, cbArray);
960
+ }).then(function(context) {
961
+ var entityId = entityConfig.prefabSource.entityId;
962
+ return context.entityMap.get(entityId);
963
+ });
964
+ };
965
+ _proto._parseChildren = function _parseChildren(parentId) {
966
+ var _this_context = this.context, entityConfigMap = _this_context.entityConfigMap, entityMap = _this_context.entityMap;
967
+ var children = entityConfigMap.get(parentId).children;
676
968
  if (children && children.length > 0) {
677
- var parent = entities.get(parentId);
969
+ var parent = entityMap.get(parentId);
678
970
  for(var i = 0; i < children.length; i++){
679
971
  var childId = children[i];
680
- var entity = entities.get(childId);
972
+ var entity = entityMap.get(childId);
681
973
  parent.addChild(entity);
682
- this.parseChildren(entitiesConfig, entities, childId);
974
+ this._parseChildren(childId);
683
975
  }
684
976
  }
685
977
  };
686
- return PrefabParser;
978
+ _proto._applyEntityData = function _applyEntityData(entity, entityConfig) {
979
+ if (entityConfig === void 0) entityConfig = {};
980
+ var _entityConfig_isActive;
981
+ entity.isActive = (_entityConfig_isActive = entityConfig.isActive) != null ? _entityConfig_isActive : entity.isActive;
982
+ var _entityConfig_name;
983
+ entity.name = (_entityConfig_name = entityConfig.name) != null ? _entityConfig_name : entity.name;
984
+ var position = entityConfig.position, rotation = entityConfig.rotation, scale = entityConfig.scale, layer = entityConfig.layer;
985
+ if (position) entity.transform.position.copyFrom(position);
986
+ if (rotation) entity.transform.rotation.copyFrom(rotation);
987
+ if (scale) entity.transform.scale.copyFrom(scale);
988
+ if (layer) entity.layer = layer;
989
+ return entity;
990
+ };
991
+ _proto._traverseAddEntityToMap = function _traverseAddEntityToMap(entity, context, path) {
992
+ var entityMap = context.entityMap, components = context.components;
993
+ var componentsMap = {};
994
+ var componentIndexMap = {};
995
+ entityMap.set(path, entity);
996
+ // @ts-ignore
997
+ entity._components.forEach(function(component) {
998
+ // @ts-ignore
999
+ var name = Loader.getClassName(component.constructor);
1000
+ if (!componentsMap[name]) {
1001
+ componentsMap[name] = entity.getComponents(component.constructor, []);
1002
+ componentIndexMap[name] = 0;
1003
+ }
1004
+ components.set(path + ":" + name + "/" + componentIndexMap[name]++, component);
1005
+ });
1006
+ for(var i = 0, n = entity.children.length; i < n; i++){
1007
+ var child = entity.children[i];
1008
+ var childPath = path ? path + "/" + i : "" + i;
1009
+ this._traverseAddEntityToMap(child, context, childPath);
1010
+ }
1011
+ };
1012
+ return HierarchyParser;
687
1013
  }();
688
1014
 
689
- var ComponentMap = {
690
- Transform: Transform,
691
- Animator: Animator,
692
- DirectLight: DirectLight,
693
- Camera: Camera,
694
- MeshRenderer: MeshRenderer,
695
- ParticleRenderer: ParticleRenderer,
696
- PointLight: PointLight,
697
- SpotLight: SpotLight,
698
- Script: Script,
699
- SpriteMask: SpriteMask,
700
- SpriteRenderer: SpriteRenderer,
701
- TextRenderer: TextRenderer
702
- };
1015
+ var PrefabParser = /*#__PURE__*/ function(HierarchyParser1) {
1016
+ _inherits(PrefabParser, HierarchyParser1);
1017
+ function PrefabParser() {
1018
+ return HierarchyParser1.apply(this, arguments);
1019
+ }
1020
+ var _proto = PrefabParser.prototype;
1021
+ _proto.handleRootEntity = function handleRootEntity(id) {
1022
+ this.context.target = this.context.entityMap.get(id);
1023
+ };
1024
+ /**
1025
+ * Parse prefab data.
1026
+ * @param engine - the engine of the parser context
1027
+ * @param prefabData - prefab data which is exported by editor
1028
+ * @returns a promise of prefab
1029
+ */ PrefabParser.parse = function parse(engine, prefabData) {
1030
+ var context = new PrefabParserContext(prefabData, engine);
1031
+ var parser = new PrefabParser(context);
1032
+ parser.start();
1033
+ return parser;
1034
+ };
1035
+ return PrefabParser;
1036
+ }(HierarchyParser);
703
1037
 
704
1038
  var InterpolableValueType;
705
1039
  (function(InterpolableValueType) {
@@ -733,8 +1067,9 @@ var AnimationClipDecoder = /*#__PURE__*/ function() {
733
1067
  for(var i1 = 0; i1 < curveBindingsLen; ++i1){
734
1068
  var relativePath = bufferReader.nextStr();
735
1069
  var componentStr = bufferReader.nextStr();
736
- var componentType = ComponentMap[componentStr];
1070
+ var componentType = Loader.getClass(componentStr);
737
1071
  var property = bufferReader.nextStr();
1072
+ var getProperty = bufferReader.nextStr();
738
1073
  var curve = void 0;
739
1074
  var interpolation = bufferReader.nextUint8();
740
1075
  var keysLen = bufferReader.nextUint16();
@@ -859,13 +1194,42 @@ var AnimationClipDecoder = /*#__PURE__*/ function() {
859
1194
  for(var j7 = 0; j7 < keysLen; ++j7){
860
1195
  var keyframe8 = new Keyframe();
861
1196
  keyframe8.time = bufferReader.nextFloat32();
862
- keyframe8.value = JSON.parse(bufferReader.nextStr());
1197
+ var str = bufferReader.nextStr();
1198
+ if (str) {
1199
+ keyframe8.value = JSON.parse(str);
1200
+ } else {
1201
+ keyframe8.value = null;
1202
+ }
863
1203
  curve.addKey(keyframe8);
864
1204
  }
865
1205
  break;
866
1206
  }
1207
+ case "AnimationBoolCurve":
1208
+ {
1209
+ curve = new AnimationBoolCurve();
1210
+ curve.interpolation = interpolation;
1211
+ for(var j8 = 0; j8 < keysLen; ++j8){
1212
+ var keyframe9 = new Keyframe();
1213
+ keyframe9.time = bufferReader.nextFloat32();
1214
+ keyframe9.value = bufferReader.nextUint8() === 1;
1215
+ curve.addKey(keyframe9);
1216
+ }
1217
+ break;
1218
+ }
1219
+ case "AnimationStringCurve":
1220
+ {
1221
+ curve = new AnimationStringCurve();
1222
+ curve.interpolation = interpolation;
1223
+ for(var j9 = 0; j9 < keysLen; ++j9){
1224
+ var keyframe10 = new Keyframe();
1225
+ keyframe10.time = bufferReader.nextFloat32();
1226
+ keyframe10.value = bufferReader.nextStr();
1227
+ curve.addKey(keyframe10);
1228
+ }
1229
+ break;
1230
+ }
867
1231
  }
868
- clip.addCurveBinding(relativePath, componentType, property, curve);
1232
+ clip.addCurveBinding(relativePath, componentType, property, getProperty, curve);
869
1233
  }
870
1234
  resolve(clip);
871
1235
  });
@@ -882,145 +1246,28 @@ var SpecularMode;
882
1246
  SpecularMode["Custom"] = "Custom";
883
1247
  })(SpecularMode || (SpecularMode = {}));
884
1248
 
885
- function _array_like_to_array(arr, len) {
886
- if (len == null || len > arr.length) len = arr.length;
887
-
888
- for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
889
-
890
- return arr2;
891
- }
892
-
893
- function _unsupported_iterable_to_array(o, minLen) {
894
- if (!o) return;
895
- if (typeof o === "string") return _array_like_to_array(o, minLen);
896
-
897
- var n = Object.prototype.toString.call(o).slice(8, -1);
898
-
899
- if (n === "Object" && o.constructor) n = o.constructor.name;
900
- if (n === "Map" || n === "Set") return Array.from(n);
901
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
902
- }
903
-
904
- function _create_for_of_iterator_helper_loose(o, allowArrayLike) {
905
- var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
906
-
907
- if (it) return (it = it.call(o)).next.bind(it);
908
- // Fallback for engines without symbol support
909
- if (Array.isArray(o) || (it = _unsupported_iterable_to_array(o)) || allowArrayLike && o && typeof o.length === "number") {
910
- if (it) o = it;
911
-
912
- var i = 0;
913
-
914
- return function() {
915
- if (i >= o.length) return { done: true };
916
-
917
- return { done: false, value: o[i++] };
918
- };
919
- }
920
-
921
- throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
922
- }
923
-
924
- var SceneParserContext = /*#__PURE__*/ function() {
925
- function SceneParserContext(originalData, scene) {
926
- this.originalData = originalData;
927
- this.scene = scene;
928
- this.entityMap = new Map();
929
- this.components = new Map();
930
- this.assets = new Map();
931
- this.entityConfigMap = new Map();
932
- this.rootIds = [];
933
- this.engine = scene.engine;
934
- this.resourceManager = scene.engine.resourceManager;
1249
+ var SceneParserContext = /*#__PURE__*/ function(ParserContext1) {
1250
+ _inherits(SceneParserContext, ParserContext1);
1251
+ function SceneParserContext(originalData, engine, scene) {
1252
+ var _this;
1253
+ _this = ParserContext1.call(this, originalData, engine, scene) || this;
1254
+ _this.originalData = originalData;
1255
+ _this.engine = engine;
1256
+ _this.scene = scene;
1257
+ return _this;
935
1258
  }
936
- var _proto = SceneParserContext.prototype;
937
- _proto.destroy = function destroy() {
938
- this.entityMap.clear();
939
- this.components.clear();
940
- this.assets.clear();
941
- this.entityConfigMap.clear();
942
- this.rootIds.length = 0;
943
- };
944
1259
  return SceneParserContext;
945
- }();
1260
+ }(ParserContext);
946
1261
 
947
- /** @Internal */ var SceneParser = /*#__PURE__*/ function() {
948
- function SceneParser(context) {
949
- var _this = this;
950
- this.context = context;
951
- this._engine = context.scene.engine;
952
- this._organizeEntities = this._organizeEntities.bind(this);
953
- this._parseComponents = this._parseComponents.bind(this);
954
- this._clearAndResolveScene = this._clearAndResolveScene.bind(this);
955
- this.promise = new Promise(function(resolve, reject) {
956
- _this._reject = reject;
957
- _this._resolve = resolve;
958
- });
959
- this._reflectionParser = new ReflectionParser(context);
1262
+ /** @Internal */ var SceneParser = /*#__PURE__*/ function(HierarchyParser1) {
1263
+ _inherits(SceneParser, HierarchyParser1);
1264
+ function SceneParser() {
1265
+ return HierarchyParser1.apply(this, arguments);
960
1266
  }
961
1267
  var _proto = SceneParser.prototype;
962
- /** start parse the scene */ _proto.start = function start() {
963
- this._parseEntities().then(this._organizeEntities).then(this._parseComponents).then(this._clearAndResolveScene).then(this._resolve).catch(this._reject);
964
- };
965
- _proto._parseEntities = function _parseEntities() {
966
- var _this = this;
967
- var entitiesConfig = this.context.originalData.entities;
968
- var entityConfigMap = this.context.entityConfigMap;
969
- var entitiesMap = this.context.entityMap;
970
- var rootIds = this.context.rootIds;
971
- this._engine;
972
- var promises = entitiesConfig.map(function(entityConfig) {
973
- entityConfigMap.set(entityConfig.id, entityConfig);
974
- // record root entities
975
- if (!entityConfig.parent) rootIds.push(entityConfig.id);
976
- return _this._reflectionParser.parseEntity(entityConfig);
977
- });
978
- return Promise.all(promises).then(function(entities) {
979
- for(var i = 0, l = entities.length; i < l; i++){
980
- entitiesMap.set(entitiesConfig[i].id, entities[i]);
981
- }
982
- return entities;
983
- });
984
- };
985
- _proto._organizeEntities = function _organizeEntities() {
986
- var _this_context = this.context, entityConfigMap = _this_context.entityConfigMap, entityMap = _this_context.entityMap, scene = _this_context.scene, rootIds = _this_context.rootIds;
987
- for(var _iterator = _create_for_of_iterator_helper_loose(rootIds), _step; !(_step = _iterator()).done;){
988
- var rootId = _step.value;
989
- PrefabParser.parseChildren(entityConfigMap, entityMap, rootId);
990
- }
991
- var rootEntities = rootIds.map(function(id) {
992
- return entityMap.get(id);
993
- });
994
- for(var i = 0; i < rootEntities.length; i++){
995
- scene.addRootEntity(rootEntities[i]);
996
- }
997
- };
998
- _proto._parseComponents = function _parseComponents() {
999
- var entitiesConfig = this.context.originalData.entities;
1000
- var entityMap = this.context.entityMap;
1001
- var promises = [];
1002
- for(var i = 0, l = entitiesConfig.length; i < l; i++){
1003
- var entityConfig = entitiesConfig[i];
1004
- var entity = entityMap.get(entityConfig.id);
1005
- for(var i1 = 0; i1 < entityConfig.components.length; i1++){
1006
- var componentConfig = entityConfig.components[i1];
1007
- var key = !componentConfig.refId ? componentConfig.class : componentConfig.refId;
1008
- var component = void 0;
1009
- // TODO: remove hack code when support additional edit
1010
- if (key === "Animator") {
1011
- component = entity.getComponent(Loader.getClass(key));
1012
- }
1013
- component = component || entity.addComponent(Loader.getClass(key));
1014
- var promise = this._reflectionParser.parsePropsAndMethods(component, componentConfig);
1015
- promises.push(promise);
1016
- }
1017
- }
1018
- return Promise.all(promises);
1019
- };
1020
- _proto._clearAndResolveScene = function _clearAndResolveScene() {
1021
- var scene = this.context.scene;
1022
- this.context.destroy();
1023
- return scene;
1268
+ _proto.handleRootEntity = function handleRootEntity(id) {
1269
+ var _this_context = this.context, target = _this_context.target, entityMap = _this_context.entityMap;
1270
+ target.addRootEntity(entityMap.get(id));
1024
1271
  };
1025
1272
  /**
1026
1273
  * Parse scene data.
@@ -1029,13 +1276,13 @@ var SceneParserContext = /*#__PURE__*/ function() {
1029
1276
  * @returns a promise of scene
1030
1277
  */ SceneParser.parse = function parse(engine, sceneData) {
1031
1278
  var scene = new Scene(engine);
1032
- var context = new SceneParserContext(sceneData, scene);
1279
+ var context = new SceneParserContext(sceneData, engine, scene);
1033
1280
  var parser = new SceneParser(context);
1034
1281
  parser.start();
1035
1282
  return parser.promise;
1036
1283
  };
1037
1284
  return SceneParser;
1038
- }();
1285
+ }(HierarchyParser);
1039
1286
 
1040
1287
  var MeshLoader$1 = /*#__PURE__*/ function(Loader1) {
1041
1288
  _inherits(MeshLoader, Loader1);
@@ -1119,26 +1366,34 @@ var AnimationClipLoader = /*#__PURE__*/ function(Loader1) {
1119
1366
  var curveBindingPromises = clip.curveBindings.map(function(curveBinding) {
1120
1367
  var curve = curveBinding.curve;
1121
1368
  var promises = curve.keys.map(function(key) {
1122
- var value = key.value;
1123
- if (typeof value === "object" && value.refId) {
1124
- return new Promise(function(resolve) {
1125
- resourceManager// @ts-ignore
1126
- .getResourceByRef(value).then(function(asset) {
1127
- key.value = asset;
1128
- resolve(key);
1129
- }).catch(reject);
1130
- });
1131
- }
1369
+ return _this._parseKeyframeValue(key, resourceManager).then(function(actualValue) {
1370
+ key.value = actualValue;
1371
+ });
1132
1372
  });
1133
1373
  return Promise.all(promises);
1134
1374
  });
1135
1375
  return Promise.all(curveBindingPromises).then(function() {
1136
1376
  resolve(clip);
1137
1377
  });
1138
- });
1378
+ }).catch(reject);
1139
1379
  }).catch(reject);
1140
1380
  });
1141
1381
  };
1382
+ _proto._parseKeyframeValue = function _parseKeyframeValue(keyframe, resourceManager) {
1383
+ var _value;
1384
+ var value = keyframe.value;
1385
+ if (typeof value === "object" && ((_value = value) == null ? void 0 : _value.refId)) {
1386
+ return new Promise(function(resolve) {
1387
+ resourceManager// @ts-ignore
1388
+ .getResourceByRef(value).then(function(asset) {
1389
+ keyframe.value = asset;
1390
+ resolve(keyframe.value);
1391
+ });
1392
+ });
1393
+ } else {
1394
+ return Promise.resolve(keyframe.value);
1395
+ }
1396
+ };
1142
1397
  return AnimationClipLoader;
1143
1398
  }(Loader);
1144
1399
  AnimationClipLoader = __decorate([
@@ -1414,6 +1669,60 @@ FontLoader = __decorate([
1414
1669
  _this.url = url;
1415
1670
  return _this;
1416
1671
  }
1672
+ var _proto = GLTFResource.prototype;
1673
+ /**
1674
+ * Instantiate scene root entity.
1675
+ * @param sceneIndex - Scene index
1676
+ * @returns Root entity
1677
+ */ _proto.instantiateSceneRoot = function instantiateSceneRoot(sceneIndex) {
1678
+ var sceneRoot = sceneIndex === undefined ? this._defaultSceneRoot : this._sceneRoots[sceneIndex];
1679
+ return sceneRoot.clone();
1680
+ };
1681
+ _proto._onDestroy = function _onDestroy() {
1682
+ ReferResource1.prototype._onDestroy.call(this);
1683
+ var _this = this, textures = _this.textures, materials = _this.materials, meshes = _this.meshes;
1684
+ textures && this._disassociationSuperResource(textures);
1685
+ materials && this._disassociationSuperResource(materials);
1686
+ if (meshes) {
1687
+ for(var i = 0, n = meshes.length; i < n; i++){
1688
+ this._disassociationSuperResource(meshes[i]);
1689
+ }
1690
+ }
1691
+ };
1692
+ _proto._disassociationSuperResource = function _disassociationSuperResource(resources) {
1693
+ for(var i = 0, n = resources.length; i < n; i++){
1694
+ // @ts-ignore
1695
+ resources[i]._disassociationSuperResource(this);
1696
+ }
1697
+ };
1698
+ _create_class(GLTFResource, [
1699
+ {
1700
+ key: "extensionsData",
1701
+ get: /**
1702
+ * Extensions data.
1703
+ */ function get() {
1704
+ return this._extensionsData;
1705
+ }
1706
+ },
1707
+ {
1708
+ key: "sceneRoots",
1709
+ get: /**
1710
+ * @deprecated Please use `instantiateSceneRoot` instead.
1711
+ * RootEntities after SceneParser.
1712
+ */ function get() {
1713
+ return this._sceneRoots;
1714
+ }
1715
+ },
1716
+ {
1717
+ key: "defaultSceneRoot",
1718
+ get: /**
1719
+ * @deprecated Please use `instantiateSceneRoot` instead.
1720
+ * RootEntity after SceneParser.
1721
+ */ function get() {
1722
+ return this._defaultSceneRoot;
1723
+ }
1724
+ }
1725
+ ]);
1417
1726
  return GLTFResource;
1418
1727
  }(ReferResource);
1419
1728
 
@@ -1568,11 +1877,29 @@ var TextureWrapMode;
1568
1877
  * @internal
1569
1878
  */ var GLTFParserContext = /*#__PURE__*/ function() {
1570
1879
  function GLTFParserContext(glTFResource, resourceManager, params) {
1880
+ var _this = this;
1571
1881
  this.glTFResource = glTFResource;
1572
1882
  this.resourceManager = resourceManager;
1573
1883
  this.params = params;
1574
1884
  this.accessorBufferCache = {};
1885
+ this.needAnimatorController = false;
1575
1886
  this._resourceCache = new Map();
1887
+ this._progress = {
1888
+ taskDetail: {},
1889
+ taskComplete: {
1890
+ loaded: 0,
1891
+ total: 0
1892
+ }
1893
+ };
1894
+ this./**
1895
+ * @internal
1896
+ */ _onTaskDetail = function(url, loaded, total) {
1897
+ var _this__progress_taskDetail, _url;
1898
+ var detail = (_this__progress_taskDetail = _this._progress.taskDetail)[_url = url] || (_this__progress_taskDetail[_url] = {});
1899
+ detail.loaded = loaded;
1900
+ detail.total = total;
1901
+ _this._setTaskDetailProgress(url, loaded, total);
1902
+ };
1576
1903
  this.contentRestorer = new GLTFContentRestorer(glTFResource);
1577
1904
  }
1578
1905
  var _proto = GLTFParserContext.prototype;
@@ -1583,91 +1910,90 @@ var TextureWrapMode;
1583
1910
  return Promise.resolve(null);
1584
1911
  }
1585
1912
  var cache = this._resourceCache;
1586
- var isOnlyOne = type === 0 || type === 1;
1587
- var cacheKey = isOnlyOne || index === undefined ? "" + type : type + ":" + index;
1913
+ var cacheKey = index === undefined ? "" + type : type + ":" + index;
1588
1914
  var resource = cache.get(cacheKey);
1589
1915
  if (resource) {
1590
1916
  return resource;
1591
1917
  }
1592
- if (isOnlyOne) {
1593
- resource = parser.parse(this);
1594
- } else {
1595
- var glTFItems = this.glTF[glTFSchemaMap[type]];
1918
+ var glTFSchemaKey = glTFSchemaMap[type];
1919
+ var isSubAsset = !!glTFResourceMap[type];
1920
+ if (glTFSchemaKey) {
1921
+ var glTFItems = this.glTF[glTFSchemaKey];
1596
1922
  if (glTFItems && (index === undefined || glTFItems[index])) {
1597
1923
  if (index === undefined) {
1598
- resource = type === 7 ? glTFItems.map(function(_, index) {
1924
+ resource = type === 8 ? glTFItems.map(function(_, index) {
1599
1925
  return _this.get(type, index);
1600
1926
  }) : Promise.all(glTFItems.map(function(_, index) {
1601
1927
  return _this.get(type, index);
1602
1928
  }));
1603
1929
  } else {
1604
1930
  resource = parser.parse(this, index);
1605
- this._handleSubAsset(resource, type, index);
1931
+ isSubAsset && this._handleSubAsset(resource, type, index);
1606
1932
  }
1607
1933
  } else {
1608
1934
  resource = Promise.resolve(null);
1609
1935
  }
1936
+ } else {
1937
+ resource = parser.parse(this, index);
1938
+ isSubAsset && this._handleSubAsset(resource, type, index);
1610
1939
  }
1611
1940
  cache.set(cacheKey, resource);
1612
1941
  return resource;
1613
1942
  };
1614
1943
  _proto.parse = function parse() {
1615
1944
  var _this = this;
1616
- return this.get(0).then(function(json) {
1945
+ var promise = this.get(0).then(function(json) {
1617
1946
  _this.glTF = json;
1947
+ _this.needAnimatorController = !!(json.skins || json.animations);
1618
1948
  return Promise.all([
1619
1949
  _this.get(1),
1620
- _this.get(4),
1621
1950
  _this.get(5),
1622
1951
  _this.get(6),
1623
- _this.get(8),
1952
+ _this.get(7),
1624
1953
  _this.get(9),
1954
+ _this.get(10),
1955
+ _this.get(11),
1625
1956
  _this.get(2)
1626
1957
  ]).then(function() {
1627
1958
  var glTFResource = _this.glTFResource;
1628
- if (glTFResource.skins || glTFResource.animations) {
1629
- _this._createAnimator(_this, glTFResource.animations);
1959
+ var animatorController = glTFResource.animatorController;
1960
+ if (animatorController) {
1961
+ var animator = glTFResource._defaultSceneRoot.addComponent(Animator);
1962
+ animator.animatorController = animatorController;
1630
1963
  }
1631
1964
  _this.resourceManager.addContentRestorer(_this.contentRestorer);
1632
1965
  return glTFResource;
1633
1966
  });
1634
1967
  });
1968
+ this._addTaskCompletePromise(promise);
1969
+ return promise;
1635
1970
  };
1636
- _proto._createAnimator = function _createAnimator(context, animations) {
1637
- var defaultSceneRoot = context.glTFResource.defaultSceneRoot;
1638
- var animator = defaultSceneRoot.addComponent(Animator);
1639
- var animatorController = new AnimatorController();
1640
- var layer = new AnimatorControllerLayer("layer");
1641
- var animatorStateMachine = new AnimatorStateMachine();
1642
- animatorController.addLayer(layer);
1643
- animator.animatorController = animatorController;
1644
- layer.stateMachine = animatorStateMachine;
1645
- if (animations) {
1646
- for(var i = 0; i < animations.length; i++){
1647
- var animationClip = animations[i];
1648
- var name = animationClip.name;
1649
- var uniqueName = animatorStateMachine.makeUniqueStateName(name);
1650
- if (uniqueName !== name) {
1651
- console.warn("AnimatorState name is existed, name: " + name + " reset to " + uniqueName);
1652
- }
1653
- var animatorState = animatorStateMachine.addState(uniqueName);
1654
- animatorState.clip = animationClip;
1655
- }
1656
- }
1971
+ /**
1972
+ * @internal
1973
+ */ _proto._addTaskCompletePromise = function _addTaskCompletePromise(taskPromise) {
1974
+ var _this = this;
1975
+ var task = this._progress.taskComplete;
1976
+ task.total += 1;
1977
+ taskPromise.then(function() {
1978
+ _this._setTaskCompleteProgress(++task.loaded, task.total);
1979
+ });
1657
1980
  };
1658
1981
  _proto._handleSubAsset = function _handleSubAsset(resource, type, index) {
1659
1982
  var _this = this;
1660
1983
  var glTFResourceKey = glTFResourceMap[type];
1661
- if (!glTFResourceKey) return;
1662
- if (type === 7) {
1984
+ if (type === 8) {
1663
1985
  var _this_glTFResource, _glTFResourceKey;
1664
1986
  ((_this_glTFResource = this.glTFResource)[_glTFResourceKey = glTFResourceKey] || (_this_glTFResource[_glTFResourceKey] = []))[index] = resource;
1665
1987
  } else {
1666
1988
  var url = this.glTFResource.url;
1667
1989
  resource.then(function(item) {
1668
- var _this_glTFResource, _glTFResourceKey;
1669
- ((_this_glTFResource = _this.glTFResource)[_glTFResourceKey = glTFResourceKey] || (_this_glTFResource[_glTFResourceKey] = []))[index] = item;
1670
- if (type === 6) {
1990
+ if (index == undefined) {
1991
+ _this.glTFResource[glTFResourceKey] = item;
1992
+ } else {
1993
+ var _this_glTFResource, _glTFResourceKey;
1994
+ ((_this_glTFResource = _this.glTFResource)[_glTFResourceKey = glTFResourceKey] || (_this_glTFResource[_glTFResourceKey] = []))[index] = item;
1995
+ }
1996
+ if (type === 7) {
1671
1997
  for(var i = 0, length = item.length; i < length; i++){
1672
1998
  var mesh = item[i];
1673
1999
  // @ts-ignore
@@ -1707,17 +2033,19 @@ var GLTFParserType;
1707
2033
  GLTFParserType[GLTFParserType["Validator"] = 1] = "Validator";
1708
2034
  GLTFParserType[GLTFParserType["Scene"] = 2] = "Scene";
1709
2035
  GLTFParserType[GLTFParserType["Buffer"] = 3] = "Buffer";
1710
- GLTFParserType[GLTFParserType["Texture"] = 4] = "Texture";
1711
- GLTFParserType[GLTFParserType["Material"] = 5] = "Material";
1712
- GLTFParserType[GLTFParserType["Mesh"] = 6] = "Mesh";
1713
- GLTFParserType[GLTFParserType["Entity"] = 7] = "Entity";
1714
- GLTFParserType[GLTFParserType["Skin"] = 8] = "Skin";
1715
- GLTFParserType[GLTFParserType["Animation"] = 9] = "Animation";
2036
+ GLTFParserType[GLTFParserType["BufferView"] = 4] = "BufferView";
2037
+ GLTFParserType[GLTFParserType["Texture"] = 5] = "Texture";
2038
+ GLTFParserType[GLTFParserType["Material"] = 6] = "Material";
2039
+ GLTFParserType[GLTFParserType["Mesh"] = 7] = "Mesh";
2040
+ GLTFParserType[GLTFParserType["Entity"] = 8] = "Entity";
2041
+ GLTFParserType[GLTFParserType["Skin"] = 9] = "Skin";
2042
+ GLTFParserType[GLTFParserType["Animation"] = 10] = "Animation";
2043
+ GLTFParserType[GLTFParserType["AnimatorController"] = 11] = "AnimatorController";
1716
2044
  })(GLTFParserType || (GLTFParserType = {}));
1717
2045
  var _obj;
1718
- 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);
2046
+ 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);
1719
2047
  var _obj1;
1720
- 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);
2048
+ var glTFResourceMap = (_obj1 = {}, _obj1[2] = "_sceneRoots", _obj1[5] = "textures", _obj1[6] = "materials", _obj1[7] = "meshes", _obj1[8] = "entities", _obj1[9] = "skins", _obj1[10] = "animations", _obj1[11] = "animatorController", _obj1);
1721
2049
  function registerGLTFParser(pipeline) {
1722
2050
  return function(Parser) {
1723
2051
  var parser = new Parser();
@@ -1822,110 +2150,68 @@ function registerGLTFParser(pipeline) {
1822
2150
  };
1823
2151
  GLTFUtils.getAccessorBuffer = function getAccessorBuffer(context, bufferViews, accessor) {
1824
2152
  var componentType = accessor.componentType;
1825
- var bufferView = bufferViews[accessor.bufferView];
1826
- return context.get(GLTFParserType.Buffer).then(function(buffers) {
1827
- var bufferIndex = bufferView.buffer;
1828
- var buffer = buffers[bufferIndex];
1829
- var _bufferView_byteOffset;
1830
- var bufferByteOffset = (_bufferView_byteOffset = bufferView.byteOffset) != null ? _bufferView_byteOffset : 0;
1831
- var _accessor_byteOffset;
1832
- var byteOffset = (_accessor_byteOffset = accessor.byteOffset) != null ? _accessor_byteOffset : 0;
1833
- var TypedArray = GLTFUtils.getComponentType(componentType);
1834
- var dataElementSize = GLTFUtils.getAccessorTypeSize(accessor.type);
1835
- var dataElementBytes = TypedArray.BYTES_PER_ELEMENT;
1836
- var elementStride = dataElementSize * dataElementBytes;
1837
- var accessorCount = accessor.count;
1838
- var bufferStride = bufferView.byteStride;
1839
- var bufferInfo;
1840
- // According to the glTF official documentation only byteStride not undefined is allowed
1841
- if (bufferStride !== undefined && bufferStride !== elementStride) {
1842
- var bufferSlice = Math.floor(byteOffset / bufferStride);
1843
- var bufferCacheKey = accessor.bufferView + ":" + componentType + ":" + bufferSlice + ":" + accessorCount;
1844
- var accessorBufferCache = context.accessorBufferCache;
1845
- bufferInfo = accessorBufferCache[bufferCacheKey];
1846
- if (!bufferInfo) {
1847
- var offset = bufferByteOffset + bufferSlice * bufferStride;
1848
- var count = accessorCount * (bufferStride / dataElementBytes);
1849
- var data = new TypedArray(buffer, offset, count);
1850
- accessorBufferCache[bufferCacheKey] = bufferInfo = new BufferInfo(data, true, bufferStride);
1851
- bufferInfo.restoreInfo = new BufferDataRestoreInfo(new RestoreDataAccessor(bufferIndex, TypedArray, offset, count));
2153
+ var TypedArray = GLTFUtils.getComponentType(componentType);
2154
+ var dataElementSize = GLTFUtils.getAccessorTypeSize(accessor.type);
2155
+ var dataElementBytes = TypedArray.BYTES_PER_ELEMENT;
2156
+ var elementStride = dataElementSize * dataElementBytes;
2157
+ var accessorCount = accessor.count;
2158
+ var promise;
2159
+ if (accessor.bufferView !== undefined) {
2160
+ var bufferViewIndex = accessor.bufferView;
2161
+ var bufferView = bufferViews[bufferViewIndex];
2162
+ promise = context.get(GLTFParserType.BufferView, accessor.bufferView).then(function(bufferViewData) {
2163
+ var bufferIndex = bufferView.buffer;
2164
+ var _bufferViewData_byteOffset;
2165
+ var bufferByteOffset = (_bufferViewData_byteOffset = bufferViewData.byteOffset) != null ? _bufferViewData_byteOffset : 0;
2166
+ var _accessor_byteOffset;
2167
+ var byteOffset = (_accessor_byteOffset = accessor.byteOffset) != null ? _accessor_byteOffset : 0;
2168
+ var bufferStride = bufferView.byteStride;
2169
+ var bufferInfo;
2170
+ // According to the glTF official documentation only byteStride not undefined is allowed
2171
+ if (bufferStride !== undefined && bufferStride !== elementStride) {
2172
+ var bufferSlice = Math.floor(byteOffset / bufferStride);
2173
+ var bufferCacheKey = bufferViewIndex + ":" + componentType + ":" + bufferSlice + ":" + accessorCount;
2174
+ var accessorBufferCache = context.accessorBufferCache;
2175
+ bufferInfo = accessorBufferCache[bufferCacheKey];
2176
+ if (!bufferInfo) {
2177
+ var offset = bufferByteOffset + bufferSlice * bufferStride;
2178
+ var count = accessorCount * (bufferStride / dataElementBytes);
2179
+ var data = new TypedArray(bufferViewData.buffer, offset, count);
2180
+ accessorBufferCache[bufferCacheKey] = bufferInfo = new BufferInfo(data, true, bufferStride);
2181
+ bufferInfo.restoreInfo = new BufferDataRestoreInfo(new RestoreDataAccessor(bufferIndex, TypedArray, offset, count));
2182
+ }
2183
+ } else {
2184
+ var offset1 = bufferByteOffset + byteOffset;
2185
+ var count1 = accessorCount * dataElementSize;
2186
+ var data1 = new TypedArray(bufferViewData.buffer, offset1, count1);
2187
+ bufferInfo = new BufferInfo(data1, false, elementStride);
2188
+ bufferInfo.restoreInfo = new BufferDataRestoreInfo(new RestoreDataAccessor(bufferIndex, TypedArray, offset1, count1));
1852
2189
  }
1853
- } else {
1854
- var offset1 = bufferByteOffset + byteOffset;
1855
- var count1 = accessorCount * dataElementSize;
1856
- var data1 = new TypedArray(buffer, offset1, count1);
1857
- bufferInfo = new BufferInfo(data1, false, elementStride);
1858
- bufferInfo.restoreInfo = new BufferDataRestoreInfo(new RestoreDataAccessor(bufferIndex, TypedArray, offset1, count1));
1859
- }
1860
- if (accessor.sparse) {
1861
- GLTFUtils.processingSparseData(bufferViews, accessor, buffers, bufferInfo);
1862
- }
1863
- return bufferInfo;
1864
- });
2190
+ return bufferInfo;
2191
+ });
2192
+ } else {
2193
+ var count = accessorCount * dataElementSize;
2194
+ var data = new TypedArray(count);
2195
+ var bufferInfo = new BufferInfo(data, false, elementStride);
2196
+ bufferInfo.restoreInfo = new BufferDataRestoreInfo(new RestoreDataAccessor(undefined, TypedArray, undefined, count));
2197
+ promise = Promise.resolve(bufferInfo);
2198
+ }
2199
+ return accessor.sparse ? promise.then(function(bufferInfo) {
2200
+ return GLTFUtils.processingSparseData(context, accessor, bufferInfo).then(function() {
2201
+ return bufferInfo;
2202
+ });
2203
+ }) : promise;
1865
2204
  };
1866
- GLTFUtils.bufferToVector3Array = function bufferToVector3Array(data, byteStride, accessorByteOffset, count) {
1867
- var bytesPerElement = data.BYTES_PER_ELEMENT;
1868
- var offset = accessorByteOffset % byteStride / bytesPerElement;
1869
- var stride = byteStride / bytesPerElement;
1870
- var vector3s = new Array(count);
2205
+ GLTFUtils.bufferToVector3Array = function bufferToVector3Array(buffer, byteOffset, count, normalized, componentType) {
2206
+ var baseOffset = byteOffset / buffer.BYTES_PER_ELEMENT;
2207
+ var stride = buffer.length / count;
2208
+ var vertices = new Array(count);
2209
+ var factor = normalized ? GLTFUtils.getNormalizedComponentScale(componentType) : 1;
1871
2210
  for(var i = 0; i < count; i++){
1872
- var index = offset + i * stride;
1873
- vector3s[i] = new Vector3(data[index], data[index + 1], data[index + 2]);
1874
- }
1875
- return vector3s;
1876
- };
1877
- /**
1878
- * @deprecated
1879
- * Get accessor data.
1880
- */ GLTFUtils.getAccessorData = function getAccessorData(glTF, accessor, buffers) {
1881
- var bufferViews = glTF.bufferViews;
1882
- var bufferView = bufferViews[accessor.bufferView];
1883
- var arrayBuffer = buffers[bufferView.buffer];
1884
- var accessorByteOffset = accessor.hasOwnProperty("byteOffset") ? accessor.byteOffset : 0;
1885
- var bufferViewByteOffset = bufferView.hasOwnProperty("byteOffset") ? bufferView.byteOffset : 0;
1886
- var byteOffset = accessorByteOffset + bufferViewByteOffset;
1887
- var accessorTypeSize = GLTFUtils.getAccessorTypeSize(accessor.type);
1888
- var length = accessorTypeSize * accessor.count;
1889
- var _bufferView_byteStride;
1890
- var byteStride = (_bufferView_byteStride = bufferView.byteStride) != null ? _bufferView_byteStride : 0;
1891
- var arrayType = GLTFUtils.getComponentType(accessor.componentType);
1892
- var uint8Array;
1893
- if (byteStride) {
1894
- var accessorByteSize = accessorTypeSize * arrayType.BYTES_PER_ELEMENT;
1895
- uint8Array = new Uint8Array(accessor.count * accessorByteSize);
1896
- var originalBufferView = new Uint8Array(arrayBuffer, bufferViewByteOffset, bufferView.byteLength);
1897
- for(var i = 0; i < accessor.count; i++){
1898
- for(var j = 0; j < accessorByteSize; j++){
1899
- uint8Array[i * accessorByteSize + j] = originalBufferView[i * byteStride + accessorByteOffset + j];
1900
- }
1901
- }
1902
- } else {
1903
- uint8Array = new Uint8Array(arrayBuffer.slice(byteOffset, byteOffset + length * arrayType.BYTES_PER_ELEMENT));
1904
- }
1905
- var typedArray = new arrayType(uint8Array.buffer);
1906
- if (accessor.sparse) {
1907
- var _accessor_sparse = accessor.sparse, count = _accessor_sparse.count, indices = _accessor_sparse.indices, values = _accessor_sparse.values;
1908
- var indicesBufferView = bufferViews[indices.bufferView];
1909
- var valuesBufferView = bufferViews[values.bufferView];
1910
- var indicesArrayBuffer = buffers[indicesBufferView.buffer];
1911
- var valuesArrayBuffer = buffers[valuesBufferView.buffer];
1912
- var _indices_byteOffset, _indicesBufferView_byteOffset;
1913
- var indicesByteOffset = ((_indices_byteOffset = indices.byteOffset) != null ? _indices_byteOffset : 0) + ((_indicesBufferView_byteOffset = indicesBufferView.byteOffset) != null ? _indicesBufferView_byteOffset : 0);
1914
- var indicesByteLength = indicesBufferView.byteLength;
1915
- var _values_byteOffset, _valuesBufferView_byteOffset;
1916
- var valuesByteOffset = ((_values_byteOffset = values.byteOffset) != null ? _values_byteOffset : 0) + ((_valuesBufferView_byteOffset = valuesBufferView.byteOffset) != null ? _valuesBufferView_byteOffset : 0);
1917
- var valuesByteLength = valuesBufferView.byteLength;
1918
- var indicesType = GLTFUtils.getComponentType(indices.componentType);
1919
- var indicesArray = new indicesType(indicesArrayBuffer, indicesByteOffset, indicesByteLength / indicesType.BYTES_PER_ELEMENT);
1920
- var valuesArray = new arrayType(valuesArrayBuffer, valuesByteOffset, valuesByteLength / arrayType.BYTES_PER_ELEMENT);
1921
- for(var i1 = 0; i1 < count; i1++){
1922
- var replaceIndex = indicesArray[i1];
1923
- for(var j1 = 0; j1 < accessorTypeSize; j1++){
1924
- typedArray[replaceIndex * accessorTypeSize + j1] = valuesArray[i1 * accessorTypeSize + j1];
1925
- }
1926
- }
2211
+ var index = baseOffset + i * stride;
2212
+ vertices[i] = new Vector3(buffer[index] * factor, buffer[index + 1] * factor, buffer[index + 2] * factor);
1927
2213
  }
1928
- return typedArray;
2214
+ return vertices;
1929
2215
  };
1930
2216
  GLTFUtils.getBufferViewData = function getBufferViewData(bufferView, buffers) {
1931
2217
  var _bufferView_byteOffset = bufferView.byteOffset, byteOffset = _bufferView_byteOffset === void 0 ? 0 : _bufferView_byteOffset;
@@ -1934,40 +2220,43 @@ function registerGLTFParser(pipeline) {
1934
2220
  };
1935
2221
  /**
1936
2222
  * Get accessor data.
1937
- */ GLTFUtils.processingSparseData = function processingSparseData(bufferViews, accessor, buffers, bufferInfo) {
2223
+ */ GLTFUtils.processingSparseData = function processingSparseData(context, accessor, bufferInfo) {
1938
2224
  var restoreInfo = bufferInfo.restoreInfo;
2225
+ var bufferViews = context.glTF.bufferViews;
1939
2226
  var accessorTypeSize = GLTFUtils.getAccessorTypeSize(accessor.type);
1940
2227
  var TypedArray = GLTFUtils.getComponentType(accessor.componentType);
1941
2228
  var data = bufferInfo.data.slice();
1942
2229
  var _accessor_sparse = accessor.sparse, count = _accessor_sparse.count, indices = _accessor_sparse.indices, values = _accessor_sparse.values;
1943
2230
  var indicesBufferView = bufferViews[indices.bufferView];
1944
2231
  var valuesBufferView = bufferViews[values.bufferView];
1945
- var indicesBufferIndex = indicesBufferView.buffer;
1946
- var valuesBufferIndex = valuesBufferView.buffer;
1947
- var indicesArrayBuffer = buffers[indicesBufferIndex];
1948
- var valuesArrayBuffer = buffers[valuesBufferIndex];
1949
- var _indices_byteOffset, _indicesBufferView_byteOffset;
1950
- var indicesByteOffset = ((_indices_byteOffset = indices.byteOffset) != null ? _indices_byteOffset : 0) + ((_indicesBufferView_byteOffset = indicesBufferView.byteOffset) != null ? _indicesBufferView_byteOffset : 0);
1951
- var indicesByteLength = indicesBufferView.byteLength;
1952
- var _values_byteOffset, _valuesBufferView_byteOffset;
1953
- var valuesByteOffset = ((_values_byteOffset = values.byteOffset) != null ? _values_byteOffset : 0) + ((_valuesBufferView_byteOffset = valuesBufferView.byteOffset) != null ? _valuesBufferView_byteOffset : 0);
1954
- var valuesByteLength = valuesBufferView.byteLength;
1955
- restoreInfo.typeSize = accessorTypeSize;
1956
- restoreInfo.sparseCount = count;
1957
- var IndexTypeArray = GLTFUtils.getComponentType(indices.componentType);
1958
- var indexLength = indicesByteLength / IndexTypeArray.BYTES_PER_ELEMENT;
1959
- var indicesArray = new IndexTypeArray(indicesArrayBuffer, indicesByteOffset, indexLength);
1960
- restoreInfo.sparseIndices = new RestoreDataAccessor(indicesBufferIndex, IndexTypeArray, indicesByteOffset, indexLength);
1961
- var valueLength = valuesByteLength / TypedArray.BYTES_PER_ELEMENT;
1962
- var valuesArray = new TypedArray(valuesArrayBuffer, valuesByteOffset, valueLength);
1963
- restoreInfo.sparseValues = new RestoreDataAccessor(valuesBufferIndex, TypedArray, valuesByteOffset, valueLength);
1964
- for(var i = 0; i < count; i++){
1965
- var replaceIndex = indicesArray[i];
1966
- for(var j = 0; j < accessorTypeSize; j++){
1967
- data[replaceIndex * accessorTypeSize + j] = valuesArray[i * accessorTypeSize + j];
2232
+ return Promise.all([
2233
+ context.get(GLTFParserType.BufferView, indices.bufferView),
2234
+ context.get(GLTFParserType.BufferView, values.bufferView)
2235
+ ]).then(function(param) {
2236
+ var indicesUint8Array = param[0], valuesUin8Array = param[1];
2237
+ var _indices_byteOffset, _indicesUint8Array_byteOffset;
2238
+ var indicesByteOffset = ((_indices_byteOffset = indices.byteOffset) != null ? _indices_byteOffset : 0) + ((_indicesUint8Array_byteOffset = indicesUint8Array.byteOffset) != null ? _indicesUint8Array_byteOffset : 0);
2239
+ var indicesByteLength = indicesUint8Array.byteLength;
2240
+ var _values_byteOffset, _valuesUin8Array_byteOffset;
2241
+ var valuesByteOffset = ((_values_byteOffset = values.byteOffset) != null ? _values_byteOffset : 0) + ((_valuesUin8Array_byteOffset = valuesUin8Array.byteOffset) != null ? _valuesUin8Array_byteOffset : 0);
2242
+ var valuesByteLength = valuesUin8Array.byteLength;
2243
+ restoreInfo.typeSize = accessorTypeSize;
2244
+ restoreInfo.sparseCount = count;
2245
+ var IndexTypeArray = GLTFUtils.getComponentType(indices.componentType);
2246
+ var indexLength = indicesByteLength / IndexTypeArray.BYTES_PER_ELEMENT;
2247
+ var indicesArray = new IndexTypeArray(indicesUint8Array.buffer, indicesByteOffset, indexLength);
2248
+ restoreInfo.sparseIndices = new RestoreDataAccessor(indicesBufferView.buffer, IndexTypeArray, indicesByteOffset, indexLength);
2249
+ var valueLength = valuesByteLength / TypedArray.BYTES_PER_ELEMENT;
2250
+ var valuesArray = new TypedArray(valuesUin8Array.buffer, valuesByteOffset, valueLength);
2251
+ restoreInfo.sparseValues = new RestoreDataAccessor(valuesBufferView.buffer, TypedArray, valuesByteOffset, valueLength);
2252
+ for(var i = 0; i < count; i++){
2253
+ var replaceIndex = indicesArray[i];
2254
+ for(var j = 0; j < accessorTypeSize; j++){
2255
+ data[replaceIndex * accessorTypeSize + j] = valuesArray[i * accessorTypeSize + j];
2256
+ }
1968
2257
  }
1969
- }
1970
- bufferInfo.data = data;
2258
+ bufferInfo.data = data;
2259
+ });
1971
2260
  };
1972
2261
  GLTFUtils.getIndexFormat = function getIndexFormat(type) {
1973
2262
  switch(type){
@@ -2056,7 +2345,7 @@ function registerGLTFParser(pipeline) {
2056
2345
  };
2057
2346
  /**
2058
2347
  * Parse the glb format.
2059
- */ GLTFUtils.parseGLB = function parseGLB(context, glb) {
2348
+ */ GLTFUtils.parseGLB = function parseGLB(context, originBuffer) {
2060
2349
  var UINT32_LENGTH = 4;
2061
2350
  var GLB_HEADER_MAGIC = 0x46546c67; // 'glTF'
2062
2351
  var GLB_HEADER_LENGTH = 12;
@@ -2064,7 +2353,7 @@ function registerGLTFParser(pipeline) {
2064
2353
  JSON: 0x4e4f534a,
2065
2354
  BIN: 0x004e4942
2066
2355
  };
2067
- var dataView = new DataView(glb);
2356
+ var dataView = new DataView(originBuffer);
2068
2357
  // read header
2069
2358
  var header = {
2070
2359
  magic: dataView.getUint32(0, true),
@@ -2072,8 +2361,9 @@ function registerGLTFParser(pipeline) {
2072
2361
  length: dataView.getUint32(2 * UINT32_LENGTH, true)
2073
2362
  };
2074
2363
  if (header.magic !== GLB_HEADER_MAGIC) {
2075
- console.error("Invalid glb magic number. Expected 0x46546C67, found 0x" + header.magic.toString(16));
2076
- return null;
2364
+ return {
2365
+ originBuffer: originBuffer
2366
+ };
2077
2367
  }
2078
2368
  // read main data
2079
2369
  var chunkLength = dataView.getUint32(GLB_HEADER_LENGTH, true);
@@ -2083,7 +2373,7 @@ function registerGLTFParser(pipeline) {
2083
2373
  console.error("Invalid glb chunk type. Expected 0x4E4F534A, found 0x" + chunkType.toString(16));
2084
2374
  return null;
2085
2375
  }
2086
- var glTFData = new Uint8Array(glb, GLB_HEADER_LENGTH + 2 * UINT32_LENGTH, chunkLength);
2376
+ var glTFData = new Uint8Array(originBuffer, GLB_HEADER_LENGTH + 2 * UINT32_LENGTH, chunkLength);
2087
2377
  var glTF = JSON.parse(Utils.decodeText(glTFData));
2088
2378
  // read all buffers
2089
2379
  var buffers = [];
@@ -2097,7 +2387,7 @@ function registerGLTFParser(pipeline) {
2097
2387
  return null;
2098
2388
  }
2099
2389
  var currentOffset = byteOffset + 2 * UINT32_LENGTH;
2100
- var buffer = glb.slice(currentOffset, currentOffset + chunkLength);
2390
+ var buffer = originBuffer.slice(currentOffset, currentOffset + chunkLength);
2101
2391
  buffers.push(buffer);
2102
2392
  restoreGLBBufferSlice.push(new Vector2(currentOffset, chunkLength));
2103
2393
  byteOffset += chunkLength + 2 * UINT32_LENGTH;
@@ -2976,18 +3266,22 @@ var KTX2Loader = (_KTX2Loader = /*#__PURE__*/ function(Loader1) {
2976
3266
  /**
2977
3267
  * @internal
2978
3268
  */ _proto.load = function load(item, resourceManager) {
2979
- return this.request(item.url, {
2980
- type: "arraybuffer"
2981
- }).then(function(buffer) {
2982
- return KTX2Loader._parseBuffer(new Uint8Array(buffer), resourceManager.engine, item.params).then(function(param) {
2983
- var engine = param.engine, result = param.result, targetFormat = param.targetFormat, params = param.params;
2984
- return KTX2Loader._createTextureByBuffer(engine, result, targetFormat, params);
2985
- });
3269
+ var _this = this;
3270
+ return new AssetPromise(function(resolve, reject, setTaskCompleteProgress, setTaskDetailProgress) {
3271
+ _this.request(item.url, {
3272
+ type: "arraybuffer"
3273
+ }).onProgress(setTaskCompleteProgress, setTaskDetailProgress).then(function(buffer) {
3274
+ return KTX2Loader._parseBuffer(new Uint8Array(buffer), resourceManager.engine, item.params).then(function(param) {
3275
+ var engine = param.engine, result = param.result, targetFormat = param.targetFormat, params = param.params;
3276
+ return KTX2Loader._createTextureByBuffer(engine, result, targetFormat, params);
3277
+ });
3278
+ }).then(resolve).catch(reject);
2986
3279
  });
2987
3280
  };
2988
3281
  /**
2989
- * Destroy ktx2 transcoder worker.
2990
- */ KTX2Loader1.destroy = function destroy() {
3282
+ * Release ktx2 transcoder worker.
3283
+ * @remarks If use loader after releasing, we should release again.
3284
+ */ KTX2Loader1.release = function release() {
2991
3285
  if (this._binomialLLCTranscoder) this._binomialLLCTranscoder.destroy();
2992
3286
  if (this._khronosTranscoder) this._khronosTranscoder.destroy();
2993
3287
  this._binomialLLCTranscoder = null;
@@ -3232,16 +3526,16 @@ var KTX2Transcoder;
3232
3526
  var frame = restoreInfo.blendShape.frames[0];
3233
3527
  var position = restoreInfo.position;
3234
3528
  var positionData = _this._getBufferData(buffers, position.buffer);
3235
- frame.deltaPositions = GLTFUtils.bufferToVector3Array(positionData, position.stride, position.byteOffset, position.count);
3529
+ frame.deltaPositions = GLTFUtils.bufferToVector3Array(positionData, position.byteOffset, position.count, position.normalized, position.componentType);
3236
3530
  if (restoreInfo.normal) {
3237
3531
  var normal = restoreInfo.normal;
3238
3532
  var normalData = _this._getBufferData(buffers, normal.buffer);
3239
- frame.deltaNormals = GLTFUtils.bufferToVector3Array(normalData, normal.stride, normal.byteOffset, normal.count);
3533
+ frame.deltaNormals = GLTFUtils.bufferToVector3Array(normalData, normal.byteOffset, normal.count, normal.normalized, normal.componentType);
3240
3534
  }
3241
3535
  if (restoreInfo.tangent) {
3242
3536
  var tangent = restoreInfo.tangent;
3243
3537
  var tangentData = _this._getBufferData(buffers, tangent.buffer);
3244
- frame.deltaTangents = GLTFUtils.bufferToVector3Array(tangentData, tangent.stride, tangent.byteOffset, tangent.count);
3538
+ frame.deltaTangents = GLTFUtils.bufferToVector3Array(tangentData, tangent.byteOffset, tangent.count, tangent.normalized, tangent.componentType);
3245
3539
  }
3246
3540
  }
3247
3541
  mesh.uploadData(true);
@@ -3253,8 +3547,13 @@ var KTX2Transcoder;
3253
3547
  };
3254
3548
  _proto._getBufferData = function _getBufferData(buffers, restoreInfo) {
3255
3549
  var main = restoreInfo.main;
3256
- var buffer = buffers[main.bufferIndex];
3257
- var data = new main.TypedArray(buffer, main.byteOffset, main.length);
3550
+ var data;
3551
+ if (main) {
3552
+ var buffer = buffers[main.bufferIndex];
3553
+ data = new main.TypedArray(buffer, main.byteOffset, main.length);
3554
+ } else {
3555
+ data = new main.TypedArray(main.length);
3556
+ }
3258
3557
  var sparseCount = restoreInfo.sparseCount;
3259
3558
  if (sparseCount) {
3260
3559
  var sparseIndex = restoreInfo.sparseIndices;
@@ -3327,11 +3626,12 @@ var KTX2Transcoder;
3327
3626
  };
3328
3627
  /**
3329
3628
  * @internal
3330
- */ var BlendShapeDataRestoreInfo = function BlendShapeDataRestoreInfo(buffer, stride, byteOffset, count) {
3629
+ */ var BlendShapeDataRestoreInfo = function BlendShapeDataRestoreInfo(buffer, byteOffset, count, normalized, componentType) {
3331
3630
  this.buffer = buffer;
3332
- this.stride = stride;
3333
3631
  this.byteOffset = byteOffset;
3334
3632
  this.count = count;
3633
+ this.normalized = normalized;
3634
+ this.componentType = componentType;
3335
3635
  };
3336
3636
 
3337
3637
  /**
@@ -3507,23 +3807,20 @@ var GLTFSchemaParser = /*#__PURE__*/ function(GLTFParser1) {
3507
3807
  var requestConfig = {
3508
3808
  type: "arraybuffer"
3509
3809
  };
3510
- var isGLB = this._isGLB(url);
3511
- contentRestorer.isGLB = isGLB;
3512
- var promise = isGLB ? request(url, requestConfig).then(function(glb) {
3810
+ return request(url, requestConfig).onProgress(undefined, context._onTaskDetail).then(function(buffer) {
3513
3811
  restoreBufferRequests.push(new BufferRequestInfo(url, requestConfig));
3514
- return GLTFUtils.parseGLB(context, glb);
3515
- }).then(function(param) {
3516
- var glTF = param.glTF, buffers = param.buffers;
3517
- context.buffers = buffers;
3518
- return glTF;
3519
- }) : request(url, {
3520
- type: "json"
3812
+ return GLTFUtils.parseGLB(context, buffer);
3813
+ }).then(function(result) {
3814
+ var _result;
3815
+ if ((_result = result) == null ? void 0 : _result.glTF) {
3816
+ contentRestorer.isGLB = true;
3817
+ context.buffers = result.buffers;
3818
+ return result.glTF;
3819
+ } else {
3820
+ contentRestorer.isGLB = false;
3821
+ return JSON.parse(Utils.decodeText(new Uint8Array(result.originBuffer)));
3822
+ }
3521
3823
  });
3522
- return promise;
3523
- };
3524
- _proto._isGLB = function _isGLB(url) {
3525
- var index = url.lastIndexOf(".");
3526
- return url.substring(index + 1, index + 4) === "glb";
3527
3824
  };
3528
3825
  return GLTFSchemaParser;
3529
3826
  }(GLTFParser);
@@ -3550,9 +3847,9 @@ var GLTFAnimationParser = /*#__PURE__*/ function(GLTFParser1) {
3550
3847
  * @internal
3551
3848
  */ GLTFAnimationParser1._parseStandardProperty = function _parseStandardProperty(context, animationClip, animationInfo) {
3552
3849
  var _loop = function(j, m) {
3553
- var gltfSampler = samplers[j];
3554
- var inputAccessor = accessors[gltfSampler.input];
3555
- var outputAccessor = accessors[gltfSampler.output];
3850
+ var glTFSampler = samplers[j];
3851
+ var inputAccessor = accessors[glTFSampler.input];
3852
+ var outputAccessor = accessors[glTFSampler.output];
3556
3853
  var promise = Promise.all([
3557
3854
  GLTFUtils.getAccessorBuffer(context, bufferViews, inputAccessor),
3558
3855
  GLTFUtils.getAccessorBuffer(context, bufferViews, outputAccessor)
@@ -3568,8 +3865,8 @@ var GLTFAnimationParser = /*#__PURE__*/ function(GLTFParser1) {
3568
3865
  output = scaled;
3569
3866
  }
3570
3867
  var outputStride = output.length / input.length;
3571
- var _gltfSampler_interpolation;
3572
- var interpolation = (_gltfSampler_interpolation = gltfSampler.interpolation) != null ? _gltfSampler_interpolation : AnimationSamplerInterpolation.Linear;
3868
+ var _glTFSampler_interpolation;
3869
+ var interpolation = (_glTFSampler_interpolation = glTFSampler.interpolation) != null ? _glTFSampler_interpolation : AnimationSamplerInterpolation.Linear;
3573
3870
  var samplerInterpolation;
3574
3871
  switch(interpolation){
3575
3872
  case AnimationSamplerInterpolation.CubicSpine:
@@ -3583,13 +3880,13 @@ var GLTFAnimationParser = /*#__PURE__*/ function(GLTFParser1) {
3583
3880
  break;
3584
3881
  }
3585
3882
  input[input.length - 1];
3586
- sampleDataCollection.push({
3883
+ sampleDataCollection[j] = {
3587
3884
  type: outputAccessor.type,
3588
3885
  interpolation: samplerInterpolation,
3589
3886
  input: input,
3590
3887
  output: output,
3591
3888
  outputSize: outputStride
3592
- });
3889
+ };
3593
3890
  });
3594
3891
  promises.push(promise);
3595
3892
  };
@@ -3597,16 +3894,17 @@ var GLTFAnimationParser = /*#__PURE__*/ function(GLTFParser1) {
3597
3894
  var glTF = context.glTF;
3598
3895
  var accessors = glTF.accessors, bufferViews = glTF.bufferViews;
3599
3896
  var channels = animationInfo.channels, samplers = animationInfo.samplers;
3600
- var sampleDataCollection = new Array();
3897
+ var len = samplers.length;
3898
+ var sampleDataCollection = new Array(len);
3601
3899
  var entities = context.get(GLTFParserType.Entity);
3602
3900
  var promises = new Array();
3603
3901
  // parse samplers
3604
- for(var j = 0, m = samplers.length; j < m; j++)_loop(j);
3902
+ for(var j = 0, m = len; j < m; j++)_loop(j);
3605
3903
  promises.push(context.get(GLTFParserType.Scene));
3606
3904
  return Promise.all(promises).then(function() {
3607
3905
  for(var j = 0, m = channels.length; j < m; j++){
3608
- var gltfChannel = channels[j];
3609
- var target = gltfChannel.target;
3906
+ var glTFChannel = channels[j];
3907
+ var target = glTFChannel.target;
3610
3908
  var channelTargetEntity = entities[target.node];
3611
3909
  var relativePath = "";
3612
3910
  var entity = channelTargetEntity;
@@ -3638,14 +3936,21 @@ var GLTFAnimationParser = /*#__PURE__*/ function(GLTFParser1) {
3638
3936
  propertyName = "blendShapeWeights";
3639
3937
  break;
3640
3938
  }
3641
- var curve = _this._addCurve(target.path, gltfChannel, sampleDataCollection);
3642
- animationClip.addCurveBinding(relativePath, ComponentType, propertyName, curve);
3939
+ var curve = _this._addCurve(target.path, glTFChannel, sampleDataCollection);
3940
+ if (target.path === AnimationChannelTargetPath.WEIGHTS) {
3941
+ var mesh = glTF.nodes[target.node].mesh;
3942
+ for(var i = 0, n = glTF.meshes[mesh].primitives.length; i < n; i++){
3943
+ animationClip.addCurveBinding(relativePath, ComponentType, i, propertyName, curve);
3944
+ }
3945
+ } else {
3946
+ animationClip.addCurveBinding(relativePath, ComponentType, propertyName, curve);
3947
+ }
3643
3948
  }
3644
3949
  return animationClip;
3645
3950
  });
3646
3951
  };
3647
- GLTFAnimationParser1._addCurve = function _addCurve(animationChannelTargetPath, gltfChannel, sampleDataCollection) {
3648
- var sampleData = sampleDataCollection[gltfChannel.sampler];
3952
+ GLTFAnimationParser1._addCurve = function _addCurve(animationChannelTargetPath, glTFChannel, sampleDataCollection) {
3953
+ var sampleData = sampleDataCollection[glTFChannel.sampler];
3649
3954
  var input = sampleData.input, output = sampleData.output, outputSize = sampleData.outputSize;
3650
3955
  switch(animationChannelTargetPath){
3651
3956
  case AnimationChannelTargetPath.TRANSLATION:
@@ -3737,7 +4042,9 @@ var GLTFBufferParser = /*#__PURE__*/ function(GLTFParser1) {
3737
4042
  };
3738
4043
  var absoluteUrl = Utils.resolveAbsoluteUrl(url, bufferInfo.uri);
3739
4044
  restoreBufferRequests.push(new BufferRequestInfo(absoluteUrl, requestConfig));
3740
- return request(absoluteUrl, requestConfig);
4045
+ var promise = request(absoluteUrl, requestConfig).onProgress(undefined, context._onTaskDetail);
4046
+ context._addTaskCompletePromise(promise);
4047
+ return promise;
3741
4048
  };
3742
4049
  return GLTFBufferParser;
3743
4050
  }(GLTFParser);
@@ -3752,10 +4059,13 @@ var GLTFEntityParser = /*#__PURE__*/ function(GLTFParser1) {
3752
4059
  }
3753
4060
  var _proto = GLTFEntityParser.prototype;
3754
4061
  _proto.parse = function parse(context, index) {
4062
+ var glTFResource = context.glTFResource;
3755
4063
  var entityInfo = context.glTF.nodes[index];
3756
- var engine = context.glTFResource.engine;
4064
+ var engine = glTFResource.engine;
3757
4065
  var matrix = entityInfo.matrix, translation = entityInfo.translation, rotation = entityInfo.rotation, scale = entityInfo.scale, extensions = entityInfo.extensions;
3758
4066
  var entity = new Entity(engine, entityInfo.name || "_GLTF_ENTITY_" + index);
4067
+ // @ts-ignore
4068
+ entity._markAsTemplate(glTFResource);
3759
4069
  var transform = entity.transform;
3760
4070
  if (matrix) {
3761
4071
  var localMatrix = transform.localMatrix;
@@ -3797,7 +4107,8 @@ var GLTFMaterialParser = /*#__PURE__*/ function(GLTFParser1) {
3797
4107
  var _proto = GLTFMaterialParser1.prototype;
3798
4108
  _proto.parse = function parse(context, index) {
3799
4109
  var materialInfo = context.glTF.materials[index];
3800
- var engine = context.glTFResource.engine;
4110
+ var glTFResource = context.glTFResource;
4111
+ var engine = glTFResource.engine;
3801
4112
  var material = GLTFParser.executeExtensionsCreateAndParse(materialInfo.extensions, context, materialInfo);
3802
4113
  if (!material) {
3803
4114
  material = new PBRMaterial(engine);
@@ -3805,8 +4116,10 @@ var GLTFMaterialParser = /*#__PURE__*/ function(GLTFParser1) {
3805
4116
  GLTFMaterialParser._parseStandardProperty(context, material, materialInfo);
3806
4117
  }
3807
4118
  return Promise.resolve(material).then(function(material) {
3808
- material || (material = GLTFMaterialParser._getDefaultMaterial(context.glTFResource.engine));
4119
+ material || (material = GLTFMaterialParser._getDefaultMaterial(engine));
3809
4120
  GLTFParser.executeExtensionsAdditiveAndParse(materialInfo.extensions, context, material, materialInfo);
4121
+ // @ts-ignore
4122
+ material._associationSuperResource(glTFResource);
3810
4123
  return material;
3811
4124
  });
3812
4125
  };
@@ -3927,46 +4240,37 @@ var GLTFMeshParser = (_GLTFMeshParser = /*#__PURE__*/ function(GLTFParser1) {
3927
4240
  var mesh = GLTFParser.executeExtensionsCreateAndParse(gltfPrimitive.extensions, context, gltfPrimitive, meshInfo);
3928
4241
  if (mesh) {
3929
4242
  if (_instanceof(mesh, ModelMesh)) {
4243
+ // @ts-ignore
4244
+ mesh._associationSuperResource(glTFResource);
3930
4245
  resolve(mesh);
3931
4246
  } else {
3932
4247
  mesh.then(function(mesh) {
3933
- return resolve(mesh);
4248
+ // @ts-ignore
4249
+ mesh._associationSuperResource(glTFResource);
4250
+ resolve(mesh);
3934
4251
  });
3935
4252
  }
3936
4253
  } else {
3937
4254
  var mesh1 = new ModelMesh(engine, meshInfo.name || i + "");
4255
+ // @ts-ignore
4256
+ mesh1._associationSuperResource(glTFResource);
3938
4257
  var meshRestoreInfo = new ModelMeshRestoreInfo();
3939
4258
  meshRestoreInfo.mesh = mesh1;
3940
4259
  context.contentRestorer.meshes.push(meshRestoreInfo);
3941
- GLTFMeshParser._parseMeshFromGLTFPrimitive(context, mesh1, meshRestoreInfo, meshInfo, gltfPrimitive, glTF, function(attributeSemantic) {
3942
- return null;
3943
- }, function(attributeName, shapeIndex) {
3944
- var shapeAccessorIdx = gltfPrimitive.targets[shapeIndex];
3945
- var attributeAccessorIdx = shapeAccessorIdx[attributeName];
3946
- if (attributeAccessorIdx) {
3947
- var accessor = glTF.accessors[attributeAccessorIdx];
3948
- return GLTFUtils.getAccessorBuffer(context, context.glTF.bufferViews, accessor);
3949
- } else {
3950
- return null;
3951
- }
3952
- }, function() {
3953
- var indexAccessor = glTF.accessors[gltfPrimitive.indices];
3954
- return context.get(GLTFParserType.Buffer).then(function(buffers) {
3955
- return GLTFUtils.getAccessorData(glTF, indexAccessor, buffers);
3956
- });
3957
- }, context.params.keepMeshData).then(resolve);
4260
+ GLTFMeshParser._parseMeshFromGLTFPrimitive(context, mesh1, meshRestoreInfo, meshInfo, gltfPrimitive, glTF, context.params.keepMeshData).then(resolve);
3958
4261
  }
3959
4262
  });
3960
4263
  };
3961
4264
  var meshInfo = context.glTF.meshes[index];
3962
- var glTF = context.glTF, engine = context.glTFResource.engine;
4265
+ var glTF = context.glTF, glTFResource = context.glTFResource;
4266
+ var engine = glTFResource.engine;
3963
4267
  var primitivePromises = new Array();
3964
4268
  for(var i = 0, length = meshInfo.primitives.length; i < length; i++)_loop(i);
3965
4269
  return Promise.all(primitivePromises);
3966
4270
  };
3967
4271
  /**
3968
4272
  * @internal
3969
- */ GLTFMeshParser1._parseMeshFromGLTFPrimitive = function _parseMeshFromGLTFPrimitive(context, mesh, meshRestoreInfo, gltfMesh, gltfPrimitive, gltf, getVertexBufferData, getBlendShapeData, getIndexBufferData, keepMeshData) {
4273
+ */ GLTFMeshParser1._parseMeshFromGLTFPrimitive = function _parseMeshFromGLTFPrimitive(context, mesh, meshRestoreInfo, gltfMesh, gltfPrimitive, gltf, keepMeshData) {
3970
4274
  var _loop = function(attribute) {
3971
4275
  var accessor = accessors[attributes[attribute]];
3972
4276
  var promise = GLTFUtils.getAccessorBuffer(context, gltf.bufferViews, accessor).then(function(accessorBuffer) {
@@ -4061,61 +4365,68 @@ var GLTFMeshParser = (_GLTFMeshParser = /*#__PURE__*/ function(GLTFParser1) {
4061
4365
  }
4062
4366
  // BlendShapes
4063
4367
  if (targets) {
4064
- promises.push(GLTFMeshParser._createBlendShape(mesh, meshRestoreInfo, gltfMesh, accessors, targets, getBlendShapeData));
4368
+ promises.push(GLTFMeshParser._createBlendShape(context, mesh, meshRestoreInfo, gltfMesh, gltfPrimitive, targets));
4065
4369
  }
4066
4370
  return Promise.all(promises).then(function() {
4067
4371
  mesh.uploadData(!keepMeshData);
4068
- return Promise.resolve(mesh);
4372
+ return mesh;
4069
4373
  });
4070
4374
  });
4071
4375
  };
4376
+ GLTFMeshParser1._getBlendShapeData = function _getBlendShapeData(context, glTF, accessor) {
4377
+ return GLTFUtils.getAccessorBuffer(context, glTF.bufferViews, accessor).then(function(bufferInfo) {
4378
+ var buffer = bufferInfo.data;
4379
+ var _accessor_byteOffset;
4380
+ var byteOffset = bufferInfo.interleaved ? ((_accessor_byteOffset = accessor.byteOffset) != null ? _accessor_byteOffset : 0) % bufferInfo.stride : 0;
4381
+ var count = accessor.count, normalized = accessor.normalized, componentType = accessor.componentType;
4382
+ var vertices = GLTFUtils.bufferToVector3Array(buffer, byteOffset, count, normalized, componentType);
4383
+ var restoreInfo = new BlendShapeDataRestoreInfo(bufferInfo.restoreInfo, byteOffset, count, normalized, componentType);
4384
+ return {
4385
+ vertices: vertices,
4386
+ restoreInfo: restoreInfo
4387
+ };
4388
+ });
4389
+ };
4072
4390
  /**
4073
4391
  * @internal
4074
- */ GLTFMeshParser1._createBlendShape = function _createBlendShape(mesh, meshRestoreInfo, glTFMesh, accessors, glTFTargets, getBlendShapeData) {
4075
- var _loop = function(i, n) {
4392
+ */ GLTFMeshParser1._createBlendShape = function _createBlendShape(context, mesh, meshRestoreInfo, glTFMesh, gltfPrimitive, glTFTargets) {
4393
+ var _this = this, _loop = function(i) {
4394
+ var blendShapeData = {};
4395
+ blendShapeCollection[i] = blendShapeData;
4076
4396
  var name = blendShapeNames ? blendShapeNames[i] : "blendShape" + i;
4397
+ var targets = gltfPrimitive.targets[i];
4398
+ var normalTarget = targets["NORMAL"];
4399
+ var tangentTarget = targets["TANGENT"];
4400
+ var hasNormal = normalTarget !== undefined;
4401
+ var hasTangent = tangentTarget !== undefined;
4077
4402
  var promise = Promise.all([
4078
- getBlendShapeData("POSITION", i),
4079
- getBlendShapeData("NORMAL", i),
4080
- getBlendShapeData("TANGENT", i)
4081
- ]).then(function(infos) {
4082
- var posBufferInfo = infos[0];
4083
- var norBufferInfo = infos[1];
4084
- var tanBufferInfo = infos[2];
4085
- var target = glTFTargets[i];
4086
- var posAccessor;
4087
- var norAccessor;
4088
- var tanAccessor;
4089
- var positions = null;
4090
- if (posBufferInfo) {
4091
- posAccessor = accessors[target["POSITION"]];
4092
- var _posAccessor_byteOffset;
4093
- positions = GLTFUtils.bufferToVector3Array(posBufferInfo.data, posBufferInfo.stride, (_posAccessor_byteOffset = posAccessor.byteOffset) != null ? _posAccessor_byteOffset : 0, posAccessor.count);
4094
- }
4095
- var normals = null;
4096
- if (norBufferInfo) {
4097
- norAccessor = accessors[target["NORMAL"]];
4098
- var _norAccessor_byteOffset;
4099
- normals = GLTFUtils.bufferToVector3Array(norBufferInfo.data, norBufferInfo.stride, (_norAccessor_byteOffset = norAccessor.byteOffset) != null ? _norAccessor_byteOffset : 0, norAccessor.count);
4100
- }
4101
- var tangents = null;
4102
- if (tanBufferInfo) {
4103
- tanAccessor = accessors[target["NORMAL"]];
4104
- var _tanAccessor_byteOffset;
4105
- tangents = GLTFUtils.bufferToVector3Array(tanBufferInfo.data, tanBufferInfo.stride, (_tanAccessor_byteOffset = tanAccessor.byteOffset) != null ? _tanAccessor_byteOffset : 0, tanAccessor.count);
4106
- }
4403
+ _this._getBlendShapeData(context, glTF, accessors[targets["POSITION"]]),
4404
+ hasNormal ? _this._getBlendShapeData(context, glTF, accessors[normalTarget]) : null,
4405
+ hasTangent ? _this._getBlendShapeData(context, glTF, accessors[tangentTarget]) : null
4406
+ ]).then(function(vertices) {
4407
+ var _tangentData;
4408
+ var positionData = vertices[0], normalData = vertices[1], tangentData = vertices[2];
4107
4409
  var blendShape = new BlendShape(name);
4108
- blendShape.addFrame(1.0, positions, normals, tangents);
4109
- mesh.addBlendShape(blendShape);
4110
- var _posAccessor_byteOffset1, _norAccessor_byteOffset1, _tanAccessor_byteOffset1;
4111
- 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));
4410
+ blendShape.addFrame(1.0, positionData.vertices, hasNormal ? normalData.vertices : null, hasTangent ? tangentData.vertices : null);
4411
+ blendShapeData.blendShape = blendShape;
4412
+ blendShapeData.restoreInfo = new BlendShapeRestoreInfo(blendShape, positionData.restoreInfo, hasNormal ? normalData.restoreInfo : null, hasTangent ? (_tangentData = tangentData) == null ? void 0 : _tangentData.restoreInfo : null);
4112
4413
  });
4113
4414
  promises.push(promise);
4114
4415
  };
4416
+ var glTF = context.glTF;
4417
+ var accessors = glTF.accessors;
4115
4418
  var blendShapeNames = glTFMesh.extras ? glTFMesh.extras.targetNames : null;
4116
4419
  var promises = new Array();
4117
- for(var i = 0, n = glTFTargets.length; i < n; i++)_loop(i);
4118
- return Promise.all(promises);
4420
+ var blendShapeCount = glTFTargets.length;
4421
+ var blendShapeCollection = new Array(blendShapeCount);
4422
+ for(var i = 0; i < blendShapeCount; i++)_loop(i);
4423
+ return Promise.all(promises).then(function() {
4424
+ for(var _iterator = _create_for_of_iterator_helper_loose(blendShapeCollection), _step; !(_step = _iterator()).done;){
4425
+ var blendShape = _step.value;
4426
+ mesh.addBlendShape(blendShape.blendShape);
4427
+ meshRestoreInfo.blendShapes.push(blendShape.restoreInfo);
4428
+ }
4429
+ });
4119
4430
  };
4120
4431
  return GLTFMeshParser1;
4121
4432
  }(GLTFParser), function() {
@@ -4148,12 +4459,8 @@ var GLTFSceneParser = /*#__PURE__*/ function(GLTFParser1) {
4148
4459
  sceneRoot.addChild(childEntity);
4149
4460
  }
4150
4461
  }
4151
- // @ts-ignore
4152
- sceneRoot._hookResource = glTFResource;
4153
- // @ts-ignore
4154
- glTFResource._addReferCount(1);
4155
4462
  if (isDefaultScene) {
4156
- glTFResource.defaultSceneRoot = sceneRoot;
4463
+ glTFResource._defaultSceneRoot = sceneRoot;
4157
4464
  }
4158
4465
  var promises = new Array();
4159
4466
  for(var i1 = 0; i1 < sceneNodes.length; i1++){
@@ -4420,11 +4727,12 @@ var GLTFTextureParser = (_GLTFTextureParser = /*#__PURE__*/ function(GLTFParser1
4420
4727
  params: {
4421
4728
  mipmap: (_samplerInfo = samplerInfo) == null ? void 0 : _samplerInfo.mipmap
4422
4729
  }
4423
- }).then(function(texture) {
4730
+ }).onProgress(undefined, context._onTaskDetail).then(function(texture) {
4424
4731
  texture.name = textureName || imageName || texture.name || "texture_" + index;
4425
4732
  useSampler && GLTFUtils.parseSampler(texture, samplerInfo);
4426
4733
  return texture;
4427
4734
  });
4735
+ context._addTaskCompletePromise(texture);
4428
4736
  } else {
4429
4737
  var bufferView = glTF.bufferViews[bufferViewIndex];
4430
4738
  texture = context.get(GLTFParserType.Buffer).then(function(buffers) {
@@ -4446,6 +4754,8 @@ var GLTFTextureParser = (_GLTFTextureParser = /*#__PURE__*/ function(GLTFParser1
4446
4754
  }
4447
4755
  return Promise.resolve(texture).then(function(texture) {
4448
4756
  GLTFParser.executeExtensionsAdditiveAndParse(extensions, context, texture, textureInfo);
4757
+ // @ts-ignore
4758
+ texture._associationSuperResource(glTFResource);
4449
4759
  return texture;
4450
4760
  });
4451
4761
  };
@@ -4496,12 +4806,274 @@ GLTFValidator = __decorate([
4496
4806
  registerGLTFParser(GLTFParserType.Validator)
4497
4807
  ], GLTFValidator);
4498
4808
 
4809
+ var GLTFBufferViewParser = /*#__PURE__*/ function(GLTFParser1) {
4810
+ _inherits(GLTFBufferViewParser, GLTFParser1);
4811
+ function GLTFBufferViewParser() {
4812
+ return GLTFParser1.apply(this, arguments);
4813
+ }
4814
+ var _proto = GLTFBufferViewParser.prototype;
4815
+ _proto.parse = function parse(context, index) {
4816
+ var bufferView = context.glTF.bufferViews[index];
4817
+ var extensions = bufferView.extensions, _bufferView_byteOffset = bufferView.byteOffset, byteOffset = _bufferView_byteOffset === void 0 ? 0 : _bufferView_byteOffset, byteLength = bufferView.byteLength, bufferIndex = bufferView.buffer;
4818
+ return extensions ? GLTFParser.executeExtensionsCreateAndParse(extensions, context, bufferView) : context.get(GLTFParserType.Buffer, bufferIndex).then(function(buffer) {
4819
+ return new Uint8Array(buffer, byteOffset, byteLength);
4820
+ });
4821
+ };
4822
+ return GLTFBufferViewParser;
4823
+ }(GLTFParser);
4824
+ GLTFBufferViewParser = __decorate([
4825
+ registerGLTFParser(GLTFParserType.BufferView)
4826
+ ], GLTFBufferViewParser);
4827
+
4828
+ var GLTFAnimatorControllerParser = /*#__PURE__*/ function(GLTFParser1) {
4829
+ _inherits(GLTFAnimatorControllerParser, GLTFParser1);
4830
+ function GLTFAnimatorControllerParser() {
4831
+ return GLTFParser1.apply(this, arguments);
4832
+ }
4833
+ var _proto = GLTFAnimatorControllerParser.prototype;
4834
+ _proto.parse = function parse(context) {
4835
+ var _this = this;
4836
+ if (!context.needAnimatorController) {
4837
+ return Promise.resolve(null);
4838
+ }
4839
+ return context.get(GLTFParserType.Animation).then(function(animations) {
4840
+ var animatorController = _this._createAnimatorController(animations);
4841
+ return Promise.resolve(animatorController);
4842
+ });
4843
+ };
4844
+ _proto._createAnimatorController = function _createAnimatorController(animations) {
4845
+ var animatorController = new AnimatorController();
4846
+ var layer = new AnimatorControllerLayer("layer");
4847
+ var animatorStateMachine = new AnimatorStateMachine();
4848
+ animatorController.addLayer(layer);
4849
+ layer.stateMachine = animatorStateMachine;
4850
+ if (animations) {
4851
+ for(var i = 0; i < animations.length; i++){
4852
+ var animationClip = animations[i];
4853
+ var name = animationClip.name;
4854
+ var uniqueName = animatorStateMachine.makeUniqueStateName(name);
4855
+ if (uniqueName !== name) {
4856
+ console.warn("AnimatorState name is existed, name: " + name + " reset to " + uniqueName);
4857
+ }
4858
+ var animatorState = animatorStateMachine.addState(uniqueName);
4859
+ animatorState.clip = animationClip;
4860
+ }
4861
+ }
4862
+ return animatorController;
4863
+ };
4864
+ return GLTFAnimatorControllerParser;
4865
+ }(GLTFParser);
4866
+ GLTFAnimatorControllerParser = __decorate([
4867
+ registerGLTFParser(GLTFParserType.AnimatorController)
4868
+ ], GLTFAnimatorControllerParser);
4869
+
4870
+ // Source: https://github.com/zeux/meshoptimizer/blob/master/js/meshopt_decoder.js
4871
+ var MeshoptDecoder = function() {
4872
+ var unpack = function unpack(data) {
4873
+ var result = new Uint8Array(data.length);
4874
+ for(var i = 0; i < data.length; ++i){
4875
+ var ch = data.charCodeAt(i);
4876
+ result[i] = ch > 96 ? ch - 97 : ch > 64 ? ch - 39 : ch + 4;
4877
+ }
4878
+ var write = 0;
4879
+ for(var i1 = 0; i1 < data.length; ++i1){
4880
+ result[write++] = result[i1] < 60 ? wasmpack[result[i1]] : (result[i1] - 60) * 64 + result[++i1];
4881
+ }
4882
+ return result.buffer.slice(0, write);
4883
+ };
4884
+ var decode = function decode(fun, target, count, size, source, filter) {
4885
+ var sbrk = instance.exports.sbrk;
4886
+ var count4 = count + 3 & ~3;
4887
+ var tp = sbrk(count4 * size);
4888
+ var sp = sbrk(source.length);
4889
+ var heap = new Uint8Array(instance.exports.memory.buffer);
4890
+ heap.set(source, sp);
4891
+ var res = fun(tp, count, size, sp, source.length);
4892
+ if (res == 0 && filter) {
4893
+ filter(tp, count4, size);
4894
+ }
4895
+ target.set(heap.subarray(tp, tp + count * size));
4896
+ sbrk(tp - sbrk(0));
4897
+ if (res != 0) {
4898
+ throw new Error("Malformed buffer data: " + res);
4899
+ }
4900
+ };
4901
+ var createWorker = function createWorker(url) {
4902
+ var worker = {
4903
+ object: new Worker(url),
4904
+ pending: 0,
4905
+ requests: {}
4906
+ };
4907
+ worker.object.onmessage = function(event) {
4908
+ var data = event.data;
4909
+ worker.pending -= data.count;
4910
+ worker.requests[data.id][data.action](data.value);
4911
+ delete worker.requests[data.id];
4912
+ };
4913
+ return worker;
4914
+ };
4915
+ var initWorkers = function initWorkers(count) {
4916
+ 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 }';
4917
+ var blob = new Blob([
4918
+ source
4919
+ ], {
4920
+ type: "text/javascript"
4921
+ });
4922
+ var url = URL.createObjectURL(blob);
4923
+ for(var i = 0; i < count; ++i){
4924
+ workers[i] = createWorker(url);
4925
+ }
4926
+ URL.revokeObjectURL(url);
4927
+ };
4928
+ var decodeWorker = function decodeWorker(count, size, source, mode, filter) {
4929
+ var worker = workers[0];
4930
+ for(var i = 1; i < workers.length; ++i){
4931
+ if (workers[i].pending < worker.pending) {
4932
+ worker = workers[i];
4933
+ }
4934
+ }
4935
+ return new Promise(function(resolve, reject) {
4936
+ var data = new Uint8Array(source);
4937
+ var id = requestId++;
4938
+ worker.pending += count;
4939
+ worker.requests[id] = {
4940
+ resolve: resolve,
4941
+ reject: reject
4942
+ };
4943
+ worker.object.postMessage({
4944
+ id: id,
4945
+ count: count,
4946
+ size: size,
4947
+ source: data,
4948
+ mode: mode,
4949
+ filter: filter
4950
+ }, [
4951
+ data.buffer
4952
+ ]);
4953
+ });
4954
+ };
4955
+ 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";
4956
+ 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";
4957
+ var wasmpack = new Uint8Array([
4958
+ 32,
4959
+ 0,
4960
+ 65,
4961
+ 2,
4962
+ 1,
4963
+ 106,
4964
+ 34,
4965
+ 33,
4966
+ 3,
4967
+ 128,
4968
+ 11,
4969
+ 4,
4970
+ 13,
4971
+ 64,
4972
+ 6,
4973
+ 253,
4974
+ 10,
4975
+ 7,
4976
+ 15,
4977
+ 116,
4978
+ 127,
4979
+ 5,
4980
+ 8,
4981
+ 12,
4982
+ 40,
4983
+ 16,
4984
+ 19,
4985
+ 54,
4986
+ 20,
4987
+ 9,
4988
+ 27,
4989
+ 255,
4990
+ 113,
4991
+ 17,
4992
+ 42,
4993
+ 67,
4994
+ 24,
4995
+ 23,
4996
+ 146,
4997
+ 148,
4998
+ 18,
4999
+ 14,
5000
+ 22,
5001
+ 45,
5002
+ 70,
5003
+ 69,
5004
+ 56,
5005
+ 114,
5006
+ 101,
5007
+ 21,
5008
+ 25,
5009
+ 63,
5010
+ 75,
5011
+ 136,
5012
+ 108,
5013
+ 28,
5014
+ 118,
5015
+ 29,
5016
+ 73,
5017
+ 115
5018
+ ]);
5019
+ // @ts-ignore
5020
+ var wasm = SystemInfo._detectSIMDSupported() ? wasm_simd : wasm_base;
5021
+ var instance;
5022
+ var ready = WebAssembly.instantiate(unpack(wasm), {}).then(function(result) {
5023
+ instance = result.instance;
5024
+ instance.exports.__wasm_call_ctors();
5025
+ });
5026
+ var filters = {
5027
+ NONE: "",
5028
+ OCTAHEDRAL: "meshopt_decodeFilterOct",
5029
+ QUATERNION: "meshopt_decodeFilterQuat",
5030
+ EXPONENTIAL: "meshopt_decodeFilterExp"
5031
+ };
5032
+ var decoders = {
5033
+ ATTRIBUTES: "meshopt_decodeVertexBuffer",
5034
+ TRIANGLES: "meshopt_decodeIndexBuffer",
5035
+ INDICES: "meshopt_decodeIndexSequence"
5036
+ };
5037
+ var workers = [];
5038
+ var requestId = 0;
5039
+ return {
5040
+ workerCount: 4,
5041
+ ready: ready,
5042
+ useWorkers: function useWorkers() {
5043
+ initWorkers(this.workerCount);
5044
+ },
5045
+ decodeGltfBuffer: function decodeGltfBuffer(count, stride, source, mode, filter) {
5046
+ if (this.workerCount > 0 && workers.length === 0) this.useWorkers();
5047
+ if (workers.length > 0) return decodeWorker(count, stride, source, decoders[mode], filters[filter]);
5048
+ return ready.then(function() {
5049
+ var target = new Uint8Array(count * stride);
5050
+ decode(instance.exports[decoders[mode]], target, count, stride, source, instance.exports[filters[filter]]);
5051
+ return target;
5052
+ });
5053
+ },
5054
+ release: function release() {
5055
+ for(var i = 0; i < workers.length; i++){
5056
+ workers[i].object.terminate();
5057
+ }
5058
+ }
5059
+ };
5060
+ }();
5061
+
4499
5062
  var GLTFLoader = /*#__PURE__*/ function(Loader1) {
4500
5063
  _inherits(GLTFLoader, Loader1);
4501
5064
  function GLTFLoader() {
4502
5065
  return Loader1.apply(this, arguments);
4503
5066
  }
4504
5067
  var _proto = GLTFLoader.prototype;
5068
+ _proto.initialize = function initialize(_, configuration) {
5069
+ var _configuration_glTF;
5070
+ var meshOptOptions = (_configuration_glTF = configuration.glTF) == null ? void 0 : _configuration_glTF.meshOpt;
5071
+ if (meshOptOptions) {
5072
+ MeshoptDecoder.workerCount = meshOptOptions.workerCount;
5073
+ MeshoptDecoder.useWorkers();
5074
+ }
5075
+ return Promise.resolve();
5076
+ };
4505
5077
  _proto.load = function load(item, resourceManager) {
4506
5078
  var url = item.url;
4507
5079
  var params = item.params;
@@ -4509,7 +5081,17 @@ var GLTFLoader = /*#__PURE__*/ function(Loader1) {
4509
5081
  var context = new GLTFParserContext(glTFResource, resourceManager, _extends({
4510
5082
  keepMeshData: false
4511
5083
  }, params));
4512
- return context.parse();
5084
+ return new AssetPromise(function(resolve, reject, setTaskCompleteProgress, setTaskDetailProgress) {
5085
+ context._setTaskCompleteProgress = setTaskCompleteProgress;
5086
+ context._setTaskDetailProgress = setTaskDetailProgress;
5087
+ context.parse().then(resolve).catch(reject);
5088
+ });
5089
+ };
5090
+ /**
5091
+ * Release glTF loader memory(includes meshopt workers).
5092
+ * @remarks If use loader after releasing, we should release again.
5093
+ */ GLTFLoader.release = function release() {
5094
+ MeshoptDecoder.release();
4513
5095
  };
4514
5096
  return GLTFLoader;
4515
5097
  }(Loader);
@@ -4522,7 +5104,8 @@ GLTFLoader = __decorate([
4522
5104
 
4523
5105
  var _HDRLoader;
4524
5106
  var PI = Math.PI;
4525
- var HDRLoader = (_HDRLoader = /*#__PURE__*/ function(Loader1) {
5107
+ var HDRLoader = (_HDRLoader = // referenece: https://www.flipcode.com/archives/HDR_Image_Reader.shtml
5108
+ /*#__PURE__*/ function(Loader1) {
4526
5109
  _inherits(HDRLoader1, Loader1);
4527
5110
  function HDRLoader1() {
4528
5111
  return Loader1.apply(this, arguments);
@@ -4692,15 +5275,20 @@ var HDRLoader = (_HDRLoader = /*#__PURE__*/ function(Loader1) {
4692
5275
  var dataRGBA = new Uint8Array(4 * width * height);
4693
5276
  var offset = 0, pos = 0;
4694
5277
  var ptrEnd = 4 * scanLineWidth;
4695
- var rgbeStart = new Uint8Array(4);
4696
5278
  var scanLineBuffer = new Uint8Array(ptrEnd);
4697
5279
  var numScanLines = height; // read in each successive scanLine
4698
5280
  while(numScanLines > 0 && pos < byteLength){
4699
- rgbeStart[0] = buffer[pos++];
4700
- rgbeStart[1] = buffer[pos++];
4701
- rgbeStart[2] = buffer[pos++];
4702
- rgbeStart[3] = buffer[pos++];
4703
- if (2 != rgbeStart[0] || 2 != rgbeStart[1] || (rgbeStart[2] << 8 | rgbeStart[3]) != scanLineWidth) {
5281
+ var a = buffer[pos++];
5282
+ var b = buffer[pos++];
5283
+ var c = buffer[pos++];
5284
+ var d = buffer[pos++];
5285
+ if (a != 2 || b != 2 || c & 0x80 || width < 8 || width > 32767) {
5286
+ // this file is not run length encoded
5287
+ // read values sequentially
5288
+ return buffer;
5289
+ }
5290
+ if ((c << 8 | d) != scanLineWidth) {
5291
+ // eslint-disable-next-line no-throw-literal
4704
5292
  throw "HDR Bad header format, wrong scan line width";
4705
5293
  }
4706
5294
  // read each of the four channels for the scanline into the buffer
@@ -5220,6 +5808,86 @@ MeshLoader = __decorate([
5220
5808
  ])
5221
5809
  ], MeshLoader);
5222
5810
 
5811
+ var PrimitiveMeshLoader = /*#__PURE__*/ function(Loader1) {
5812
+ _inherits(PrimitiveMeshLoader, Loader1);
5813
+ function PrimitiveMeshLoader() {
5814
+ return Loader1.apply(this, arguments);
5815
+ }
5816
+ var _proto = PrimitiveMeshLoader.prototype;
5817
+ _proto.load = function load(item, param) {
5818
+ var engine = param.engine;
5819
+ return this.request(item.url, _extends({}, item, {
5820
+ type: "json"
5821
+ })).then(function(data) {
5822
+ switch(data.type){
5823
+ case "sphere":
5824
+ return PrimitiveMesh.createSubdivisionSurfaceSphere(engine, data.sphereRadius, data.sphereStep);
5825
+ case "capsule":
5826
+ return PrimitiveMesh.createCapsule(engine, data.capsuleRadius, data.capsuleHeight, data.capsuleRadialSegments, data.capsuleHeightSegments);
5827
+ case "cone":
5828
+ return PrimitiveMesh.createCone(engine, data.coneRadius, data.coneHeight, data.coneRadialSegment, data.coneHeightSegment);
5829
+ case "cuboid":
5830
+ return PrimitiveMesh.createCuboid(engine, data.cuboidWidth, data.cuboidHeight, data.cuboidDepth);
5831
+ case "cylinder":
5832
+ return PrimitiveMesh.createCylinder(engine, data.cylinderRadiusTop, data.cylinderRadiusBottom, data.cylinderHeight, data.cylinderRadialSegment, data.cylinderHeightSegment);
5833
+ case "plane":
5834
+ return PrimitiveMesh.createPlane(engine, data.planeWidth, data.planeHeight, data.planeHorizontalSegments, data.planeVerticalSegments);
5835
+ case "torus":
5836
+ return PrimitiveMesh.createTorus(engine, data.torusRadius, data.torusTubeRadius, data.torusRadialSegments, data.torusTubularSegments, data.torusArc);
5837
+ }
5838
+ });
5839
+ };
5840
+ return PrimitiveMeshLoader;
5841
+ }(Loader);
5842
+ PrimitiveMeshLoader = __decorate([
5843
+ resourceLoader(AssetType.PrimitiveMesh, [
5844
+ "mesh"
5845
+ ], false)
5846
+ ], PrimitiveMeshLoader);
5847
+ var /** @internal */ PrimitiveMeshType;
5848
+ (function(PrimitiveMeshType) {
5849
+ PrimitiveMeshType["Sphere"] = "sphere";
5850
+ PrimitiveMeshType["Cuboid"] = "cuboid";
5851
+ PrimitiveMeshType["Plane"] = "plane";
5852
+ PrimitiveMeshType["Cylinder"] = "cylinder";
5853
+ PrimitiveMeshType["Torus"] = "torus";
5854
+ PrimitiveMeshType["Cone"] = "cone";
5855
+ PrimitiveMeshType["Capsule"] = "capsule";
5856
+ })(PrimitiveMeshType || (PrimitiveMeshType = {}));
5857
+
5858
+ var ProjectLoader = /*#__PURE__*/ function(Loader1) {
5859
+ _inherits(ProjectLoader, Loader1);
5860
+ function ProjectLoader() {
5861
+ return Loader1.apply(this, arguments);
5862
+ }
5863
+ var _proto = ProjectLoader.prototype;
5864
+ _proto.load = function load(item, resourceManager) {
5865
+ var _this = this;
5866
+ var engine = resourceManager.engine;
5867
+ return new AssetPromise(function(resolve, reject) {
5868
+ _this.request(item.url, {
5869
+ type: "json"
5870
+ }).then(function(data) {
5871
+ // @ts-ignore
5872
+ engine.resourceManager.initVirtualResources(data.files);
5873
+ return resourceManager.load({
5874
+ type: AssetType.Scene,
5875
+ url: data.scene
5876
+ }).then(function(scene) {
5877
+ engine.sceneManager.activeScene = scene;
5878
+ resolve();
5879
+ });
5880
+ }).catch(reject);
5881
+ });
5882
+ };
5883
+ return ProjectLoader;
5884
+ }(Loader);
5885
+ ProjectLoader = __decorate([
5886
+ resourceLoader(AssetType.Project, [
5887
+ "proj"
5888
+ ], false)
5889
+ ], ProjectLoader);
5890
+
5223
5891
  var SourceFontLoader = /*#__PURE__*/ function(Loader1) {
5224
5892
  _inherits(SourceFontLoader, Loader1);
5225
5893
  function SourceFontLoader() {
@@ -5282,7 +5950,7 @@ var SpriteAtlasLoader = /*#__PURE__*/ function(Loader1) {
5282
5950
  var _proto = SpriteAtlasLoader.prototype;
5283
5951
  _proto.load = function load(item, resourceManager) {
5284
5952
  var _this = this;
5285
- return new AssetPromise(function(resolve, reject, _, onCancel) {
5953
+ return new AssetPromise(function(resolve, reject, _, __, onCancel) {
5286
5954
  var chainPromises = [];
5287
5955
  onCancel(function() {
5288
5956
  for(var i = 0; i < chainPromises.length; i++){
@@ -5445,12 +6113,12 @@ var Texture2DLoader = /*#__PURE__*/ function(Loader1) {
5445
6113
  var _proto = Texture2DLoader.prototype;
5446
6114
  _proto.load = function load(item, resourceManager) {
5447
6115
  var _this = this;
5448
- return new AssetPromise(function(resolve, reject) {
6116
+ return new AssetPromise(function(resolve, reject, setTaskCompleteProgress, setTaskDetailProgress) {
5449
6117
  var url = item.url;
5450
6118
  var requestConfig = _extends({}, item, {
5451
6119
  type: "image"
5452
6120
  });
5453
- _this.request(url, requestConfig).then(function(image) {
6121
+ _this.request(url, requestConfig).onProgress(setTaskCompleteProgress, setTaskDetailProgress).then(function(image) {
5454
6122
  var _item_params;
5455
6123
  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;
5456
6124
  var texture = new Texture2D(resourceManager.engine, image.width, image.height, format, mipmap);
@@ -5555,39 +6223,6 @@ TextureCubeLoader = __decorate([
5555
6223
  ])
5556
6224
  ], TextureCubeLoader);
5557
6225
 
5558
- var ProjectLoader = /*#__PURE__*/ function(Loader1) {
5559
- _inherits(ProjectLoader, Loader1);
5560
- function ProjectLoader() {
5561
- return Loader1.apply(this, arguments);
5562
- }
5563
- var _proto = ProjectLoader.prototype;
5564
- _proto.load = function load(item, resourceManager) {
5565
- var _this = this;
5566
- var engine = resourceManager.engine;
5567
- return new AssetPromise(function(resolve, reject) {
5568
- _this.request(item.url, {
5569
- type: "json"
5570
- }).then(function(data) {
5571
- // @ts-ignore
5572
- engine.resourceManager.initVirtualResources(data.files);
5573
- return resourceManager.load({
5574
- type: AssetType.Scene,
5575
- url: data.scene
5576
- }).then(function(scene) {
5577
- engine.sceneManager.activeScene = scene;
5578
- resolve();
5579
- });
5580
- }).catch(reject);
5581
- });
5582
- };
5583
- return ProjectLoader;
5584
- }(Loader);
5585
- ProjectLoader = __decorate([
5586
- resourceLoader(AssetType.Project, [
5587
- "proj"
5588
- ], false)
5589
- ], ProjectLoader);
5590
-
5591
6226
  var SceneLoader = /*#__PURE__*/ function(Loader1) {
5592
6227
  _inherits(SceneLoader, Loader1);
5593
6228
  function SceneLoader() {
@@ -5606,7 +6241,7 @@ var SceneLoader = /*#__PURE__*/ function(Loader1) {
5606
6241
  // parse ambient light
5607
6242
  var ambient = data.scene.ambient;
5608
6243
  if (ambient) {
5609
- var useCustomAmbient = ambient.specularMode === "Custom";
6244
+ var useCustomAmbient = ambient.specularMode === SpecularMode.Custom;
5610
6245
  var useSH = ambient.diffuseMode === DiffuseMode.SphericalHarmonics;
5611
6246
  scene.ambientLight.diffuseIntensity = ambient.diffuseIntensity;
5612
6247
  scene.ambientLight.specularIntensity = ambient.specularIntensity;
@@ -5634,6 +6269,7 @@ var SceneLoader = /*#__PURE__*/ function(Loader1) {
5634
6269
  }));
5635
6270
  }
5636
6271
  }
6272
+ // parse background
5637
6273
  var background = data.scene.background;
5638
6274
  scene.background.mode = background.mode;
5639
6275
  switch(scene.background.mode){
@@ -5677,6 +6313,17 @@ var SceneLoader = /*#__PURE__*/ function(Loader1) {
5677
6313
  var _shadow_shadowTwoCascadeSplits;
5678
6314
  scene.shadowTwoCascadeSplits = (_shadow_shadowTwoCascadeSplits = shadow.shadowTwoCascadeSplits) != null ? _shadow_shadowTwoCascadeSplits : scene.shadowTwoCascadeSplits;
5679
6315
  shadow.shadowFourCascadeSplits && scene.shadowFourCascadeSplits.copyFrom(shadow.shadowFourCascadeSplits);
6316
+ var _shadow_shadowFadeBorder;
6317
+ scene.shadowFadeBorder = (_shadow_shadowFadeBorder = shadow.shadowFadeBorder) != null ? _shadow_shadowFadeBorder : scene.shadowFadeBorder;
6318
+ }
6319
+ // parse fog
6320
+ var fog = data.scene.fog;
6321
+ if (fog) {
6322
+ if (fog.fogMode != undefined) scene.fogMode = fog.fogMode;
6323
+ if (fog.fogStart != undefined) scene.fogStart = fog.fogStart;
6324
+ if (fog.fogEnd != undefined) scene.fogEnd = fog.fogEnd;
6325
+ if (fog.fogDensity != undefined) scene.fogDensity = fog.fogDensity;
6326
+ if (fog.fogColor != undefined) scene.fogColor.copyFrom(fog.fogColor);
5680
6327
  }
5681
6328
  return Promise.all(promises).then(function() {
5682
6329
  resolve(scene);
@@ -5707,170 +6354,6 @@ ReflectionParser.registerCustomParseComponent("TextRenderer", /*#__PURE__*/ _asy
5707
6354
  });
5708
6355
  }));
5709
6356
 
5710
- var _KHR_draco_mesh_compression;
5711
- var KHR_draco_mesh_compression = (_KHR_draco_mesh_compression = /*#__PURE__*/ function(GLTFExtensionParser1) {
5712
- _inherits(KHR_draco_mesh_compression1, GLTFExtensionParser1);
5713
- function KHR_draco_mesh_compression1() {
5714
- return GLTFExtensionParser1.apply(this, arguments);
5715
- }
5716
- var _proto = KHR_draco_mesh_compression1.prototype;
5717
- _proto.createAndParse = function createAndParse(context, schema, glTFPrimitive, glTFMesh) {
5718
- var _this = this;
5719
- this._initialize();
5720
- var glTF = context.glTF, engine = context.glTFResource.engine;
5721
- var bufferViews = glTF.bufferViews, accessors = glTF.accessors;
5722
- var bufferViewIndex = schema.bufferView, gltfAttributeMap = schema.attributes;
5723
- var attributeMap = {};
5724
- var attributeTypeMap = {};
5725
- for(var attributeName in gltfAttributeMap){
5726
- attributeMap[attributeName] = gltfAttributeMap[attributeName];
5727
- }
5728
- for(var attributeName1 in glTFPrimitive.attributes){
5729
- if (gltfAttributeMap[attributeName1] !== undefined) {
5730
- var accessorDef = accessors[glTFPrimitive.attributes[attributeName1]];
5731
- attributeTypeMap[attributeName1] = GLTFUtils.getComponentType(accessorDef.componentType).name;
5732
- }
5733
- }
5734
- var indexAccessor = accessors[glTFPrimitive.indices];
5735
- var indexType = GLTFUtils.getComponentType(indexAccessor.componentType).name;
5736
- var taskConfig = {
5737
- attributeIDs: attributeMap,
5738
- attributeTypes: attributeTypeMap,
5739
- useUniqueIDs: true,
5740
- indexType: indexType
5741
- };
5742
- return context.get(GLTFParserType.Buffer).then(function(buffers) {
5743
- var buffer = GLTFUtils.getBufferViewData(bufferViews[bufferViewIndex], buffers);
5744
- return KHR_draco_mesh_compression._decoder.decode(buffer, taskConfig).then(function(decodedGeometry) {
5745
- var mesh = new ModelMesh(engine, glTFMesh.name);
5746
- return _this._parseMeshFromGLTFPrimitiveDraco(mesh, glTFMesh, glTFPrimitive, glTF, function(attributeSemantic) {
5747
- for(var j = 0; j < decodedGeometry.attributes.length; j++){
5748
- if (decodedGeometry.attributes[j].name === attributeSemantic) {
5749
- return decodedGeometry.attributes[j].array;
5750
- }
5751
- }
5752
- return null;
5753
- }, function(attributeSemantic, shapeIndex) {
5754
- throw "BlendShape animation is not supported when using draco.";
5755
- }, function() {
5756
- return decodedGeometry.index.array;
5757
- }, context.params.keepMeshData);
5758
- });
5759
- });
5760
- };
5761
- _proto._initialize = function _initialize() {
5762
- if (!KHR_draco_mesh_compression._decoder) {
5763
- KHR_draco_mesh_compression._decoder = new DRACODecoder();
5764
- }
5765
- };
5766
- _proto._parseMeshFromGLTFPrimitiveDraco = function _parseMeshFromGLTFPrimitiveDraco(mesh, gltfMesh, gltfPrimitive, gltf, getVertexBufferData, getBlendShapeData, getIndexBufferData, keepMeshData) {
5767
- var attributes = gltfPrimitive.attributes, targets = gltfPrimitive.targets, indices = gltfPrimitive.indices, mode = gltfPrimitive.mode;
5768
- var vertexCount;
5769
- var accessors = gltf.accessors;
5770
- var accessor = accessors[attributes["POSITION"]];
5771
- var positionBuffer = getVertexBufferData("POSITION");
5772
- var positions = GLTFUtils.floatBufferToVector3Array(positionBuffer);
5773
- mesh.setPositions(positions);
5774
- var bounds = mesh.bounds;
5775
- vertexCount = accessor.count;
5776
- if (accessor.min && accessor.max) {
5777
- bounds.min.copyFromArray(accessor.min);
5778
- bounds.max.copyFromArray(accessor.max);
5779
- } else {
5780
- var position = KHR_draco_mesh_compression._tempVector3;
5781
- var min = bounds.min, max = bounds.max;
5782
- min.set(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
5783
- max.set(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
5784
- var stride = positionBuffer.length / vertexCount;
5785
- for(var j = 0; j < vertexCount; j++){
5786
- var offset = j * stride;
5787
- position.copyFromArray(positionBuffer, offset);
5788
- Vector3.min(min, position, min);
5789
- Vector3.max(max, position, max);
5790
- }
5791
- }
5792
- for(var attributeSemantic in attributes){
5793
- if (attributeSemantic === "POSITION") {
5794
- continue;
5795
- }
5796
- var bufferData = getVertexBufferData(attributeSemantic);
5797
- switch(attributeSemantic){
5798
- case "NORMAL":
5799
- var normals = GLTFUtils.floatBufferToVector3Array(bufferData);
5800
- mesh.setNormals(normals);
5801
- break;
5802
- case "TEXCOORD_0":
5803
- var texturecoords = GLTFUtils.floatBufferToVector2Array(bufferData);
5804
- mesh.setUVs(texturecoords, 0);
5805
- break;
5806
- case "TEXCOORD_1":
5807
- var texturecoords1 = GLTFUtils.floatBufferToVector2Array(bufferData);
5808
- mesh.setUVs(texturecoords1, 1);
5809
- break;
5810
- case "TEXCOORD_2":
5811
- var texturecoords2 = GLTFUtils.floatBufferToVector2Array(bufferData);
5812
- mesh.setUVs(texturecoords2, 2);
5813
- break;
5814
- case "TEXCOORD_3":
5815
- var texturecoords3 = GLTFUtils.floatBufferToVector2Array(bufferData);
5816
- mesh.setUVs(texturecoords3, 3);
5817
- break;
5818
- case "TEXCOORD_4":
5819
- var texturecoords4 = GLTFUtils.floatBufferToVector2Array(bufferData);
5820
- mesh.setUVs(texturecoords4, 4);
5821
- break;
5822
- case "TEXCOORD_5":
5823
- var texturecoords5 = GLTFUtils.floatBufferToVector2Array(bufferData);
5824
- mesh.setUVs(texturecoords5, 5);
5825
- break;
5826
- case "TEXCOORD_6":
5827
- var texturecoords6 = GLTFUtils.floatBufferToVector2Array(bufferData);
5828
- mesh.setUVs(texturecoords6, 6);
5829
- break;
5830
- case "TEXCOORD_7":
5831
- var texturecoords7 = GLTFUtils.floatBufferToVector2Array(bufferData);
5832
- mesh.setUVs(texturecoords7, 7);
5833
- break;
5834
- case "COLOR_0":
5835
- var colors = GLTFUtils.floatBufferToColorArray(bufferData, accessors[attributes["COLOR_0"]].type === AccessorType.VEC3);
5836
- mesh.setColors(colors);
5837
- break;
5838
- case "TANGENT":
5839
- var tangents = GLTFUtils.floatBufferToVector4Array(bufferData);
5840
- mesh.setTangents(tangents);
5841
- break;
5842
- case "JOINTS_0":
5843
- var joints = GLTFUtils.floatBufferToVector4Array(bufferData);
5844
- mesh.setBoneIndices(joints);
5845
- break;
5846
- case "WEIGHTS_0":
5847
- var weights = GLTFUtils.floatBufferToVector4Array(bufferData);
5848
- mesh.setBoneWeights(weights);
5849
- break;
5850
- }
5851
- }
5852
- // Indices
5853
- if (indices !== undefined) {
5854
- var indexAccessor = gltf.accessors[indices];
5855
- var indexData = getIndexBufferData();
5856
- mesh.setIndices(indexData);
5857
- mesh.addSubMesh(0, indexAccessor.count, mode);
5858
- } else {
5859
- mesh.addSubMesh(0, vertexCount, mode);
5860
- }
5861
- // BlendShapes
5862
- targets && GLTFMeshParser._createBlendShape(mesh, null, gltfMesh, accessors, targets, getBlendShapeData);
5863
- mesh.uploadData(!keepMeshData);
5864
- return Promise.resolve(mesh);
5865
- };
5866
- return KHR_draco_mesh_compression1;
5867
- }(GLTFExtensionParser), function() {
5868
- _KHR_draco_mesh_compression._tempVector3 = new Vector3();
5869
- }(), _KHR_draco_mesh_compression);
5870
- KHR_draco_mesh_compression = __decorate([
5871
- registerGLTFExtension("KHR_draco_mesh_compression", GLTFExtensionMode.CreateAndParse)
5872
- ], KHR_draco_mesh_compression);
5873
-
5874
6357
  var KHR_lights_punctual = /*#__PURE__*/ function(GLTFExtensionParser1) {
5875
6358
  _inherits(KHR_lights_punctual, GLTFExtensionParser1);
5876
6359
  function KHR_lights_punctual() {
@@ -6045,7 +6528,7 @@ var KHR_materials_variants = /*#__PURE__*/ function(GLTFExtensionParser1) {
6045
6528
  var _glTFResource;
6046
6529
  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;
6047
6530
  var mappings = schema.mappings;
6048
- (_glTFResource = glTFResource).extensionsData || (_glTFResource.extensionsData = {});
6531
+ (_glTFResource = glTFResource)._extensionsData || (_glTFResource._extensionsData = {});
6049
6532
  var extensionData = [];
6050
6533
  glTFResource.extensionsData.variants = extensionData;
6051
6534
  for(var i = 0; i < mappings.length; i++)_loop(i);
@@ -6075,7 +6558,7 @@ var KHR_texture_basisu = /*#__PURE__*/ function(GLTFExtensionParser1) {
6075
6558
  var _proto = KHR_texture_basisu.prototype;
6076
6559
  _proto.createAndParse = function createAndParse(context, schema, textureInfo) {
6077
6560
  return _async_to_generator(function() {
6078
- var glTF, glTFResource, engine, url, sampler, textureName, source, _glTF_images_source, uri, bufferViewIndex, mimeType, imageName, samplerInfo, index, bufferView;
6561
+ var glTF, glTFResource, engine, url, sampler, textureName, source, _glTF_images_source, uri, bufferViewIndex, mimeType, imageName, samplerInfo, index, promise, bufferView;
6079
6562
  return __generator(this, function(_state) {
6080
6563
  glTF = context.glTF, glTFResource = context.glTFResource;
6081
6564
  engine = glTFResource.engine, url = glTFResource.url;
@@ -6085,20 +6568,22 @@ var KHR_texture_basisu = /*#__PURE__*/ function(GLTFExtensionParser1) {
6085
6568
  samplerInfo = sampler !== undefined && GLTFUtils.getSamplerInfo(glTF.samplers[sampler]);
6086
6569
  if (uri) {
6087
6570
  index = uri.lastIndexOf(".");
6571
+ promise = engine.resourceManager.load({
6572
+ url: Utils.resolveAbsoluteUrl(url, uri),
6573
+ type: AssetType.KTX2
6574
+ }).onProgress(undefined, context._onTaskDetail).then(function(texture) {
6575
+ if (!texture.name) {
6576
+ texture.name = textureName || imageName || "texture_" + index;
6577
+ }
6578
+ if (sampler !== undefined) {
6579
+ GLTFUtils.parseSampler(texture, samplerInfo);
6580
+ }
6581
+ return texture;
6582
+ });
6583
+ context._addTaskCompletePromise(promise);
6088
6584
  return [
6089
6585
  2,
6090
- engine.resourceManager.load({
6091
- url: Utils.resolveAbsoluteUrl(url, uri),
6092
- type: AssetType.KTX2
6093
- }).then(function(texture) {
6094
- if (!texture.name) {
6095
- texture.name = textureName || imageName || "texture_" + index;
6096
- }
6097
- if (sampler !== undefined) {
6098
- GLTFUtils.parseSampler(texture, samplerInfo);
6099
- }
6100
- return texture;
6101
- })
6586
+ promise
6102
6587
  ];
6103
6588
  } else {
6104
6589
  bufferView = glTF.bufferViews[bufferViewIndex];
@@ -6168,7 +6653,9 @@ var GALACEAN_materials_remap = /*#__PURE__*/ function(GLTFExtensionParser1) {
6168
6653
  _proto.createAndParse = function createAndParse(context, schema) {
6169
6654
  var engine = context.glTFResource.engine;
6170
6655
  // @ts-ignore
6171
- return engine.resourceManager.getResourceByRef(schema);
6656
+ var promise = engine.resourceManager.getResourceByRef(schema);
6657
+ context._addTaskCompletePromise(promise);
6658
+ return promise;
6172
6659
  };
6173
6660
  return GALACEAN_materials_remap;
6174
6661
  }(GLTFExtensionParser);
@@ -6199,5 +6686,45 @@ GALACEAN_animation_event = __decorate([
6199
6686
  registerGLTFExtension("GALACEAN_animation_event", GLTFExtensionMode.AdditiveParse)
6200
6687
  ], GALACEAN_animation_event);
6201
6688
 
6202
- export { AnimationClipDecoder, ComponentMap, EditorTextureLoader, GLTFAnimationParser, GLTFBufferParser, GLTFEntityParser, GLTFExtensionMode, GLTFExtensionParser, GLTFMaterialParser, GLTFMeshParser, GLTFParser, GLTFParserContext, GLTFParserType, GLTFResource, GLTFSceneParser, GLTFSchemaParser, GLTFSkinParser, GLTFTextureParser, GLTFUtils, GLTFValidator, InterpolableValueType, KTX2Loader, KTX2TargetFormat, KTX2Transcoder, MeshDecoder, MeshLoader$1 as MeshLoader, PrefabParser, ReflectionParser, SceneParser, SpecularMode, Texture2DDecoder, decode, parseSingleKTX, registerGLTFExtension, registerGLTFParser };
6689
+ var EXT_meshopt_compression = /*#__PURE__*/ function(GLTFExtensionParser1) {
6690
+ _inherits(EXT_meshopt_compression, GLTFExtensionParser1);
6691
+ function EXT_meshopt_compression() {
6692
+ return GLTFExtensionParser1.apply(this, arguments);
6693
+ }
6694
+ var _proto = EXT_meshopt_compression.prototype;
6695
+ _proto.createAndParse = function createAndParse(context, schema) {
6696
+ return context.get(GLTFParserType.Buffer, schema.buffer).then(function(arrayBuffer) {
6697
+ return MeshoptDecoder.decodeGltfBuffer(schema.count, schema.byteStride, new Uint8Array(arrayBuffer, schema.byteOffset, schema.byteLength), schema.mode, schema.filter);
6698
+ });
6699
+ };
6700
+ return EXT_meshopt_compression;
6701
+ }(GLTFExtensionParser);
6702
+ EXT_meshopt_compression = __decorate([
6703
+ registerGLTFExtension("EXT_meshopt_compression", GLTFExtensionMode.CreateAndParse)
6704
+ ], EXT_meshopt_compression);
6705
+
6706
+ var KHR_materials_anisotropy = /*#__PURE__*/ function(GLTFExtensionParser1) {
6707
+ _inherits(KHR_materials_anisotropy, GLTFExtensionParser1);
6708
+ function KHR_materials_anisotropy() {
6709
+ return GLTFExtensionParser1.apply(this, arguments);
6710
+ }
6711
+ var _proto = KHR_materials_anisotropy.prototype;
6712
+ _proto.additiveParse = function additiveParse(context, material, schema) {
6713
+ 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;
6714
+ material.anisotropy = anisotropyStrength;
6715
+ material.anisotropyRotation = anisotropyRotation;
6716
+ if (anisotropyTexture) {
6717
+ GLTFMaterialParser._checkOtherTextureTransform(anisotropyTexture, "Anisotropy texture");
6718
+ context.get(GLTFParserType.Texture, anisotropyTexture.index).then(function(texture) {
6719
+ material.anisotropyTexture = texture;
6720
+ });
6721
+ }
6722
+ };
6723
+ return KHR_materials_anisotropy;
6724
+ }(GLTFExtensionParser);
6725
+ KHR_materials_anisotropy = __decorate([
6726
+ registerGLTFExtension("KHR_materials_anisotropy", GLTFExtensionMode.AdditiveParse)
6727
+ ], KHR_materials_anisotropy);
6728
+
6729
+ export { AccessorType, AnimationClipDecoder, BufferInfo, EditorTextureLoader, GLTFAnimationParser, GLTFAnimatorControllerParser, GLTFBufferParser, GLTFBufferViewParser, GLTFEntityParser, GLTFExtensionMode, GLTFExtensionParser, GLTFLoader, GLTFMaterialParser, GLTFMeshParser, GLTFParser, GLTFParserContext, GLTFParserType, GLTFResource, GLTFSceneParser, GLTFSchemaParser, GLTFSkinParser, GLTFTextureParser, GLTFUtils, GLTFValidator, InterpolableValueType, KTX2Loader, KTX2TargetFormat, KTX2Transcoder, MeshDecoder, MeshLoader$1 as MeshLoader, ParserContext, PrefabParser, ReflectionParser, SceneParser, SpecularMode, Texture2DDecoder, decode, parseSingleKTX, registerGLTFExtension, registerGLTFParser };
6203
6730
  //# sourceMappingURL=module.js.map