@galacean/engine-loader 1.1.0-alpha.3 → 1.1.0-alpha.4

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.
@@ -681,6 +681,8 @@ exports.InterpolableValueType = void 0;
681
681
  InterpolableValueType[InterpolableValueType["Color"] = 6] = "Color";
682
682
  InterpolableValueType[InterpolableValueType["Array"] = 7] = "Array";
683
683
  InterpolableValueType[InterpolableValueType["Boolean"] = 8] = "Boolean";
684
+ InterpolableValueType[InterpolableValueType["Rect"] = 9] = "Rect";
685
+ InterpolableValueType[InterpolableValueType["ReferResource"] = 10] = "ReferResource";
684
686
  })(exports.InterpolableValueType || (exports.InterpolableValueType = {}));
685
687
  exports.AnimationClipDecoder = /*#__PURE__*/ function() {
686
688
  function AnimationClipDecoder() {}
@@ -709,7 +711,7 @@ exports.AnimationClipDecoder = /*#__PURE__*/ function() {
709
711
  switch(curveType){
710
712
  case "AnimationFloatCurve":
711
713
  {
712
- curve = curve || new miniprogram.AnimationFloatCurve();
714
+ curve = new miniprogram.AnimationFloatCurve();
713
715
  curve.interpolation = interpolation;
714
716
  for(var j = 0; j < keysLen; ++j){
715
717
  var keyframe = new miniprogram.Keyframe();
@@ -723,7 +725,7 @@ exports.AnimationClipDecoder = /*#__PURE__*/ function() {
723
725
  }
724
726
  case "AnimationArrayCurve":
725
727
  {
726
- curve = curve || new miniprogram.AnimationArrayCurve();
728
+ curve = new miniprogram.AnimationArrayCurve();
727
729
  curve.interpolation = interpolation;
728
730
  for(var j1 = 0; j1 < keysLen; ++j1){
729
731
  var keyframe1 = new miniprogram.Keyframe();
@@ -738,7 +740,7 @@ exports.AnimationClipDecoder = /*#__PURE__*/ function() {
738
740
  }
739
741
  case "AnimationFloatArrayCurve":
740
742
  {
741
- curve = curve || new miniprogram.AnimationFloatArrayCurve();
743
+ curve = new miniprogram.AnimationFloatArrayCurve();
742
744
  curve.interpolation = interpolation;
743
745
  for(var j2 = 0; j2 < keysLen; ++j2){
744
746
  var keyframe2 = new miniprogram.Keyframe();
@@ -753,7 +755,7 @@ exports.AnimationClipDecoder = /*#__PURE__*/ function() {
753
755
  }
754
756
  case "AnimationVector2Curve":
755
757
  {
756
- curve = curve || new miniprogram.AnimationVector2Curve();
758
+ curve = new miniprogram.AnimationVector2Curve();
757
759
  curve.interpolation = interpolation;
758
760
  for(var j3 = 0; j3 < keysLen; ++j3){
759
761
  var keyframe3 = new miniprogram.Keyframe();
@@ -767,7 +769,7 @@ exports.AnimationClipDecoder = /*#__PURE__*/ function() {
767
769
  }
768
770
  case "AnimationVector3Curve":
769
771
  {
770
- curve = curve || new miniprogram.AnimationVector3Curve();
772
+ curve = new miniprogram.AnimationVector3Curve();
771
773
  curve.interpolation = interpolation;
772
774
  for(var j4 = 0; j4 < keysLen; ++j4){
773
775
  var keyframe4 = new miniprogram.Keyframe();
@@ -781,7 +783,7 @@ exports.AnimationClipDecoder = /*#__PURE__*/ function() {
781
783
  }
782
784
  case "AnimationVector4Curve":
783
785
  {
784
- curve = curve || new miniprogram.AnimationVector4Curve();
786
+ curve = new miniprogram.AnimationVector4Curve();
785
787
  curve.interpolation = interpolation;
786
788
  var keyframe5 = new miniprogram.Keyframe();
787
789
  keyframe5.time = bufferReader.nextFloat32();
@@ -793,7 +795,7 @@ exports.AnimationClipDecoder = /*#__PURE__*/ function() {
793
795
  }
794
796
  case "AnimationColorCurve":
795
797
  {
796
- curve = curve || new miniprogram.AnimationColorCurve();
798
+ curve = new miniprogram.AnimationColorCurve();
797
799
  curve.interpolation = interpolation;
798
800
  for(var j5 = 0; j5 < keysLen; ++j5){
799
801
  var keyframe6 = new miniprogram.Keyframe();
@@ -807,7 +809,7 @@ exports.AnimationClipDecoder = /*#__PURE__*/ function() {
807
809
  }
808
810
  case "AnimationQuaternionCurve":
809
811
  {
810
- curve = curve || new miniprogram.AnimationQuaternionCurve();
812
+ curve = new miniprogram.AnimationQuaternionCurve();
811
813
  curve.interpolation = interpolation;
812
814
  for(var j6 = 0; j6 < keysLen; ++j6){
813
815
  var keyframe7 = new miniprogram.Keyframe();
@@ -819,6 +821,18 @@ exports.AnimationClipDecoder = /*#__PURE__*/ function() {
819
821
  }
820
822
  break;
821
823
  }
824
+ case "AnimationRefCurve":
825
+ {
826
+ curve = new miniprogram.AnimationRefCurve();
827
+ curve.interpolation = interpolation;
828
+ for(var j7 = 0; j7 < keysLen; ++j7){
829
+ var keyframe8 = new miniprogram.Keyframe();
830
+ keyframe8.time = bufferReader.nextFloat32();
831
+ keyframe8.value = JSON.parse(bufferReader.nextStr());
832
+ curve.addKey(keyframe8);
833
+ }
834
+ break;
835
+ }
822
836
  }
823
837
  clip.addCurveBinding(relativePath, componentType, property, curve);
824
838
  }
@@ -1066,7 +1080,27 @@ var AnimationClipLoader = /*#__PURE__*/ function(Loader) {
1066
1080
  _this.request(item.url, _extends({}, item, {
1067
1081
  type: "arraybuffer"
1068
1082
  })).then(function(data) {
1069
- return decode(data, resourceManager.engine).then(resolve);
1083
+ return decode(data, resourceManager.engine).then(function(clip) {
1084
+ var curveBindingPromises = clip.curveBindings.map(function(curveBinding) {
1085
+ var curve = curveBinding.curve;
1086
+ var promises = curve.keys.map(function(key) {
1087
+ var value = key.value;
1088
+ if (typeof value === "object" && value.refId) {
1089
+ return new Promise(function(resolve) {
1090
+ resourceManager// @ts-ignore
1091
+ .getResourceByRef(value).then(function(asset) {
1092
+ key.value = asset;
1093
+ resolve(key);
1094
+ }).catch(reject);
1095
+ });
1096
+ }
1097
+ });
1098
+ return Promise.all(promises);
1099
+ });
1100
+ return Promise.all(curveBindingPromises).then(function() {
1101
+ resolve(clip);
1102
+ });
1103
+ });
1070
1104
  }).catch(reject);
1071
1105
  });
1072
1106
  };
package/dist/module.js CHANGED
@@ -1,4 +1,4 @@
1
- import { Utils, ModelMesh, BlendShape, Texture2D, Entity, Loader, Transform, Animator, DirectLight, Camera, MeshRenderer, ParticleRenderer, PointLight, SpotLight, Script, SpriteMask, SpriteRenderer, TextRenderer, AnimationClip, AnimationEvent, AnimationQuaternionCurve, Keyframe, 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, Entity, Loader, 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';
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
4
  import { DRACODecoder } from '@galacean/engine-draco';
@@ -676,6 +676,8 @@ var InterpolableValueType;
676
676
  InterpolableValueType[InterpolableValueType["Color"] = 6] = "Color";
677
677
  InterpolableValueType[InterpolableValueType["Array"] = 7] = "Array";
678
678
  InterpolableValueType[InterpolableValueType["Boolean"] = 8] = "Boolean";
679
+ InterpolableValueType[InterpolableValueType["Rect"] = 9] = "Rect";
680
+ InterpolableValueType[InterpolableValueType["ReferResource"] = 10] = "ReferResource";
679
681
  })(InterpolableValueType || (InterpolableValueType = {}));
680
682
  var AnimationClipDecoder = /*#__PURE__*/ function() {
681
683
  function AnimationClipDecoder() {}
@@ -704,7 +706,7 @@ var AnimationClipDecoder = /*#__PURE__*/ function() {
704
706
  switch(curveType){
705
707
  case "AnimationFloatCurve":
706
708
  {
707
- curve = curve || new AnimationFloatCurve();
709
+ curve = new AnimationFloatCurve();
708
710
  curve.interpolation = interpolation;
709
711
  for(var j = 0; j < keysLen; ++j){
710
712
  var keyframe = new Keyframe();
@@ -718,7 +720,7 @@ var AnimationClipDecoder = /*#__PURE__*/ function() {
718
720
  }
719
721
  case "AnimationArrayCurve":
720
722
  {
721
- curve = curve || new AnimationArrayCurve();
723
+ curve = new AnimationArrayCurve();
722
724
  curve.interpolation = interpolation;
723
725
  for(var j1 = 0; j1 < keysLen; ++j1){
724
726
  var keyframe1 = new Keyframe();
@@ -733,7 +735,7 @@ var AnimationClipDecoder = /*#__PURE__*/ function() {
733
735
  }
734
736
  case "AnimationFloatArrayCurve":
735
737
  {
736
- curve = curve || new AnimationFloatArrayCurve();
738
+ curve = new AnimationFloatArrayCurve();
737
739
  curve.interpolation = interpolation;
738
740
  for(var j2 = 0; j2 < keysLen; ++j2){
739
741
  var keyframe2 = new Keyframe();
@@ -748,7 +750,7 @@ var AnimationClipDecoder = /*#__PURE__*/ function() {
748
750
  }
749
751
  case "AnimationVector2Curve":
750
752
  {
751
- curve = curve || new AnimationVector2Curve();
753
+ curve = new AnimationVector2Curve();
752
754
  curve.interpolation = interpolation;
753
755
  for(var j3 = 0; j3 < keysLen; ++j3){
754
756
  var keyframe3 = new Keyframe();
@@ -762,7 +764,7 @@ var AnimationClipDecoder = /*#__PURE__*/ function() {
762
764
  }
763
765
  case "AnimationVector3Curve":
764
766
  {
765
- curve = curve || new AnimationVector3Curve();
767
+ curve = new AnimationVector3Curve();
766
768
  curve.interpolation = interpolation;
767
769
  for(var j4 = 0; j4 < keysLen; ++j4){
768
770
  var keyframe4 = new Keyframe();
@@ -776,7 +778,7 @@ var AnimationClipDecoder = /*#__PURE__*/ function() {
776
778
  }
777
779
  case "AnimationVector4Curve":
778
780
  {
779
- curve = curve || new AnimationVector4Curve();
781
+ curve = new AnimationVector4Curve();
780
782
  curve.interpolation = interpolation;
781
783
  var keyframe5 = new Keyframe();
782
784
  keyframe5.time = bufferReader.nextFloat32();
@@ -788,7 +790,7 @@ var AnimationClipDecoder = /*#__PURE__*/ function() {
788
790
  }
789
791
  case "AnimationColorCurve":
790
792
  {
791
- curve = curve || new AnimationColorCurve();
793
+ curve = new AnimationColorCurve();
792
794
  curve.interpolation = interpolation;
793
795
  for(var j5 = 0; j5 < keysLen; ++j5){
794
796
  var keyframe6 = new Keyframe();
@@ -802,7 +804,7 @@ var AnimationClipDecoder = /*#__PURE__*/ function() {
802
804
  }
803
805
  case "AnimationQuaternionCurve":
804
806
  {
805
- curve = curve || new AnimationQuaternionCurve();
807
+ curve = new AnimationQuaternionCurve();
806
808
  curve.interpolation = interpolation;
807
809
  for(var j6 = 0; j6 < keysLen; ++j6){
808
810
  var keyframe7 = new Keyframe();
@@ -814,6 +816,18 @@ var AnimationClipDecoder = /*#__PURE__*/ function() {
814
816
  }
815
817
  break;
816
818
  }
819
+ case "AnimationRefCurve":
820
+ {
821
+ curve = new AnimationRefCurve();
822
+ curve.interpolation = interpolation;
823
+ for(var j7 = 0; j7 < keysLen; ++j7){
824
+ var keyframe8 = new Keyframe();
825
+ keyframe8.time = bufferReader.nextFloat32();
826
+ keyframe8.value = JSON.parse(bufferReader.nextStr());
827
+ curve.addKey(keyframe8);
828
+ }
829
+ break;
830
+ }
817
831
  }
818
832
  clip.addCurveBinding(relativePath, componentType, property, curve);
819
833
  }
@@ -1061,7 +1075,27 @@ var AnimationClipLoader = /*#__PURE__*/ function(Loader) {
1061
1075
  _this.request(item.url, _extends({}, item, {
1062
1076
  type: "arraybuffer"
1063
1077
  })).then(function(data) {
1064
- return decode(data, resourceManager.engine).then(resolve);
1078
+ return decode(data, resourceManager.engine).then(function(clip) {
1079
+ var curveBindingPromises = clip.curveBindings.map(function(curveBinding) {
1080
+ var curve = curveBinding.curve;
1081
+ var promises = curve.keys.map(function(key) {
1082
+ var value = key.value;
1083
+ if (typeof value === "object" && value.refId) {
1084
+ return new Promise(function(resolve) {
1085
+ resourceManager// @ts-ignore
1086
+ .getResourceByRef(value).then(function(asset) {
1087
+ key.value = asset;
1088
+ resolve(key);
1089
+ }).catch(reject);
1090
+ });
1091
+ }
1092
+ });
1093
+ return Promise.all(promises);
1094
+ });
1095
+ return Promise.all(curveBindingPromises).then(function() {
1096
+ resolve(clip);
1097
+ });
1098
+ });
1065
1099
  }).catch(reject);
1066
1100
  });
1067
1101
  };