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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/LICENSE +2 -2
  2. package/dist/main.js +1310 -706
  3. package/dist/main.js.map +1 -1
  4. package/dist/miniprogram.js +1309 -706
  5. package/dist/module.js +1298 -695
  6. package/dist/module.js.map +1 -1
  7. package/package.json +4 -5
  8. package/types/GLTFContentRestorer.d.ts +7 -6
  9. package/types/GLTFLoader.d.ts +7 -1
  10. package/types/PrimitiveMeshLoader.d.ts +1 -0
  11. package/types/ShaderChunkLoader.d.ts +1 -0
  12. package/types/ShaderLoader.d.ts +1 -0
  13. package/types/gltf/GLTFResource.d.ts +50 -16
  14. package/types/gltf/GLTFSchema.d.ts +1 -1
  15. package/types/gltf/GLTFUtils.d.ts +6 -10
  16. package/types/gltf/extensions/EXT_meshopt_compression.d.ts +13 -0
  17. package/types/gltf/extensions/GLTFExtensionParser.d.ts +1 -1
  18. package/types/gltf/extensions/GLTFExtensionSchema.d.ts +18 -10
  19. package/types/gltf/extensions/KHR_materials_anisotropy.d.ts +1 -0
  20. package/types/gltf/extensions/MeshoptDecoder.d.ts +8 -0
  21. package/types/gltf/extensions/index.d.ts +2 -1
  22. package/types/gltf/index.d.ts +2 -1
  23. package/types/gltf/parser/GLTFBufferViewParser.d.ts +5 -0
  24. package/types/gltf/parser/GLTFJSONParser.d.ts +7 -0
  25. package/types/gltf/parser/GLTFMeshParser.d.ts +7 -6
  26. package/types/gltf/parser/GLTFParser.d.ts +1 -1
  27. package/types/gltf/parser/GLTFParserContext.d.ts +20 -6
  28. package/types/gltf/parser/GLTFSchemaParser.d.ts +0 -1
  29. package/types/gltf/parser/index.d.ts +2 -1
  30. package/types/index.d.ts +5 -1
  31. package/types/ktx2/KTX2Loader.d.ts +4 -3
  32. package/types/resource-deserialize/index.d.ts +2 -1
  33. package/types/resource-deserialize/resources/animationClip/AnimationClipDecoder.d.ts +0 -1
  34. package/types/resource-deserialize/resources/parser/HierarchyParser.d.ts +36 -0
  35. package/types/resource-deserialize/resources/parser/ParserContext.d.ts +29 -0
  36. package/types/resource-deserialize/resources/parser/ReflectionParser.d.ts +4 -4
  37. package/types/resource-deserialize/resources/prefab/PrefabDesign.d.ts +70 -0
  38. package/types/resource-deserialize/resources/prefab/PrefabParser.d.ts +14 -0
  39. package/types/resource-deserialize/resources/prefab/PrefabParserContext.d.ts +5 -0
  40. package/types/resource-deserialize/resources/prefab/ReflectionParser.d.ts +14 -0
  41. package/types/resource-deserialize/resources/scene/SceneParser.d.ts +3 -17
  42. package/types/resource-deserialize/resources/scene/SceneParserContext.d.ts +6 -12
  43. package/types/resource-deserialize/resources/schema/BasicSchema.d.ts +27 -1
  44. package/types/resource-deserialize/resources/schema/MaterialSchema.d.ts +2 -1
  45. package/types/resource-deserialize/resources/schema/SceneSchema.d.ts +9 -1
package/dist/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, Shader, Material, PrimitiveMesh, SpriteAtlas, Sprite, ShaderFactory, 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,28 @@ 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 = {};
1575
1885
  this._resourceCache = new Map();
1886
+ this._progress = {
1887
+ taskDetail: {},
1888
+ taskComplete: {
1889
+ loaded: 0,
1890
+ total: 0
1891
+ }
1892
+ };
1893
+ this./**
1894
+ * @internal
1895
+ */ _onTaskDetail = function(url, loaded, total) {
1896
+ var _this__progress_taskDetail, _url;
1897
+ var detail = (_this__progress_taskDetail = _this._progress.taskDetail)[_url = url] || (_this__progress_taskDetail[_url] = {});
1898
+ detail.loaded = loaded;
1899
+ detail.total = total;
1900
+ _this._setTaskDetailProgress(url, loaded, total);
1901
+ };
1576
1902
  this.contentRestorer = new GLTFContentRestorer(glTFResource);
1577
1903
  }
1578
1904
  var _proto = GLTFParserContext.prototype;
@@ -1595,7 +1921,7 @@ var TextureWrapMode;
1595
1921
  var glTFItems = this.glTF[glTFSchemaMap[type]];
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);
@@ -1613,15 +1939,15 @@ var TextureWrapMode;
1613
1939
  };
1614
1940
  _proto.parse = function parse() {
1615
1941
  var _this = this;
1616
- return this.get(0).then(function(json) {
1942
+ var promise = this.get(0).then(function(json) {
1617
1943
  _this.glTF = json;
1618
1944
  return Promise.all([
1619
1945
  _this.get(1),
1620
- _this.get(4),
1621
1946
  _this.get(5),
1622
1947
  _this.get(6),
1623
- _this.get(8),
1948
+ _this.get(7),
1624
1949
  _this.get(9),
1950
+ _this.get(10),
1625
1951
  _this.get(2)
1626
1952
  ]).then(function() {
1627
1953
  var glTFResource = _this.glTFResource;
@@ -1632,6 +1958,18 @@ var TextureWrapMode;
1632
1958
  return glTFResource;
1633
1959
  });
1634
1960
  });
1961
+ this._addTaskCompletePromise(promise);
1962
+ return promise;
1963
+ };
1964
+ /**
1965
+ * @internal
1966
+ */ _proto._addTaskCompletePromise = function _addTaskCompletePromise(taskPromise) {
1967
+ var _this = this;
1968
+ var task = this._progress.taskComplete;
1969
+ task.total += 1;
1970
+ taskPromise.then(function() {
1971
+ _this._setTaskCompleteProgress(++task.loaded, task.total);
1972
+ });
1635
1973
  };
1636
1974
  _proto._createAnimator = function _createAnimator(context, animations) {
1637
1975
  var defaultSceneRoot = context.glTFResource.defaultSceneRoot;
@@ -1659,7 +1997,7 @@ var TextureWrapMode;
1659
1997
  var _this = this;
1660
1998
  var glTFResourceKey = glTFResourceMap[type];
1661
1999
  if (!glTFResourceKey) return;
1662
- if (type === 7) {
2000
+ if (type === 8) {
1663
2001
  var _this_glTFResource, _glTFResourceKey;
1664
2002
  ((_this_glTFResource = this.glTFResource)[_glTFResourceKey = glTFResourceKey] || (_this_glTFResource[_glTFResourceKey] = []))[index] = resource;
1665
2003
  } else {
@@ -1667,7 +2005,7 @@ var TextureWrapMode;
1667
2005
  resource.then(function(item) {
1668
2006
  var _this_glTFResource, _glTFResourceKey;
1669
2007
  ((_this_glTFResource = _this.glTFResource)[_glTFResourceKey = glTFResourceKey] || (_this_glTFResource[_glTFResourceKey] = []))[index] = item;
1670
- if (type === 6) {
2008
+ if (type === 7) {
1671
2009
  for(var i = 0, length = item.length; i < length; i++){
1672
2010
  var mesh = item[i];
1673
2011
  // @ts-ignore
@@ -1707,17 +2045,18 @@ var GLTFParserType;
1707
2045
  GLTFParserType[GLTFParserType["Validator"] = 1] = "Validator";
1708
2046
  GLTFParserType[GLTFParserType["Scene"] = 2] = "Scene";
1709
2047
  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";
2048
+ GLTFParserType[GLTFParserType["BufferView"] = 4] = "BufferView";
2049
+ GLTFParserType[GLTFParserType["Texture"] = 5] = "Texture";
2050
+ GLTFParserType[GLTFParserType["Material"] = 6] = "Material";
2051
+ GLTFParserType[GLTFParserType["Mesh"] = 7] = "Mesh";
2052
+ GLTFParserType[GLTFParserType["Entity"] = 8] = "Entity";
2053
+ GLTFParserType[GLTFParserType["Skin"] = 9] = "Skin";
2054
+ GLTFParserType[GLTFParserType["Animation"] = 10] = "Animation";
1716
2055
  })(GLTFParserType || (GLTFParserType = {}));
1717
2056
  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);
2057
+ 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
2058
  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);
2059
+ 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);
1721
2060
  function registerGLTFParser(pipeline) {
1722
2061
  return function(Parser) {
1723
2062
  var parser = new Parser();
@@ -1822,110 +2161,68 @@ function registerGLTFParser(pipeline) {
1822
2161
  };
1823
2162
  GLTFUtils.getAccessorBuffer = function getAccessorBuffer(context, bufferViews, accessor) {
1824
2163
  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));
2164
+ var TypedArray = GLTFUtils.getComponentType(componentType);
2165
+ var dataElementSize = GLTFUtils.getAccessorTypeSize(accessor.type);
2166
+ var dataElementBytes = TypedArray.BYTES_PER_ELEMENT;
2167
+ var elementStride = dataElementSize * dataElementBytes;
2168
+ var accessorCount = accessor.count;
2169
+ var promise;
2170
+ if (accessor.bufferView !== undefined) {
2171
+ var bufferViewIndex = accessor.bufferView;
2172
+ var bufferView = bufferViews[bufferViewIndex];
2173
+ promise = context.get(GLTFParserType.BufferView, accessor.bufferView).then(function(bufferViewData) {
2174
+ var bufferIndex = bufferView.buffer;
2175
+ var _bufferViewData_byteOffset;
2176
+ var bufferByteOffset = (_bufferViewData_byteOffset = bufferViewData.byteOffset) != null ? _bufferViewData_byteOffset : 0;
2177
+ var _accessor_byteOffset;
2178
+ var byteOffset = (_accessor_byteOffset = accessor.byteOffset) != null ? _accessor_byteOffset : 0;
2179
+ var bufferStride = bufferView.byteStride;
2180
+ var bufferInfo;
2181
+ // According to the glTF official documentation only byteStride not undefined is allowed
2182
+ if (bufferStride !== undefined && bufferStride !== elementStride) {
2183
+ var bufferSlice = Math.floor(byteOffset / bufferStride);
2184
+ var bufferCacheKey = bufferViewIndex + ":" + componentType + ":" + bufferSlice + ":" + accessorCount;
2185
+ var accessorBufferCache = context.accessorBufferCache;
2186
+ bufferInfo = accessorBufferCache[bufferCacheKey];
2187
+ if (!bufferInfo) {
2188
+ var offset = bufferByteOffset + bufferSlice * bufferStride;
2189
+ var count = accessorCount * (bufferStride / dataElementBytes);
2190
+ var data = new TypedArray(bufferViewData.buffer, offset, count);
2191
+ accessorBufferCache[bufferCacheKey] = bufferInfo = new BufferInfo(data, true, bufferStride);
2192
+ bufferInfo.restoreInfo = new BufferDataRestoreInfo(new RestoreDataAccessor(bufferIndex, TypedArray, offset, count));
2193
+ }
2194
+ } else {
2195
+ var offset1 = bufferByteOffset + byteOffset;
2196
+ var count1 = accessorCount * dataElementSize;
2197
+ var data1 = new TypedArray(bufferViewData.buffer, offset1, count1);
2198
+ bufferInfo = new BufferInfo(data1, false, elementStride);
2199
+ bufferInfo.restoreInfo = new BufferDataRestoreInfo(new RestoreDataAccessor(bufferIndex, TypedArray, offset1, count1));
1852
2200
  }
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
- });
2201
+ return bufferInfo;
2202
+ });
2203
+ } else {
2204
+ var count = accessorCount * dataElementSize;
2205
+ var data = new TypedArray(count);
2206
+ var bufferInfo = new BufferInfo(data, false, elementStride);
2207
+ bufferInfo.restoreInfo = new BufferDataRestoreInfo(new RestoreDataAccessor(undefined, TypedArray, undefined, count));
2208
+ promise = Promise.resolve(bufferInfo);
2209
+ }
2210
+ return accessor.sparse ? promise.then(function(bufferInfo) {
2211
+ return GLTFUtils.processingSparseData(context, accessor, bufferInfo).then(function() {
2212
+ return bufferInfo;
2213
+ });
2214
+ }) : promise;
1865
2215
  };
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);
2216
+ GLTFUtils.bufferToVector3Array = function bufferToVector3Array(buffer, byteOffset, count, normalized, componentType) {
2217
+ var baseOffset = byteOffset / buffer.BYTES_PER_ELEMENT;
2218
+ var stride = buffer.length / count;
2219
+ var vertices = new Array(count);
2220
+ var factor = normalized ? GLTFUtils.getNormalizedComponentScale(componentType) : 1;
1871
2221
  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]);
2222
+ var index = baseOffset + i * stride;
2223
+ vertices[i] = new Vector3(buffer[index] * factor, buffer[index + 1] * factor, buffer[index + 2] * factor);
1874
2224
  }
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
- }
1927
- }
1928
- return typedArray;
2225
+ return vertices;
1929
2226
  };
1930
2227
  GLTFUtils.getBufferViewData = function getBufferViewData(bufferView, buffers) {
1931
2228
  var _bufferView_byteOffset = bufferView.byteOffset, byteOffset = _bufferView_byteOffset === void 0 ? 0 : _bufferView_byteOffset;
@@ -1934,40 +2231,43 @@ function registerGLTFParser(pipeline) {
1934
2231
  };
1935
2232
  /**
1936
2233
  * Get accessor data.
1937
- */ GLTFUtils.processingSparseData = function processingSparseData(bufferViews, accessor, buffers, bufferInfo) {
2234
+ */ GLTFUtils.processingSparseData = function processingSparseData(context, accessor, bufferInfo) {
1938
2235
  var restoreInfo = bufferInfo.restoreInfo;
2236
+ var bufferViews = context.glTF.bufferViews;
1939
2237
  var accessorTypeSize = GLTFUtils.getAccessorTypeSize(accessor.type);
1940
2238
  var TypedArray = GLTFUtils.getComponentType(accessor.componentType);
1941
2239
  var data = bufferInfo.data.slice();
1942
2240
  var _accessor_sparse = accessor.sparse, count = _accessor_sparse.count, indices = _accessor_sparse.indices, values = _accessor_sparse.values;
1943
2241
  var indicesBufferView = bufferViews[indices.bufferView];
1944
2242
  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];
2243
+ return Promise.all([
2244
+ context.get(GLTFParserType.BufferView, indices.bufferView),
2245
+ context.get(GLTFParserType.BufferView, values.bufferView)
2246
+ ]).then(function(param) {
2247
+ var indicesUint8Array = param[0], valuesUin8Array = param[1];
2248
+ var _indices_byteOffset, _indicesUint8Array_byteOffset;
2249
+ var indicesByteOffset = ((_indices_byteOffset = indices.byteOffset) != null ? _indices_byteOffset : 0) + ((_indicesUint8Array_byteOffset = indicesUint8Array.byteOffset) != null ? _indicesUint8Array_byteOffset : 0);
2250
+ var indicesByteLength = indicesUint8Array.byteLength;
2251
+ var _values_byteOffset, _valuesUin8Array_byteOffset;
2252
+ var valuesByteOffset = ((_values_byteOffset = values.byteOffset) != null ? _values_byteOffset : 0) + ((_valuesUin8Array_byteOffset = valuesUin8Array.byteOffset) != null ? _valuesUin8Array_byteOffset : 0);
2253
+ var valuesByteLength = valuesUin8Array.byteLength;
2254
+ restoreInfo.typeSize = accessorTypeSize;
2255
+ restoreInfo.sparseCount = count;
2256
+ var IndexTypeArray = GLTFUtils.getComponentType(indices.componentType);
2257
+ var indexLength = indicesByteLength / IndexTypeArray.BYTES_PER_ELEMENT;
2258
+ var indicesArray = new IndexTypeArray(indicesUint8Array.buffer, indicesByteOffset, indexLength);
2259
+ restoreInfo.sparseIndices = new RestoreDataAccessor(indicesBufferView.buffer, IndexTypeArray, indicesByteOffset, indexLength);
2260
+ var valueLength = valuesByteLength / TypedArray.BYTES_PER_ELEMENT;
2261
+ var valuesArray = new TypedArray(valuesUin8Array.buffer, valuesByteOffset, valueLength);
2262
+ restoreInfo.sparseValues = new RestoreDataAccessor(valuesBufferView.buffer, TypedArray, valuesByteOffset, valueLength);
2263
+ for(var i = 0; i < count; i++){
2264
+ var replaceIndex = indicesArray[i];
2265
+ for(var j = 0; j < accessorTypeSize; j++){
2266
+ data[replaceIndex * accessorTypeSize + j] = valuesArray[i * accessorTypeSize + j];
2267
+ }
1968
2268
  }
1969
- }
1970
- bufferInfo.data = data;
2269
+ bufferInfo.data = data;
2270
+ });
1971
2271
  };
1972
2272
  GLTFUtils.getIndexFormat = function getIndexFormat(type) {
1973
2273
  switch(type){
@@ -2056,7 +2356,7 @@ function registerGLTFParser(pipeline) {
2056
2356
  };
2057
2357
  /**
2058
2358
  * Parse the glb format.
2059
- */ GLTFUtils.parseGLB = function parseGLB(context, glb) {
2359
+ */ GLTFUtils.parseGLB = function parseGLB(context, originBuffer) {
2060
2360
  var UINT32_LENGTH = 4;
2061
2361
  var GLB_HEADER_MAGIC = 0x46546c67; // 'glTF'
2062
2362
  var GLB_HEADER_LENGTH = 12;
@@ -2064,7 +2364,7 @@ function registerGLTFParser(pipeline) {
2064
2364
  JSON: 0x4e4f534a,
2065
2365
  BIN: 0x004e4942
2066
2366
  };
2067
- var dataView = new DataView(glb);
2367
+ var dataView = new DataView(originBuffer);
2068
2368
  // read header
2069
2369
  var header = {
2070
2370
  magic: dataView.getUint32(0, true),
@@ -2072,8 +2372,9 @@ function registerGLTFParser(pipeline) {
2072
2372
  length: dataView.getUint32(2 * UINT32_LENGTH, true)
2073
2373
  };
2074
2374
  if (header.magic !== GLB_HEADER_MAGIC) {
2075
- console.error("Invalid glb magic number. Expected 0x46546C67, found 0x" + header.magic.toString(16));
2076
- return null;
2375
+ return {
2376
+ originBuffer: originBuffer
2377
+ };
2077
2378
  }
2078
2379
  // read main data
2079
2380
  var chunkLength = dataView.getUint32(GLB_HEADER_LENGTH, true);
@@ -2083,7 +2384,7 @@ function registerGLTFParser(pipeline) {
2083
2384
  console.error("Invalid glb chunk type. Expected 0x4E4F534A, found 0x" + chunkType.toString(16));
2084
2385
  return null;
2085
2386
  }
2086
- var glTFData = new Uint8Array(glb, GLB_HEADER_LENGTH + 2 * UINT32_LENGTH, chunkLength);
2387
+ var glTFData = new Uint8Array(originBuffer, GLB_HEADER_LENGTH + 2 * UINT32_LENGTH, chunkLength);
2087
2388
  var glTF = JSON.parse(Utils.decodeText(glTFData));
2088
2389
  // read all buffers
2089
2390
  var buffers = [];
@@ -2097,7 +2398,7 @@ function registerGLTFParser(pipeline) {
2097
2398
  return null;
2098
2399
  }
2099
2400
  var currentOffset = byteOffset + 2 * UINT32_LENGTH;
2100
- var buffer = glb.slice(currentOffset, currentOffset + chunkLength);
2401
+ var buffer = originBuffer.slice(currentOffset, currentOffset + chunkLength);
2101
2402
  buffers.push(buffer);
2102
2403
  restoreGLBBufferSlice.push(new Vector2(currentOffset, chunkLength));
2103
2404
  byteOffset += chunkLength + 2 * UINT32_LENGTH;
@@ -2976,18 +3277,22 @@ var KTX2Loader = (_KTX2Loader = /*#__PURE__*/ function(Loader1) {
2976
3277
  /**
2977
3278
  * @internal
2978
3279
  */ _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
- });
3280
+ var _this = this;
3281
+ return new AssetPromise(function(resolve, reject, setTaskCompleteProgress, setTaskDetailProgress) {
3282
+ _this.request(item.url, {
3283
+ type: "arraybuffer"
3284
+ }).onProgress(setTaskCompleteProgress, setTaskDetailProgress).then(function(buffer) {
3285
+ return KTX2Loader._parseBuffer(new Uint8Array(buffer), resourceManager.engine, item.params).then(function(param) {
3286
+ var engine = param.engine, result = param.result, targetFormat = param.targetFormat, params = param.params;
3287
+ return KTX2Loader._createTextureByBuffer(engine, result, targetFormat, params);
3288
+ });
3289
+ }).then(resolve).catch(reject);
2986
3290
  });
2987
3291
  };
2988
3292
  /**
2989
- * Destroy ktx2 transcoder worker.
2990
- */ KTX2Loader1.destroy = function destroy() {
3293
+ * Release ktx2 transcoder worker.
3294
+ * @remarks If use loader after releasing, we should release again.
3295
+ */ KTX2Loader1.release = function release() {
2991
3296
  if (this._binomialLLCTranscoder) this._binomialLLCTranscoder.destroy();
2992
3297
  if (this._khronosTranscoder) this._khronosTranscoder.destroy();
2993
3298
  this._binomialLLCTranscoder = null;
@@ -3232,16 +3537,16 @@ var KTX2Transcoder;
3232
3537
  var frame = restoreInfo.blendShape.frames[0];
3233
3538
  var position = restoreInfo.position;
3234
3539
  var positionData = _this._getBufferData(buffers, position.buffer);
3235
- frame.deltaPositions = GLTFUtils.bufferToVector3Array(positionData, position.stride, position.byteOffset, position.count);
3540
+ frame.deltaPositions = GLTFUtils.bufferToVector3Array(positionData, position.byteOffset, position.count, position.normalized, position.componentType);
3236
3541
  if (restoreInfo.normal) {
3237
3542
  var normal = restoreInfo.normal;
3238
3543
  var normalData = _this._getBufferData(buffers, normal.buffer);
3239
- frame.deltaNormals = GLTFUtils.bufferToVector3Array(normalData, normal.stride, normal.byteOffset, normal.count);
3544
+ frame.deltaNormals = GLTFUtils.bufferToVector3Array(normalData, normal.byteOffset, normal.count, normal.normalized, normal.componentType);
3240
3545
  }
3241
3546
  if (restoreInfo.tangent) {
3242
3547
  var tangent = restoreInfo.tangent;
3243
3548
  var tangentData = _this._getBufferData(buffers, tangent.buffer);
3244
- frame.deltaTangents = GLTFUtils.bufferToVector3Array(tangentData, tangent.stride, tangent.byteOffset, tangent.count);
3549
+ frame.deltaTangents = GLTFUtils.bufferToVector3Array(tangentData, tangent.byteOffset, tangent.count, tangent.normalized, tangent.componentType);
3245
3550
  }
3246
3551
  }
3247
3552
  mesh.uploadData(true);
@@ -3253,8 +3558,13 @@ var KTX2Transcoder;
3253
3558
  };
3254
3559
  _proto._getBufferData = function _getBufferData(buffers, restoreInfo) {
3255
3560
  var main = restoreInfo.main;
3256
- var buffer = buffers[main.bufferIndex];
3257
- var data = new main.TypedArray(buffer, main.byteOffset, main.length);
3561
+ var data;
3562
+ if (main) {
3563
+ var buffer = buffers[main.bufferIndex];
3564
+ data = new main.TypedArray(buffer, main.byteOffset, main.length);
3565
+ } else {
3566
+ data = new main.TypedArray(main.length);
3567
+ }
3258
3568
  var sparseCount = restoreInfo.sparseCount;
3259
3569
  if (sparseCount) {
3260
3570
  var sparseIndex = restoreInfo.sparseIndices;
@@ -3327,11 +3637,12 @@ var KTX2Transcoder;
3327
3637
  };
3328
3638
  /**
3329
3639
  * @internal
3330
- */ var BlendShapeDataRestoreInfo = function BlendShapeDataRestoreInfo(buffer, stride, byteOffset, count) {
3640
+ */ var BlendShapeDataRestoreInfo = function BlendShapeDataRestoreInfo(buffer, byteOffset, count, normalized, componentType) {
3331
3641
  this.buffer = buffer;
3332
- this.stride = stride;
3333
3642
  this.byteOffset = byteOffset;
3334
3643
  this.count = count;
3644
+ this.normalized = normalized;
3645
+ this.componentType = componentType;
3335
3646
  };
3336
3647
 
3337
3648
  /**
@@ -3507,23 +3818,20 @@ var GLTFSchemaParser = /*#__PURE__*/ function(GLTFParser1) {
3507
3818
  var requestConfig = {
3508
3819
  type: "arraybuffer"
3509
3820
  };
3510
- var isGLB = this._isGLB(url);
3511
- contentRestorer.isGLB = isGLB;
3512
- var promise = isGLB ? request(url, requestConfig).then(function(glb) {
3821
+ return request(url, requestConfig).onProgress(undefined, context._onTaskDetail).then(function(buffer) {
3513
3822
  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"
3823
+ return GLTFUtils.parseGLB(context, buffer);
3824
+ }).then(function(result) {
3825
+ var _result;
3826
+ if ((_result = result) == null ? void 0 : _result.glTF) {
3827
+ contentRestorer.isGLB = true;
3828
+ context.buffers = result.buffers;
3829
+ return result.glTF;
3830
+ } else {
3831
+ contentRestorer.isGLB = false;
3832
+ return JSON.parse(Utils.decodeText(new Uint8Array(result.originBuffer)));
3833
+ }
3521
3834
  });
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
3835
  };
3528
3836
  return GLTFSchemaParser;
3529
3837
  }(GLTFParser);
@@ -3550,9 +3858,9 @@ var GLTFAnimationParser = /*#__PURE__*/ function(GLTFParser1) {
3550
3858
  * @internal
3551
3859
  */ GLTFAnimationParser1._parseStandardProperty = function _parseStandardProperty(context, animationClip, animationInfo) {
3552
3860
  var _loop = function(j, m) {
3553
- var gltfSampler = samplers[j];
3554
- var inputAccessor = accessors[gltfSampler.input];
3555
- var outputAccessor = accessors[gltfSampler.output];
3861
+ var glTFSampler = samplers[j];
3862
+ var inputAccessor = accessors[glTFSampler.input];
3863
+ var outputAccessor = accessors[glTFSampler.output];
3556
3864
  var promise = Promise.all([
3557
3865
  GLTFUtils.getAccessorBuffer(context, bufferViews, inputAccessor),
3558
3866
  GLTFUtils.getAccessorBuffer(context, bufferViews, outputAccessor)
@@ -3568,8 +3876,8 @@ var GLTFAnimationParser = /*#__PURE__*/ function(GLTFParser1) {
3568
3876
  output = scaled;
3569
3877
  }
3570
3878
  var outputStride = output.length / input.length;
3571
- var _gltfSampler_interpolation;
3572
- var interpolation = (_gltfSampler_interpolation = gltfSampler.interpolation) != null ? _gltfSampler_interpolation : AnimationSamplerInterpolation.Linear;
3879
+ var _glTFSampler_interpolation;
3880
+ var interpolation = (_glTFSampler_interpolation = glTFSampler.interpolation) != null ? _glTFSampler_interpolation : AnimationSamplerInterpolation.Linear;
3573
3881
  var samplerInterpolation;
3574
3882
  switch(interpolation){
3575
3883
  case AnimationSamplerInterpolation.CubicSpine:
@@ -3583,13 +3891,13 @@ var GLTFAnimationParser = /*#__PURE__*/ function(GLTFParser1) {
3583
3891
  break;
3584
3892
  }
3585
3893
  input[input.length - 1];
3586
- sampleDataCollection.push({
3894
+ sampleDataCollection[j] = {
3587
3895
  type: outputAccessor.type,
3588
3896
  interpolation: samplerInterpolation,
3589
3897
  input: input,
3590
3898
  output: output,
3591
3899
  outputSize: outputStride
3592
- });
3900
+ };
3593
3901
  });
3594
3902
  promises.push(promise);
3595
3903
  };
@@ -3597,16 +3905,17 @@ var GLTFAnimationParser = /*#__PURE__*/ function(GLTFParser1) {
3597
3905
  var glTF = context.glTF;
3598
3906
  var accessors = glTF.accessors, bufferViews = glTF.bufferViews;
3599
3907
  var channels = animationInfo.channels, samplers = animationInfo.samplers;
3600
- var sampleDataCollection = new Array();
3908
+ var len = samplers.length;
3909
+ var sampleDataCollection = new Array(len);
3601
3910
  var entities = context.get(GLTFParserType.Entity);
3602
3911
  var promises = new Array();
3603
3912
  // parse samplers
3604
- for(var j = 0, m = samplers.length; j < m; j++)_loop(j);
3913
+ for(var j = 0, m = len; j < m; j++)_loop(j);
3605
3914
  promises.push(context.get(GLTFParserType.Scene));
3606
3915
  return Promise.all(promises).then(function() {
3607
3916
  for(var j = 0, m = channels.length; j < m; j++){
3608
- var gltfChannel = channels[j];
3609
- var target = gltfChannel.target;
3917
+ var glTFChannel = channels[j];
3918
+ var target = glTFChannel.target;
3610
3919
  var channelTargetEntity = entities[target.node];
3611
3920
  var relativePath = "";
3612
3921
  var entity = channelTargetEntity;
@@ -3638,14 +3947,21 @@ var GLTFAnimationParser = /*#__PURE__*/ function(GLTFParser1) {
3638
3947
  propertyName = "blendShapeWeights";
3639
3948
  break;
3640
3949
  }
3641
- var curve = _this._addCurve(target.path, gltfChannel, sampleDataCollection);
3642
- animationClip.addCurveBinding(relativePath, ComponentType, propertyName, curve);
3950
+ var curve = _this._addCurve(target.path, glTFChannel, sampleDataCollection);
3951
+ if (target.path === AnimationChannelTargetPath.WEIGHTS) {
3952
+ var mesh = glTF.nodes[target.node].mesh;
3953
+ for(var i = 0, n = glTF.meshes[mesh].primitives.length; i < n; i++){
3954
+ animationClip.addCurveBinding(relativePath, ComponentType, i, propertyName, curve);
3955
+ }
3956
+ } else {
3957
+ animationClip.addCurveBinding(relativePath, ComponentType, propertyName, curve);
3958
+ }
3643
3959
  }
3644
3960
  return animationClip;
3645
3961
  });
3646
3962
  };
3647
- GLTFAnimationParser1._addCurve = function _addCurve(animationChannelTargetPath, gltfChannel, sampleDataCollection) {
3648
- var sampleData = sampleDataCollection[gltfChannel.sampler];
3963
+ GLTFAnimationParser1._addCurve = function _addCurve(animationChannelTargetPath, glTFChannel, sampleDataCollection) {
3964
+ var sampleData = sampleDataCollection[glTFChannel.sampler];
3649
3965
  var input = sampleData.input, output = sampleData.output, outputSize = sampleData.outputSize;
3650
3966
  switch(animationChannelTargetPath){
3651
3967
  case AnimationChannelTargetPath.TRANSLATION:
@@ -3737,7 +4053,9 @@ var GLTFBufferParser = /*#__PURE__*/ function(GLTFParser1) {
3737
4053
  };
3738
4054
  var absoluteUrl = Utils.resolveAbsoluteUrl(url, bufferInfo.uri);
3739
4055
  restoreBufferRequests.push(new BufferRequestInfo(absoluteUrl, requestConfig));
3740
- return request(absoluteUrl, requestConfig);
4056
+ var promise = request(absoluteUrl, requestConfig).onProgress(undefined, context._onTaskDetail);
4057
+ context._addTaskCompletePromise(promise);
4058
+ return promise;
3741
4059
  };
3742
4060
  return GLTFBufferParser;
3743
4061
  }(GLTFParser);
@@ -3752,10 +4070,13 @@ var GLTFEntityParser = /*#__PURE__*/ function(GLTFParser1) {
3752
4070
  }
3753
4071
  var _proto = GLTFEntityParser.prototype;
3754
4072
  _proto.parse = function parse(context, index) {
4073
+ var glTFResource = context.glTFResource;
3755
4074
  var entityInfo = context.glTF.nodes[index];
3756
- var engine = context.glTFResource.engine;
4075
+ var engine = glTFResource.engine;
3757
4076
  var matrix = entityInfo.matrix, translation = entityInfo.translation, rotation = entityInfo.rotation, scale = entityInfo.scale, extensions = entityInfo.extensions;
3758
4077
  var entity = new Entity(engine, entityInfo.name || "_GLTF_ENTITY_" + index);
4078
+ // @ts-ignore
4079
+ entity._markAsTemplate(glTFResource);
3759
4080
  var transform = entity.transform;
3760
4081
  if (matrix) {
3761
4082
  var localMatrix = transform.localMatrix;
@@ -3797,7 +4118,8 @@ var GLTFMaterialParser = /*#__PURE__*/ function(GLTFParser1) {
3797
4118
  var _proto = GLTFMaterialParser1.prototype;
3798
4119
  _proto.parse = function parse(context, index) {
3799
4120
  var materialInfo = context.glTF.materials[index];
3800
- var engine = context.glTFResource.engine;
4121
+ var glTFResource = context.glTFResource;
4122
+ var engine = glTFResource.engine;
3801
4123
  var material = GLTFParser.executeExtensionsCreateAndParse(materialInfo.extensions, context, materialInfo);
3802
4124
  if (!material) {
3803
4125
  material = new PBRMaterial(engine);
@@ -3805,8 +4127,10 @@ var GLTFMaterialParser = /*#__PURE__*/ function(GLTFParser1) {
3805
4127
  GLTFMaterialParser._parseStandardProperty(context, material, materialInfo);
3806
4128
  }
3807
4129
  return Promise.resolve(material).then(function(material) {
3808
- material || (material = GLTFMaterialParser._getDefaultMaterial(context.glTFResource.engine));
4130
+ material || (material = GLTFMaterialParser._getDefaultMaterial(engine));
3809
4131
  GLTFParser.executeExtensionsAdditiveAndParse(materialInfo.extensions, context, material, materialInfo);
4132
+ // @ts-ignore
4133
+ material._associationSuperResource(glTFResource);
3810
4134
  return material;
3811
4135
  });
3812
4136
  };
@@ -3927,46 +4251,37 @@ var GLTFMeshParser = (_GLTFMeshParser = /*#__PURE__*/ function(GLTFParser1) {
3927
4251
  var mesh = GLTFParser.executeExtensionsCreateAndParse(gltfPrimitive.extensions, context, gltfPrimitive, meshInfo);
3928
4252
  if (mesh) {
3929
4253
  if (_instanceof(mesh, ModelMesh)) {
4254
+ // @ts-ignore
4255
+ mesh._associationSuperResource(glTFResource);
3930
4256
  resolve(mesh);
3931
4257
  } else {
3932
4258
  mesh.then(function(mesh) {
3933
- return resolve(mesh);
4259
+ // @ts-ignore
4260
+ mesh._associationSuperResource(glTFResource);
4261
+ resolve(mesh);
3934
4262
  });
3935
4263
  }
3936
4264
  } else {
3937
4265
  var mesh1 = new ModelMesh(engine, meshInfo.name || i + "");
4266
+ // @ts-ignore
4267
+ mesh1._associationSuperResource(glTFResource);
3938
4268
  var meshRestoreInfo = new ModelMeshRestoreInfo();
3939
4269
  meshRestoreInfo.mesh = mesh1;
3940
4270
  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);
4271
+ GLTFMeshParser._parseMeshFromGLTFPrimitive(context, mesh1, meshRestoreInfo, meshInfo, gltfPrimitive, glTF, context.params.keepMeshData).then(resolve);
3958
4272
  }
3959
4273
  });
3960
4274
  };
3961
4275
  var meshInfo = context.glTF.meshes[index];
3962
- var glTF = context.glTF, engine = context.glTFResource.engine;
4276
+ var glTF = context.glTF, glTFResource = context.glTFResource;
4277
+ var engine = glTFResource.engine;
3963
4278
  var primitivePromises = new Array();
3964
4279
  for(var i = 0, length = meshInfo.primitives.length; i < length; i++)_loop(i);
3965
4280
  return Promise.all(primitivePromises);
3966
4281
  };
3967
4282
  /**
3968
4283
  * @internal
3969
- */ GLTFMeshParser1._parseMeshFromGLTFPrimitive = function _parseMeshFromGLTFPrimitive(context, mesh, meshRestoreInfo, gltfMesh, gltfPrimitive, gltf, getVertexBufferData, getBlendShapeData, getIndexBufferData, keepMeshData) {
4284
+ */ GLTFMeshParser1._parseMeshFromGLTFPrimitive = function _parseMeshFromGLTFPrimitive(context, mesh, meshRestoreInfo, gltfMesh, gltfPrimitive, gltf, keepMeshData) {
3970
4285
  var _loop = function(attribute) {
3971
4286
  var accessor = accessors[attributes[attribute]];
3972
4287
  var promise = GLTFUtils.getAccessorBuffer(context, gltf.bufferViews, accessor).then(function(accessorBuffer) {
@@ -4061,61 +4376,68 @@ var GLTFMeshParser = (_GLTFMeshParser = /*#__PURE__*/ function(GLTFParser1) {
4061
4376
  }
4062
4377
  // BlendShapes
4063
4378
  if (targets) {
4064
- promises.push(GLTFMeshParser._createBlendShape(mesh, meshRestoreInfo, gltfMesh, accessors, targets, getBlendShapeData));
4379
+ promises.push(GLTFMeshParser._createBlendShape(context, mesh, meshRestoreInfo, gltfMesh, gltfPrimitive, targets));
4065
4380
  }
4066
4381
  return Promise.all(promises).then(function() {
4067
4382
  mesh.uploadData(!keepMeshData);
4068
- return Promise.resolve(mesh);
4383
+ return mesh;
4069
4384
  });
4070
4385
  });
4071
4386
  };
4387
+ GLTFMeshParser1._getBlendShapeData = function _getBlendShapeData(context, glTF, accessor) {
4388
+ return GLTFUtils.getAccessorBuffer(context, glTF.bufferViews, accessor).then(function(bufferInfo) {
4389
+ var buffer = bufferInfo.data;
4390
+ var _accessor_byteOffset;
4391
+ var byteOffset = bufferInfo.interleaved ? ((_accessor_byteOffset = accessor.byteOffset) != null ? _accessor_byteOffset : 0) % bufferInfo.stride : 0;
4392
+ var count = accessor.count, normalized = accessor.normalized, componentType = accessor.componentType;
4393
+ var vertices = GLTFUtils.bufferToVector3Array(buffer, byteOffset, count, normalized, componentType);
4394
+ var restoreInfo = new BlendShapeDataRestoreInfo(bufferInfo.restoreInfo, byteOffset, count, normalized, componentType);
4395
+ return {
4396
+ vertices: vertices,
4397
+ restoreInfo: restoreInfo
4398
+ };
4399
+ });
4400
+ };
4072
4401
  /**
4073
4402
  * @internal
4074
- */ GLTFMeshParser1._createBlendShape = function _createBlendShape(mesh, meshRestoreInfo, glTFMesh, accessors, glTFTargets, getBlendShapeData) {
4075
- var _loop = function(i, n) {
4403
+ */ GLTFMeshParser1._createBlendShape = function _createBlendShape(context, mesh, meshRestoreInfo, glTFMesh, gltfPrimitive, glTFTargets) {
4404
+ var _this = this, _loop = function(i) {
4405
+ var blendShapeData = {};
4406
+ blendShapeCollection[i] = blendShapeData;
4076
4407
  var name = blendShapeNames ? blendShapeNames[i] : "blendShape" + i;
4408
+ var targets = gltfPrimitive.targets[i];
4409
+ var normalTarget = targets["NORMAL"];
4410
+ var tangentTarget = targets["TANGENT"];
4411
+ var hasNormal = normalTarget !== undefined;
4412
+ var hasTangent = tangentTarget !== undefined;
4077
4413
  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
- }
4414
+ _this._getBlendShapeData(context, glTF, accessors[targets["POSITION"]]),
4415
+ hasNormal ? _this._getBlendShapeData(context, glTF, accessors[normalTarget]) : null,
4416
+ hasTangent ? _this._getBlendShapeData(context, glTF, accessors[tangentTarget]) : null
4417
+ ]).then(function(vertices) {
4418
+ var _tangentData;
4419
+ var positionData = vertices[0], normalData = vertices[1], tangentData = vertices[2];
4107
4420
  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));
4421
+ blendShape.addFrame(1.0, positionData.vertices, hasNormal ? normalData.vertices : null, hasTangent ? tangentData.vertices : null);
4422
+ blendShapeData.blendShape = blendShape;
4423
+ blendShapeData.restoreInfo = new BlendShapeRestoreInfo(blendShape, positionData.restoreInfo, hasNormal ? normalData.restoreInfo : null, hasTangent ? (_tangentData = tangentData) == null ? void 0 : _tangentData.restoreInfo : null);
4112
4424
  });
4113
4425
  promises.push(promise);
4114
4426
  };
4427
+ var glTF = context.glTF;
4428
+ var accessors = glTF.accessors;
4115
4429
  var blendShapeNames = glTFMesh.extras ? glTFMesh.extras.targetNames : null;
4116
4430
  var promises = new Array();
4117
- for(var i = 0, n = glTFTargets.length; i < n; i++)_loop(i);
4118
- return Promise.all(promises);
4431
+ var blendShapeCount = glTFTargets.length;
4432
+ var blendShapeCollection = new Array(blendShapeCount);
4433
+ for(var i = 0; i < blendShapeCount; i++)_loop(i);
4434
+ return Promise.all(promises).then(function() {
4435
+ for(var _iterator = _create_for_of_iterator_helper_loose(blendShapeCollection), _step; !(_step = _iterator()).done;){
4436
+ var blendShape = _step.value;
4437
+ mesh.addBlendShape(blendShape.blendShape);
4438
+ meshRestoreInfo.blendShapes.push(blendShape.restoreInfo);
4439
+ }
4440
+ });
4119
4441
  };
4120
4442
  return GLTFMeshParser1;
4121
4443
  }(GLTFParser), function() {
@@ -4148,12 +4470,8 @@ var GLTFSceneParser = /*#__PURE__*/ function(GLTFParser1) {
4148
4470
  sceneRoot.addChild(childEntity);
4149
4471
  }
4150
4472
  }
4151
- // @ts-ignore
4152
- sceneRoot._hookResource = glTFResource;
4153
- // @ts-ignore
4154
- glTFResource._addReferCount(1);
4155
4473
  if (isDefaultScene) {
4156
- glTFResource.defaultSceneRoot = sceneRoot;
4474
+ glTFResource._defaultSceneRoot = sceneRoot;
4157
4475
  }
4158
4476
  var promises = new Array();
4159
4477
  for(var i1 = 0; i1 < sceneNodes.length; i1++){
@@ -4420,11 +4738,12 @@ var GLTFTextureParser = (_GLTFTextureParser = /*#__PURE__*/ function(GLTFParser1
4420
4738
  params: {
4421
4739
  mipmap: (_samplerInfo = samplerInfo) == null ? void 0 : _samplerInfo.mipmap
4422
4740
  }
4423
- }).then(function(texture) {
4741
+ }).onProgress(undefined, context._onTaskDetail).then(function(texture) {
4424
4742
  texture.name = textureName || imageName || texture.name || "texture_" + index;
4425
4743
  useSampler && GLTFUtils.parseSampler(texture, samplerInfo);
4426
4744
  return texture;
4427
4745
  });
4746
+ context._addTaskCompletePromise(texture);
4428
4747
  } else {
4429
4748
  var bufferView = glTF.bufferViews[bufferViewIndex];
4430
4749
  texture = context.get(GLTFParserType.Buffer).then(function(buffers) {
@@ -4446,6 +4765,8 @@ var GLTFTextureParser = (_GLTFTextureParser = /*#__PURE__*/ function(GLTFParser1
4446
4765
  }
4447
4766
  return Promise.resolve(texture).then(function(texture) {
4448
4767
  GLTFParser.executeExtensionsAdditiveAndParse(extensions, context, texture, textureInfo);
4768
+ // @ts-ignore
4769
+ texture._associationSuperResource(glTFResource);
4449
4770
  return texture;
4450
4771
  });
4451
4772
  };
@@ -4496,12 +4817,232 @@ GLTFValidator = __decorate([
4496
4817
  registerGLTFParser(GLTFParserType.Validator)
4497
4818
  ], GLTFValidator);
4498
4819
 
4820
+ var GLTFBufferViewParser = /*#__PURE__*/ function(GLTFParser1) {
4821
+ _inherits(GLTFBufferViewParser, GLTFParser1);
4822
+ function GLTFBufferViewParser() {
4823
+ return GLTFParser1.apply(this, arguments);
4824
+ }
4825
+ var _proto = GLTFBufferViewParser.prototype;
4826
+ _proto.parse = function parse(context, index) {
4827
+ var bufferView = context.glTF.bufferViews[index];
4828
+ var extensions = bufferView.extensions, _bufferView_byteOffset = bufferView.byteOffset, byteOffset = _bufferView_byteOffset === void 0 ? 0 : _bufferView_byteOffset, byteLength = bufferView.byteLength, bufferIndex = bufferView.buffer;
4829
+ return extensions ? GLTFParser.executeExtensionsCreateAndParse(extensions, context, bufferView) : context.get(GLTFParserType.Buffer, bufferIndex).then(function(buffer) {
4830
+ return new Uint8Array(buffer, byteOffset, byteLength);
4831
+ });
4832
+ };
4833
+ return GLTFBufferViewParser;
4834
+ }(GLTFParser);
4835
+ GLTFBufferViewParser = __decorate([
4836
+ registerGLTFParser(GLTFParserType.BufferView)
4837
+ ], GLTFBufferViewParser);
4838
+
4839
+ // Source: https://github.com/zeux/meshoptimizer/blob/master/js/meshopt_decoder.js
4840
+ var MeshoptDecoder = function() {
4841
+ var unpack = function unpack(data) {
4842
+ var result = new Uint8Array(data.length);
4843
+ for(var i = 0; i < data.length; ++i){
4844
+ var ch = data.charCodeAt(i);
4845
+ result[i] = ch > 96 ? ch - 97 : ch > 64 ? ch - 39 : ch + 4;
4846
+ }
4847
+ var write = 0;
4848
+ for(var i1 = 0; i1 < data.length; ++i1){
4849
+ result[write++] = result[i1] < 60 ? wasmpack[result[i1]] : (result[i1] - 60) * 64 + result[++i1];
4850
+ }
4851
+ return result.buffer.slice(0, write);
4852
+ };
4853
+ var decode = function decode(fun, target, count, size, source, filter) {
4854
+ var sbrk = instance.exports.sbrk;
4855
+ var count4 = count + 3 & ~3;
4856
+ var tp = sbrk(count4 * size);
4857
+ var sp = sbrk(source.length);
4858
+ var heap = new Uint8Array(instance.exports.memory.buffer);
4859
+ heap.set(source, sp);
4860
+ var res = fun(tp, count, size, sp, source.length);
4861
+ if (res == 0 && filter) {
4862
+ filter(tp, count4, size);
4863
+ }
4864
+ target.set(heap.subarray(tp, tp + count * size));
4865
+ sbrk(tp - sbrk(0));
4866
+ if (res != 0) {
4867
+ throw new Error("Malformed buffer data: " + res);
4868
+ }
4869
+ };
4870
+ var createWorker = function createWorker(url) {
4871
+ var worker = {
4872
+ object: new Worker(url),
4873
+ pending: 0,
4874
+ requests: {}
4875
+ };
4876
+ worker.object.onmessage = function(event) {
4877
+ var data = event.data;
4878
+ worker.pending -= data.count;
4879
+ worker.requests[data.id][data.action](data.value);
4880
+ delete worker.requests[data.id];
4881
+ };
4882
+ return worker;
4883
+ };
4884
+ var initWorkers = function initWorkers(count) {
4885
+ 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 }';
4886
+ var blob = new Blob([
4887
+ source
4888
+ ], {
4889
+ type: "text/javascript"
4890
+ });
4891
+ var url = URL.createObjectURL(blob);
4892
+ for(var i = 0; i < count; ++i){
4893
+ workers[i] = createWorker(url);
4894
+ }
4895
+ URL.revokeObjectURL(url);
4896
+ };
4897
+ var decodeWorker = function decodeWorker(count, size, source, mode, filter) {
4898
+ var worker = workers[0];
4899
+ for(var i = 1; i < workers.length; ++i){
4900
+ if (workers[i].pending < worker.pending) {
4901
+ worker = workers[i];
4902
+ }
4903
+ }
4904
+ return new Promise(function(resolve, reject) {
4905
+ var data = new Uint8Array(source);
4906
+ var id = requestId++;
4907
+ worker.pending += count;
4908
+ worker.requests[id] = {
4909
+ resolve: resolve,
4910
+ reject: reject
4911
+ };
4912
+ worker.object.postMessage({
4913
+ id: id,
4914
+ count: count,
4915
+ size: size,
4916
+ source: data,
4917
+ mode: mode,
4918
+ filter: filter
4919
+ }, [
4920
+ data.buffer
4921
+ ]);
4922
+ });
4923
+ };
4924
+ 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";
4925
+ 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";
4926
+ var wasmpack = new Uint8Array([
4927
+ 32,
4928
+ 0,
4929
+ 65,
4930
+ 2,
4931
+ 1,
4932
+ 106,
4933
+ 34,
4934
+ 33,
4935
+ 3,
4936
+ 128,
4937
+ 11,
4938
+ 4,
4939
+ 13,
4940
+ 64,
4941
+ 6,
4942
+ 253,
4943
+ 10,
4944
+ 7,
4945
+ 15,
4946
+ 116,
4947
+ 127,
4948
+ 5,
4949
+ 8,
4950
+ 12,
4951
+ 40,
4952
+ 16,
4953
+ 19,
4954
+ 54,
4955
+ 20,
4956
+ 9,
4957
+ 27,
4958
+ 255,
4959
+ 113,
4960
+ 17,
4961
+ 42,
4962
+ 67,
4963
+ 24,
4964
+ 23,
4965
+ 146,
4966
+ 148,
4967
+ 18,
4968
+ 14,
4969
+ 22,
4970
+ 45,
4971
+ 70,
4972
+ 69,
4973
+ 56,
4974
+ 114,
4975
+ 101,
4976
+ 21,
4977
+ 25,
4978
+ 63,
4979
+ 75,
4980
+ 136,
4981
+ 108,
4982
+ 28,
4983
+ 118,
4984
+ 29,
4985
+ 73,
4986
+ 115
4987
+ ]);
4988
+ // @ts-ignore
4989
+ var wasm = SystemInfo._detectSIMDSupported() ? wasm_simd : wasm_base;
4990
+ var instance;
4991
+ var ready = WebAssembly.instantiate(unpack(wasm), {}).then(function(result) {
4992
+ instance = result.instance;
4993
+ instance.exports.__wasm_call_ctors();
4994
+ });
4995
+ var filters = {
4996
+ NONE: "",
4997
+ OCTAHEDRAL: "meshopt_decodeFilterOct",
4998
+ QUATERNION: "meshopt_decodeFilterQuat",
4999
+ EXPONENTIAL: "meshopt_decodeFilterExp"
5000
+ };
5001
+ var decoders = {
5002
+ ATTRIBUTES: "meshopt_decodeVertexBuffer",
5003
+ TRIANGLES: "meshopt_decodeIndexBuffer",
5004
+ INDICES: "meshopt_decodeIndexSequence"
5005
+ };
5006
+ var workers = [];
5007
+ var requestId = 0;
5008
+ return {
5009
+ workerCount: 4,
5010
+ ready: ready,
5011
+ useWorkers: function useWorkers() {
5012
+ initWorkers(this.workerCount);
5013
+ },
5014
+ decodeGltfBuffer: function decodeGltfBuffer(count, stride, source, mode, filter) {
5015
+ if (this.workerCount > 0 && workers.length === 0) this.useWorkers();
5016
+ if (workers.length > 0) return decodeWorker(count, stride, source, decoders[mode], filters[filter]);
5017
+ return ready.then(function() {
5018
+ var target = new Uint8Array(count * stride);
5019
+ decode(instance.exports[decoders[mode]], target, count, stride, source, instance.exports[filters[filter]]);
5020
+ return target;
5021
+ });
5022
+ },
5023
+ release: function release() {
5024
+ for(var i = 0; i < workers.length; i++){
5025
+ workers[i].object.terminate();
5026
+ }
5027
+ }
5028
+ };
5029
+ }();
5030
+
4499
5031
  var GLTFLoader = /*#__PURE__*/ function(Loader1) {
4500
5032
  _inherits(GLTFLoader, Loader1);
4501
5033
  function GLTFLoader() {
4502
5034
  return Loader1.apply(this, arguments);
4503
5035
  }
4504
5036
  var _proto = GLTFLoader.prototype;
5037
+ _proto.initialize = function initialize(_, configuration) {
5038
+ var _configuration_glTF;
5039
+ var meshOptOptions = (_configuration_glTF = configuration.glTF) == null ? void 0 : _configuration_glTF.meshOpt;
5040
+ if (meshOptOptions) {
5041
+ MeshoptDecoder.workerCount = meshOptOptions.workerCount;
5042
+ MeshoptDecoder.useWorkers();
5043
+ }
5044
+ return Promise.resolve();
5045
+ };
4505
5046
  _proto.load = function load(item, resourceManager) {
4506
5047
  var url = item.url;
4507
5048
  var params = item.params;
@@ -4509,7 +5050,17 @@ var GLTFLoader = /*#__PURE__*/ function(Loader1) {
4509
5050
  var context = new GLTFParserContext(glTFResource, resourceManager, _extends({
4510
5051
  keepMeshData: false
4511
5052
  }, params));
4512
- return context.parse();
5053
+ return new AssetPromise(function(resolve, reject, setTaskCompleteProgress, setTaskDetailProgress) {
5054
+ context._setTaskCompleteProgress = setTaskCompleteProgress;
5055
+ context._setTaskDetailProgress = setTaskDetailProgress;
5056
+ context.parse().then(resolve).catch(reject);
5057
+ });
5058
+ };
5059
+ /**
5060
+ * Release glTF loader memory(includes meshopt workers).
5061
+ * @remarks If use loader after releasing, we should release again.
5062
+ */ GLTFLoader.release = function release() {
5063
+ MeshoptDecoder.release();
4513
5064
  };
4514
5065
  return GLTFLoader;
4515
5066
  }(Loader);
@@ -5132,60 +5683,73 @@ var MaterialLoader = /*#__PURE__*/ function(Loader1) {
5132
5683
  _this.request(item.url, _extends({}, item, {
5133
5684
  type: "json"
5134
5685
  })).then(function(materialSchema) {
5135
- var _loop = function(key) {
5136
- var _shaderData_key = shaderData[key], type = _shaderData_key.type, value = _shaderData_key.value;
5137
- switch(type){
5138
- case "Vector2":
5139
- materialShaderData.setVector2(key, new Vector2(value.x, value.y));
5140
- break;
5141
- case "Vector3":
5142
- materialShaderData.setVector3(key, new Vector3(value.x, value.y, value.z));
5143
- break;
5144
- case "Vector4":
5145
- materialShaderData.setVector4(key, new Vector4(value.x, value.y, value.z, value.w));
5146
- break;
5147
- case "Color":
5148
- materialShaderData.setColor(key, new Color(value.r, value.g, value.b, value.a));
5149
- break;
5150
- case "Float":
5151
- materialShaderData.setFloat(key, value);
5152
- break;
5153
- case "Texture":
5154
- texturePromises.push(// @ts-ignore
5155
- resourceManager.getResourceByRef(value).then(function(texture) {
5156
- materialShaderData.setTexture(key, texture);
5157
- }));
5158
- break;
5159
- case "Boolean":
5160
- materialShaderData.setInt(key, value ? 1 : 0);
5161
- break;
5162
- case "Integer":
5163
- materialShaderData.setInt(key, Number(value));
5164
- break;
5165
- }
5166
- };
5167
5686
  var engine = resourceManager.engine;
5168
- var name = materialSchema.name, shader = materialSchema.shader, shaderData = materialSchema.shaderData, macros = materialSchema.macros, renderState = materialSchema.renderState;
5169
- var material = new Material(engine, Shader.find(shader));
5170
- material.name = name;
5171
- var texturePromises = new Array();
5172
- var materialShaderData = material.shaderData;
5173
- for(var key in shaderData)_loop(key);
5174
- for(var i = 0, length = macros.length; i < length; i++){
5175
- var _macros_i = macros[i], name1 = _macros_i.name, value = _macros_i.value;
5176
- if (value == undefined) {
5177
- materialShaderData.enableMacro(name1);
5178
- } else {
5179
- materialShaderData.enableMacro(name1, value);
5180
- }
5687
+ var shaderRef = materialSchema.shaderRef, shader = materialSchema.shader;
5688
+ if (shaderRef) {
5689
+ resolve(resourceManager// @ts-ignore
5690
+ .getResourceByRef(shaderRef).then(function(shaderObject) {
5691
+ return _this.getMaterialByShader(materialSchema, shaderObject, engine);
5692
+ }));
5693
+ } else {
5694
+ // compatible with 1.2-pre version material schema
5695
+ var shaderObject = Shader.find(shader);
5696
+ resolve(_this.getMaterialByShader(materialSchema, shaderObject, engine));
5181
5697
  }
5182
- parseProperty(material, "renderState", renderState);
5183
- return Promise.all(texturePromises).then(function() {
5184
- resolve(material);
5185
- });
5186
5698
  }).catch(reject);
5187
5699
  });
5188
5700
  };
5701
+ _proto.getMaterialByShader = function getMaterialByShader(materialSchema, shader, engine) {
5702
+ var _loop = function(key) {
5703
+ var _shaderData_key = shaderData[key], type = _shaderData_key.type, value = _shaderData_key.value;
5704
+ switch(type){
5705
+ case "Vector2":
5706
+ materialShaderData.setVector2(key, new Vector2(value.x, value.y));
5707
+ break;
5708
+ case "Vector3":
5709
+ materialShaderData.setVector3(key, new Vector3(value.x, value.y, value.z));
5710
+ break;
5711
+ case "Vector4":
5712
+ materialShaderData.setVector4(key, new Vector4(value.x, value.y, value.z, value.w));
5713
+ break;
5714
+ case "Color":
5715
+ materialShaderData.setColor(key, new Color(value.r, value.g, value.b, value.a));
5716
+ break;
5717
+ case "Float":
5718
+ materialShaderData.setFloat(key, value);
5719
+ break;
5720
+ case "Texture":
5721
+ texturePromises.push(// @ts-ignore
5722
+ engine.resourceManager.getResourceByRef(value).then(function(texture) {
5723
+ materialShaderData.setTexture(key, texture);
5724
+ }));
5725
+ break;
5726
+ case "Boolean":
5727
+ materialShaderData.setInt(key, value ? 1 : 0);
5728
+ break;
5729
+ case "Integer":
5730
+ materialShaderData.setInt(key, Number(value));
5731
+ break;
5732
+ }
5733
+ };
5734
+ var name = materialSchema.name, shaderData = materialSchema.shaderData, macros = materialSchema.macros, renderState = materialSchema.renderState;
5735
+ var material = new Material(engine, shader);
5736
+ material.name = name;
5737
+ var texturePromises = new Array();
5738
+ var materialShaderData = material.shaderData;
5739
+ for(var key in shaderData)_loop(key);
5740
+ for(var i = 0, length = macros.length; i < length; i++){
5741
+ var _macros_i = macros[i], name1 = _macros_i.name, value = _macros_i.value;
5742
+ if (value == undefined) {
5743
+ materialShaderData.enableMacro(name1);
5744
+ } else {
5745
+ materialShaderData.enableMacro(name1, value);
5746
+ }
5747
+ }
5748
+ parseProperty(material, "renderState", renderState);
5749
+ return Promise.all(texturePromises).then(function() {
5750
+ return material;
5751
+ });
5752
+ };
5189
5753
  return MaterialLoader;
5190
5754
  }(Loader);
5191
5755
  MaterialLoader = __decorate([
@@ -5220,6 +5784,86 @@ MeshLoader = __decorate([
5220
5784
  ])
5221
5785
  ], MeshLoader);
5222
5786
 
5787
+ var PrimitiveMeshLoader = /*#__PURE__*/ function(Loader1) {
5788
+ _inherits(PrimitiveMeshLoader, Loader1);
5789
+ function PrimitiveMeshLoader() {
5790
+ return Loader1.apply(this, arguments);
5791
+ }
5792
+ var _proto = PrimitiveMeshLoader.prototype;
5793
+ _proto.load = function load(item, param) {
5794
+ var engine = param.engine;
5795
+ return this.request(item.url, _extends({}, item, {
5796
+ type: "json"
5797
+ })).then(function(data) {
5798
+ switch(data.type){
5799
+ case "sphere":
5800
+ return PrimitiveMesh.createSubdivisionSurfaceSphere(engine, data.sphereRadius, data.sphereStep);
5801
+ case "capsule":
5802
+ return PrimitiveMesh.createCapsule(engine, data.capsuleRadius, data.capsuleHeight, data.capsuleRadialSegments, data.capsuleHeightSegments);
5803
+ case "cone":
5804
+ return PrimitiveMesh.createCone(engine, data.coneRadius, data.coneHeight, data.coneRadialSegment, data.coneHeightSegment);
5805
+ case "cuboid":
5806
+ return PrimitiveMesh.createCuboid(engine, data.cuboidWidth, data.cuboidHeight, data.cuboidDepth);
5807
+ case "cylinder":
5808
+ return PrimitiveMesh.createCylinder(engine, data.cylinderRadiusTop, data.cylinderRadiusBottom, data.cylinderHeight, data.cylinderRadialSegment, data.cylinderHeightSegment);
5809
+ case "plane":
5810
+ return PrimitiveMesh.createPlane(engine, data.planeWidth, data.planeHeight, data.planeHorizontalSegments, data.planeVerticalSegments);
5811
+ case "torus":
5812
+ return PrimitiveMesh.createTorus(engine, data.torusRadius, data.torusTubeRadius, data.torusRadialSegments, data.torusTubularSegments, data.torusArc);
5813
+ }
5814
+ });
5815
+ };
5816
+ return PrimitiveMeshLoader;
5817
+ }(Loader);
5818
+ PrimitiveMeshLoader = __decorate([
5819
+ resourceLoader(AssetType.PrimitiveMesh, [
5820
+ "mesh"
5821
+ ], false)
5822
+ ], PrimitiveMeshLoader);
5823
+ var /** @internal */ PrimitiveMeshType;
5824
+ (function(PrimitiveMeshType) {
5825
+ PrimitiveMeshType["Sphere"] = "sphere";
5826
+ PrimitiveMeshType["Cuboid"] = "cuboid";
5827
+ PrimitiveMeshType["Plane"] = "plane";
5828
+ PrimitiveMeshType["Cylinder"] = "cylinder";
5829
+ PrimitiveMeshType["Torus"] = "torus";
5830
+ PrimitiveMeshType["Cone"] = "cone";
5831
+ PrimitiveMeshType["Capsule"] = "capsule";
5832
+ })(PrimitiveMeshType || (PrimitiveMeshType = {}));
5833
+
5834
+ var ProjectLoader = /*#__PURE__*/ function(Loader1) {
5835
+ _inherits(ProjectLoader, Loader1);
5836
+ function ProjectLoader() {
5837
+ return Loader1.apply(this, arguments);
5838
+ }
5839
+ var _proto = ProjectLoader.prototype;
5840
+ _proto.load = function load(item, resourceManager) {
5841
+ var _this = this;
5842
+ var engine = resourceManager.engine;
5843
+ return new AssetPromise(function(resolve, reject) {
5844
+ _this.request(item.url, {
5845
+ type: "json"
5846
+ }).then(function(data) {
5847
+ // @ts-ignore
5848
+ engine.resourceManager.initVirtualResources(data.files);
5849
+ return resourceManager.load({
5850
+ type: AssetType.Scene,
5851
+ url: data.scene
5852
+ }).then(function(scene) {
5853
+ engine.sceneManager.activeScene = scene;
5854
+ resolve();
5855
+ });
5856
+ }).catch(reject);
5857
+ });
5858
+ };
5859
+ return ProjectLoader;
5860
+ }(Loader);
5861
+ ProjectLoader = __decorate([
5862
+ resourceLoader(AssetType.Project, [
5863
+ "proj"
5864
+ ], false)
5865
+ ], ProjectLoader);
5866
+
5223
5867
  var SourceFontLoader = /*#__PURE__*/ function(Loader1) {
5224
5868
  _inherits(SourceFontLoader, Loader1);
5225
5869
  function SourceFontLoader() {
@@ -5282,7 +5926,7 @@ var SpriteAtlasLoader = /*#__PURE__*/ function(Loader1) {
5282
5926
  var _proto = SpriteAtlasLoader.prototype;
5283
5927
  _proto.load = function load(item, resourceManager) {
5284
5928
  var _this = this;
5285
- return new AssetPromise(function(resolve, reject, _, onCancel) {
5929
+ return new AssetPromise(function(resolve, reject, _, __, onCancel) {
5286
5930
  var chainPromises = [];
5287
5931
  onCancel(function() {
5288
5932
  for(var i = 0; i < chainPromises.length; i++){
@@ -5445,12 +6089,12 @@ var Texture2DLoader = /*#__PURE__*/ function(Loader1) {
5445
6089
  var _proto = Texture2DLoader.prototype;
5446
6090
  _proto.load = function load(item, resourceManager) {
5447
6091
  var _this = this;
5448
- return new AssetPromise(function(resolve, reject) {
6092
+ return new AssetPromise(function(resolve, reject, setTaskCompleteProgress, setTaskDetailProgress) {
5449
6093
  var url = item.url;
5450
6094
  var requestConfig = _extends({}, item, {
5451
6095
  type: "image"
5452
6096
  });
5453
- _this.request(url, requestConfig).then(function(image) {
6097
+ _this.request(url, requestConfig).onProgress(setTaskCompleteProgress, setTaskDetailProgress).then(function(image) {
5454
6098
  var _item_params;
5455
6099
  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
6100
  var texture = new Texture2D(resourceManager.engine, image.width, image.height, format, mipmap);
@@ -5555,38 +6199,105 @@ TextureCubeLoader = __decorate([
5555
6199
  ])
5556
6200
  ], TextureCubeLoader);
5557
6201
 
5558
- var ProjectLoader = /*#__PURE__*/ function(Loader1) {
5559
- _inherits(ProjectLoader, Loader1);
5560
- function ProjectLoader() {
6202
+ var ShaderLoader = /*#__PURE__*/ function(Loader1) {
6203
+ _inherits(ShaderLoader, Loader1);
6204
+ function ShaderLoader() {
5561
6205
  return Loader1.apply(this, arguments);
5562
6206
  }
5563
- var _proto = ProjectLoader.prototype;
6207
+ var _proto = ShaderLoader.prototype;
5564
6208
  _proto.load = function load(item, resourceManager) {
5565
6209
  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);
6210
+ return this.request(item.url, _extends({}, item, {
6211
+ type: "text"
6212
+ })).then(function(code) {
6213
+ var builtinShader = _this.getBuiltinShader(code);
6214
+ if (builtinShader) {
6215
+ return Shader.find(builtinShader);
6216
+ }
6217
+ var matches = code.matchAll(/^[ \t]*#include +"([^$\\"]+)"/gm);
6218
+ return Promise.all(Array.from(matches).map(function(m) {
6219
+ var path = m[1];
6220
+ if (path) {
6221
+ // @ts-ignore
6222
+ var resource = resourceManager._virtualPathMap[path];
6223
+ if (!resource) return;
6224
+ return resourceManager.load({
6225
+ type: AssetType.ShaderChunk,
6226
+ url: resource,
6227
+ params: {
6228
+ includeKey: path
6229
+ }
6230
+ });
6231
+ }
6232
+ })).then(function() {
6233
+ return Shader.create(code);
6234
+ });
5581
6235
  });
5582
6236
  };
5583
- return ProjectLoader;
6237
+ _proto.getBuiltinShader = function getBuiltinShader(code) {
6238
+ var match = code.match(/^\s*\/\/\s*@builtin\s+(\w+)/);
6239
+ if (match && match[1]) return match[1];
6240
+ };
6241
+ return ShaderLoader;
5584
6242
  }(Loader);
5585
- ProjectLoader = __decorate([
5586
- resourceLoader(AssetType.Project, [
5587
- "proj"
6243
+ ShaderLoader = __decorate([
6244
+ resourceLoader(AssetType.Shader, [
6245
+ "gs",
6246
+ "gsl"
5588
6247
  ], false)
5589
- ], ProjectLoader);
6248
+ ], ShaderLoader);
6249
+
6250
+ var ShaderChunkLoader = /*#__PURE__*/ function(Loader1) {
6251
+ _inherits(ShaderChunkLoader, Loader1);
6252
+ function ShaderChunkLoader() {
6253
+ return Loader1.apply(this, arguments);
6254
+ }
6255
+ var _proto = ShaderChunkLoader.prototype;
6256
+ _proto.load = function load(item, resourceManager) {
6257
+ return this.request(item.url, _extends({}, item, {
6258
+ type: "text"
6259
+ })).then(/*#__PURE__*/ _async_to_generator(function(code) {
6260
+ var includeKey, matches;
6261
+ return __generator(this, function(_state) {
6262
+ switch(_state.label){
6263
+ case 0:
6264
+ includeKey = item.params.includeKey;
6265
+ ShaderFactory.registerInclude(includeKey, code);
6266
+ matches = code.matchAll(/^[ \t]*#include +"([^$\\"]+)"/gm);
6267
+ return [
6268
+ 4,
6269
+ Promise.all(Array.from(matches).map(function(m) {
6270
+ var path = m[1];
6271
+ if (path) {
6272
+ // @ts-ignore
6273
+ var resource = resourceManager._virtualPathMap[path];
6274
+ if (!resource) return;
6275
+ return resourceManager.load({
6276
+ type: AssetType.ShaderChunk,
6277
+ url: resource,
6278
+ params: {
6279
+ includeKey: path
6280
+ }
6281
+ });
6282
+ }
6283
+ }))
6284
+ ];
6285
+ case 1:
6286
+ _state.sent();
6287
+ return [
6288
+ 2
6289
+ ];
6290
+ }
6291
+ });
6292
+ }));
6293
+ };
6294
+ return ShaderChunkLoader;
6295
+ }(Loader);
6296
+ ShaderChunkLoader = __decorate([
6297
+ resourceLoader(AssetType.ShaderChunk, [
6298
+ "glsl"
6299
+ ], false)
6300
+ ], ShaderChunkLoader);
5590
6301
 
5591
6302
  var SceneLoader = /*#__PURE__*/ function(Loader1) {
5592
6303
  _inherits(SceneLoader, Loader1);
@@ -5606,7 +6317,7 @@ var SceneLoader = /*#__PURE__*/ function(Loader1) {
5606
6317
  // parse ambient light
5607
6318
  var ambient = data.scene.ambient;
5608
6319
  if (ambient) {
5609
- var useCustomAmbient = ambient.specularMode === "Custom";
6320
+ var useCustomAmbient = ambient.specularMode === SpecularMode.Custom;
5610
6321
  var useSH = ambient.diffuseMode === DiffuseMode.SphericalHarmonics;
5611
6322
  scene.ambientLight.diffuseIntensity = ambient.diffuseIntensity;
5612
6323
  scene.ambientLight.specularIntensity = ambient.specularIntensity;
@@ -5634,6 +6345,7 @@ var SceneLoader = /*#__PURE__*/ function(Loader1) {
5634
6345
  }));
5635
6346
  }
5636
6347
  }
6348
+ // parse background
5637
6349
  var background = data.scene.background;
5638
6350
  scene.background.mode = background.mode;
5639
6351
  switch(scene.background.mode){
@@ -5677,6 +6389,17 @@ var SceneLoader = /*#__PURE__*/ function(Loader1) {
5677
6389
  var _shadow_shadowTwoCascadeSplits;
5678
6390
  scene.shadowTwoCascadeSplits = (_shadow_shadowTwoCascadeSplits = shadow.shadowTwoCascadeSplits) != null ? _shadow_shadowTwoCascadeSplits : scene.shadowTwoCascadeSplits;
5679
6391
  shadow.shadowFourCascadeSplits && scene.shadowFourCascadeSplits.copyFrom(shadow.shadowFourCascadeSplits);
6392
+ var _shadow_shadowFadeBorder;
6393
+ scene.shadowFadeBorder = (_shadow_shadowFadeBorder = shadow.shadowFadeBorder) != null ? _shadow_shadowFadeBorder : scene.shadowFadeBorder;
6394
+ }
6395
+ // parse fog
6396
+ var fog = data.scene.fog;
6397
+ if (fog) {
6398
+ if (fog.fogMode != undefined) scene.fogMode = fog.fogMode;
6399
+ if (fog.fogStart != undefined) scene.fogStart = fog.fogStart;
6400
+ if (fog.fogEnd != undefined) scene.fogEnd = fog.fogEnd;
6401
+ if (fog.fogDensity != undefined) scene.fogDensity = fog.fogDensity;
6402
+ if (fog.fogColor != undefined) scene.fogColor.copyFrom(fog.fogColor);
5680
6403
  }
5681
6404
  return Promise.all(promises).then(function() {
5682
6405
  resolve(scene);
@@ -5707,170 +6430,6 @@ ReflectionParser.registerCustomParseComponent("TextRenderer", /*#__PURE__*/ _asy
5707
6430
  });
5708
6431
  }));
5709
6432
 
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
6433
  var KHR_lights_punctual = /*#__PURE__*/ function(GLTFExtensionParser1) {
5875
6434
  _inherits(KHR_lights_punctual, GLTFExtensionParser1);
5876
6435
  function KHR_lights_punctual() {
@@ -6045,7 +6604,7 @@ var KHR_materials_variants = /*#__PURE__*/ function(GLTFExtensionParser1) {
6045
6604
  var _glTFResource;
6046
6605
  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
6606
  var mappings = schema.mappings;
6048
- (_glTFResource = glTFResource).extensionsData || (_glTFResource.extensionsData = {});
6607
+ (_glTFResource = glTFResource)._extensionsData || (_glTFResource._extensionsData = {});
6049
6608
  var extensionData = [];
6050
6609
  glTFResource.extensionsData.variants = extensionData;
6051
6610
  for(var i = 0; i < mappings.length; i++)_loop(i);
@@ -6075,7 +6634,7 @@ var KHR_texture_basisu = /*#__PURE__*/ function(GLTFExtensionParser1) {
6075
6634
  var _proto = KHR_texture_basisu.prototype;
6076
6635
  _proto.createAndParse = function createAndParse(context, schema, textureInfo) {
6077
6636
  return _async_to_generator(function() {
6078
- var glTF, glTFResource, engine, url, sampler, textureName, source, _glTF_images_source, uri, bufferViewIndex, mimeType, imageName, samplerInfo, index, bufferView;
6637
+ var glTF, glTFResource, engine, url, sampler, textureName, source, _glTF_images_source, uri, bufferViewIndex, mimeType, imageName, samplerInfo, index, promise, bufferView;
6079
6638
  return __generator(this, function(_state) {
6080
6639
  glTF = context.glTF, glTFResource = context.glTFResource;
6081
6640
  engine = glTFResource.engine, url = glTFResource.url;
@@ -6085,20 +6644,22 @@ var KHR_texture_basisu = /*#__PURE__*/ function(GLTFExtensionParser1) {
6085
6644
  samplerInfo = sampler !== undefined && GLTFUtils.getSamplerInfo(glTF.samplers[sampler]);
6086
6645
  if (uri) {
6087
6646
  index = uri.lastIndexOf(".");
6647
+ promise = engine.resourceManager.load({
6648
+ url: Utils.resolveAbsoluteUrl(url, uri),
6649
+ type: AssetType.KTX2
6650
+ }).onProgress(undefined, context._onTaskDetail).then(function(texture) {
6651
+ if (!texture.name) {
6652
+ texture.name = textureName || imageName || "texture_" + index;
6653
+ }
6654
+ if (sampler !== undefined) {
6655
+ GLTFUtils.parseSampler(texture, samplerInfo);
6656
+ }
6657
+ return texture;
6658
+ });
6659
+ context._addTaskCompletePromise(promise);
6088
6660
  return [
6089
6661
  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
- })
6662
+ promise
6102
6663
  ];
6103
6664
  } else {
6104
6665
  bufferView = glTF.bufferViews[bufferViewIndex];
@@ -6168,7 +6729,9 @@ var GALACEAN_materials_remap = /*#__PURE__*/ function(GLTFExtensionParser1) {
6168
6729
  _proto.createAndParse = function createAndParse(context, schema) {
6169
6730
  var engine = context.glTFResource.engine;
6170
6731
  // @ts-ignore
6171
- return engine.resourceManager.getResourceByRef(schema);
6732
+ var promise = engine.resourceManager.getResourceByRef(schema);
6733
+ context._addTaskCompletePromise(promise);
6734
+ return promise;
6172
6735
  };
6173
6736
  return GALACEAN_materials_remap;
6174
6737
  }(GLTFExtensionParser);
@@ -6199,5 +6762,45 @@ GALACEAN_animation_event = __decorate([
6199
6762
  registerGLTFExtension("GALACEAN_animation_event", GLTFExtensionMode.AdditiveParse)
6200
6763
  ], GALACEAN_animation_event);
6201
6764
 
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 };
6765
+ var EXT_meshopt_compression = /*#__PURE__*/ function(GLTFExtensionParser1) {
6766
+ _inherits(EXT_meshopt_compression, GLTFExtensionParser1);
6767
+ function EXT_meshopt_compression() {
6768
+ return GLTFExtensionParser1.apply(this, arguments);
6769
+ }
6770
+ var _proto = EXT_meshopt_compression.prototype;
6771
+ _proto.createAndParse = function createAndParse(context, schema) {
6772
+ return context.get(GLTFParserType.Buffer, schema.buffer).then(function(arrayBuffer) {
6773
+ return MeshoptDecoder.decodeGltfBuffer(schema.count, schema.byteStride, new Uint8Array(arrayBuffer, schema.byteOffset, schema.byteLength), schema.mode, schema.filter);
6774
+ });
6775
+ };
6776
+ return EXT_meshopt_compression;
6777
+ }(GLTFExtensionParser);
6778
+ EXT_meshopt_compression = __decorate([
6779
+ registerGLTFExtension("EXT_meshopt_compression", GLTFExtensionMode.CreateAndParse)
6780
+ ], EXT_meshopt_compression);
6781
+
6782
+ var KHR_materials_anisotropy = /*#__PURE__*/ function(GLTFExtensionParser1) {
6783
+ _inherits(KHR_materials_anisotropy, GLTFExtensionParser1);
6784
+ function KHR_materials_anisotropy() {
6785
+ return GLTFExtensionParser1.apply(this, arguments);
6786
+ }
6787
+ var _proto = KHR_materials_anisotropy.prototype;
6788
+ _proto.additiveParse = function additiveParse(context, material, schema) {
6789
+ 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;
6790
+ material.anisotropy = anisotropyStrength;
6791
+ material.anisotropyRotation = anisotropyRotation;
6792
+ if (anisotropyTexture) {
6793
+ GLTFMaterialParser._checkOtherTextureTransform(anisotropyTexture, "Anisotropy texture");
6794
+ context.get(GLTFParserType.Texture, anisotropyTexture.index).then(function(texture) {
6795
+ material.anisotropyTexture = texture;
6796
+ });
6797
+ }
6798
+ };
6799
+ return KHR_materials_anisotropy;
6800
+ }(GLTFExtensionParser);
6801
+ KHR_materials_anisotropy = __decorate([
6802
+ registerGLTFExtension("KHR_materials_anisotropy", GLTFExtensionMode.AdditiveParse)
6803
+ ], KHR_materials_anisotropy);
6804
+
6805
+ export { AccessorType, AnimationClipDecoder, BufferInfo, EditorTextureLoader, GLTFAnimationParser, 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
6806
  //# sourceMappingURL=module.js.map