@galacean/effects-threejs 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 threejs plugin 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';
@@ -4624,9 +4624,6 @@ function getDirectStore(target) {
4624
4624
  };
4625
4625
  return EffectsObject;
4626
4626
  }();
4627
- __decorate([
4628
- serialize()
4629
- ], EffectsObject.prototype, "guid", void 0);
4630
4627
 
4631
4628
  /**
4632
4629
  * @since 2.0.0
@@ -4904,8 +4901,8 @@ exports.CameraController = /*#__PURE__*/ function(ItemBehaviour) {
4904
4901
  camera.far = this.options.far;
4905
4902
  camera.fov = this.options.fov;
4906
4903
  camera.clipMode = this.options.clipMode;
4907
- camera.position = this.transform.position;
4908
- camera.rotation = this.transform.rotation;
4904
+ camera.position = this.transform.getWorldPosition();
4905
+ camera.rotation = this.transform.getWorldRotation();
4909
4906
  }
4910
4907
  };
4911
4908
  _proto.fromData = function fromData(data) {
@@ -7890,6 +7887,7 @@ exports.TextureSourceType = void 0;
7890
7887
  return Downloader;
7891
7888
  }();
7892
7889
  var webPFailed = false;
7890
+ var avifFailed = false;
7893
7891
  /**
7894
7892
  * 异步加载一个 WebP 图片文件,如果不支持 WebP,则加载 PNG 图片文件
7895
7893
  * @param png - PNG 图片文件的 URL
@@ -7965,6 +7963,81 @@ function _loadWebPOptional() {
7965
7963
  });
7966
7964
  return _loadWebPOptional.apply(this, arguments);
7967
7965
  }
7966
+ /**
7967
+ * 异步加载一个 AVIF 图片文件,如果不支持 AVIF,则加载 PNG 图片文件
7968
+ * @param png - PNG 图片文件的 URL
7969
+ * @param avif - AVIF 图片文件的 URL
7970
+ */ function loadAVIFOptional(png, avif) {
7971
+ return _loadAVIFOptional.apply(this, arguments);
7972
+ }
7973
+ function _loadAVIFOptional() {
7974
+ _loadAVIFOptional = _async_to_generator(function(png, avif) {
7975
+ var image, image1, image2;
7976
+ return __generator(this, function(_state) {
7977
+ switch(_state.label){
7978
+ case 0:
7979
+ if (!(avifFailed || !avif)) return [
7980
+ 3,
7981
+ 2
7982
+ ];
7983
+ return [
7984
+ 4,
7985
+ loadImage(png)
7986
+ ];
7987
+ case 1:
7988
+ image = _state.sent();
7989
+ return [
7990
+ 2,
7991
+ {
7992
+ image: image,
7993
+ url: png
7994
+ }
7995
+ ];
7996
+ case 2:
7997
+ _state.trys.push([
7998
+ 2,
7999
+ 4,
8000
+ ,
8001
+ 6
8002
+ ]);
8003
+ return [
8004
+ 4,
8005
+ loadImage(avif)
8006
+ ];
8007
+ case 3:
8008
+ image1 = _state.sent();
8009
+ return [
8010
+ 2,
8011
+ {
8012
+ image: image1,
8013
+ url: avif
8014
+ }
8015
+ ];
8016
+ case 4:
8017
+ _state.sent();
8018
+ avifFailed = true;
8019
+ return [
8020
+ 4,
8021
+ loadImage(png)
8022
+ ];
8023
+ case 5:
8024
+ image2 = _state.sent();
8025
+ return [
8026
+ 2,
8027
+ {
8028
+ image: image2,
8029
+ url: png
8030
+ }
8031
+ ];
8032
+ case 6:
8033
+ return [
8034
+ 2
8035
+ ];
8036
+ }
8037
+ });
8038
+ });
8039
+ return _loadAVIFOptional.apply(this, arguments);
8040
+ }
7968
8041
  /**
7969
8042
  * 异步加载一个图片文件
7970
8043
  * @param source - 图片文件的 URL、Blob 或 HTMLImageElement 对象
@@ -11606,7 +11679,7 @@ var gaussianDownVFrag = "precision highp float;varying vec2 uv;uniform sampler2D
11606
11679
 
11607
11680
  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);}";
11608
11681
 
11609
- 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);}";
11682
+ 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);}";
11610
11683
 
11611
11684
  // Bloom 阈值 Pass
11612
11685
  var BloomThresholdPass = /*#__PURE__*/ function(RenderPass) {
@@ -11904,28 +11977,6 @@ var ToneMappingPass = /*#__PURE__*/ function(RenderPass) {
11904
11977
  return ToneMappingPass;
11905
11978
  }(RenderPass);
11906
11979
 
11907
- /**
11908
- * 后处理配置
11909
- */ var defaultGlobalVolume = {
11910
- useHDR: false,
11911
- /***** Material Uniform *****/ // Bloom
11912
- useBloom: true,
11913
- threshold: 1.0,
11914
- bloomIntensity: 1.0,
11915
- // ColorAdjustments
11916
- brightness: 1.0,
11917
- saturation: 1.0,
11918
- contrast: 1.0,
11919
- // Vignette
11920
- // vignetteColor: new math.Color(0, 0, 0, 1),
11921
- // vignetteCenter: new math.Vector2(0.5, 0.5),
11922
- vignetteIntensity: 0.2,
11923
- vignetteSmoothness: 0.4,
11924
- vignetteRoundness: 1.0,
11925
- // ToneMapping
11926
- useToneMapping: true
11927
- };
11928
-
11929
11980
  var RENDER_PASS_NAME_PREFIX = "_effects_default_";
11930
11981
  var seed$6 = 1;
11931
11982
  /**
@@ -11949,7 +12000,7 @@ var seed$6 = 1;
11949
12000
  } : _options_clearAction;
11950
12001
  var engine = renderer.engine;
11951
12002
  if (globalVolume) {
11952
- this.globalVolume = _extends({}, defaultGlobalVolume, globalVolume);
12003
+ this.globalVolume = globalVolume;
11953
12004
  }
11954
12005
  this.globalUniforms = new GlobalUniforms();
11955
12006
  var attachments = []; //渲染场景物体Pass的RT
@@ -12986,6 +13037,28 @@ var Renderer = /*#__PURE__*/ function() {
12986
13037
  return Renderer;
12987
13038
  }();
12988
13039
 
13040
+ /**
13041
+ * 后处理配置
13042
+ */ var defaultGlobalVolume = {
13043
+ useHDR: false,
13044
+ /***** Material Uniform *****/ // Bloom
13045
+ useBloom: true,
13046
+ threshold: 1.0,
13047
+ bloomIntensity: 1.0,
13048
+ // ColorAdjustments
13049
+ brightness: 1.0,
13050
+ saturation: 1.0,
13051
+ contrast: 1.0,
13052
+ // Vignette
13053
+ // vignetteColor: new math.Color(0, 0, 0, 1),
13054
+ // vignetteCenter: new math.Vector2(0.5, 0.5),
13055
+ vignetteIntensity: 0.2,
13056
+ vignetteSmoothness: 0.4,
13057
+ vignetteRoundness: 1.0,
13058
+ // ToneMapping
13059
+ useToneMapping: true
13060
+ };
13061
+
12989
13062
  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";
12990
13063
  var fragment = "\nprecision highp float;\n\n#define fragColor gl_FragColor\n\nvarying vec4 vColor;\nvoid main() {\n gl_FragColor = vColor;\n}\n";
12991
13064
  var seed$5 = 1;
@@ -13132,6 +13205,7 @@ exports.InteractComponent = /*#__PURE__*/ function(RendererComponent) {
13132
13205
  }
13133
13206
  var _proto = InteractComponent.prototype;
13134
13207
  _proto.start = function start() {
13208
+ var _this = this;
13135
13209
  var options = this.item.props.content.options;
13136
13210
  var env = this.item.engine.renderer.env;
13137
13211
  var composition = this.item.composition;
@@ -13153,6 +13227,16 @@ exports.InteractComponent = /*#__PURE__*/ function(RendererComponent) {
13153
13227
  this.materials = this.previewContent.mesh.materials;
13154
13228
  }
13155
13229
  this.item.getHitTestParams = this.getHitTestParams;
13230
+ this.item.onEnd = function() {
13231
+ if (_this.item && _this.item.composition) {
13232
+ var _this_previewContent;
13233
+ _this.item.composition.removeInteractiveItem(_this.item, _this.item.props.content.options.type);
13234
+ _this.clickable = false;
13235
+ _this.hasBeenAddedToComposition = false;
13236
+ (_this_previewContent = _this.previewContent) == null ? void 0 : _this_previewContent.mesh.dispose();
13237
+ _this.endDragTarget();
13238
+ }
13239
+ };
13156
13240
  };
13157
13241
  _proto.update = function update(dt) {
13158
13242
  var _this_previewContent;
@@ -13181,15 +13265,7 @@ exports.InteractComponent = /*#__PURE__*/ function(RendererComponent) {
13181
13265
  this.previewContent.mesh.render(renderer);
13182
13266
  }
13183
13267
  };
13184
- _proto.onDestroy = function onDestroy() {
13185
- if (this.item && this.item.composition) {
13186
- var _this_previewContent;
13187
- this.item.composition.removeInteractiveItem(this.item, this.item.props.content.options.type);
13188
- this.clickable = false;
13189
- (_this_previewContent = this.previewContent) == null ? void 0 : _this_previewContent.mesh.dispose();
13190
- this.endDragTarget();
13191
- }
13192
- };
13268
+ _proto.onDestroy = function onDestroy() {};
13193
13269
  _proto.endDragTarget = function endDragTarget() {
13194
13270
  // OVERRIDE
13195
13271
  };
@@ -13772,6 +13848,10 @@ var SpriteColorPlayable = /*#__PURE__*/ function(Playable) {
13772
13848
  }
13773
13849
  if (!this.spriteMaterial) {
13774
13850
  this.spriteMaterial = boundObject.getComponent(exports.SpriteComponent).material;
13851
+ var startColor = this.spriteMaterial.getVector4("_Color");
13852
+ if (startColor) {
13853
+ this.startColor = startColor.toArray();
13854
+ }
13775
13855
  }
13776
13856
  var colorInc = vecFill(tempColor, 1);
13777
13857
  var colorChanged;
@@ -13801,12 +13881,6 @@ var SpriteColorPlayable = /*#__PURE__*/ function(Playable) {
13801
13881
  this.colorOverLifetime = colorStopsFromGradient(colorOverLifetime.color[1]);
13802
13882
  }
13803
13883
  }
13804
- this.startColor = clipData.startColor || [
13805
- 1,
13806
- 1,
13807
- 1,
13808
- 1
13809
- ];
13810
13884
  return this;
13811
13885
  };
13812
13886
  return SpriteColorPlayable;
@@ -14114,7 +14188,7 @@ exports.SpriteComponent = /*#__PURE__*/ function(RendererComponent) {
14114
14188
  var splits = item.splits, renderer = item.renderer, textureSheetAnimation = item.textureSheetAnimation;
14115
14189
  var sx = 1, sy = 1;
14116
14190
  if (renderer.shape) {
14117
- var _renderer_shape = renderer.shape, index = _renderer_shape.index, aPoint = _renderer_shape.aPoint;
14191
+ 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;
14118
14192
  var point = new Float32Array(aPoint);
14119
14193
  var position = [];
14120
14194
  var atlasOffset = [];
@@ -16984,6 +17058,12 @@ exports.ParticleSystem = /*#__PURE__*/ function(Component) {
16984
17058
  area: area
16985
17059
  };
16986
17060
  };
17061
+ _proto.onAttached = function onAttached() {
17062
+ Component.prototype.onAttached.call(this);
17063
+ this.renderer.item = this.item;
17064
+ this.item.components.push(this.renderer);
17065
+ this.item.rendererComponents.push(this.renderer);
17066
+ };
16987
17067
  _proto.fromData = function fromData(data) {
16988
17068
  Component.prototype.fromData.call(this, data);
16989
17069
  var props = data;
@@ -17265,9 +17345,6 @@ exports.ParticleSystem = /*#__PURE__*/ function(Component) {
17265
17345
  }
17266
17346
  this.item.getHitTestParams = this.getHitTestParams;
17267
17347
  this.item._content = this;
17268
- this.renderer.item = this.item;
17269
- this.item.components.push(this.renderer);
17270
- this.item.rendererComponents.push(this.renderer);
17271
17348
  };
17272
17349
  _create_class(ParticleSystem, [
17273
17350
  {
@@ -19297,7 +19374,7 @@ function compareTracks(a, b) {
19297
19374
  _proto.hitTest = function hitTest(ray, x, y, regions, force, options) {
19298
19375
  var _this, _loop = function(i) {
19299
19376
  var item = _this.items[i];
19300
- if (item.getVisible() && !item.ended && !exports.VFXItem.isComposition(item) && !skip(item)) {
19377
+ if (item.getVisible() && item.transform.getValid() && !item.ended && !exports.VFXItem.isComposition(item) && !skip(item)) {
19301
19378
  var hitParams = item.getHitTestParams(force);
19302
19379
  if (hitParams) {
19303
19380
  var success = false;
@@ -19453,18 +19530,6 @@ var TextLayout = /*#__PURE__*/ function() {
19453
19530
  var tempWidth = fontSize + letterSpace;
19454
19531
  this.autoWidth = autoWidth;
19455
19532
  this.maxTextWidth = text.length * tempWidth;
19456
- // if (autoWidth) {
19457
- // this.width = this.maxTextWidth + this.lineWidth;
19458
- // this.height = fontSize + this.lineHeight;
19459
- // } else {
19460
- // if (textWidth) {
19461
- // this.maxCharCount = Math.floor((textWidth - this.lineWidth) / (tempWidth));
19462
- // this.width = textWidth;
19463
- // } else {
19464
- // this.width = basicScale[0] * 100;
19465
- // }
19466
- // this.height = basicScale[1] * 100;
19467
- // }
19468
19533
  this.width = textWidth;
19469
19534
  this.height = textHeight;
19470
19535
  this.letterSpace = letterSpace;
@@ -19901,6 +19966,17 @@ var TextComponentBase = /*#__PURE__*/ function() {
19901
19966
  this.isDirty = true;
19902
19967
  };
19903
19968
  /**
19969
+ * 设置自适应宽高开关
19970
+ * @param value - 是否自适应宽高开关
19971
+ * @returns
19972
+ */ _proto.setAutoWidth = function setAutoWidth(value) {
19973
+ if (this.textLayout.autoWidth === value) {
19974
+ return;
19975
+ }
19976
+ this.textLayout.autoWidth = value;
19977
+ this.isDirty = true;
19978
+ };
19979
+ /**
19904
19980
  * 更新文本
19905
19981
  * @returns
19906
19982
  */ _proto.updateTexture = function updateTexture(flipY) {
@@ -19913,20 +19989,26 @@ var TextComponentBase = /*#__PURE__*/ function() {
19913
19989
  var layout = this.textLayout;
19914
19990
  var fontScale = style.fontScale;
19915
19991
  var width = (layout.width + style.fontOffset) * fontScale;
19916
- var height = layout.height * fontScale;
19992
+ var finalHeight = layout.lineHeight * this.lineCount;
19917
19993
  var fontSize = style.fontSize * fontScale;
19918
19994
  var lineHeight = layout.lineHeight * fontScale;
19919
19995
  this.char = (this.text || "").split("");
19920
19996
  this.canvas.width = width;
19921
- this.canvas.height = height;
19922
- context.clearRect(0, 0, width, this.canvas.height);
19997
+ if (layout.autoWidth) {
19998
+ this.canvas.height = finalHeight * fontScale;
19999
+ this.item.transform.size.set(1, finalHeight / layout.height);
20000
+ } else {
20001
+ this.canvas.height = layout.height * fontScale;
20002
+ }
20003
+ var height = this.canvas.height;
20004
+ context.clearRect(0, 0, width, height);
19923
20005
  // fix bug 1/255
19924
20006
  context.fillStyle = "rgba(255, 255, 255, 0.0039)";
19925
20007
  if (!flipY) {
19926
20008
  context.translate(0, height);
19927
20009
  context.scale(1, -1);
19928
20010
  }
19929
- context.fillRect(0, 0, width, this.canvas.height);
20011
+ context.fillRect(0, 0, width, height);
19930
20012
  style.fontDesc = this.getFontDesc();
19931
20013
  context.font = style.fontDesc;
19932
20014
  if (style.hasShadow) {
@@ -20237,39 +20319,10 @@ exports.PostProcessVolume = /*#__PURE__*/ function(ItemBehaviour) {
20237
20319
  _proto.start = function start() {
20238
20320
  var composition = this.item.composition;
20239
20321
  if (composition) {
20240
- composition.globalVolume = {
20241
- useHDR: this.useHDR,
20242
- useBloom: this.useBloom,
20243
- threshold: this.threshold,
20244
- bloomIntensity: this.bloomIntensity,
20245
- brightness: this.brightness,
20246
- saturation: this.saturation,
20247
- contrast: this.contrast,
20248
- vignetteIntensity: this.vignetteIntensity,
20249
- vignetteSmoothness: this.vignetteSmoothness,
20250
- vignetteRoundness: this.vignetteRoundness,
20251
- useToneMapping: this.useToneMapping
20252
- };
20322
+ composition.globalVolume = this;
20253
20323
  composition.createRenderFrame();
20254
20324
  }
20255
20325
  };
20256
- _proto.update = function update(dt) {
20257
- var composition = this.item.composition;
20258
- if (composition) {
20259
- var globalVolume = composition.renderFrame.globalVolume;
20260
- globalVolume.useHDR = this.useHDR;
20261
- globalVolume.useBloom = this.useBloom;
20262
- globalVolume.threshold = this.threshold;
20263
- globalVolume.bloomIntensity = this.bloomIntensity;
20264
- globalVolume.brightness = this.brightness;
20265
- globalVolume.saturation = this.saturation;
20266
- globalVolume.contrast = this.contrast;
20267
- globalVolume.vignetteIntensity = this.vignetteIntensity;
20268
- globalVolume.vignetteSmoothness = this.vignetteSmoothness;
20269
- globalVolume.vignetteRoundness = this.vignetteRoundness;
20270
- globalVolume.useToneMapping = this.useToneMapping;
20271
- }
20272
- };
20273
20326
  return PostProcessVolume;
20274
20327
  }(ItemBehaviour);
20275
20328
  __decorate([
@@ -21269,27 +21322,46 @@ var SerializationHelper = /*#__PURE__*/ function() {
21269
21322
  res1
21270
21323
  ];
21271
21324
  case 7:
21272
- if (isObject(property) && property.constructor === Object) {
21273
- if (type) {
21274
- res2 = new type();
21275
- } else {
21276
- res2 = {};
21277
- }
21278
- for(_iterator1 = _create_for_of_iterator_helper_loose(Object.keys(property)); !(_step1 = _iterator1()).done;){
21279
- key = _step1.value;
21280
- res2[key] = SerializationHelper.deserializeProperty(property[key], engine, level + 1);
21281
- }
21282
- return [
21283
- 2,
21284
- res2
21285
- ];
21325
+ if (!(isObject(property) && property.constructor === Object)) return [
21326
+ 3,
21327
+ 12
21328
+ ];
21329
+ if (type) {
21330
+ res2 = new type();
21286
21331
  } else {
21287
- return [
21288
- 2,
21289
- property
21290
- ];
21332
+ res2 = {};
21291
21333
  }
21334
+ _iterator1 = _create_for_of_iterator_helper_loose(Object.keys(property));
21335
+ _state.label = 8;
21292
21336
  case 8:
21337
+ if (!!(_step1 = _iterator1()).done) return [
21338
+ 3,
21339
+ 11
21340
+ ];
21341
+ key = _step1.value;
21342
+ return [
21343
+ 4,
21344
+ SerializationHelper.deserializePropertyAsync(property[key], engine, level + 1)
21345
+ ];
21346
+ case 9:
21347
+ res2[key] = _state.sent();
21348
+ _state.label = 10;
21349
+ case 10:
21350
+ return [
21351
+ 3,
21352
+ 8
21353
+ ];
21354
+ case 11:
21355
+ return [
21356
+ 2,
21357
+ res2
21358
+ ];
21359
+ case 12:
21360
+ return [
21361
+ 2,
21362
+ property
21363
+ ];
21364
+ case 13:
21293
21365
  return [
21294
21366
  2
21295
21367
  ];
@@ -21948,277 +22020,39 @@ function getBezierCurveFromHermiteInGE(geHermiteCurves) {
21948
22020
  });
21949
22021
  }
21950
22022
 
21951
- function getStandardParticleContent(particle) {
21952
- var options = particle.options;
21953
- var transform = particle.transform;
21954
- var shape = {
21955
- type: ShapeType.NONE
21956
- };
21957
- if (particle.shape) {
21958
- var _particle_shape_shape;
21959
- var shapeType = (_particle_shape_shape = particle.shape.shape) == null ? void 0 : _particle_shape_shape.replace(/([A-Z])/g, "_$1").toUpperCase().replace(/^_/, "");
21960
- shape = _extends({}, particle.shape, {
21961
- type: ShapeType[shapeType]
21962
- });
21963
- if (particle.shape.upDirection) {
21964
- var _particle_shape_upDirection = particle.shape.upDirection, x = _particle_shape_upDirection[0], y = _particle_shape_upDirection[1], z = _particle_shape_upDirection[2];
21965
- if (x === 0 && y === 0 && z === 0) {
21966
- delete shape.upDirection;
21967
- }
21968
- }
21969
- }
21970
- if (options.startTurbulence) {
21971
- shape.turbulenceX = ensureNumberExpression(options.turbulenceX);
21972
- shape.turbulenceY = ensureNumberExpression(options.turbulenceY);
21973
- shape.turbulenceZ = ensureNumberExpression(options.turbulenceZ);
21974
- }
21975
- var emission = particle.emission;
21976
- if (emission.bursts && emission.bursts.length > 0) {
21977
- emission.bursts = emission.bursts.map(function(b) {
21978
- return objectValueToNumber(b);
21979
- });
21980
- }
21981
- if (emission.burstOffsets && emission.burstOffsets.length > 0) {
21982
- emission.burstOffsets = emission.burstOffsets.map(function(b) {
21983
- return objectValueToNumber(b);
21984
- });
21985
- }
21986
- if (emission.rateOverTime) {
21987
- emission.rateOverTime = ensureNumberExpression(emission.rateOverTime);
21988
- }
22023
+ function getStandardCameraContent(model) {
22024
+ var _model_transform;
22025
+ var opt = model.options;
21989
22026
  var ret = {
21990
- renderer: particle.renderer,
21991
- shape: shape,
21992
- splits: particle.splits,
21993
- emission: emission,
21994
22027
  options: {
21995
- startLifetime: ensureNumberExpression(options.startLifetime),
21996
- start3DSize: !!options.start3DSize,
21997
- startSize: ensureNumberExpression(options.startSize),
21998
- startSizeX: ensureNumberExpression(options.startSizeX),
21999
- startSizeY: ensureNumberExpression(options.startSizeY),
22000
- sizeAspect: ensureNumberExpression(options.sizeAspect),
22001
- maxCount: options.maxCount,
22002
- startDelay: ensureNumberExpression(options.startDelay),
22003
- startColor: ensureColorExpression(options.startColor, true),
22004
- startRotationZ: ensureNumberExpression(options.startRotation || options.startRotationZ),
22005
- particleFollowParent: options.particleFollowParent
22028
+ fov: opt.fov,
22029
+ far: opt.far,
22030
+ near: opt.near,
22031
+ clipMode: opt.clipMode
22006
22032
  }
22007
22033
  };
22008
- if (options.start3DRotation) {
22009
- ret.options.startRotationX = ensureNumberExpression(options.startRotationX);
22010
- ret.options.startRotationY = ensureNumberExpression(options.startRotationY);
22011
- }
22012
- if (transform && transform.path) {
22013
- ret.emitterTransform = {
22014
- path: ensureFixedVec3(transform.path)
22015
- };
22016
- }
22017
- var sizeOverLifetime = particle.sizeOverLifetime;
22018
- if (sizeOverLifetime) {
22019
- if (sizeOverLifetime.separateAxes) {
22020
- ret.sizeOverLifetime = {
22021
- separateAxes: true,
22022
- x: ensureNumberExpression(sizeOverLifetime.x),
22023
- y: ensureNumberExpression(sizeOverLifetime.y)
22024
- };
22025
- } else {
22026
- ret.sizeOverLifetime = {
22027
- size: ensureNumberExpression(sizeOverLifetime.size)
22028
- };
22029
- }
22030
- }
22031
- var velocityOverLifetime = particle.velocityOverLifetime || {};
22032
- var sol = velocityOverLifetime.speedOverLifetime;
22033
- if (sol) {
22034
- sol = ensureFixedNumber(sol);
22035
- } else {
22036
- sol = undefined;
22037
- }
22038
- ret.positionOverLifetime = {
22039
- gravity: options.gravity,
22040
- gravityOverLifetime: ensureFixedNumber(options.gravityModifier),
22041
- startSpeed: ensureNumberExpression(options.startSpeed),
22042
- speedOverLifetime: sol,
22043
- asMovement: velocityOverLifetime.asMovement,
22044
- linearX: ensureNumberExpression(velocityOverLifetime.linearX),
22045
- linearY: ensureNumberExpression(velocityOverLifetime.linearY),
22046
- linearZ: ensureNumberExpression(velocityOverLifetime.linearZ),
22047
- asRotation: velocityOverLifetime.asRotation,
22048
- orbCenter: velocityOverLifetime.orbCenter,
22049
- orbitalX: ensureNumberExpression(velocityOverLifetime.orbitalX),
22050
- orbitalY: ensureNumberExpression(velocityOverLifetime.orbitalY),
22051
- orbitalZ: ensureNumberExpression(velocityOverLifetime.orbitalZ),
22052
- forceTarget: velocityOverLifetime.forceTarget,
22053
- target: velocityOverLifetime.target,
22054
- forceCurve: ensureFixedNumber(velocityOverLifetime.forceCurve)
22055
- };
22056
- deleteEmptyValue(ret.positionOverLifetime);
22057
- var rotationOverLifetime = particle.rotationOverLifetime;
22058
- if (rotationOverLifetime) {
22059
- ret.rotationOverLifetime = {
22060
- separateAxes: rotationOverLifetime.separateAxes,
22061
- asRotation: rotationOverLifetime.asRotation,
22062
- z: ensureNumberExpression(rotationOverLifetime.separateAxes ? rotationOverLifetime.z : rotationOverLifetime.angularVelocity)
22063
- };
22064
- if (rotationOverLifetime.separateAxes) {
22065
- ret.rotationOverLifetime.y = ensureFixedNumber(rotationOverLifetime.y);
22066
- ret.rotationOverLifetime.x = ensureFixedNumber(rotationOverLifetime.x);
22067
- }
22068
- }
22069
- var colorOverLifetime = particle.colorOverLifetime;
22070
- if (colorOverLifetime) {
22071
- var col = ret.colorOverLifetime = {
22072
- opacity: ensureFixedNumber(colorOverLifetime.opacity)
22073
- };
22074
- if (colorOverLifetime.color) {
22075
- col.color = getGradientColor(colorOverLifetime.color);
22076
- }
22077
- }
22078
- var textureSheetAnimation = particle.textureSheetAnimation;
22079
- if (textureSheetAnimation) {
22080
- ret.textureSheetAnimation = {
22081
- row: textureSheetAnimation.row,
22082
- col: textureSheetAnimation.col,
22083
- total: textureSheetAnimation.total,
22084
- animate: textureSheetAnimation.animate,
22085
- cycles: ensureFixedNumber(textureSheetAnimation.cycles),
22086
- animationDelay: ensureFixedNumberWithRandom(textureSheetAnimation.animationDelay, 0),
22087
- animationDuration: ensureFixedNumberWithRandom(textureSheetAnimation.animationDuration, 0)
22088
- };
22089
- }
22090
- var trials = particle.trails;
22091
- if (trials) {
22092
- ret.trails = {
22093
- lifetime: ensureNumberExpression(trials.lifetime),
22094
- dieWithParticles: trials.dieWithParticles,
22095
- maxPointPerTrail: trials.maxPointPerTrail,
22096
- minimumVertexDistance: trials.minimumVertexDistance,
22097
- widthOverTrail: ensureFixedNumber(trials.widthOverTrail),
22098
- colorOverTrail: trials.colorOverTrail && getGradientColor(trials.colorOverTrail, false),
22099
- blending: trials.blending,
22100
- colorOverLifetime: trials.colorOverLifetime && getGradientColor(trials.colorOverLifetime, false),
22101
- inheritParticleColor: trials.inheritParticleColor,
22102
- occlusion: trials.occlusion,
22103
- transparentOcclusion: trials.transparentOcclusion,
22104
- orderOffset: trials.orderOffset,
22105
- sizeAffectsLifetime: trials.sizeAffectsLifetime,
22106
- sizeAffectsWidth: trials.sizeAffectsWidth,
22107
- texture: trials.texture,
22108
- parentAffectsPosition: trials.parentAffectsPosition,
22109
- opacityOverLifetime: ensureNumberExpression(trials.opacityOverLifetime)
22110
- };
22111
- }
22112
- ret.trails && deleteEmptyValue(ret.trails);
22113
- var interaction = particle.interaction;
22114
- if (interaction) {
22115
- ret.interaction = {
22116
- behavior: interaction.behavior,
22117
- radius: interaction.radius,
22118
- multiple: interaction.multiple
22119
- };
22120
- }
22121
- return ret;
22122
- }
22123
-
22124
- function getStandardNullContent(sprite, transform) {
22125
- var _sprite_transform;
22126
- var opt = sprite.options;
22127
- var velocityOverLifetime = sprite.velocityOverLifetime || {};
22128
- var positionOverLifetime = {
22129
- path: ensureFixedVec3((_sprite_transform = sprite.transform) == null ? void 0 : _sprite_transform.path),
22130
- gravity: opt.gravity,
22131
- gravityOverLifetime: ensureFixedNumber(opt.gravityModifier),
22132
- direction: opt.direction,
22133
- startSpeed: opt.startSpeed,
22134
- asMovement: velocityOverLifetime.asMovement,
22135
- linearX: ensureFixedNumber(velocityOverLifetime.linearX),
22136
- linearY: ensureFixedNumber(velocityOverLifetime.linearY),
22137
- linearZ: ensureFixedNumber(velocityOverLifetime.linearZ),
22138
- asRotation: velocityOverLifetime.asRotation,
22139
- orbCenter: velocityOverLifetime.orbCenter,
22140
- orbitalX: ensureFixedNumber(velocityOverLifetime.orbitalX),
22141
- orbitalY: ensureFixedNumber(velocityOverLifetime.orbitalY),
22142
- orbitalZ: ensureFixedNumber(velocityOverLifetime.orbitalZ),
22143
- speedOverLifetime: ensureFixedNumber(velocityOverLifetime.speedOverLifetime)
22144
- };
22145
- deleteEmptyValue(positionOverLifetime);
22146
- var ret = {
22147
- options: {
22148
- startColor: ensureRGBAValue(opt.startColor)
22149
- },
22150
- positionOverLifetime: positionOverLifetime
22151
- };
22152
- if (opt.startSize) {
22153
- transform.scale = [
22154
- opt.startSize,
22155
- opt.startSize / (opt.sizeAspect || 1),
22156
- 1
22157
- ];
22158
- }
22159
- if (opt.startRotation) {
22160
- if (!transform.rotation) {
22161
- transform.rotation = [
22162
- 0,
22163
- 0,
22164
- opt.startRotation
22165
- ];
22166
- } else {
22167
- transform.rotation[2] += opt.startRotation;
22168
- }
22169
- }
22170
- var rotationOverLifetime = sprite.rotationOverLifetime;
22171
- if (rotationOverLifetime) {
22172
- var rot = ret.rotationOverLifetime = {
22173
- separateAxes: rotationOverLifetime.separateAxes,
22174
- asRotation: rotationOverLifetime.asRotation
22175
- };
22176
- if (rot.separateAxes) {
22177
- rot.x = ensureFixedNumber(rotationOverLifetime.x);
22178
- rot.y = ensureFixedNumber(rotationOverLifetime.y);
22179
- rot.z = ensureFixedNumber(rotationOverLifetime.z);
22180
- } else {
22181
- rot.z = ensureFixedNumber(rotationOverLifetime.angularVelocity);
22182
- }
22183
- }
22184
- var colorOverLifetime = sprite.colorOverLifetime;
22185
- if (colorOverLifetime) {
22186
- var col = ret.colorOverLifetime = {
22187
- opacity: ensureFixedNumber(colorOverLifetime.opacity)
22188
- };
22189
- if (colorOverLifetime.color) {
22190
- col.color = getGradientColor(colorOverLifetime.color);
22191
- }
22192
- }
22193
- var sizeOverLifetime = sprite.sizeOverLifetime;
22194
- if (sizeOverLifetime) {
22195
- ret.sizeOverLifetime = {
22196
- separateAxes: sizeOverLifetime.separateAxes,
22197
- size: ensureFixedNumber(sizeOverLifetime.size),
22198
- x: ensureFixedNumber(sizeOverLifetime.x),
22199
- y: ensureFixedNumber(sizeOverLifetime.y),
22200
- z: ensureFixedNumber(sizeOverLifetime.z)
22034
+ var velocityOverLifetime = model.velocityOverLifetime;
22035
+ if (velocityOverLifetime || ((_model_transform = model.transform) == null ? void 0 : _model_transform.path)) {
22036
+ var _model_transform1;
22037
+ var positionOverLifetime = {
22038
+ path: ensureFixedVec3((_model_transform1 = model.transform) == null ? void 0 : _model_transform1.path),
22039
+ linearX: ensureFixedNumber(velocityOverLifetime == null ? void 0 : velocityOverLifetime.translateX),
22040
+ linearY: ensureFixedNumber(velocityOverLifetime == null ? void 0 : velocityOverLifetime.translateY),
22041
+ linearZ: ensureFixedNumber(velocityOverLifetime == null ? void 0 : velocityOverLifetime.translateZ)
22201
22042
  };
22043
+ deleteEmptyValue(positionOverLifetime);
22044
+ ret.positionOverLifetime = positionOverLifetime;
22202
22045
  }
22203
- return ret;
22204
- }
22205
- function getStandardSpriteContent(sprite, transform) {
22206
- var ret = getStandardNullContent(sprite, transform);
22207
- var texAni = sprite.textureSheetAnimation;
22208
- if (texAni) {
22209
- ret.textureSheetAnimation = {
22210
- row: texAni.row,
22211
- col: texAni.col,
22212
- total: texAni.total || undefined,
22213
- animate: texAni.animate
22046
+ var rol = model.rotationOverLifetime;
22047
+ if (rol) {
22048
+ var rotationOverLifetime = {
22049
+ separateAxes: rol.separateAxes,
22050
+ x: ensureFixedNumber(rol == null ? void 0 : rol.rotateX),
22051
+ y: ensureFixedNumber(rol == null ? void 0 : rol.rotateY),
22052
+ z: rol.separateAxes ? ensureFixedNumber(rol == null ? void 0 : rol.rotateZ) : ensureFixedNumber(rol.rotation)
22214
22053
  };
22215
- }
22216
- ret.renderer = sprite.renderer;
22217
- if (sprite.splits) {
22218
- ret.splits = sprite.splits;
22219
- }
22220
- if (sprite.interaction) {
22221
- ret.interaction = sprite.interaction;
22054
+ deleteEmptyValue(rotationOverLifetime);
22055
+ ret.rotationOverLifetime = rotationOverLifetime;
22222
22056
  }
22223
22057
  return ret;
22224
22058
  }
@@ -22263,43 +22097,6 @@ function getStandardInteractContent(ui) {
22263
22097
  return ret;
22264
22098
  }
22265
22099
 
22266
- function getStandardCameraContent(model) {
22267
- var _model_transform;
22268
- var opt = model.options;
22269
- var ret = {
22270
- options: {
22271
- fov: opt.fov,
22272
- far: opt.far,
22273
- near: opt.near,
22274
- clipMode: opt.clipMode
22275
- }
22276
- };
22277
- var velocityOverLifetime = model.velocityOverLifetime;
22278
- if (velocityOverLifetime || ((_model_transform = model.transform) == null ? void 0 : _model_transform.path)) {
22279
- var _model_transform1;
22280
- var positionOverLifetime = {
22281
- path: ensureFixedVec3((_model_transform1 = model.transform) == null ? void 0 : _model_transform1.path),
22282
- linearX: ensureFixedNumber(velocityOverLifetime == null ? void 0 : velocityOverLifetime.translateX),
22283
- linearY: ensureFixedNumber(velocityOverLifetime == null ? void 0 : velocityOverLifetime.translateY),
22284
- linearZ: ensureFixedNumber(velocityOverLifetime == null ? void 0 : velocityOverLifetime.translateZ)
22285
- };
22286
- deleteEmptyValue(positionOverLifetime);
22287
- ret.positionOverLifetime = positionOverLifetime;
22288
- }
22289
- var rol = model.rotationOverLifetime;
22290
- if (rol) {
22291
- var rotationOverLifetime = {
22292
- separateAxes: rol.separateAxes,
22293
- x: ensureFixedNumber(rol == null ? void 0 : rol.rotateX),
22294
- y: ensureFixedNumber(rol == null ? void 0 : rol.rotateY),
22295
- z: rol.separateAxes ? ensureFixedNumber(rol == null ? void 0 : rol.rotateZ) : ensureFixedNumber(rol.rotation)
22296
- };
22297
- deleteEmptyValue(rotationOverLifetime);
22298
- ret.rotationOverLifetime = rotationOverLifetime;
22299
- }
22300
- return ret;
22301
- }
22302
-
22303
22100
  /**
22304
22101
  * 2.1 以下版本数据适配(mars-player@2.4.0 及以上版本支持 2.1 以下数据的适配)
22305
22102
  */ function version21Migration(json) {
@@ -22416,11 +22213,12 @@ function getStandardCameraContent(model) {
22416
22213
  var _textures;
22417
22214
  (_textures = (_result = result).textures) != null ? _textures : _result.textures = [];
22418
22215
  result.textures.forEach(function(textureOptions) {
22216
+ var _result_images_textureOptions_source;
22419
22217
  textureOptions.id = generateGUID();
22420
22218
  textureOptions.dataType = DataType.Texture;
22421
22219
  // @ts-expect-error
22422
22220
  textureOptions.source = {
22423
- id: result.images[textureOptions.source].id
22221
+ id: (_result_images_textureOptions_source = result.images[textureOptions.source]) == null ? void 0 : _result_images_textureOptions_source.id
22424
22222
  };
22425
22223
  });
22426
22224
  if (result.textures.length < result.images.length) {
@@ -22774,8 +22572,7 @@ function convertTimelineAsset(composition, guidToItemMap, jsonScene) {
22774
22572
  var newSpriteColorPlayableAssetData = {
22775
22573
  id: generateGUID(),
22776
22574
  dataType: "SpriteColorPlayableAsset",
22777
- colorOverLifetime: item.content.colorOverLifetime,
22778
- startColor: item.content.options.startColor
22575
+ colorOverLifetime: item.content.colorOverLifetime
22779
22576
  };
22780
22577
  playableAssetDatas.push(newSpriteColorPlayableAssetData);
22781
22578
  var newTrackData1 = {
@@ -22830,77 +22627,352 @@ function convertTimelineAsset(composition, guidToItemMap, jsonScene) {
22830
22627
  children: subTrackDatas,
22831
22628
  clips: []
22832
22629
  };
22833
- trackDatas.push(bindingTrackData);
22834
- timelineAssetData.tracks.push({
22835
- id: bindingTrackData.id
22836
- });
22837
- sceneBindings.push({
22838
- key: {
22839
- id: bindingTrackData.id
22840
- },
22841
- value: {
22842
- id: item.id
22843
- }
22844
- });
22630
+ trackDatas.push(bindingTrackData);
22631
+ timelineAssetData.tracks.push({
22632
+ id: bindingTrackData.id
22633
+ });
22634
+ sceneBindings.push({
22635
+ key: {
22636
+ id: bindingTrackData.id
22637
+ },
22638
+ value: {
22639
+ id: item.id
22640
+ }
22641
+ });
22642
+ }
22643
+ var trackIds = [];
22644
+ for(var _iterator1 = _create_for_of_iterator_helper_loose(trackDatas), _step1; !(_step1 = _iterator1()).done;){
22645
+ var trackData = _step1.value;
22646
+ trackIds.push({
22647
+ id: trackData.id
22648
+ });
22649
+ }
22650
+ composition.timelineAsset = {
22651
+ id: timelineAssetData.id
22652
+ };
22653
+ composition.sceneBindings = sceneBindings;
22654
+ jsonScene.miscs.push(timelineAssetData);
22655
+ for(var _iterator2 = _create_for_of_iterator_helper_loose(trackDatas), _step2; !(_step2 = _iterator2()).done;){
22656
+ var trackData1 = _step2.value;
22657
+ //@ts-expect-error
22658
+ jsonScene.miscs.push(trackData1);
22659
+ }
22660
+ for(var _iterator3 = _create_for_of_iterator_helper_loose(playableAssetDatas), _step3; !(_step3 = _iterator3()).done;){
22661
+ var playableAsset = _step3.value;
22662
+ //@ts-expect-error
22663
+ jsonScene.miscs.push(playableAsset);
22664
+ }
22665
+ }
22666
+ function convertBinaryAsset(bins, jsonScene) {
22667
+ //@ts-expect-error
22668
+ jsonScene.bins = bins.map(function(bin) {
22669
+ return {
22670
+ url: bin.url,
22671
+ "dataType": "BinaryAsset",
22672
+ id: generateGUID()
22673
+ };
22674
+ });
22675
+ }
22676
+ function convertSpineData(resource, content, jsonScene) {
22677
+ //@ts-expect-error
22678
+ content.resource = {
22679
+ "atlas": {
22680
+ "bins": {
22681
+ //@ts-expect-error
22682
+ "id": jsonScene.bins[resource.atlas[1][0]].id
22683
+ },
22684
+ "source": resource.atlas[1].slice(1)
22685
+ },
22686
+ "skeleton": {
22687
+ "bins": {
22688
+ //@ts-expect-error
22689
+ "id": jsonScene.bins[resource.skeleton[1][0]].id
22690
+ },
22691
+ "source": resource.skeleton[1].slice(1)
22692
+ },
22693
+ "skeletonType": resource.skeletonType,
22694
+ "images": resource.images.map(function(i) {
22695
+ return {
22696
+ //@ts-expect-error
22697
+ id: jsonScene.textures[i].id
22698
+ };
22699
+ })
22700
+ };
22701
+ }
22702
+
22703
+ function getStandardParticleContent(particle) {
22704
+ var options = particle.options;
22705
+ var transform = particle.transform;
22706
+ var shape = {
22707
+ type: ShapeType.NONE
22708
+ };
22709
+ if (particle.shape) {
22710
+ var _particle_shape_shape;
22711
+ var shapeType = (_particle_shape_shape = particle.shape.shape) == null ? void 0 : _particle_shape_shape.replace(/([A-Z])/g, "_$1").toUpperCase().replace(/^_/, "");
22712
+ shape = _extends({}, particle.shape, {
22713
+ type: ShapeType[shapeType]
22714
+ });
22715
+ if (particle.shape.upDirection) {
22716
+ var _particle_shape_upDirection = particle.shape.upDirection, x = _particle_shape_upDirection[0], y = _particle_shape_upDirection[1], z = _particle_shape_upDirection[2];
22717
+ if (x === 0 && y === 0 && z === 0) {
22718
+ delete shape.upDirection;
22719
+ }
22720
+ }
22721
+ }
22722
+ if (options.startTurbulence) {
22723
+ shape.turbulenceX = ensureNumberExpression(options.turbulenceX);
22724
+ shape.turbulenceY = ensureNumberExpression(options.turbulenceY);
22725
+ shape.turbulenceZ = ensureNumberExpression(options.turbulenceZ);
22726
+ }
22727
+ var emission = particle.emission;
22728
+ if (emission.bursts && emission.bursts.length > 0) {
22729
+ emission.bursts = emission.bursts.map(function(b) {
22730
+ return objectValueToNumber(b);
22731
+ });
22732
+ }
22733
+ if (emission.burstOffsets && emission.burstOffsets.length > 0) {
22734
+ emission.burstOffsets = emission.burstOffsets.map(function(b) {
22735
+ return objectValueToNumber(b);
22736
+ });
22737
+ }
22738
+ if (emission.rateOverTime) {
22739
+ emission.rateOverTime = ensureNumberExpression(emission.rateOverTime);
22740
+ }
22741
+ var ret = {
22742
+ renderer: particle.renderer,
22743
+ shape: shape,
22744
+ splits: particle.splits,
22745
+ emission: emission,
22746
+ options: {
22747
+ startLifetime: ensureNumberExpression(options.startLifetime),
22748
+ start3DSize: !!options.start3DSize,
22749
+ startSize: ensureNumberExpression(options.startSize),
22750
+ startSizeX: ensureNumberExpression(options.startSizeX),
22751
+ startSizeY: ensureNumberExpression(options.startSizeY),
22752
+ sizeAspect: ensureNumberExpression(options.sizeAspect),
22753
+ maxCount: options.maxCount,
22754
+ startDelay: ensureNumberExpression(options.startDelay),
22755
+ startColor: ensureColorExpression(options.startColor, true),
22756
+ startRotationZ: ensureNumberExpression(options.startRotation || options.startRotationZ),
22757
+ particleFollowParent: options.particleFollowParent
22758
+ }
22759
+ };
22760
+ if (options.start3DRotation) {
22761
+ ret.options.startRotationX = ensureNumberExpression(options.startRotationX);
22762
+ ret.options.startRotationY = ensureNumberExpression(options.startRotationY);
22763
+ }
22764
+ if (transform && transform.path) {
22765
+ ret.emitterTransform = {
22766
+ path: ensureFixedVec3(transform.path)
22767
+ };
22768
+ }
22769
+ var sizeOverLifetime = particle.sizeOverLifetime;
22770
+ if (sizeOverLifetime) {
22771
+ if (sizeOverLifetime.separateAxes) {
22772
+ ret.sizeOverLifetime = {
22773
+ separateAxes: true,
22774
+ x: ensureNumberExpression(sizeOverLifetime.x),
22775
+ y: ensureNumberExpression(sizeOverLifetime.y)
22776
+ };
22777
+ } else {
22778
+ ret.sizeOverLifetime = {
22779
+ size: ensureNumberExpression(sizeOverLifetime.size)
22780
+ };
22781
+ }
22782
+ }
22783
+ var velocityOverLifetime = particle.velocityOverLifetime || {};
22784
+ var sol = velocityOverLifetime.speedOverLifetime;
22785
+ if (sol) {
22786
+ sol = ensureFixedNumber(sol);
22787
+ } else {
22788
+ sol = undefined;
22789
+ }
22790
+ ret.positionOverLifetime = {
22791
+ gravity: options.gravity,
22792
+ gravityOverLifetime: ensureFixedNumber(options.gravityModifier),
22793
+ startSpeed: ensureNumberExpression(options.startSpeed),
22794
+ speedOverLifetime: sol,
22795
+ asMovement: velocityOverLifetime.asMovement,
22796
+ linearX: ensureNumberExpression(velocityOverLifetime.linearX),
22797
+ linearY: ensureNumberExpression(velocityOverLifetime.linearY),
22798
+ linearZ: ensureNumberExpression(velocityOverLifetime.linearZ),
22799
+ asRotation: velocityOverLifetime.asRotation,
22800
+ orbCenter: velocityOverLifetime.orbCenter,
22801
+ orbitalX: ensureNumberExpression(velocityOverLifetime.orbitalX),
22802
+ orbitalY: ensureNumberExpression(velocityOverLifetime.orbitalY),
22803
+ orbitalZ: ensureNumberExpression(velocityOverLifetime.orbitalZ),
22804
+ forceTarget: velocityOverLifetime.forceTarget,
22805
+ target: velocityOverLifetime.target,
22806
+ forceCurve: ensureFixedNumber(velocityOverLifetime.forceCurve)
22807
+ };
22808
+ deleteEmptyValue(ret.positionOverLifetime);
22809
+ var rotationOverLifetime = particle.rotationOverLifetime;
22810
+ if (rotationOverLifetime) {
22811
+ ret.rotationOverLifetime = {
22812
+ separateAxes: rotationOverLifetime.separateAxes,
22813
+ asRotation: rotationOverLifetime.asRotation,
22814
+ z: ensureNumberExpression(rotationOverLifetime.separateAxes ? rotationOverLifetime.z : rotationOverLifetime.angularVelocity)
22815
+ };
22816
+ if (rotationOverLifetime.separateAxes) {
22817
+ ret.rotationOverLifetime.y = ensureFixedNumber(rotationOverLifetime.y);
22818
+ ret.rotationOverLifetime.x = ensureFixedNumber(rotationOverLifetime.x);
22819
+ }
22845
22820
  }
22846
- var trackIds = [];
22847
- for(var _iterator1 = _create_for_of_iterator_helper_loose(trackDatas), _step1; !(_step1 = _iterator1()).done;){
22848
- var trackData = _step1.value;
22849
- trackIds.push({
22850
- id: trackData.id
22851
- });
22821
+ var colorOverLifetime = particle.colorOverLifetime;
22822
+ if (colorOverLifetime) {
22823
+ var col = ret.colorOverLifetime = {
22824
+ opacity: ensureFixedNumber(colorOverLifetime.opacity)
22825
+ };
22826
+ if (colorOverLifetime.color) {
22827
+ col.color = getGradientColor(colorOverLifetime.color);
22828
+ }
22852
22829
  }
22853
- composition.timelineAsset = {
22854
- id: timelineAssetData.id
22855
- };
22856
- composition.sceneBindings = sceneBindings;
22857
- jsonScene.miscs.push(timelineAssetData);
22858
- for(var _iterator2 = _create_for_of_iterator_helper_loose(trackDatas), _step2; !(_step2 = _iterator2()).done;){
22859
- var trackData1 = _step2.value;
22860
- //@ts-expect-error
22861
- jsonScene.miscs.push(trackData1);
22830
+ var textureSheetAnimation = particle.textureSheetAnimation;
22831
+ if (textureSheetAnimation) {
22832
+ ret.textureSheetAnimation = {
22833
+ row: textureSheetAnimation.row,
22834
+ col: textureSheetAnimation.col,
22835
+ total: textureSheetAnimation.total,
22836
+ animate: textureSheetAnimation.animate,
22837
+ cycles: ensureFixedNumber(textureSheetAnimation.cycles),
22838
+ animationDelay: ensureFixedNumberWithRandom(textureSheetAnimation.animationDelay, 0),
22839
+ animationDuration: ensureFixedNumberWithRandom(textureSheetAnimation.animationDuration, 0)
22840
+ };
22862
22841
  }
22863
- for(var _iterator3 = _create_for_of_iterator_helper_loose(playableAssetDatas), _step3; !(_step3 = _iterator3()).done;){
22864
- var playableAsset = _step3.value;
22865
- //@ts-expect-error
22866
- jsonScene.miscs.push(playableAsset);
22842
+ var trials = particle.trails;
22843
+ if (trials) {
22844
+ ret.trails = {
22845
+ lifetime: ensureNumberExpression(trials.lifetime),
22846
+ dieWithParticles: trials.dieWithParticles,
22847
+ maxPointPerTrail: trials.maxPointPerTrail,
22848
+ minimumVertexDistance: trials.minimumVertexDistance,
22849
+ widthOverTrail: ensureFixedNumber(trials.widthOverTrail),
22850
+ colorOverTrail: trials.colorOverTrail && getGradientColor(trials.colorOverTrail, false),
22851
+ blending: trials.blending,
22852
+ colorOverLifetime: trials.colorOverLifetime && getGradientColor(trials.colorOverLifetime, false),
22853
+ inheritParticleColor: trials.inheritParticleColor,
22854
+ occlusion: trials.occlusion,
22855
+ transparentOcclusion: trials.transparentOcclusion,
22856
+ orderOffset: trials.orderOffset,
22857
+ sizeAffectsLifetime: trials.sizeAffectsLifetime,
22858
+ sizeAffectsWidth: trials.sizeAffectsWidth,
22859
+ texture: trials.texture,
22860
+ parentAffectsPosition: trials.parentAffectsPosition,
22861
+ opacityOverLifetime: ensureNumberExpression(trials.opacityOverLifetime)
22862
+ };
22867
22863
  }
22868
- }
22869
- function convertBinaryAsset(bins, jsonScene) {
22870
- //@ts-expect-error
22871
- jsonScene.bins = bins.map(function(bin) {
22872
- return {
22873
- url: bin.url,
22874
- "dataType": "BinaryAsset",
22875
- id: generateGUID()
22864
+ ret.trails && deleteEmptyValue(ret.trails);
22865
+ var interaction = particle.interaction;
22866
+ if (interaction) {
22867
+ ret.interaction = {
22868
+ behavior: interaction.behavior,
22869
+ radius: interaction.radius,
22870
+ multiple: interaction.multiple
22876
22871
  };
22877
- });
22872
+ }
22873
+ return ret;
22878
22874
  }
22879
- function convertSpineData(resource, content, jsonScene) {
22880
- //@ts-expect-error
22881
- content.resource = {
22882
- "atlas": {
22883
- "bins": {
22884
- //@ts-expect-error
22885
- "id": jsonScene.bins[resource.atlas[1][0]].id
22886
- },
22887
- "source": resource.atlas[1].slice(1)
22888
- },
22889
- "skeleton": {
22890
- "bins": {
22891
- //@ts-expect-error
22892
- "id": jsonScene.bins[resource.skeleton[1][0]].id
22893
- },
22894
- "source": resource.skeleton[1].slice(1)
22875
+
22876
+ function getStandardNullContent(sprite, transform) {
22877
+ var _sprite_transform;
22878
+ var opt = sprite.options;
22879
+ var velocityOverLifetime = sprite.velocityOverLifetime || {};
22880
+ var positionOverLifetime = {
22881
+ path: ensureFixedVec3((_sprite_transform = sprite.transform) == null ? void 0 : _sprite_transform.path),
22882
+ gravity: opt.gravity,
22883
+ gravityOverLifetime: ensureFixedNumber(opt.gravityModifier),
22884
+ direction: opt.direction,
22885
+ startSpeed: opt.startSpeed,
22886
+ asMovement: velocityOverLifetime.asMovement,
22887
+ linearX: ensureFixedNumber(velocityOverLifetime.linearX),
22888
+ linearY: ensureFixedNumber(velocityOverLifetime.linearY),
22889
+ linearZ: ensureFixedNumber(velocityOverLifetime.linearZ),
22890
+ asRotation: velocityOverLifetime.asRotation,
22891
+ orbCenter: velocityOverLifetime.orbCenter,
22892
+ orbitalX: ensureFixedNumber(velocityOverLifetime.orbitalX),
22893
+ orbitalY: ensureFixedNumber(velocityOverLifetime.orbitalY),
22894
+ orbitalZ: ensureFixedNumber(velocityOverLifetime.orbitalZ),
22895
+ speedOverLifetime: ensureFixedNumber(velocityOverLifetime.speedOverLifetime)
22896
+ };
22897
+ deleteEmptyValue(positionOverLifetime);
22898
+ var ret = {
22899
+ options: {
22900
+ startColor: ensureRGBAValue(opt.startColor)
22895
22901
  },
22896
- "skeletonType": resource.skeletonType,
22897
- "images": resource.images.map(function(i) {
22898
- return {
22899
- //@ts-expect-error
22900
- id: jsonScene.textures[i].id
22901
- };
22902
- })
22902
+ positionOverLifetime: positionOverLifetime
22903
22903
  };
22904
+ if (opt.startSize) {
22905
+ transform.scale = [
22906
+ opt.startSize,
22907
+ opt.startSize / (opt.sizeAspect || 1),
22908
+ 1
22909
+ ];
22910
+ }
22911
+ if (opt.startRotation) {
22912
+ if (!transform.rotation) {
22913
+ transform.rotation = [
22914
+ 0,
22915
+ 0,
22916
+ opt.startRotation
22917
+ ];
22918
+ } else {
22919
+ transform.rotation[2] += opt.startRotation;
22920
+ }
22921
+ }
22922
+ var rotationOverLifetime = sprite.rotationOverLifetime;
22923
+ if (rotationOverLifetime) {
22924
+ var rot = ret.rotationOverLifetime = {
22925
+ separateAxes: rotationOverLifetime.separateAxes,
22926
+ asRotation: rotationOverLifetime.asRotation
22927
+ };
22928
+ if (rot.separateAxes) {
22929
+ rot.x = ensureFixedNumber(rotationOverLifetime.x);
22930
+ rot.y = ensureFixedNumber(rotationOverLifetime.y);
22931
+ rot.z = ensureFixedNumber(rotationOverLifetime.z);
22932
+ } else {
22933
+ rot.z = ensureFixedNumber(rotationOverLifetime.angularVelocity);
22934
+ }
22935
+ }
22936
+ var colorOverLifetime = sprite.colorOverLifetime;
22937
+ if (colorOverLifetime) {
22938
+ var col = ret.colorOverLifetime = {
22939
+ opacity: ensureFixedNumber(colorOverLifetime.opacity)
22940
+ };
22941
+ if (colorOverLifetime.color) {
22942
+ col.color = getGradientColor(colorOverLifetime.color);
22943
+ }
22944
+ }
22945
+ var sizeOverLifetime = sprite.sizeOverLifetime;
22946
+ if (sizeOverLifetime) {
22947
+ ret.sizeOverLifetime = {
22948
+ separateAxes: sizeOverLifetime.separateAxes,
22949
+ size: ensureFixedNumber(sizeOverLifetime.size),
22950
+ x: ensureFixedNumber(sizeOverLifetime.x),
22951
+ y: ensureFixedNumber(sizeOverLifetime.y),
22952
+ z: ensureFixedNumber(sizeOverLifetime.z)
22953
+ };
22954
+ }
22955
+ return ret;
22956
+ }
22957
+ function getStandardSpriteContent(sprite, transform) {
22958
+ var ret = getStandardNullContent(sprite, transform);
22959
+ var texAni = sprite.textureSheetAnimation;
22960
+ if (texAni) {
22961
+ ret.textureSheetAnimation = {
22962
+ row: texAni.row,
22963
+ col: texAni.col,
22964
+ total: texAni.total || undefined,
22965
+ animate: texAni.animate
22966
+ };
22967
+ }
22968
+ ret.renderer = sprite.renderer;
22969
+ if (sprite.splits) {
22970
+ ret.splits = sprite.splits;
22971
+ }
22972
+ if (sprite.interaction) {
22973
+ ret.interaction = sprite.interaction;
22974
+ }
22975
+ return ret;
22904
22976
  }
22905
22977
 
22906
22978
  var v0 = /^(\d+)\.(\d+)\.(\d+)(-(\w+)\.\d+)?$/;
@@ -23282,7 +23354,7 @@ function getBackgroundImage(template, variables) {
23282
23354
  }
23283
23355
  function _combineImageTemplate() {
23284
23356
  _combineImageTemplate = _async_to_generator(function(url, template, variables) {
23285
- var image, drawImage, templateBackground, _tmp;
23357
+ var image, templateBackground;
23286
23358
  return __generator(this, function(_state) {
23287
23359
  switch(_state.label){
23288
23360
  case 0:
@@ -23313,37 +23385,25 @@ function _combineImageTemplate() {
23313
23385
  image
23314
23386
  ];
23315
23387
  }
23316
- drawImage = image;
23317
23388
  // 获取动态换图的图片对象或 url 地址
23318
23389
  templateBackground = getBackgroundImage(template, variables);
23319
- if (!(templateBackground && isString(templateBackground) && templateBackground !== image.src)) return [
23320
- 3,
23321
- 7
23322
- ];
23323
- if (!isString(templateBackground)) return [
23324
- 3,
23325
- 5
23326
- ];
23327
- return [
23328
- 4,
23329
- loadImage(templateBackground)
23330
- ];
23331
- case 4:
23332
- _tmp = _state.sent();
23333
- return [
23334
- 3,
23335
- 6
23336
- ];
23337
- case 5:
23338
- _tmp = templateBackground;
23339
- _state.label = 6;
23340
- case 6:
23341
- drawImage = _tmp;
23342
- _state.label = 7;
23343
- case 7:
23390
+ if (templateBackground) {
23391
+ if (isString(templateBackground) && templateBackground !== image.src) {
23392
+ return [
23393
+ 2,
23394
+ loadImage(templateBackground)
23395
+ ];
23396
+ }
23397
+ if (_instanceof1(templateBackground, HTMLImageElement)) {
23398
+ return [
23399
+ 2,
23400
+ templateBackground
23401
+ ];
23402
+ }
23403
+ }
23344
23404
  return [
23345
23405
  2,
23346
- drawImage
23406
+ image
23347
23407
  ];
23348
23408
  }
23349
23409
  });
@@ -23807,15 +23867,17 @@ var seed$1 = 1;
23807
23867
  _this_options = _this.options, useCompressedTexture = _this_options.useCompressedTexture, variables = _this_options.variables;
23808
23868
  baseUrl = _this.baseUrl;
23809
23869
  jobs = images.map(/*#__PURE__*/ _async_to_generator(function(img, idx) {
23810
- var png, webp, imageURL, webpURL, template, background, url, isVideo, loadFn, resultImage, e, compressed, src, bufferURL, _ref, url1, image;
23870
+ var png, webp, avif, imageURL, webpURL, avifURL, template, background, url, isVideo, loadFn, resultImage, e, compressed, src, bufferURL, _ref, url1, image, _tmp;
23811
23871
  return __generator(this, function(_state) {
23812
23872
  switch(_state.label){
23813
23873
  case 0:
23814
- png = img.url, webp = img.webp;
23874
+ png = img.url, webp = img.webp, avif = img.avif;
23815
23875
  // eslint-disable-next-line compat/compat
23816
23876
  imageURL = new URL(png, baseUrl).href;
23817
23877
  // eslint-disable-next-line compat/compat
23818
23878
  webpURL = webp && new URL(webp, baseUrl).href;
23879
+ // eslint-disable-next-line compat/compat
23880
+ avifURL = avif && new URL(avif, baseUrl).href;
23819
23881
  if (!("template" in img)) return [
23820
23882
  3,
23821
23883
  8
@@ -23915,12 +23977,30 @@ var seed$1 = 1;
23915
23977
  }
23916
23978
  _state.label = 9;
23917
23979
  case 9:
23980
+ if (!avifURL) return [
23981
+ 3,
23982
+ 11
23983
+ ];
23918
23984
  return [
23919
23985
  4,
23920
- loadWebPOptional(imageURL, webpURL)
23986
+ loadAVIFOptional(imageURL, avifURL)
23921
23987
  ];
23922
23988
  case 10:
23923
- _ref = _state.sent(), url1 = _ref.url, image = _ref.image;
23989
+ _tmp = _state.sent();
23990
+ return [
23991
+ 3,
23992
+ 13
23993
+ ];
23994
+ case 11:
23995
+ return [
23996
+ 4,
23997
+ loadWebPOptional(imageURL, webpURL)
23998
+ ];
23999
+ case 12:
24000
+ _tmp = _state.sent();
24001
+ _state.label = 13;
24002
+ case 13:
24003
+ _ref = _tmp, url1 = _ref.url, image = _ref.image;
23924
24004
  _this.assets[idx] = {
23925
24005
  url: url1,
23926
24006
  type: exports.TextureSourceType.image
@@ -27390,7 +27470,7 @@ registerPlugin("sprite", SpriteLoader, exports.VFXItem, true);
27390
27470
  registerPlugin("particle", ParticleLoader, exports.VFXItem, true);
27391
27471
  registerPlugin("cal", CalculateLoader, exports.VFXItem, true);
27392
27472
  registerPlugin("interact", InteractLoader, exports.VFXItem, true);
27393
- var version$1 = "2.0.0-alpha.28";
27473
+ var version$1 = "2.0.0-alpha.29";
27394
27474
  logger.info("Core version: " + version$1 + ".");
27395
27475
 
27396
27476
  var _obj;
@@ -29023,7 +29103,7 @@ setMaxSpriteMeshItemCount(8);
29023
29103
  */ Mesh.create = function(engine, props) {
29024
29104
  return new ThreeMesh(engine, props);
29025
29105
  };
29026
- var version = "2.0.0-alpha.28";
29106
+ var version = "2.0.0-alpha.29";
29027
29107
  logger.info("THREEJS plugin version: " + version + ".");
29028
29108
 
29029
29109
  exports.AbstractPlugin = AbstractPlugin;
@@ -29227,6 +29307,7 @@ exports.isWechatMiniApp = isWechatMiniApp;
29227
29307
  exports.itemFrag = itemFrag;
29228
29308
  exports.itemFrameFrag = itemFrameFrag;
29229
29309
  exports.itemVert = itemVert;
29310
+ exports.loadAVIFOptional = loadAVIFOptional;
29230
29311
  exports.loadBinary = loadBinary;
29231
29312
  exports.loadBlob = loadBlob;
29232
29313
  exports.loadImage = loadImage;