@galacean/effects-core 2.0.0-alpha.28 → 2.0.0-alpha.29

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.
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@
3
3
  * Description: Galacean Effects runtime core for the web
4
4
  * Author: Ant Group CO., Ltd.
5
5
  * Contributors: 燃然,飂兮,十弦,云垣,茂安,意绮
6
- * Version: v2.0.0-alpha.28
6
+ * Version: v2.0.0-alpha.29
7
7
  */
8
8
 
9
9
  'use strict';
@@ -4602,9 +4602,6 @@ function getDirectStore(target) {
4602
4602
  };
4603
4603
  return EffectsObject;
4604
4604
  }();
4605
- __decorate([
4606
- serialize()
4607
- ], EffectsObject.prototype, "guid", void 0);
4608
4605
 
4609
4606
  /**
4610
4607
  * @since 2.0.0
@@ -4882,8 +4879,8 @@ exports.CameraController = /*#__PURE__*/ function(ItemBehaviour) {
4882
4879
  camera.far = this.options.far;
4883
4880
  camera.fov = this.options.fov;
4884
4881
  camera.clipMode = this.options.clipMode;
4885
- camera.position = this.transform.position;
4886
- camera.rotation = this.transform.rotation;
4882
+ camera.position = this.transform.getWorldPosition();
4883
+ camera.rotation = this.transform.getWorldRotation();
4887
4884
  }
4888
4885
  };
4889
4886
  _proto.fromData = function fromData(data) {
@@ -7868,6 +7865,7 @@ exports.TextureSourceType = void 0;
7868
7865
  return Downloader;
7869
7866
  }();
7870
7867
  var webPFailed = false;
7868
+ var avifFailed = false;
7871
7869
  /**
7872
7870
  * 异步加载一个 WebP 图片文件,如果不支持 WebP,则加载 PNG 图片文件
7873
7871
  * @param png - PNG 图片文件的 URL
@@ -7943,6 +7941,81 @@ function _loadWebPOptional() {
7943
7941
  });
7944
7942
  return _loadWebPOptional.apply(this, arguments);
7945
7943
  }
7944
+ /**
7945
+ * 异步加载一个 AVIF 图片文件,如果不支持 AVIF,则加载 PNG 图片文件
7946
+ * @param png - PNG 图片文件的 URL
7947
+ * @param avif - AVIF 图片文件的 URL
7948
+ */ function loadAVIFOptional(png, avif) {
7949
+ return _loadAVIFOptional.apply(this, arguments);
7950
+ }
7951
+ function _loadAVIFOptional() {
7952
+ _loadAVIFOptional = _async_to_generator(function(png, avif) {
7953
+ var image, image1, image2;
7954
+ return __generator(this, function(_state) {
7955
+ switch(_state.label){
7956
+ case 0:
7957
+ if (!(avifFailed || !avif)) return [
7958
+ 3,
7959
+ 2
7960
+ ];
7961
+ return [
7962
+ 4,
7963
+ loadImage(png)
7964
+ ];
7965
+ case 1:
7966
+ image = _state.sent();
7967
+ return [
7968
+ 2,
7969
+ {
7970
+ image: image,
7971
+ url: png
7972
+ }
7973
+ ];
7974
+ case 2:
7975
+ _state.trys.push([
7976
+ 2,
7977
+ 4,
7978
+ ,
7979
+ 6
7980
+ ]);
7981
+ return [
7982
+ 4,
7983
+ loadImage(avif)
7984
+ ];
7985
+ case 3:
7986
+ image1 = _state.sent();
7987
+ return [
7988
+ 2,
7989
+ {
7990
+ image: image1,
7991
+ url: avif
7992
+ }
7993
+ ];
7994
+ case 4:
7995
+ _state.sent();
7996
+ avifFailed = true;
7997
+ return [
7998
+ 4,
7999
+ loadImage(png)
8000
+ ];
8001
+ case 5:
8002
+ image2 = _state.sent();
8003
+ return [
8004
+ 2,
8005
+ {
8006
+ image: image2,
8007
+ url: png
8008
+ }
8009
+ ];
8010
+ case 6:
8011
+ return [
8012
+ 2
8013
+ ];
8014
+ }
8015
+ });
8016
+ });
8017
+ return _loadAVIFOptional.apply(this, arguments);
8018
+ }
7946
8019
  /**
7947
8020
  * 异步加载一个图片文件
7948
8021
  * @param source - 图片文件的 URL、Blob 或 HTMLImageElement 对象
@@ -11584,7 +11657,7 @@ var gaussianDownVFrag = "precision highp float;varying vec2 uv;uniform sampler2D
11584
11657
 
11585
11658
  var gaussianUpFrag = "precision highp float;varying vec2 uv;uniform sampler2D _MainTex;uniform sampler2D _GaussianDownTex;uniform vec2 _GaussianDownTextureSize;float GaussWeight2D(float x,float y,float sigma){float PI=3.14159265358;float E=2.71828182846;float sigma_2=pow(sigma,2.0);float a=-(x*x+y*y)/(2.0*sigma_2);return pow(E,a)/(2.0*PI*sigma_2);}vec3 GaussNxN(sampler2D tex,vec2 uv,vec2 stride,float sigma){vec3 color=vec3(0.,0.,0.);const int r=1;float weight=0.0;for(int i=-r;i<=r;i++){for(int j=-r;j<=r;j++){float w=GaussWeight2D(float(i),float(j),sigma);vec2 coord=uv+vec2(i,j)*stride;color+=texture2D(tex,coord).rgb*w;weight+=w;}}color/=weight;return color;}void main(){vec3 lowResColor=GaussNxN(_MainTex,uv,0.5/_GaussianDownTextureSize,1.0);vec3 highResColor=GaussNxN(_GaussianDownTex,uv,1.0/_GaussianDownTextureSize,1.0);vec3 color=mix(highResColor,lowResColor,0.7);gl_FragColor=vec4(color,1.0);}";
11586
11659
 
11587
- var thresholdFrag = "precision highp float;varying vec2 uv;uniform sampler2D _MainTex;uniform float _Threshold;void main(){vec4 mainColor=texture2D(_MainTex,uv);mainColor.rgb=pow(mainColor.rgb,vec3(2.2));float brightness=max(mainColor.r,max(mainColor.g,mainColor.b));float w=max(0.0,brightness-_Threshold)/max(brightness,0.00001);mainColor.rgb*=w;gl_FragColor=vec4(mainColor.rgb,1.0);}";
11660
+ var thresholdFrag = "precision highp float;varying vec2 uv;uniform sampler2D _MainTex;uniform float _Threshold;void main(){vec4 mainTex=texture2D(_MainTex,uv);mainTex.rgb=pow(mainTex.rgb,vec3(2.2));float brightness=max(mainTex.r,max(mainTex.g,mainTex.b));float w=max(0.0,brightness-_Threshold)/max(brightness,0.00001);mainTex.rgb*=w;mainTex.rgb*=mainTex.a;gl_FragColor=vec4(mainTex.rgb,1.0);}";
11588
11661
 
11589
11662
  // Bloom 阈值 Pass
11590
11663
  var BloomThresholdPass = /*#__PURE__*/ function(RenderPass) {
@@ -11882,28 +11955,6 @@ var ToneMappingPass = /*#__PURE__*/ function(RenderPass) {
11882
11955
  return ToneMappingPass;
11883
11956
  }(RenderPass);
11884
11957
 
11885
- /**
11886
- * 后处理配置
11887
- */ var defaultGlobalVolume = {
11888
- useHDR: false,
11889
- /***** Material Uniform *****/ // Bloom
11890
- useBloom: true,
11891
- threshold: 1.0,
11892
- bloomIntensity: 1.0,
11893
- // ColorAdjustments
11894
- brightness: 1.0,
11895
- saturation: 1.0,
11896
- contrast: 1.0,
11897
- // Vignette
11898
- // vignetteColor: new math.Color(0, 0, 0, 1),
11899
- // vignetteCenter: new math.Vector2(0.5, 0.5),
11900
- vignetteIntensity: 0.2,
11901
- vignetteSmoothness: 0.4,
11902
- vignetteRoundness: 1.0,
11903
- // ToneMapping
11904
- useToneMapping: true
11905
- };
11906
-
11907
11958
  var RENDER_PASS_NAME_PREFIX = "_effects_default_";
11908
11959
  var seed$5 = 1;
11909
11960
  /**
@@ -11927,7 +11978,7 @@ var seed$5 = 1;
11927
11978
  } : _options_clearAction;
11928
11979
  var engine = renderer.engine;
11929
11980
  if (globalVolume) {
11930
- this.globalVolume = _extends({}, defaultGlobalVolume, globalVolume);
11981
+ this.globalVolume = globalVolume;
11931
11982
  }
11932
11983
  this.globalUniforms = new GlobalUniforms();
11933
11984
  var attachments = []; //渲染场景物体Pass的RT
@@ -12964,6 +13015,28 @@ var Renderer = /*#__PURE__*/ function() {
12964
13015
  return Renderer;
12965
13016
  }();
12966
13017
 
13018
+ /**
13019
+ * 后处理配置
13020
+ */ var defaultGlobalVolume = {
13021
+ useHDR: false,
13022
+ /***** Material Uniform *****/ // Bloom
13023
+ useBloom: true,
13024
+ threshold: 1.0,
13025
+ bloomIntensity: 1.0,
13026
+ // ColorAdjustments
13027
+ brightness: 1.0,
13028
+ saturation: 1.0,
13029
+ contrast: 1.0,
13030
+ // Vignette
13031
+ // vignetteColor: new math.Color(0, 0, 0, 1),
13032
+ // vignetteCenter: new math.Vector2(0.5, 0.5),
13033
+ vignetteIntensity: 0.2,
13034
+ vignetteSmoothness: 0.4,
13035
+ vignetteRoundness: 1.0,
13036
+ // ToneMapping
13037
+ useToneMapping: true
13038
+ };
13039
+
12967
13040
  var vertex = "\nprecision highp float;\n\nattribute vec2 aPoint;\nuniform vec4 uPos;\nuniform vec2 uSize;\nuniform vec4 uQuat;\nuniform vec4 uColor;\nuniform mat4 effects_ObjectToWorld;\nuniform mat4 effects_MatrixInvV;\nuniform mat4 effects_MatrixVP;\nvarying vec4 vColor;\n#ifdef ENV_EDITOR\n uniform vec4 uEditorTransform;\n#endif\n\nvec3 rotateByQuat(vec3 a, vec4 quat){\n vec3 qvec = quat.xyz;\n vec3 uv = cross(qvec, a);\n vec3 uuv = cross(qvec, uv) * 2.;\n return a +(uv * 2. * quat.w + uuv);\n}\n\nvoid main() {\n vec4 _pos = uPos;\n vec3 point = rotateByQuat(vec3(aPoint.xy * uSize, 0.),uQuat);\n vec4 pos = vec4(_pos.xyz, 1.0);\n pos = effects_ObjectToWorld * pos;\n pos.xyz += effects_MatrixInvV[0].xyz * point.x+ effects_MatrixInvV[1].xyz * point.y;\n gl_Position = effects_MatrixVP * pos;\n vColor = uColor;\n #ifdef ENV_EDITOR\n gl_Position = vec4(gl_Position.xy * uEditorTransform.xy + uEditorTransform.zw * gl_Position.w, gl_Position.zw);\n #endif\n}\n";
12968
13041
  var fragment = "\nprecision highp float;\n\n#define fragColor gl_FragColor\n\nvarying vec4 vColor;\nvoid main() {\n gl_FragColor = vColor;\n}\n";
12969
13042
  var seed$4 = 1;
@@ -13110,6 +13183,7 @@ exports.InteractComponent = /*#__PURE__*/ function(RendererComponent) {
13110
13183
  }
13111
13184
  var _proto = InteractComponent.prototype;
13112
13185
  _proto.start = function start() {
13186
+ var _this = this;
13113
13187
  var options = this.item.props.content.options;
13114
13188
  var env = this.item.engine.renderer.env;
13115
13189
  var composition = this.item.composition;
@@ -13131,6 +13205,16 @@ exports.InteractComponent = /*#__PURE__*/ function(RendererComponent) {
13131
13205
  this.materials = this.previewContent.mesh.materials;
13132
13206
  }
13133
13207
  this.item.getHitTestParams = this.getHitTestParams;
13208
+ this.item.onEnd = function() {
13209
+ if (_this.item && _this.item.composition) {
13210
+ var _this_previewContent;
13211
+ _this.item.composition.removeInteractiveItem(_this.item, _this.item.props.content.options.type);
13212
+ _this.clickable = false;
13213
+ _this.hasBeenAddedToComposition = false;
13214
+ (_this_previewContent = _this.previewContent) == null ? void 0 : _this_previewContent.mesh.dispose();
13215
+ _this.endDragTarget();
13216
+ }
13217
+ };
13134
13218
  };
13135
13219
  _proto.update = function update(dt) {
13136
13220
  var _this_previewContent;
@@ -13159,15 +13243,7 @@ exports.InteractComponent = /*#__PURE__*/ function(RendererComponent) {
13159
13243
  this.previewContent.mesh.render(renderer);
13160
13244
  }
13161
13245
  };
13162
- _proto.onDestroy = function onDestroy() {
13163
- if (this.item && this.item.composition) {
13164
- var _this_previewContent;
13165
- this.item.composition.removeInteractiveItem(this.item, this.item.props.content.options.type);
13166
- this.clickable = false;
13167
- (_this_previewContent = this.previewContent) == null ? void 0 : _this_previewContent.mesh.dispose();
13168
- this.endDragTarget();
13169
- }
13170
- };
13246
+ _proto.onDestroy = function onDestroy() {};
13171
13247
  _proto.endDragTarget = function endDragTarget() {
13172
13248
  // OVERRIDE
13173
13249
  };
@@ -13750,6 +13826,10 @@ var SpriteColorPlayable = /*#__PURE__*/ function(Playable) {
13750
13826
  }
13751
13827
  if (!this.spriteMaterial) {
13752
13828
  this.spriteMaterial = boundObject.getComponent(exports.SpriteComponent).material;
13829
+ var startColor = this.spriteMaterial.getVector4("_Color");
13830
+ if (startColor) {
13831
+ this.startColor = startColor.toArray();
13832
+ }
13753
13833
  }
13754
13834
  var colorInc = vecFill(tempColor, 1);
13755
13835
  var colorChanged;
@@ -13779,12 +13859,6 @@ var SpriteColorPlayable = /*#__PURE__*/ function(Playable) {
13779
13859
  this.colorOverLifetime = colorStopsFromGradient(colorOverLifetime.color[1]);
13780
13860
  }
13781
13861
  }
13782
- this.startColor = clipData.startColor || [
13783
- 1,
13784
- 1,
13785
- 1,
13786
- 1
13787
- ];
13788
13862
  return this;
13789
13863
  };
13790
13864
  return SpriteColorPlayable;
@@ -14092,7 +14166,7 @@ exports.SpriteComponent = /*#__PURE__*/ function(RendererComponent) {
14092
14166
  var splits = item.splits, renderer = item.renderer, textureSheetAnimation = item.textureSheetAnimation;
14093
14167
  var sx = 1, sy = 1;
14094
14168
  if (renderer.shape) {
14095
- var _renderer_shape = renderer.shape, index = _renderer_shape.index, aPoint = _renderer_shape.aPoint;
14169
+ var _renderer_shape = renderer.shape, _renderer_shape_index = _renderer_shape.index, index = _renderer_shape_index === void 0 ? [] : _renderer_shape_index, _renderer_shape_aPoint = _renderer_shape.aPoint, aPoint = _renderer_shape_aPoint === void 0 ? [] : _renderer_shape_aPoint;
14096
14170
  var point = new Float32Array(aPoint);
14097
14171
  var position = [];
14098
14172
  var atlasOffset = [];
@@ -16962,6 +17036,12 @@ exports.ParticleSystem = /*#__PURE__*/ function(Component) {
16962
17036
  area: area
16963
17037
  };
16964
17038
  };
17039
+ _proto.onAttached = function onAttached() {
17040
+ Component.prototype.onAttached.call(this);
17041
+ this.renderer.item = this.item;
17042
+ this.item.components.push(this.renderer);
17043
+ this.item.rendererComponents.push(this.renderer);
17044
+ };
16965
17045
  _proto.fromData = function fromData(data) {
16966
17046
  Component.prototype.fromData.call(this, data);
16967
17047
  var props = data;
@@ -17243,9 +17323,6 @@ exports.ParticleSystem = /*#__PURE__*/ function(Component) {
17243
17323
  }
17244
17324
  this.item.getHitTestParams = this.getHitTestParams;
17245
17325
  this.item._content = this;
17246
- this.renderer.item = this.item;
17247
- this.item.components.push(this.renderer);
17248
- this.item.rendererComponents.push(this.renderer);
17249
17326
  };
17250
17327
  _create_class(ParticleSystem, [
17251
17328
  {
@@ -19275,7 +19352,7 @@ function compareTracks(a, b) {
19275
19352
  _proto.hitTest = function hitTest(ray, x, y, regions, force, options) {
19276
19353
  var _this, _loop = function(i) {
19277
19354
  var item = _this.items[i];
19278
- if (item.getVisible() && !item.ended && !exports.VFXItem.isComposition(item) && !skip(item)) {
19355
+ if (item.getVisible() && item.transform.getValid() && !item.ended && !exports.VFXItem.isComposition(item) && !skip(item)) {
19279
19356
  var hitParams = item.getHitTestParams(force);
19280
19357
  if (hitParams) {
19281
19358
  var success = false;
@@ -19431,18 +19508,6 @@ var TextLayout = /*#__PURE__*/ function() {
19431
19508
  var tempWidth = fontSize + letterSpace;
19432
19509
  this.autoWidth = autoWidth;
19433
19510
  this.maxTextWidth = text.length * tempWidth;
19434
- // if (autoWidth) {
19435
- // this.width = this.maxTextWidth + this.lineWidth;
19436
- // this.height = fontSize + this.lineHeight;
19437
- // } else {
19438
- // if (textWidth) {
19439
- // this.maxCharCount = Math.floor((textWidth - this.lineWidth) / (tempWidth));
19440
- // this.width = textWidth;
19441
- // } else {
19442
- // this.width = basicScale[0] * 100;
19443
- // }
19444
- // this.height = basicScale[1] * 100;
19445
- // }
19446
19511
  this.width = textWidth;
19447
19512
  this.height = textHeight;
19448
19513
  this.letterSpace = letterSpace;
@@ -19879,6 +19944,17 @@ var TextComponentBase = /*#__PURE__*/ function() {
19879
19944
  this.isDirty = true;
19880
19945
  };
19881
19946
  /**
19947
+ * 设置自适应宽高开关
19948
+ * @param value - 是否自适应宽高开关
19949
+ * @returns
19950
+ */ _proto.setAutoWidth = function setAutoWidth(value) {
19951
+ if (this.textLayout.autoWidth === value) {
19952
+ return;
19953
+ }
19954
+ this.textLayout.autoWidth = value;
19955
+ this.isDirty = true;
19956
+ };
19957
+ /**
19882
19958
  * 更新文本
19883
19959
  * @returns
19884
19960
  */ _proto.updateTexture = function updateTexture(flipY) {
@@ -19891,20 +19967,26 @@ var TextComponentBase = /*#__PURE__*/ function() {
19891
19967
  var layout = this.textLayout;
19892
19968
  var fontScale = style.fontScale;
19893
19969
  var width = (layout.width + style.fontOffset) * fontScale;
19894
- var height = layout.height * fontScale;
19970
+ var finalHeight = layout.lineHeight * this.lineCount;
19895
19971
  var fontSize = style.fontSize * fontScale;
19896
19972
  var lineHeight = layout.lineHeight * fontScale;
19897
19973
  this.char = (this.text || "").split("");
19898
19974
  this.canvas.width = width;
19899
- this.canvas.height = height;
19900
- context.clearRect(0, 0, width, this.canvas.height);
19975
+ if (layout.autoWidth) {
19976
+ this.canvas.height = finalHeight * fontScale;
19977
+ this.item.transform.size.set(1, finalHeight / layout.height);
19978
+ } else {
19979
+ this.canvas.height = layout.height * fontScale;
19980
+ }
19981
+ var height = this.canvas.height;
19982
+ context.clearRect(0, 0, width, height);
19901
19983
  // fix bug 1/255
19902
19984
  context.fillStyle = "rgba(255, 255, 255, 0.0039)";
19903
19985
  if (!flipY) {
19904
19986
  context.translate(0, height);
19905
19987
  context.scale(1, -1);
19906
19988
  }
19907
- context.fillRect(0, 0, width, this.canvas.height);
19989
+ context.fillRect(0, 0, width, height);
19908
19990
  style.fontDesc = this.getFontDesc();
19909
19991
  context.font = style.fontDesc;
19910
19992
  if (style.hasShadow) {
@@ -20215,39 +20297,10 @@ exports.PostProcessVolume = /*#__PURE__*/ function(ItemBehaviour) {
20215
20297
  _proto.start = function start() {
20216
20298
  var composition = this.item.composition;
20217
20299
  if (composition) {
20218
- composition.globalVolume = {
20219
- useHDR: this.useHDR,
20220
- useBloom: this.useBloom,
20221
- threshold: this.threshold,
20222
- bloomIntensity: this.bloomIntensity,
20223
- brightness: this.brightness,
20224
- saturation: this.saturation,
20225
- contrast: this.contrast,
20226
- vignetteIntensity: this.vignetteIntensity,
20227
- vignetteSmoothness: this.vignetteSmoothness,
20228
- vignetteRoundness: this.vignetteRoundness,
20229
- useToneMapping: this.useToneMapping
20230
- };
20300
+ composition.globalVolume = this;
20231
20301
  composition.createRenderFrame();
20232
20302
  }
20233
20303
  };
20234
- _proto.update = function update(dt) {
20235
- var composition = this.item.composition;
20236
- if (composition) {
20237
- var globalVolume = composition.renderFrame.globalVolume;
20238
- globalVolume.useHDR = this.useHDR;
20239
- globalVolume.useBloom = this.useBloom;
20240
- globalVolume.threshold = this.threshold;
20241
- globalVolume.bloomIntensity = this.bloomIntensity;
20242
- globalVolume.brightness = this.brightness;
20243
- globalVolume.saturation = this.saturation;
20244
- globalVolume.contrast = this.contrast;
20245
- globalVolume.vignetteIntensity = this.vignetteIntensity;
20246
- globalVolume.vignetteSmoothness = this.vignetteSmoothness;
20247
- globalVolume.vignetteRoundness = this.vignetteRoundness;
20248
- globalVolume.useToneMapping = this.useToneMapping;
20249
- }
20250
- };
20251
20304
  return PostProcessVolume;
20252
20305
  }(ItemBehaviour);
20253
20306
  __decorate([
@@ -21247,27 +21300,46 @@ var SerializationHelper = /*#__PURE__*/ function() {
21247
21300
  res1
21248
21301
  ];
21249
21302
  case 7:
21250
- if (isObject(property) && property.constructor === Object) {
21251
- if (type) {
21252
- res2 = new type();
21253
- } else {
21254
- res2 = {};
21255
- }
21256
- for(_iterator1 = _create_for_of_iterator_helper_loose(Object.keys(property)); !(_step1 = _iterator1()).done;){
21257
- key = _step1.value;
21258
- res2[key] = SerializationHelper.deserializeProperty(property[key], engine, level + 1);
21259
- }
21260
- return [
21261
- 2,
21262
- res2
21263
- ];
21303
+ if (!(isObject(property) && property.constructor === Object)) return [
21304
+ 3,
21305
+ 12
21306
+ ];
21307
+ if (type) {
21308
+ res2 = new type();
21264
21309
  } else {
21265
- return [
21266
- 2,
21267
- property
21268
- ];
21310
+ res2 = {};
21269
21311
  }
21312
+ _iterator1 = _create_for_of_iterator_helper_loose(Object.keys(property));
21313
+ _state.label = 8;
21270
21314
  case 8:
21315
+ if (!!(_step1 = _iterator1()).done) return [
21316
+ 3,
21317
+ 11
21318
+ ];
21319
+ key = _step1.value;
21320
+ return [
21321
+ 4,
21322
+ SerializationHelper.deserializePropertyAsync(property[key], engine, level + 1)
21323
+ ];
21324
+ case 9:
21325
+ res2[key] = _state.sent();
21326
+ _state.label = 10;
21327
+ case 10:
21328
+ return [
21329
+ 3,
21330
+ 8
21331
+ ];
21332
+ case 11:
21333
+ return [
21334
+ 2,
21335
+ res2
21336
+ ];
21337
+ case 12:
21338
+ return [
21339
+ 2,
21340
+ property
21341
+ ];
21342
+ case 13:
21271
21343
  return [
21272
21344
  2
21273
21345
  ];
@@ -21926,277 +21998,39 @@ function getBezierCurveFromHermiteInGE(geHermiteCurves) {
21926
21998
  });
21927
21999
  }
21928
22000
 
21929
- function getStandardParticleContent(particle) {
21930
- var options = particle.options;
21931
- var transform = particle.transform;
21932
- var shape = {
21933
- type: ShapeType.NONE
21934
- };
21935
- if (particle.shape) {
21936
- var _particle_shape_shape;
21937
- var shapeType = (_particle_shape_shape = particle.shape.shape) == null ? void 0 : _particle_shape_shape.replace(/([A-Z])/g, "_$1").toUpperCase().replace(/^_/, "");
21938
- shape = _extends({}, particle.shape, {
21939
- type: ShapeType[shapeType]
21940
- });
21941
- if (particle.shape.upDirection) {
21942
- var _particle_shape_upDirection = particle.shape.upDirection, x = _particle_shape_upDirection[0], y = _particle_shape_upDirection[1], z = _particle_shape_upDirection[2];
21943
- if (x === 0 && y === 0 && z === 0) {
21944
- delete shape.upDirection;
21945
- }
21946
- }
21947
- }
21948
- if (options.startTurbulence) {
21949
- shape.turbulenceX = ensureNumberExpression(options.turbulenceX);
21950
- shape.turbulenceY = ensureNumberExpression(options.turbulenceY);
21951
- shape.turbulenceZ = ensureNumberExpression(options.turbulenceZ);
21952
- }
21953
- var emission = particle.emission;
21954
- if (emission.bursts && emission.bursts.length > 0) {
21955
- emission.bursts = emission.bursts.map(function(b) {
21956
- return objectValueToNumber(b);
21957
- });
21958
- }
21959
- if (emission.burstOffsets && emission.burstOffsets.length > 0) {
21960
- emission.burstOffsets = emission.burstOffsets.map(function(b) {
21961
- return objectValueToNumber(b);
21962
- });
21963
- }
21964
- if (emission.rateOverTime) {
21965
- emission.rateOverTime = ensureNumberExpression(emission.rateOverTime);
21966
- }
22001
+ function getStandardCameraContent(model) {
22002
+ var _model_transform;
22003
+ var opt = model.options;
21967
22004
  var ret = {
21968
- renderer: particle.renderer,
21969
- shape: shape,
21970
- splits: particle.splits,
21971
- emission: emission,
21972
22005
  options: {
21973
- startLifetime: ensureNumberExpression(options.startLifetime),
21974
- start3DSize: !!options.start3DSize,
21975
- startSize: ensureNumberExpression(options.startSize),
21976
- startSizeX: ensureNumberExpression(options.startSizeX),
21977
- startSizeY: ensureNumberExpression(options.startSizeY),
21978
- sizeAspect: ensureNumberExpression(options.sizeAspect),
21979
- maxCount: options.maxCount,
21980
- startDelay: ensureNumberExpression(options.startDelay),
21981
- startColor: ensureColorExpression(options.startColor, true),
21982
- startRotationZ: ensureNumberExpression(options.startRotation || options.startRotationZ),
21983
- particleFollowParent: options.particleFollowParent
22006
+ fov: opt.fov,
22007
+ far: opt.far,
22008
+ near: opt.near,
22009
+ clipMode: opt.clipMode
21984
22010
  }
21985
22011
  };
21986
- if (options.start3DRotation) {
21987
- ret.options.startRotationX = ensureNumberExpression(options.startRotationX);
21988
- ret.options.startRotationY = ensureNumberExpression(options.startRotationY);
21989
- }
21990
- if (transform && transform.path) {
21991
- ret.emitterTransform = {
21992
- path: ensureFixedVec3(transform.path)
21993
- };
21994
- }
21995
- var sizeOverLifetime = particle.sizeOverLifetime;
21996
- if (sizeOverLifetime) {
21997
- if (sizeOverLifetime.separateAxes) {
21998
- ret.sizeOverLifetime = {
21999
- separateAxes: true,
22000
- x: ensureNumberExpression(sizeOverLifetime.x),
22001
- y: ensureNumberExpression(sizeOverLifetime.y)
22002
- };
22003
- } else {
22004
- ret.sizeOverLifetime = {
22005
- size: ensureNumberExpression(sizeOverLifetime.size)
22006
- };
22007
- }
22008
- }
22009
- var velocityOverLifetime = particle.velocityOverLifetime || {};
22010
- var sol = velocityOverLifetime.speedOverLifetime;
22011
- if (sol) {
22012
- sol = ensureFixedNumber(sol);
22013
- } else {
22014
- sol = undefined;
22015
- }
22016
- ret.positionOverLifetime = {
22017
- gravity: options.gravity,
22018
- gravityOverLifetime: ensureFixedNumber(options.gravityModifier),
22019
- startSpeed: ensureNumberExpression(options.startSpeed),
22020
- speedOverLifetime: sol,
22021
- asMovement: velocityOverLifetime.asMovement,
22022
- linearX: ensureNumberExpression(velocityOverLifetime.linearX),
22023
- linearY: ensureNumberExpression(velocityOverLifetime.linearY),
22024
- linearZ: ensureNumberExpression(velocityOverLifetime.linearZ),
22025
- asRotation: velocityOverLifetime.asRotation,
22026
- orbCenter: velocityOverLifetime.orbCenter,
22027
- orbitalX: ensureNumberExpression(velocityOverLifetime.orbitalX),
22028
- orbitalY: ensureNumberExpression(velocityOverLifetime.orbitalY),
22029
- orbitalZ: ensureNumberExpression(velocityOverLifetime.orbitalZ),
22030
- forceTarget: velocityOverLifetime.forceTarget,
22031
- target: velocityOverLifetime.target,
22032
- forceCurve: ensureFixedNumber(velocityOverLifetime.forceCurve)
22033
- };
22034
- deleteEmptyValue(ret.positionOverLifetime);
22035
- var rotationOverLifetime = particle.rotationOverLifetime;
22036
- if (rotationOverLifetime) {
22037
- ret.rotationOverLifetime = {
22038
- separateAxes: rotationOverLifetime.separateAxes,
22039
- asRotation: rotationOverLifetime.asRotation,
22040
- z: ensureNumberExpression(rotationOverLifetime.separateAxes ? rotationOverLifetime.z : rotationOverLifetime.angularVelocity)
22041
- };
22042
- if (rotationOverLifetime.separateAxes) {
22043
- ret.rotationOverLifetime.y = ensureFixedNumber(rotationOverLifetime.y);
22044
- ret.rotationOverLifetime.x = ensureFixedNumber(rotationOverLifetime.x);
22045
- }
22046
- }
22047
- var colorOverLifetime = particle.colorOverLifetime;
22048
- if (colorOverLifetime) {
22049
- var col = ret.colorOverLifetime = {
22050
- opacity: ensureFixedNumber(colorOverLifetime.opacity)
22051
- };
22052
- if (colorOverLifetime.color) {
22053
- col.color = getGradientColor(colorOverLifetime.color);
22054
- }
22055
- }
22056
- var textureSheetAnimation = particle.textureSheetAnimation;
22057
- if (textureSheetAnimation) {
22058
- ret.textureSheetAnimation = {
22059
- row: textureSheetAnimation.row,
22060
- col: textureSheetAnimation.col,
22061
- total: textureSheetAnimation.total,
22062
- animate: textureSheetAnimation.animate,
22063
- cycles: ensureFixedNumber(textureSheetAnimation.cycles),
22064
- animationDelay: ensureFixedNumberWithRandom(textureSheetAnimation.animationDelay, 0),
22065
- animationDuration: ensureFixedNumberWithRandom(textureSheetAnimation.animationDuration, 0)
22066
- };
22067
- }
22068
- var trials = particle.trails;
22069
- if (trials) {
22070
- ret.trails = {
22071
- lifetime: ensureNumberExpression(trials.lifetime),
22072
- dieWithParticles: trials.dieWithParticles,
22073
- maxPointPerTrail: trials.maxPointPerTrail,
22074
- minimumVertexDistance: trials.minimumVertexDistance,
22075
- widthOverTrail: ensureFixedNumber(trials.widthOverTrail),
22076
- colorOverTrail: trials.colorOverTrail && getGradientColor(trials.colorOverTrail, false),
22077
- blending: trials.blending,
22078
- colorOverLifetime: trials.colorOverLifetime && getGradientColor(trials.colorOverLifetime, false),
22079
- inheritParticleColor: trials.inheritParticleColor,
22080
- occlusion: trials.occlusion,
22081
- transparentOcclusion: trials.transparentOcclusion,
22082
- orderOffset: trials.orderOffset,
22083
- sizeAffectsLifetime: trials.sizeAffectsLifetime,
22084
- sizeAffectsWidth: trials.sizeAffectsWidth,
22085
- texture: trials.texture,
22086
- parentAffectsPosition: trials.parentAffectsPosition,
22087
- opacityOverLifetime: ensureNumberExpression(trials.opacityOverLifetime)
22088
- };
22089
- }
22090
- ret.trails && deleteEmptyValue(ret.trails);
22091
- var interaction = particle.interaction;
22092
- if (interaction) {
22093
- ret.interaction = {
22094
- behavior: interaction.behavior,
22095
- radius: interaction.radius,
22096
- multiple: interaction.multiple
22097
- };
22098
- }
22099
- return ret;
22100
- }
22101
-
22102
- function getStandardNullContent(sprite, transform) {
22103
- var _sprite_transform;
22104
- var opt = sprite.options;
22105
- var velocityOverLifetime = sprite.velocityOverLifetime || {};
22106
- var positionOverLifetime = {
22107
- path: ensureFixedVec3((_sprite_transform = sprite.transform) == null ? void 0 : _sprite_transform.path),
22108
- gravity: opt.gravity,
22109
- gravityOverLifetime: ensureFixedNumber(opt.gravityModifier),
22110
- direction: opt.direction,
22111
- startSpeed: opt.startSpeed,
22112
- asMovement: velocityOverLifetime.asMovement,
22113
- linearX: ensureFixedNumber(velocityOverLifetime.linearX),
22114
- linearY: ensureFixedNumber(velocityOverLifetime.linearY),
22115
- linearZ: ensureFixedNumber(velocityOverLifetime.linearZ),
22116
- asRotation: velocityOverLifetime.asRotation,
22117
- orbCenter: velocityOverLifetime.orbCenter,
22118
- orbitalX: ensureFixedNumber(velocityOverLifetime.orbitalX),
22119
- orbitalY: ensureFixedNumber(velocityOverLifetime.orbitalY),
22120
- orbitalZ: ensureFixedNumber(velocityOverLifetime.orbitalZ),
22121
- speedOverLifetime: ensureFixedNumber(velocityOverLifetime.speedOverLifetime)
22122
- };
22123
- deleteEmptyValue(positionOverLifetime);
22124
- var ret = {
22125
- options: {
22126
- startColor: ensureRGBAValue(opt.startColor)
22127
- },
22128
- positionOverLifetime: positionOverLifetime
22129
- };
22130
- if (opt.startSize) {
22131
- transform.scale = [
22132
- opt.startSize,
22133
- opt.startSize / (opt.sizeAspect || 1),
22134
- 1
22135
- ];
22136
- }
22137
- if (opt.startRotation) {
22138
- if (!transform.rotation) {
22139
- transform.rotation = [
22140
- 0,
22141
- 0,
22142
- opt.startRotation
22143
- ];
22144
- } else {
22145
- transform.rotation[2] += opt.startRotation;
22146
- }
22147
- }
22148
- var rotationOverLifetime = sprite.rotationOverLifetime;
22149
- if (rotationOverLifetime) {
22150
- var rot = ret.rotationOverLifetime = {
22151
- separateAxes: rotationOverLifetime.separateAxes,
22152
- asRotation: rotationOverLifetime.asRotation
22153
- };
22154
- if (rot.separateAxes) {
22155
- rot.x = ensureFixedNumber(rotationOverLifetime.x);
22156
- rot.y = ensureFixedNumber(rotationOverLifetime.y);
22157
- rot.z = ensureFixedNumber(rotationOverLifetime.z);
22158
- } else {
22159
- rot.z = ensureFixedNumber(rotationOverLifetime.angularVelocity);
22160
- }
22161
- }
22162
- var colorOverLifetime = sprite.colorOverLifetime;
22163
- if (colorOverLifetime) {
22164
- var col = ret.colorOverLifetime = {
22165
- opacity: ensureFixedNumber(colorOverLifetime.opacity)
22166
- };
22167
- if (colorOverLifetime.color) {
22168
- col.color = getGradientColor(colorOverLifetime.color);
22169
- }
22170
- }
22171
- var sizeOverLifetime = sprite.sizeOverLifetime;
22172
- if (sizeOverLifetime) {
22173
- ret.sizeOverLifetime = {
22174
- separateAxes: sizeOverLifetime.separateAxes,
22175
- size: ensureFixedNumber(sizeOverLifetime.size),
22176
- x: ensureFixedNumber(sizeOverLifetime.x),
22177
- y: ensureFixedNumber(sizeOverLifetime.y),
22178
- z: ensureFixedNumber(sizeOverLifetime.z)
22012
+ var velocityOverLifetime = model.velocityOverLifetime;
22013
+ if (velocityOverLifetime || ((_model_transform = model.transform) == null ? void 0 : _model_transform.path)) {
22014
+ var _model_transform1;
22015
+ var positionOverLifetime = {
22016
+ path: ensureFixedVec3((_model_transform1 = model.transform) == null ? void 0 : _model_transform1.path),
22017
+ linearX: ensureFixedNumber(velocityOverLifetime == null ? void 0 : velocityOverLifetime.translateX),
22018
+ linearY: ensureFixedNumber(velocityOverLifetime == null ? void 0 : velocityOverLifetime.translateY),
22019
+ linearZ: ensureFixedNumber(velocityOverLifetime == null ? void 0 : velocityOverLifetime.translateZ)
22179
22020
  };
22021
+ deleteEmptyValue(positionOverLifetime);
22022
+ ret.positionOverLifetime = positionOverLifetime;
22180
22023
  }
22181
- return ret;
22182
- }
22183
- function getStandardSpriteContent(sprite, transform) {
22184
- var ret = getStandardNullContent(sprite, transform);
22185
- var texAni = sprite.textureSheetAnimation;
22186
- if (texAni) {
22187
- ret.textureSheetAnimation = {
22188
- row: texAni.row,
22189
- col: texAni.col,
22190
- total: texAni.total || undefined,
22191
- animate: texAni.animate
22024
+ var rol = model.rotationOverLifetime;
22025
+ if (rol) {
22026
+ var rotationOverLifetime = {
22027
+ separateAxes: rol.separateAxes,
22028
+ x: ensureFixedNumber(rol == null ? void 0 : rol.rotateX),
22029
+ y: ensureFixedNumber(rol == null ? void 0 : rol.rotateY),
22030
+ z: rol.separateAxes ? ensureFixedNumber(rol == null ? void 0 : rol.rotateZ) : ensureFixedNumber(rol.rotation)
22192
22031
  };
22193
- }
22194
- ret.renderer = sprite.renderer;
22195
- if (sprite.splits) {
22196
- ret.splits = sprite.splits;
22197
- }
22198
- if (sprite.interaction) {
22199
- ret.interaction = sprite.interaction;
22032
+ deleteEmptyValue(rotationOverLifetime);
22033
+ ret.rotationOverLifetime = rotationOverLifetime;
22200
22034
  }
22201
22035
  return ret;
22202
22036
  }
@@ -22241,43 +22075,6 @@ function getStandardInteractContent(ui) {
22241
22075
  return ret;
22242
22076
  }
22243
22077
 
22244
- function getStandardCameraContent(model) {
22245
- var _model_transform;
22246
- var opt = model.options;
22247
- var ret = {
22248
- options: {
22249
- fov: opt.fov,
22250
- far: opt.far,
22251
- near: opt.near,
22252
- clipMode: opt.clipMode
22253
- }
22254
- };
22255
- var velocityOverLifetime = model.velocityOverLifetime;
22256
- if (velocityOverLifetime || ((_model_transform = model.transform) == null ? void 0 : _model_transform.path)) {
22257
- var _model_transform1;
22258
- var positionOverLifetime = {
22259
- path: ensureFixedVec3((_model_transform1 = model.transform) == null ? void 0 : _model_transform1.path),
22260
- linearX: ensureFixedNumber(velocityOverLifetime == null ? void 0 : velocityOverLifetime.translateX),
22261
- linearY: ensureFixedNumber(velocityOverLifetime == null ? void 0 : velocityOverLifetime.translateY),
22262
- linearZ: ensureFixedNumber(velocityOverLifetime == null ? void 0 : velocityOverLifetime.translateZ)
22263
- };
22264
- deleteEmptyValue(positionOverLifetime);
22265
- ret.positionOverLifetime = positionOverLifetime;
22266
- }
22267
- var rol = model.rotationOverLifetime;
22268
- if (rol) {
22269
- var rotationOverLifetime = {
22270
- separateAxes: rol.separateAxes,
22271
- x: ensureFixedNumber(rol == null ? void 0 : rol.rotateX),
22272
- y: ensureFixedNumber(rol == null ? void 0 : rol.rotateY),
22273
- z: rol.separateAxes ? ensureFixedNumber(rol == null ? void 0 : rol.rotateZ) : ensureFixedNumber(rol.rotation)
22274
- };
22275
- deleteEmptyValue(rotationOverLifetime);
22276
- ret.rotationOverLifetime = rotationOverLifetime;
22277
- }
22278
- return ret;
22279
- }
22280
-
22281
22078
  /**
22282
22079
  * 2.1 以下版本数据适配(mars-player@2.4.0 及以上版本支持 2.1 以下数据的适配)
22283
22080
  */ function version21Migration(json) {
@@ -22394,11 +22191,12 @@ function getStandardCameraContent(model) {
22394
22191
  var _textures;
22395
22192
  (_textures = (_result = result).textures) != null ? _textures : _result.textures = [];
22396
22193
  result.textures.forEach(function(textureOptions) {
22194
+ var _result_images_textureOptions_source;
22397
22195
  textureOptions.id = generateGUID();
22398
22196
  textureOptions.dataType = DataType.Texture;
22399
22197
  // @ts-expect-error
22400
22198
  textureOptions.source = {
22401
- id: result.images[textureOptions.source].id
22199
+ id: (_result_images_textureOptions_source = result.images[textureOptions.source]) == null ? void 0 : _result_images_textureOptions_source.id
22402
22200
  };
22403
22201
  });
22404
22202
  if (result.textures.length < result.images.length) {
@@ -22752,8 +22550,7 @@ function convertTimelineAsset(composition, guidToItemMap, jsonScene) {
22752
22550
  var newSpriteColorPlayableAssetData = {
22753
22551
  id: generateGUID(),
22754
22552
  dataType: "SpriteColorPlayableAsset",
22755
- colorOverLifetime: item.content.colorOverLifetime,
22756
- startColor: item.content.options.startColor
22553
+ colorOverLifetime: item.content.colorOverLifetime
22757
22554
  };
22758
22555
  playableAssetDatas.push(newSpriteColorPlayableAssetData);
22759
22556
  var newTrackData1 = {
@@ -22808,77 +22605,352 @@ function convertTimelineAsset(composition, guidToItemMap, jsonScene) {
22808
22605
  children: subTrackDatas,
22809
22606
  clips: []
22810
22607
  };
22811
- trackDatas.push(bindingTrackData);
22812
- timelineAssetData.tracks.push({
22813
- id: bindingTrackData.id
22814
- });
22815
- sceneBindings.push({
22816
- key: {
22817
- id: bindingTrackData.id
22818
- },
22819
- value: {
22820
- id: item.id
22821
- }
22822
- });
22608
+ trackDatas.push(bindingTrackData);
22609
+ timelineAssetData.tracks.push({
22610
+ id: bindingTrackData.id
22611
+ });
22612
+ sceneBindings.push({
22613
+ key: {
22614
+ id: bindingTrackData.id
22615
+ },
22616
+ value: {
22617
+ id: item.id
22618
+ }
22619
+ });
22620
+ }
22621
+ var trackIds = [];
22622
+ for(var _iterator1 = _create_for_of_iterator_helper_loose(trackDatas), _step1; !(_step1 = _iterator1()).done;){
22623
+ var trackData = _step1.value;
22624
+ trackIds.push({
22625
+ id: trackData.id
22626
+ });
22627
+ }
22628
+ composition.timelineAsset = {
22629
+ id: timelineAssetData.id
22630
+ };
22631
+ composition.sceneBindings = sceneBindings;
22632
+ jsonScene.miscs.push(timelineAssetData);
22633
+ for(var _iterator2 = _create_for_of_iterator_helper_loose(trackDatas), _step2; !(_step2 = _iterator2()).done;){
22634
+ var trackData1 = _step2.value;
22635
+ //@ts-expect-error
22636
+ jsonScene.miscs.push(trackData1);
22637
+ }
22638
+ for(var _iterator3 = _create_for_of_iterator_helper_loose(playableAssetDatas), _step3; !(_step3 = _iterator3()).done;){
22639
+ var playableAsset = _step3.value;
22640
+ //@ts-expect-error
22641
+ jsonScene.miscs.push(playableAsset);
22642
+ }
22643
+ }
22644
+ function convertBinaryAsset(bins, jsonScene) {
22645
+ //@ts-expect-error
22646
+ jsonScene.bins = bins.map(function(bin) {
22647
+ return {
22648
+ url: bin.url,
22649
+ "dataType": "BinaryAsset",
22650
+ id: generateGUID()
22651
+ };
22652
+ });
22653
+ }
22654
+ function convertSpineData(resource, content, jsonScene) {
22655
+ //@ts-expect-error
22656
+ content.resource = {
22657
+ "atlas": {
22658
+ "bins": {
22659
+ //@ts-expect-error
22660
+ "id": jsonScene.bins[resource.atlas[1][0]].id
22661
+ },
22662
+ "source": resource.atlas[1].slice(1)
22663
+ },
22664
+ "skeleton": {
22665
+ "bins": {
22666
+ //@ts-expect-error
22667
+ "id": jsonScene.bins[resource.skeleton[1][0]].id
22668
+ },
22669
+ "source": resource.skeleton[1].slice(1)
22670
+ },
22671
+ "skeletonType": resource.skeletonType,
22672
+ "images": resource.images.map(function(i) {
22673
+ return {
22674
+ //@ts-expect-error
22675
+ id: jsonScene.textures[i].id
22676
+ };
22677
+ })
22678
+ };
22679
+ }
22680
+
22681
+ function getStandardParticleContent(particle) {
22682
+ var options = particle.options;
22683
+ var transform = particle.transform;
22684
+ var shape = {
22685
+ type: ShapeType.NONE
22686
+ };
22687
+ if (particle.shape) {
22688
+ var _particle_shape_shape;
22689
+ var shapeType = (_particle_shape_shape = particle.shape.shape) == null ? void 0 : _particle_shape_shape.replace(/([A-Z])/g, "_$1").toUpperCase().replace(/^_/, "");
22690
+ shape = _extends({}, particle.shape, {
22691
+ type: ShapeType[shapeType]
22692
+ });
22693
+ if (particle.shape.upDirection) {
22694
+ var _particle_shape_upDirection = particle.shape.upDirection, x = _particle_shape_upDirection[0], y = _particle_shape_upDirection[1], z = _particle_shape_upDirection[2];
22695
+ if (x === 0 && y === 0 && z === 0) {
22696
+ delete shape.upDirection;
22697
+ }
22698
+ }
22699
+ }
22700
+ if (options.startTurbulence) {
22701
+ shape.turbulenceX = ensureNumberExpression(options.turbulenceX);
22702
+ shape.turbulenceY = ensureNumberExpression(options.turbulenceY);
22703
+ shape.turbulenceZ = ensureNumberExpression(options.turbulenceZ);
22704
+ }
22705
+ var emission = particle.emission;
22706
+ if (emission.bursts && emission.bursts.length > 0) {
22707
+ emission.bursts = emission.bursts.map(function(b) {
22708
+ return objectValueToNumber(b);
22709
+ });
22710
+ }
22711
+ if (emission.burstOffsets && emission.burstOffsets.length > 0) {
22712
+ emission.burstOffsets = emission.burstOffsets.map(function(b) {
22713
+ return objectValueToNumber(b);
22714
+ });
22715
+ }
22716
+ if (emission.rateOverTime) {
22717
+ emission.rateOverTime = ensureNumberExpression(emission.rateOverTime);
22718
+ }
22719
+ var ret = {
22720
+ renderer: particle.renderer,
22721
+ shape: shape,
22722
+ splits: particle.splits,
22723
+ emission: emission,
22724
+ options: {
22725
+ startLifetime: ensureNumberExpression(options.startLifetime),
22726
+ start3DSize: !!options.start3DSize,
22727
+ startSize: ensureNumberExpression(options.startSize),
22728
+ startSizeX: ensureNumberExpression(options.startSizeX),
22729
+ startSizeY: ensureNumberExpression(options.startSizeY),
22730
+ sizeAspect: ensureNumberExpression(options.sizeAspect),
22731
+ maxCount: options.maxCount,
22732
+ startDelay: ensureNumberExpression(options.startDelay),
22733
+ startColor: ensureColorExpression(options.startColor, true),
22734
+ startRotationZ: ensureNumberExpression(options.startRotation || options.startRotationZ),
22735
+ particleFollowParent: options.particleFollowParent
22736
+ }
22737
+ };
22738
+ if (options.start3DRotation) {
22739
+ ret.options.startRotationX = ensureNumberExpression(options.startRotationX);
22740
+ ret.options.startRotationY = ensureNumberExpression(options.startRotationY);
22741
+ }
22742
+ if (transform && transform.path) {
22743
+ ret.emitterTransform = {
22744
+ path: ensureFixedVec3(transform.path)
22745
+ };
22746
+ }
22747
+ var sizeOverLifetime = particle.sizeOverLifetime;
22748
+ if (sizeOverLifetime) {
22749
+ if (sizeOverLifetime.separateAxes) {
22750
+ ret.sizeOverLifetime = {
22751
+ separateAxes: true,
22752
+ x: ensureNumberExpression(sizeOverLifetime.x),
22753
+ y: ensureNumberExpression(sizeOverLifetime.y)
22754
+ };
22755
+ } else {
22756
+ ret.sizeOverLifetime = {
22757
+ size: ensureNumberExpression(sizeOverLifetime.size)
22758
+ };
22759
+ }
22760
+ }
22761
+ var velocityOverLifetime = particle.velocityOverLifetime || {};
22762
+ var sol = velocityOverLifetime.speedOverLifetime;
22763
+ if (sol) {
22764
+ sol = ensureFixedNumber(sol);
22765
+ } else {
22766
+ sol = undefined;
22767
+ }
22768
+ ret.positionOverLifetime = {
22769
+ gravity: options.gravity,
22770
+ gravityOverLifetime: ensureFixedNumber(options.gravityModifier),
22771
+ startSpeed: ensureNumberExpression(options.startSpeed),
22772
+ speedOverLifetime: sol,
22773
+ asMovement: velocityOverLifetime.asMovement,
22774
+ linearX: ensureNumberExpression(velocityOverLifetime.linearX),
22775
+ linearY: ensureNumberExpression(velocityOverLifetime.linearY),
22776
+ linearZ: ensureNumberExpression(velocityOverLifetime.linearZ),
22777
+ asRotation: velocityOverLifetime.asRotation,
22778
+ orbCenter: velocityOverLifetime.orbCenter,
22779
+ orbitalX: ensureNumberExpression(velocityOverLifetime.orbitalX),
22780
+ orbitalY: ensureNumberExpression(velocityOverLifetime.orbitalY),
22781
+ orbitalZ: ensureNumberExpression(velocityOverLifetime.orbitalZ),
22782
+ forceTarget: velocityOverLifetime.forceTarget,
22783
+ target: velocityOverLifetime.target,
22784
+ forceCurve: ensureFixedNumber(velocityOverLifetime.forceCurve)
22785
+ };
22786
+ deleteEmptyValue(ret.positionOverLifetime);
22787
+ var rotationOverLifetime = particle.rotationOverLifetime;
22788
+ if (rotationOverLifetime) {
22789
+ ret.rotationOverLifetime = {
22790
+ separateAxes: rotationOverLifetime.separateAxes,
22791
+ asRotation: rotationOverLifetime.asRotation,
22792
+ z: ensureNumberExpression(rotationOverLifetime.separateAxes ? rotationOverLifetime.z : rotationOverLifetime.angularVelocity)
22793
+ };
22794
+ if (rotationOverLifetime.separateAxes) {
22795
+ ret.rotationOverLifetime.y = ensureFixedNumber(rotationOverLifetime.y);
22796
+ ret.rotationOverLifetime.x = ensureFixedNumber(rotationOverLifetime.x);
22797
+ }
22823
22798
  }
22824
- var trackIds = [];
22825
- for(var _iterator1 = _create_for_of_iterator_helper_loose(trackDatas), _step1; !(_step1 = _iterator1()).done;){
22826
- var trackData = _step1.value;
22827
- trackIds.push({
22828
- id: trackData.id
22829
- });
22799
+ var colorOverLifetime = particle.colorOverLifetime;
22800
+ if (colorOverLifetime) {
22801
+ var col = ret.colorOverLifetime = {
22802
+ opacity: ensureFixedNumber(colorOverLifetime.opacity)
22803
+ };
22804
+ if (colorOverLifetime.color) {
22805
+ col.color = getGradientColor(colorOverLifetime.color);
22806
+ }
22830
22807
  }
22831
- composition.timelineAsset = {
22832
- id: timelineAssetData.id
22833
- };
22834
- composition.sceneBindings = sceneBindings;
22835
- jsonScene.miscs.push(timelineAssetData);
22836
- for(var _iterator2 = _create_for_of_iterator_helper_loose(trackDatas), _step2; !(_step2 = _iterator2()).done;){
22837
- var trackData1 = _step2.value;
22838
- //@ts-expect-error
22839
- jsonScene.miscs.push(trackData1);
22808
+ var textureSheetAnimation = particle.textureSheetAnimation;
22809
+ if (textureSheetAnimation) {
22810
+ ret.textureSheetAnimation = {
22811
+ row: textureSheetAnimation.row,
22812
+ col: textureSheetAnimation.col,
22813
+ total: textureSheetAnimation.total,
22814
+ animate: textureSheetAnimation.animate,
22815
+ cycles: ensureFixedNumber(textureSheetAnimation.cycles),
22816
+ animationDelay: ensureFixedNumberWithRandom(textureSheetAnimation.animationDelay, 0),
22817
+ animationDuration: ensureFixedNumberWithRandom(textureSheetAnimation.animationDuration, 0)
22818
+ };
22840
22819
  }
22841
- for(var _iterator3 = _create_for_of_iterator_helper_loose(playableAssetDatas), _step3; !(_step3 = _iterator3()).done;){
22842
- var playableAsset = _step3.value;
22843
- //@ts-expect-error
22844
- jsonScene.miscs.push(playableAsset);
22820
+ var trials = particle.trails;
22821
+ if (trials) {
22822
+ ret.trails = {
22823
+ lifetime: ensureNumberExpression(trials.lifetime),
22824
+ dieWithParticles: trials.dieWithParticles,
22825
+ maxPointPerTrail: trials.maxPointPerTrail,
22826
+ minimumVertexDistance: trials.minimumVertexDistance,
22827
+ widthOverTrail: ensureFixedNumber(trials.widthOverTrail),
22828
+ colorOverTrail: trials.colorOverTrail && getGradientColor(trials.colorOverTrail, false),
22829
+ blending: trials.blending,
22830
+ colorOverLifetime: trials.colorOverLifetime && getGradientColor(trials.colorOverLifetime, false),
22831
+ inheritParticleColor: trials.inheritParticleColor,
22832
+ occlusion: trials.occlusion,
22833
+ transparentOcclusion: trials.transparentOcclusion,
22834
+ orderOffset: trials.orderOffset,
22835
+ sizeAffectsLifetime: trials.sizeAffectsLifetime,
22836
+ sizeAffectsWidth: trials.sizeAffectsWidth,
22837
+ texture: trials.texture,
22838
+ parentAffectsPosition: trials.parentAffectsPosition,
22839
+ opacityOverLifetime: ensureNumberExpression(trials.opacityOverLifetime)
22840
+ };
22845
22841
  }
22846
- }
22847
- function convertBinaryAsset(bins, jsonScene) {
22848
- //@ts-expect-error
22849
- jsonScene.bins = bins.map(function(bin) {
22850
- return {
22851
- url: bin.url,
22852
- "dataType": "BinaryAsset",
22853
- id: generateGUID()
22842
+ ret.trails && deleteEmptyValue(ret.trails);
22843
+ var interaction = particle.interaction;
22844
+ if (interaction) {
22845
+ ret.interaction = {
22846
+ behavior: interaction.behavior,
22847
+ radius: interaction.radius,
22848
+ multiple: interaction.multiple
22854
22849
  };
22855
- });
22850
+ }
22851
+ return ret;
22856
22852
  }
22857
- function convertSpineData(resource, content, jsonScene) {
22858
- //@ts-expect-error
22859
- content.resource = {
22860
- "atlas": {
22861
- "bins": {
22862
- //@ts-expect-error
22863
- "id": jsonScene.bins[resource.atlas[1][0]].id
22864
- },
22865
- "source": resource.atlas[1].slice(1)
22866
- },
22867
- "skeleton": {
22868
- "bins": {
22869
- //@ts-expect-error
22870
- "id": jsonScene.bins[resource.skeleton[1][0]].id
22871
- },
22872
- "source": resource.skeleton[1].slice(1)
22853
+
22854
+ function getStandardNullContent(sprite, transform) {
22855
+ var _sprite_transform;
22856
+ var opt = sprite.options;
22857
+ var velocityOverLifetime = sprite.velocityOverLifetime || {};
22858
+ var positionOverLifetime = {
22859
+ path: ensureFixedVec3((_sprite_transform = sprite.transform) == null ? void 0 : _sprite_transform.path),
22860
+ gravity: opt.gravity,
22861
+ gravityOverLifetime: ensureFixedNumber(opt.gravityModifier),
22862
+ direction: opt.direction,
22863
+ startSpeed: opt.startSpeed,
22864
+ asMovement: velocityOverLifetime.asMovement,
22865
+ linearX: ensureFixedNumber(velocityOverLifetime.linearX),
22866
+ linearY: ensureFixedNumber(velocityOverLifetime.linearY),
22867
+ linearZ: ensureFixedNumber(velocityOverLifetime.linearZ),
22868
+ asRotation: velocityOverLifetime.asRotation,
22869
+ orbCenter: velocityOverLifetime.orbCenter,
22870
+ orbitalX: ensureFixedNumber(velocityOverLifetime.orbitalX),
22871
+ orbitalY: ensureFixedNumber(velocityOverLifetime.orbitalY),
22872
+ orbitalZ: ensureFixedNumber(velocityOverLifetime.orbitalZ),
22873
+ speedOverLifetime: ensureFixedNumber(velocityOverLifetime.speedOverLifetime)
22874
+ };
22875
+ deleteEmptyValue(positionOverLifetime);
22876
+ var ret = {
22877
+ options: {
22878
+ startColor: ensureRGBAValue(opt.startColor)
22873
22879
  },
22874
- "skeletonType": resource.skeletonType,
22875
- "images": resource.images.map(function(i) {
22876
- return {
22877
- //@ts-expect-error
22878
- id: jsonScene.textures[i].id
22879
- };
22880
- })
22880
+ positionOverLifetime: positionOverLifetime
22881
22881
  };
22882
+ if (opt.startSize) {
22883
+ transform.scale = [
22884
+ opt.startSize,
22885
+ opt.startSize / (opt.sizeAspect || 1),
22886
+ 1
22887
+ ];
22888
+ }
22889
+ if (opt.startRotation) {
22890
+ if (!transform.rotation) {
22891
+ transform.rotation = [
22892
+ 0,
22893
+ 0,
22894
+ opt.startRotation
22895
+ ];
22896
+ } else {
22897
+ transform.rotation[2] += opt.startRotation;
22898
+ }
22899
+ }
22900
+ var rotationOverLifetime = sprite.rotationOverLifetime;
22901
+ if (rotationOverLifetime) {
22902
+ var rot = ret.rotationOverLifetime = {
22903
+ separateAxes: rotationOverLifetime.separateAxes,
22904
+ asRotation: rotationOverLifetime.asRotation
22905
+ };
22906
+ if (rot.separateAxes) {
22907
+ rot.x = ensureFixedNumber(rotationOverLifetime.x);
22908
+ rot.y = ensureFixedNumber(rotationOverLifetime.y);
22909
+ rot.z = ensureFixedNumber(rotationOverLifetime.z);
22910
+ } else {
22911
+ rot.z = ensureFixedNumber(rotationOverLifetime.angularVelocity);
22912
+ }
22913
+ }
22914
+ var colorOverLifetime = sprite.colorOverLifetime;
22915
+ if (colorOverLifetime) {
22916
+ var col = ret.colorOverLifetime = {
22917
+ opacity: ensureFixedNumber(colorOverLifetime.opacity)
22918
+ };
22919
+ if (colorOverLifetime.color) {
22920
+ col.color = getGradientColor(colorOverLifetime.color);
22921
+ }
22922
+ }
22923
+ var sizeOverLifetime = sprite.sizeOverLifetime;
22924
+ if (sizeOverLifetime) {
22925
+ ret.sizeOverLifetime = {
22926
+ separateAxes: sizeOverLifetime.separateAxes,
22927
+ size: ensureFixedNumber(sizeOverLifetime.size),
22928
+ x: ensureFixedNumber(sizeOverLifetime.x),
22929
+ y: ensureFixedNumber(sizeOverLifetime.y),
22930
+ z: ensureFixedNumber(sizeOverLifetime.z)
22931
+ };
22932
+ }
22933
+ return ret;
22934
+ }
22935
+ function getStandardSpriteContent(sprite, transform) {
22936
+ var ret = getStandardNullContent(sprite, transform);
22937
+ var texAni = sprite.textureSheetAnimation;
22938
+ if (texAni) {
22939
+ ret.textureSheetAnimation = {
22940
+ row: texAni.row,
22941
+ col: texAni.col,
22942
+ total: texAni.total || undefined,
22943
+ animate: texAni.animate
22944
+ };
22945
+ }
22946
+ ret.renderer = sprite.renderer;
22947
+ if (sprite.splits) {
22948
+ ret.splits = sprite.splits;
22949
+ }
22950
+ if (sprite.interaction) {
22951
+ ret.interaction = sprite.interaction;
22952
+ }
22953
+ return ret;
22882
22954
  }
22883
22955
 
22884
22956
  var v0 = /^(\d+)\.(\d+)\.(\d+)(-(\w+)\.\d+)?$/;
@@ -23260,7 +23332,7 @@ function getBackgroundImage(template, variables) {
23260
23332
  }
23261
23333
  function _combineImageTemplate() {
23262
23334
  _combineImageTemplate = _async_to_generator(function(url, template, variables) {
23263
- var image, drawImage, templateBackground, _tmp;
23335
+ var image, templateBackground;
23264
23336
  return __generator(this, function(_state) {
23265
23337
  switch(_state.label){
23266
23338
  case 0:
@@ -23291,37 +23363,25 @@ function _combineImageTemplate() {
23291
23363
  image
23292
23364
  ];
23293
23365
  }
23294
- drawImage = image;
23295
23366
  // 获取动态换图的图片对象或 url 地址
23296
23367
  templateBackground = getBackgroundImage(template, variables);
23297
- if (!(templateBackground && isString(templateBackground) && templateBackground !== image.src)) return [
23298
- 3,
23299
- 7
23300
- ];
23301
- if (!isString(templateBackground)) return [
23302
- 3,
23303
- 5
23304
- ];
23305
- return [
23306
- 4,
23307
- loadImage(templateBackground)
23308
- ];
23309
- case 4:
23310
- _tmp = _state.sent();
23311
- return [
23312
- 3,
23313
- 6
23314
- ];
23315
- case 5:
23316
- _tmp = templateBackground;
23317
- _state.label = 6;
23318
- case 6:
23319
- drawImage = _tmp;
23320
- _state.label = 7;
23321
- case 7:
23368
+ if (templateBackground) {
23369
+ if (isString(templateBackground) && templateBackground !== image.src) {
23370
+ return [
23371
+ 2,
23372
+ loadImage(templateBackground)
23373
+ ];
23374
+ }
23375
+ if (_instanceof1(templateBackground, HTMLImageElement)) {
23376
+ return [
23377
+ 2,
23378
+ templateBackground
23379
+ ];
23380
+ }
23381
+ }
23322
23382
  return [
23323
23383
  2,
23324
- drawImage
23384
+ image
23325
23385
  ];
23326
23386
  }
23327
23387
  });
@@ -23785,15 +23845,17 @@ var seed = 1;
23785
23845
  _this_options = _this.options, useCompressedTexture = _this_options.useCompressedTexture, variables = _this_options.variables;
23786
23846
  baseUrl = _this.baseUrl;
23787
23847
  jobs = images.map(/*#__PURE__*/ _async_to_generator(function(img, idx) {
23788
- var png, webp, imageURL, webpURL, template, background, url, isVideo, loadFn, resultImage, e, compressed, src, bufferURL, _ref, url1, image;
23848
+ var png, webp, avif, imageURL, webpURL, avifURL, template, background, url, isVideo, loadFn, resultImage, e, compressed, src, bufferURL, _ref, url1, image, _tmp;
23789
23849
  return __generator(this, function(_state) {
23790
23850
  switch(_state.label){
23791
23851
  case 0:
23792
- png = img.url, webp = img.webp;
23852
+ png = img.url, webp = img.webp, avif = img.avif;
23793
23853
  // eslint-disable-next-line compat/compat
23794
23854
  imageURL = new URL(png, baseUrl).href;
23795
23855
  // eslint-disable-next-line compat/compat
23796
23856
  webpURL = webp && new URL(webp, baseUrl).href;
23857
+ // eslint-disable-next-line compat/compat
23858
+ avifURL = avif && new URL(avif, baseUrl).href;
23797
23859
  if (!("template" in img)) return [
23798
23860
  3,
23799
23861
  8
@@ -23893,12 +23955,30 @@ var seed = 1;
23893
23955
  }
23894
23956
  _state.label = 9;
23895
23957
  case 9:
23958
+ if (!avifURL) return [
23959
+ 3,
23960
+ 11
23961
+ ];
23896
23962
  return [
23897
23963
  4,
23898
- loadWebPOptional(imageURL, webpURL)
23964
+ loadAVIFOptional(imageURL, avifURL)
23899
23965
  ];
23900
23966
  case 10:
23901
- _ref = _state.sent(), url1 = _ref.url, image = _ref.image;
23967
+ _tmp = _state.sent();
23968
+ return [
23969
+ 3,
23970
+ 13
23971
+ ];
23972
+ case 11:
23973
+ return [
23974
+ 4,
23975
+ loadWebPOptional(imageURL, webpURL)
23976
+ ];
23977
+ case 12:
23978
+ _tmp = _state.sent();
23979
+ _state.label = 13;
23980
+ case 13:
23981
+ _ref = _tmp, url1 = _ref.url, image = _ref.image;
23902
23982
  _this.assets[idx] = {
23903
23983
  url: url1,
23904
23984
  type: exports.TextureSourceType.image
@@ -27368,7 +27448,7 @@ registerPlugin("sprite", SpriteLoader, exports.VFXItem, true);
27368
27448
  registerPlugin("particle", ParticleLoader, exports.VFXItem, true);
27369
27449
  registerPlugin("cal", CalculateLoader, exports.VFXItem, true);
27370
27450
  registerPlugin("interact", InteractLoader, exports.VFXItem, true);
27371
- var version = "2.0.0-alpha.28";
27451
+ var version = "2.0.0-alpha.29";
27372
27452
  logger.info("Core version: " + version + ".");
27373
27453
 
27374
27454
  exports.AbstractPlugin = AbstractPlugin;
@@ -27562,6 +27642,7 @@ exports.isWechatMiniApp = isWechatMiniApp;
27562
27642
  exports.itemFrag = itemFrag;
27563
27643
  exports.itemFrameFrag = itemFrameFrag;
27564
27644
  exports.itemVert = itemVert;
27645
+ exports.loadAVIFOptional = loadAVIFOptional;
27565
27646
  exports.loadBinary = loadBinary;
27566
27647
  exports.loadBlob = loadBlob;
27567
27648
  exports.loadImage = loadImage;