@galacean/effects-core 2.7.0-alpha.1 → 2.7.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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.7.0-alpha.1
6
+ * Version: v2.7.0-beta.0
7
7
  */
8
8
 
9
9
  'use strict';
@@ -3662,15 +3662,30 @@ var MaterialBlending;
3662
3662
  var TextOverflow;
3663
3663
  (function(TextOverflow) {
3664
3664
  /**
3665
- * display 模式下,会显示所有文本,文本大小会根据边界框调整。
3666
- */ TextOverflow[TextOverflow["display"] = 0] = "display";
3665
+ * visible 模式下,文本内容超出边界框时,会继续显示内容,不进行裁剪或缩放。
3666
+ */ TextOverflow[TextOverflow["visible"] = 0] = "visible";
3667
+ /**
3668
+ * display 模式下,会显示所有文本,文本字号大小会根据边界框调整。
3669
+ */ TextOverflow[TextOverflow["display"] = 1] = "display";
3667
3670
  /**
3668
3671
  * clip 模式下,当文本内容超出边界框时,多余的会被截断。
3669
- */ TextOverflow[TextOverflow["clip"] = 1] = "clip";
3672
+ */ TextOverflow[TextOverflow["clip"] = 2] = "clip";
3670
3673
  /**
3671
3674
  * ellipsis 模式下,会使用(...)来代替超出边界框的内容。
3672
- */ TextOverflow[TextOverflow["ellipsis"] = 2] = "ellipsis";
3675
+ */ TextOverflow[TextOverflow["ellipsis"] = 3] = "ellipsis";
3673
3676
  })(TextOverflow || (TextOverflow = {}));
3677
+ var TextSizeMode;
3678
+ (function(TextSizeMode) {
3679
+ /**
3680
+ * 自适应宽度
3681
+ */ TextSizeMode[TextSizeMode["autoWidth"] = 0] = "autoWidth";
3682
+ /**
3683
+ * 自适应高度
3684
+ */ TextSizeMode[TextSizeMode["autoHeight"] = 1] = "autoHeight";
3685
+ /**
3686
+ * 固定宽高
3687
+ */ TextSizeMode[TextSizeMode["fixed"] = 2] = "fixed";
3688
+ })(TextSizeMode || (TextSizeMode = {}));
3674
3689
  var TextBaseline;
3675
3690
  (function(TextBaseline) {
3676
3691
  /**
@@ -3734,20 +3749,21 @@ var BuiltinObjectGUID = {
3734
3749
  UnlitShader: "unlit000000000000000000000000000"
3735
3750
  };
3736
3751
 
3737
- /**
3738
- * 填充类型
3739
- */ var FillType;
3752
+ var FillType;
3740
3753
  (function(FillType) {
3741
- /**
3742
- * 纯色
3743
- */ FillType[FillType["Solid"] = 0] = "Solid";
3744
- /**
3745
- * 线性渐变
3746
- */ FillType[FillType["LinearGradient"] = 1] = "LinearGradient";
3747
- /**
3748
- * 径向渐变
3749
- */ FillType[FillType["RadialGradient"] = 2] = "RadialGradient";
3754
+ FillType[FillType["Solid"] = 0] = "Solid";
3755
+ FillType[FillType["GradientLinear"] = 1] = "GradientLinear";
3756
+ FillType[FillType["GradientRadial"] = 2] = "GradientRadial";
3757
+ FillType[FillType["GradientAngular"] = 3] = "GradientAngular";
3758
+ FillType[FillType["Texture"] = 4] = "Texture";
3750
3759
  })(FillType || (FillType = {}));
3760
+ var TexturePaintScaleMode;
3761
+ (function(TexturePaintScaleMode) {
3762
+ TexturePaintScaleMode[TexturePaintScaleMode["Fill"] = 0] = "Fill";
3763
+ TexturePaintScaleMode[TexturePaintScaleMode["Fit"] = 1] = "Fit";
3764
+ TexturePaintScaleMode[TexturePaintScaleMode["Crop"] = 2] = "Crop";
3765
+ TexturePaintScaleMode[TexturePaintScaleMode["Tile"] = 3] = "Tile";
3766
+ })(TexturePaintScaleMode || (TexturePaintScaleMode = {}));
3751
3767
 
3752
3768
  /**
3753
3769
  * 矢量图形类型
@@ -4011,12 +4027,14 @@ var index$1 = /*#__PURE__*/Object.freeze({
4011
4027
  get MaterialBlending () { return MaterialBlending; },
4012
4028
  get RenderMode3D () { return RenderMode3D; },
4013
4029
  get TextOverflow () { return TextOverflow; },
4030
+ get TextSizeMode () { return TextSizeMode; },
4014
4031
  get TextBaseline () { return TextBaseline; },
4015
4032
  get TextAlignment () { return TextAlignment; },
4016
4033
  get TextWeight () { return TextWeight; },
4017
4034
  get FontStyle () { return FontStyle; },
4018
4035
  BuiltinObjectGUID: BuiltinObjectGUID,
4019
4036
  get FillType () { return FillType; },
4037
+ get TexturePaintScaleMode () { return TexturePaintScaleMode; },
4020
4038
  get ShapePrimitiveType () { return ShapePrimitiveType; },
4021
4039
  get LineCap () { return LineCap; },
4022
4040
  get LineJoin () { return LineJoin; },
@@ -4124,10 +4142,16 @@ function getDirectStore(target) {
4124
4142
  * 反序列化函数
4125
4143
  *
4126
4144
  * @param data - 对象的序列化的数据
4127
- */ _proto.fromData = function fromData(data) {};
4145
+ */ _proto.fromData = function fromData(data) {
4146
+ if (data.id !== undefined) {
4147
+ this.setInstanceId(data.id);
4148
+ }
4149
+ };
4128
4150
  /**
4129
- *
4130
- */ _proto.dispose = function dispose() {};
4151
+ * 销毁当前对象
4152
+ */ _proto.dispose = function dispose() {
4153
+ this.engine.removeInstance(this.guid);
4154
+ };
4131
4155
  /**
4132
4156
  *
4133
4157
  * @param obj
@@ -5221,7 +5245,7 @@ var Pose = /*#__PURE__*/ function() {
5221
5245
  }
5222
5246
  for(var _iterator2 = _create_for_of_iterator_helper_loose(skeleton.defaultColorPropertyValues), _step2; !(_step2 = _iterator2()).done;){
5223
5247
  var defaultColor = _step2.value;
5224
- this.colorPropertyValues.push(defaultColor);
5248
+ this.colorPropertyValues.push(new Color().copyFrom(defaultColor));
5225
5249
  }
5226
5250
  }
5227
5251
  var _proto = Pose.prototype;
@@ -6696,7 +6720,7 @@ var Skeleton = /*#__PURE__*/ function() {
6696
6720
  break;
6697
6721
  case 1:
6698
6722
  this.colorAnimatedObjects.push(animatedObject);
6699
- this.defaultColorPropertyValues.push(directTarget[lastPropertyName]);
6723
+ this.defaultColorPropertyValues.push(new Color().copyFrom(directTarget[lastPropertyName]));
6700
6724
  this.pathToObjectIndex.set(totalPath, this.colorAnimatedObjects.length - 1);
6701
6725
  }
6702
6726
  };
@@ -6993,6 +7017,7 @@ function _create_class(Constructor, protoProps, staticProps) {
6993
7017
  if (this.item) {
6994
7018
  removeItem(this.item.components, this);
6995
7019
  }
7020
+ EffectsObject.prototype.dispose.call(this);
6996
7021
  };
6997
7022
  _proto.start = function start() {
6998
7023
  if (this.isStartCalled) {
@@ -12183,9 +12208,8 @@ var seed$7 = 1;
12183
12208
  this.destroyed = true;
12184
12209
  if (this.engine !== undefined) {
12185
12210
  this.engine.removeMesh(this);
12186
- // @ts-expect-error
12187
- this.engine = undefined;
12188
12211
  }
12212
+ RendererComponent.prototype.dispose.call(this);
12189
12213
  };
12190
12214
  _create_class(Mesh, [
12191
12215
  {
@@ -13341,8 +13365,6 @@ var seed$5 = 1;
13341
13365
  this.clearAction = clearAction;
13342
13366
  this.name = "RenderFrame" + seed$5++;
13343
13367
  var firstRP = renderPasses[0];
13344
- this.emptyTexture = generateWhiteTexture(engine);
13345
- this.transparentTexture = generateTransparentTexture(engine);
13346
13368
  this.camera = camera;
13347
13369
  this.keepColorBuffer = keepColorBuffer;
13348
13370
  this.renderPassInfoMap.set(firstRP, {
@@ -13391,8 +13413,6 @@ var seed$5 = 1;
13391
13413
  }
13392
13414
  this.passTextureCache.dispose();
13393
13415
  this._renderPasses.length = 0;
13394
- this.emptyTexture.dispose();
13395
- this.transparentTexture.dispose();
13396
13416
  if (this.resource) {
13397
13417
  var _this_resource_depthStencil_texture, _this_resource_depthStencil;
13398
13418
  this.resource.color_a.dispose();
@@ -14052,7 +14072,7 @@ var Renderer = /*#__PURE__*/ function() {
14052
14072
  _this.renderer = {
14053
14073
  renderMode: RenderMode.MESH,
14054
14074
  blending: BlendingMode.ALPHA,
14055
- texture: _this.engine.emptyTexture,
14075
+ texture: _this.engine.whiteTexture,
14056
14076
  occlusion: false,
14057
14077
  transparentOcclusion: false,
14058
14078
  side: SideMode.DOUBLE,
@@ -14260,7 +14280,7 @@ var Renderer = /*#__PURE__*/ function() {
14260
14280
  this.renderer = {
14261
14281
  renderMode: (_renderer_renderMode = renderer.renderMode) != null ? _renderer_renderMode : RenderMode.MESH,
14262
14282
  blending: (_renderer_blending = renderer.blending) != null ? _renderer_blending : BlendingMode.ALPHA,
14263
- texture: renderer.texture ? this.engine.findObject(renderer.texture) : this.engine.emptyTexture,
14283
+ texture: renderer.texture ? this.engine.findObject(renderer.texture) : this.engine.whiteTexture,
14264
14284
  occlusion: !!renderer.occlusion,
14265
14285
  transparentOcclusion: !!renderer.transparentOcclusion || this.maskManager.maskMode === exports.MaskMode.MASK,
14266
14286
  side: (_renderer_side = renderer.side) != null ? _renderer_side : SideMode.DOUBLE,
@@ -16104,20 +16124,26 @@ function oldBezierKeyFramesToNew(props) {
16104
16124
  keyDatas.push(keyData);
16105
16125
  lastControl = p2;
16106
16126
  }
16107
- var calculateSlop = function(p0, p1) {
16127
+ var calculateSlope = function(p0, p1) {
16108
16128
  return (p1.y - p0.y) / (p1.x - p0.x + NumberEpsilon);
16109
16129
  };
16110
16130
  for(var i1 = 0; i1 < keyDatas.length; i1++){
16111
16131
  var leftControl = keyDatas[i1].leftControl;
16112
16132
  var value = keyDatas[i1].value;
16113
16133
  var rightControl = keyDatas[i1].rightControl;
16114
- var outSlop = calculateSlop(value, rightControl);
16115
- var inSlop = calculateSlop(leftControl, value);
16134
+ var inSlope = 0;
16135
+ var outSlope = 0;
16136
+ if (i1 > 0) {
16137
+ inSlope = calculateSlope(leftControl, value);
16138
+ }
16139
+ if (i1 < keyDatas.length - 1) {
16140
+ outSlope = calculateSlope(value, rightControl);
16141
+ }
16116
16142
  var keyframe = {
16117
16143
  time: value.x,
16118
16144
  value: value.y,
16119
- inSlope: inSlop,
16120
- outSlope: outSlop,
16145
+ inSlope: inSlope,
16146
+ outSlope: outSlope,
16121
16147
  inWeight: 0,
16122
16148
  outWeight: 0,
16123
16149
  tangentMode: keyDatas[i1].tangentMode,
@@ -16240,16 +16266,8 @@ var ColorCurve = /*#__PURE__*/ function(ValueGetter) {
16240
16266
 
16241
16267
  var vert = "precision highp float;attribute vec3 aPos;attribute vec2 aUV;varying vec2 uv0;uniform mat4 effects_MatrixVP;uniform mat4 effects_MatrixInvV;uniform mat4 effects_ObjectToWorld;void main(){vec4 pos=vec4(aPos.xyz,1.0);uv0=aUV;gl_Position=effects_MatrixVP*effects_ObjectToWorld*pos;}";
16242
16268
 
16243
- var frag = "precision highp float;\n#define _MAX_STOPS 8\n#define PI 3.14159265359\nuniform vec4 _Color;uniform vec4 _Colors[_MAX_STOPS];uniform float _Stops[_MAX_STOPS];uniform int _StopsCount;uniform float _FillType;uniform vec2 _StartPoint;uniform vec2 _EndPoint;uniform sampler2D _ImageTex;uniform vec2 _ImageSize;uniform vec2 _DestSize;uniform int _ImageScaleMode;uniform mat3 _ImageTransform;uniform float _ImageScalingFactor;uniform float _ImageOpacity;varying vec2 uv0;vec4 smoothMix(vec4 a,vec4 b,float t){return mix(a,b,smoothstep(0.0,1.0,t));}float calculateAngleRatio(vec2 v1,vec2 v2){float angle=atan(v2.y,v2.x)-atan(v1.y,v1.x);if(angle<0.0)angle+=2.0*PI;return angle/(2.0*PI);}vec2 applyTransform(mat3 m,vec2 uv){vec3 p=m*vec3(uv,1.0);return p.xy;}void main(){vec4 finalColor=vec4(1.0);if(_FillType==0.0){finalColor=_Color;}else if(_FillType==1.0||_FillType==2.0||_FillType==3.0){float t=0.0;if(_FillType==1.0){vec2 gradientVector=_EndPoint-_StartPoint;vec2 pixelVector=uv0-_StartPoint;float denom=max(dot(gradientVector,gradientVector),1e-6);t=clamp(dot(pixelVector,gradientVector)/denom,0.0,1.0);}else if(_FillType==2.0){float maxRadius=max(distance(_EndPoint,_StartPoint),0.001);t=clamp(distance(uv0,_StartPoint)/maxRadius,0.0,1.0);}else{vec2 center=_StartPoint;vec2 referenceVector=_EndPoint-center;vec2 targetVector=uv0-center;if(length(targetVector)>0.001){t=calculateAngleRatio(referenceVector,targetVector);}}finalColor=_Colors[0];for(int i=1;i<_MAX_STOPS;i++){if(i>=_StopsCount)break;float prevStop=_Stops[i-1];float currStop=_Stops[i];if(t>=prevStop&&t<=currStop){float localT=(t-prevStop)/max(currStop-prevStop,1e-6);finalColor=smoothMix(_Colors[i-1],_Colors[i],localT);break;}}}else if(_FillType==4.0){vec2 uv=uv0;float rSrc=_ImageSize.x/max(_ImageSize.y,1.0);float rDst=_DestSize.x/max(_DestSize.y,1.0);bool maskOutside=false;if(_ImageScaleMode==0){vec2 scale=vec2(1.0);if(rDst>rSrc){scale=vec2(1.0,rSrc/rDst);}else{scale=vec2(rDst/rSrc,1.0);}uv=(uv-0.5)*scale+0.5;uv=clamp(uv,0.0,1.0);}else if(_ImageScaleMode==1){vec2 scale=vec2(1.0);if(rDst>rSrc){scale=vec2(rSrc/rDst,1.0);}else{scale=vec2(1.0,rSrc/rDst);}uv=(uv-0.5)*scale+0.5;maskOutside=true;}else if(_ImageScaleMode==2){uv=applyTransform(_ImageTransform,uv0);maskOutside=true;}else if(_ImageScaleMode==3){float aspectFix=rDst/max(rSrc,1e-6);vec2 uvTile=(uv0-0.5)*vec2(aspectFix,1.0)+0.5;float s=max(abs(_ImageScalingFactor),1e-6);uv=fract(uvTile*s);}vec4 img=texture2D(_ImageTex,uv);if(maskOutside){if(uv.x<0.0||uv.x>1.0||uv.y<0.0||uv.y>1.0){img.a=0.0;}}img.a*=_ImageOpacity;finalColor=img;}finalColor.rgb*=finalColor.a;gl_FragColor=finalColor;}";
16269
+ var frag = "precision highp float;\n#define _MAX_STOPS 8\n#define PI 3.14159265359\nuniform vec4 _Color;uniform vec4 _Colors[_MAX_STOPS];uniform float _Stops[_MAX_STOPS];uniform int _StopsCount;uniform float _FillType;uniform vec2 _StartPoint;uniform vec2 _EndPoint;uniform sampler2D _ImageTex;uniform vec2 _ImageSize;uniform vec2 _DestSize;uniform int _ImageScaleMode;uniform mat3 _TextureTransform;uniform float _ImageScalingFactor;uniform float _ImageOpacity;varying vec2 uv0;vec4 smoothMix(vec4 a,vec4 b,float t){return mix(a,b,smoothstep(0.0,1.0,t));}float calculateAngleRatio(vec2 v1,vec2 v2){float angle=atan(v2.y,v2.x)-atan(v1.y,v1.x);if(angle<0.0)angle+=2.0*PI;return angle/(2.0*PI);}vec2 applyTransform(mat3 m,vec2 uv){uv=uv-vec2(0.5,0.5);vec3 p=m*vec3(uv,1.0);p.xy=p.xy+vec2(0.5,0.5);return p.xy;}void main(){vec4 finalColor=vec4(1.0);if(_FillType==0.0){finalColor=_Color;}else if(_FillType==1.0||_FillType==2.0||_FillType==3.0){float t=0.0;if(_FillType==1.0){vec2 gradientVector=_EndPoint-_StartPoint;vec2 pixelVector=uv0-_StartPoint;float denom=max(dot(gradientVector,gradientVector),1e-6);t=clamp(dot(pixelVector,gradientVector)/denom,0.0,1.0);}else if(_FillType==2.0){float maxRadius=max(distance(_EndPoint,_StartPoint),0.001);t=clamp(distance(uv0,_StartPoint)/maxRadius,0.0,1.0);}else{vec2 center=_StartPoint;vec2 referenceVector=_EndPoint-center;vec2 targetVector=uv0-center;if(length(targetVector)>0.001){t=calculateAngleRatio(referenceVector,targetVector);}}finalColor=_Colors[0];for(int i=1;i<_MAX_STOPS;i++){if(i>=_StopsCount)break;float prevStop=_Stops[i-1];float currStop=_Stops[i];if(t>=prevStop&&t<=currStop){float localT=(t-prevStop)/max(currStop-prevStop,1e-6);finalColor=smoothMix(_Colors[i-1],_Colors[i],localT);break;}}}else if(_FillType==4.0){vec2 uv=uv0;float rSrc=_ImageSize.x/max(_ImageSize.y,1.0);float rDst=_DestSize.x/max(_DestSize.y,1.0);bool maskOutside=false;if(_ImageScaleMode==0){vec2 scale=vec2(1.0);if(rDst>rSrc){scale=vec2(1.0,rSrc/rDst);}else{scale=vec2(rDst/rSrc,1.0);}uv=(uv-0.5)*scale+0.5;uv=clamp(uv,0.0,1.0);}else if(_ImageScaleMode==1){vec2 scale=vec2(1.0);if(rDst>rSrc){scale=vec2(rSrc/rDst,1.0);}else{scale=vec2(1.0,rSrc/rDst);}uv=(uv-0.5)*scale+0.5;maskOutside=true;}else if(_ImageScaleMode==2){uv=applyTransform(_TextureTransform,uv0);maskOutside=true;}else if(_ImageScaleMode==3){float aspectFix=rDst/max(rSrc,1e-6);vec2 uvTile=(uv0-0.5)*vec2(aspectFix,1.0)+0.5;float s=max(abs(_ImageScalingFactor),1e-6);uv=fract(uvTile*s);}vec4 img=texture2D(_ImageTex,uv);if(maskOutside){if(uv.x<0.0||uv.x>1.0||uv.y<0.0||uv.y>1.0){img.a=0.0;}}img.a*=_ImageOpacity;finalColor=img;}finalColor.rgb*=finalColor.a;gl_FragColor=finalColor;}";
16244
16270
 
16245
- exports.FillType = void 0;
16246
- (function(FillType) {
16247
- FillType[FillType["Solid"] = 0] = "Solid";
16248
- FillType[FillType["GradientLinear"] = 1] = "GradientLinear";
16249
- FillType[FillType["GradientRadial"] = 2] = "GradientRadial";
16250
- FillType[FillType["GradientAngular"] = 3] = "GradientAngular";
16251
- FillType[FillType["Texture"] = 4] = "Texture";
16252
- })(exports.FillType || (exports.FillType = {}));
16253
16271
  exports.TexturePaintScaleMode = void 0;
16254
16272
  (function(TexturePaintScaleMode) {
16255
16273
  TexturePaintScaleMode[TexturePaintScaleMode["Fill"] = 0] = "Fill";
@@ -16262,8 +16280,6 @@ exports.ShapeComponent = /*#__PURE__*/ function(RendererComponent) {
16262
16280
  function ShapeComponent(engine) {
16263
16281
  var _this;
16264
16282
  _this = RendererComponent.call(this, engine) || this;
16265
- _this.hasStroke = false;
16266
- _this.hasFill = false;
16267
16283
  _this.shapeDirty = true;
16268
16284
  _this.materialDirty = true;
16269
16285
  _this.graphicsPath = new GraphicsPath();
@@ -16275,10 +16291,15 @@ exports.ShapeComponent = /*#__PURE__*/ function(RendererComponent) {
16275
16291
  join: LineJoin.Miter,
16276
16292
  miterLimit: 10
16277
16293
  };
16294
+ _this.strokeWidth = 1;
16295
+ _this.strokeCap = LineCap.Butt;
16296
+ _this.strokeJoin = LineJoin.Miter;
16278
16297
  _this.strokes = [];
16279
16298
  /**
16280
16299
  * 用于点击测试的碰撞器
16281
16300
  */ _this.meshCollider = new MeshCollider();
16301
+ _this.fillMaterials = [];
16302
+ _this.strokeMaterials = [];
16282
16303
  _this.getHitTestParams = function(force) {
16283
16304
  var sizeMatrix = Matrix4.fromScale(_this.transform.size.x, _this.transform.size.y, 1);
16284
16305
  var worldMatrix = sizeMatrix.premultiply(_this.transform.getWorldMatrix());
@@ -16290,15 +16311,15 @@ exports.ShapeComponent = /*#__PURE__*/ function(RendererComponent) {
16290
16311
  behavior: 0,
16291
16312
  type: area.type,
16292
16313
  triangles: area.area,
16293
- backfaceCulling: _this.renderer.side === SideMode.FRONT
16314
+ backfaceCulling: _this.rendererOptions.side === SideMode.FRONT
16294
16315
  };
16295
16316
  }
16296
16317
  }
16297
16318
  };
16298
- _this.renderer = {
16319
+ _this.rendererOptions = {
16299
16320
  renderMode: RenderMode.MESH,
16300
16321
  blending: BlendingMode.ALPHA,
16301
- texture: _this.engine.emptyTexture,
16322
+ texture: _this.engine.whiteTexture,
16302
16323
  occlusion: false,
16303
16324
  transparentOcclusion: false,
16304
16325
  side: SideMode.DOUBLE,
@@ -16308,12 +16329,12 @@ exports.ShapeComponent = /*#__PURE__*/ function(RendererComponent) {
16308
16329
  // Create Shape Attrributes
16309
16330
  //-------------------------------------------------------------------------
16310
16331
  var gradientStrokeFill = {
16311
- type: 0,
16332
+ type: FillType.Solid,
16312
16333
  color: new Color(1, 1, 1, 1)
16313
16334
  };
16314
16335
  _this.strokes.push(gradientStrokeFill);
16315
16336
  var gradientLayerFill = {
16316
- type: 0,
16337
+ type: FillType.Solid,
16317
16338
  color: new Color(1, 1, 1, 1)
16318
16339
  };
16319
16340
  _this.fills.push(gradientLayerFill);
@@ -16386,25 +16407,6 @@ exports.ShapeComponent = /*#__PURE__*/ function(RendererComponent) {
16386
16407
  indexCount: 0,
16387
16408
  vertexCount: 0
16388
16409
  });
16389
- // Create Material
16390
- //-------------------------------------------------------------------------
16391
- var materialProps = {
16392
- shader: {
16393
- vertex: vert,
16394
- fragment: frag,
16395
- glslVersion: exports.GLSLVersion.GLSL1
16396
- }
16397
- };
16398
- var fillMaterial = Material.create(engine, materialProps);
16399
- var strokeMaterial = Material.create(engine, materialProps);
16400
- fillMaterial.depthMask = false;
16401
- fillMaterial.depthTest = true;
16402
- fillMaterial.blending = true;
16403
- _this.material = fillMaterial;
16404
- strokeMaterial.depthMask = false;
16405
- strokeMaterial.depthTest = true;
16406
- strokeMaterial.blending = true;
16407
- _this.materials[1] = strokeMaterial;
16408
16410
  return _this;
16409
16411
  }
16410
16412
  var _proto = ShapeComponent.prototype;
@@ -16432,18 +16434,26 @@ exports.ShapeComponent = /*#__PURE__*/ function(RendererComponent) {
16432
16434
  if (!this.isActiveAndEnabled) {
16433
16435
  return;
16434
16436
  }
16435
- var previousColorMask0 = this.material.colorMask;
16436
- var previousColorMask1 = this.materials[1].colorMask;
16437
- this.material.colorMask = false;
16438
- this.materials[1].colorMask = false;
16439
- this.draw(renderer);
16440
- this.material.colorMask = previousColorMask0;
16441
- this.materials[1].colorMask = previousColorMask1;
16437
+ var previousColorMask = false;
16438
+ for(var i = 0; i < this.fillMaterials.length; i++){
16439
+ previousColorMask = this.fillMaterials[i].colorMask;
16440
+ this.fillMaterials[i].colorMask = false;
16441
+ renderer.drawGeometry(this.geometry, this.transform.getWorldMatrix(), this.fillMaterials[i], 0);
16442
+ this.fillMaterials[i].colorMask = previousColorMask;
16443
+ }
16444
+ for(var i1 = 0; i1 < this.strokeMaterials.length; i1++){
16445
+ previousColorMask = this.strokeMaterials[i1].colorMask;
16446
+ this.strokeMaterials[i1].colorMask = false;
16447
+ renderer.drawGeometry(this.geometry, this.transform.getWorldMatrix(), this.strokeMaterials[i1], 1);
16448
+ this.strokeMaterials[i1].colorMask = previousColorMask;
16449
+ }
16442
16450
  };
16443
16451
  _proto.draw = function draw(renderer) {
16444
- for(var i = 0; i < this.materials.length; i++){
16445
- var material = this.materials[i];
16446
- renderer.drawGeometry(this.geometry, this.transform.getWorldMatrix(), material, i);
16452
+ for(var i = 0; i < this.fillMaterials.length; i++){
16453
+ renderer.drawGeometry(this.geometry, this.transform.getWorldMatrix(), this.fillMaterials[i], 0);
16454
+ }
16455
+ for(var i1 = 0; i1 < this.strokeMaterials.length; i1++){
16456
+ renderer.drawGeometry(this.geometry, this.transform.getWorldMatrix(), this.strokeMaterials[i1], 1);
16447
16457
  }
16448
16458
  };
16449
16459
  _proto.getBoundingBox = function getBoundingBox() {
@@ -16457,7 +16467,7 @@ exports.ShapeComponent = /*#__PURE__*/ function(RendererComponent) {
16457
16467
  var vertices = [];
16458
16468
  var indices = [];
16459
16469
  // Triangulate shapePrimitives, build fill and stroke shape geometry
16460
- if (this.hasFill) {
16470
+ if (this.fills.length > 0) {
16461
16471
  for(var _iterator = _create_for_of_iterator_helper_loose(shapePrimitives), _step; !(_step = _iterator()).done;){
16462
16472
  var shapePrimitive = _step.value;
16463
16473
  var shape = shapePrimitive.shape;
@@ -16469,7 +16479,7 @@ exports.ShapeComponent = /*#__PURE__*/ function(RendererComponent) {
16469
16479
  }
16470
16480
  }
16471
16481
  var fillIndexCount = indices.length;
16472
- if (this.hasStroke) {
16482
+ if (this.strokes.length > 0) {
16473
16483
  for(var _iterator1 = _create_for_of_iterator_helper_loose(shapePrimitives), _step1; !(_step1 = _iterator1()).done;){
16474
16484
  var shapePrimitive1 = _step1.value;
16475
16485
  var shape1 = shapePrimitive1.shape;
@@ -16477,6 +16487,9 @@ exports.ShapeComponent = /*#__PURE__*/ function(RendererComponent) {
16477
16487
  indices.length;
16478
16488
  var vertOffset1 = vertices.length / 2;
16479
16489
  var lineStyle = this.strokeAttributes;
16490
+ lineStyle.cap = this.strokeCap;
16491
+ lineStyle.join = this.strokeJoin;
16492
+ lineStyle.width = this.strokeWidth;
16480
16493
  var close = true;
16481
16494
  if (this.shapeAttributes.type === ShapePrimitiveType.Custom) {
16482
16495
  close = shape1.closePath;
@@ -16604,48 +16617,20 @@ exports.ShapeComponent = /*#__PURE__*/ function(RendererComponent) {
16604
16617
  }
16605
16618
  };
16606
16619
  _proto.updateMaterials = function updateMaterials() {
16607
- for(var _iterator = _create_for_of_iterator_helper_loose(this.materials), _step; !(_step = _iterator()).done;){
16608
- var material = _step.value;
16609
- var renderer = this.renderer;
16610
- var side = renderer.side, occlusion = renderer.occlusion, blendMode = renderer.blending, mask = renderer.mask, texture = renderer.texture;
16611
- var maskMode = this.maskManager.maskMode;
16612
- material.blending = true;
16613
- material.depthTest = true;
16614
- material.depthMask = occlusion;
16615
- material.stencilRef = mask !== undefined ? [
16616
- mask,
16617
- mask
16618
- ] : undefined;
16619
- setBlendMode(material, blendMode);
16620
- // 兼容旧数据中模板需要渲染的情况
16621
- setMaskMode(material, maskMode);
16622
- setSideMode(material, side);
16623
- material.shader.shaderData.properties = '_MainTex("_MainTex",2D) = "white" {}';
16624
- material.setVector4("_TexOffset", new Vector4(0, 0, 1, 1));
16625
- material.setTexture("_MainTex", texture);
16626
- var preMultiAlpha = getPreMultiAlpha(blendMode);
16627
- var texParams = new Vector4();
16628
- texParams.x = renderer.occlusion ? +renderer.transparentOcclusion : 1;
16629
- texParams.y = preMultiAlpha;
16630
- texParams.z = renderer.renderMode;
16631
- texParams.w = maskMode;
16632
- material.setVector4("_TexParams", texParams);
16633
- if (texParams.x === 0 || this.maskManager.alphaMaskEnabled) {
16634
- material.enableMacro("ALPHA_CLIP");
16635
- } else {
16636
- material.disableMacro("ALPHA_CLIP");
16637
- }
16620
+ for(var i = 0; i < this.fills.length; i++){
16621
+ this.updatePaintMaterial(this.fillMaterials[i], this.fills[i]);
16622
+ }
16623
+ for(var i1 = 0; i1 < this.strokes.length; i1++){
16624
+ this.updatePaintMaterial(this.strokeMaterials[i1], this.strokes[i1]);
16638
16625
  }
16639
- this.updatePaintMaterial(this.material, this.fills[0]);
16640
- this.updatePaintMaterial(this.materials[1], this.strokes[0]);
16641
16626
  };
16642
16627
  _proto.updatePaintMaterial = function updatePaintMaterial(material, paint) {
16643
16628
  material.setFloat("_FillType", paint.type);
16644
- if (paint.type === 0) {
16629
+ if (paint.type === FillType.Solid) {
16645
16630
  material.color = paint.color;
16646
- } else if (paint.type === 1 || paint.type === 3 || paint.type === 2) {
16631
+ } else if (paint.type === FillType.GradientLinear || paint.type === FillType.GradientAngular || paint.type === FillType.GradientRadial) {
16647
16632
  this.updateGradientMaterial(material, paint.gradientStops, paint.startPoint, paint.endPoint);
16648
- } else if (paint.type === 4) {
16633
+ } else if (paint.type === FillType.Texture) {
16649
16634
  material.setInt("_ImageScaleMode", paint.scaleMode);
16650
16635
  material.setVector2("_ImageSize", new Vector2(paint.texture.getWidth(), paint.texture.getHeight()));
16651
16636
  var boundingBox = this.getBoundingBox();
@@ -16655,6 +16640,8 @@ exports.ShapeComponent = /*#__PURE__*/ function(RendererComponent) {
16655
16640
  material.setFloat("_ImageOpacity", paint.opacity);
16656
16641
  material.setFloat("_ImageScalingFactor", paint.scalingFactor);
16657
16642
  material.setTexture("_ImageTex", paint.texture);
16643
+ var transform = paint.textureTransform;
16644
+ material.setMatrix3("_TextureTransform", new Matrix3().scale(transform.scale.x, transform.scale.y).rotate(transform.rotation).translate(transform.offset.x, transform.offset.y).invert());
16658
16645
  }
16659
16646
  };
16660
16647
  _proto.updateGradientMaterial = function updateGradientMaterial(material, gradient, startPoint, endPoint) {
@@ -16672,6 +16659,46 @@ exports.ShapeComponent = /*#__PURE__*/ function(RendererComponent) {
16672
16659
  material.setVector2("_StartPoint", startPoint);
16673
16660
  material.setVector2("_EndPoint", endPoint);
16674
16661
  };
16662
+ _proto.createMaterialFromRendererOptions = function createMaterialFromRendererOptions(rendererOptions) {
16663
+ var materialProps = {
16664
+ shader: {
16665
+ vertex: vert,
16666
+ fragment: frag,
16667
+ glslVersion: exports.GLSLVersion.GLSL1
16668
+ }
16669
+ };
16670
+ var material = Material.create(this.engine, materialProps);
16671
+ var renderer = rendererOptions;
16672
+ var side = renderer.side, occlusion = renderer.occlusion, blendMode = renderer.blending, mask = renderer.mask, texture = renderer.texture;
16673
+ var maskMode = this.maskManager.maskMode;
16674
+ material.blending = true;
16675
+ material.depthTest = true;
16676
+ material.depthMask = occlusion;
16677
+ material.stencilRef = mask !== undefined ? [
16678
+ mask,
16679
+ mask
16680
+ ] : undefined;
16681
+ setBlendMode(material, blendMode);
16682
+ // 兼容旧数据中模板需要渲染的情况
16683
+ setMaskMode(material, maskMode);
16684
+ setSideMode(material, side);
16685
+ material.shader.shaderData.properties = '_ImageTex("_ImageTex",2D) = "white" {}';
16686
+ material.setVector4("_TexOffset", new Vector4(0, 0, 1, 1));
16687
+ material.setTexture("_ImageTex", texture);
16688
+ var preMultiAlpha = getPreMultiAlpha(blendMode);
16689
+ var texParams = new Vector4();
16690
+ texParams.x = renderer.occlusion ? +renderer.transparentOcclusion : 1;
16691
+ texParams.y = preMultiAlpha;
16692
+ texParams.z = renderer.renderMode;
16693
+ texParams.w = maskMode;
16694
+ material.setVector4("_TexParams", texParams);
16695
+ if (texParams.x === 0 || this.maskManager.alphaMaskEnabled) {
16696
+ material.enableMacro("ALPHA_CLIP");
16697
+ } else {
16698
+ material.disableMacro("ALPHA_CLIP");
16699
+ }
16700
+ return material;
16701
+ };
16675
16702
  _proto.fromData = function fromData(data) {
16676
16703
  RendererComponent.prototype.fromData.call(this, data);
16677
16704
  this.shapeDirty = true;
@@ -16680,44 +16707,37 @@ exports.ShapeComponent = /*#__PURE__*/ function(RendererComponent) {
16680
16707
  }
16681
16708
  var _data_renderer;
16682
16709
  var renderer = (_data_renderer = data.renderer) != null ? _data_renderer : {};
16683
- var _renderer_renderMode, _renderer_blending, _renderer_side;
16684
- this.renderer = {
16685
- renderMode: (_renderer_renderMode = renderer.renderMode) != null ? _renderer_renderMode : RenderMode.MESH,
16710
+ var _renderer_blending, _renderer_side;
16711
+ this.rendererOptions = {
16712
+ renderMode: RenderMode.MESH,
16686
16713
  blending: (_renderer_blending = renderer.blending) != null ? _renderer_blending : BlendingMode.ALPHA,
16687
- texture: renderer.texture ? this.engine.findObject(renderer.texture) : this.engine.emptyTexture,
16714
+ texture: renderer.texture ? this.engine.findObject(renderer.texture) : this.engine.whiteTexture,
16688
16715
  occlusion: !!renderer.occlusion,
16689
16716
  transparentOcclusion: !!renderer.transparentOcclusion || this.maskManager.maskMode === exports.MaskMode.MASK,
16690
16717
  side: (_renderer_side = renderer.side) != null ? _renderer_side : SideMode.DOUBLE,
16691
16718
  mask: this.maskManager.getRefValue()
16692
16719
  };
16693
- var strokeAttributes = data.stroke;
16694
- if (strokeAttributes) {
16695
- this.strokeAttributes = {
16696
- width: strokeAttributes.width,
16697
- alignment: 0.5,
16698
- cap: strokeAttributes.cap,
16699
- join: strokeAttributes.join,
16700
- miterLimit: 10
16701
- };
16702
- }
16703
- //@ts-expect-error
16704
- for(var _iterator = _create_for_of_iterator_helper_loose(data.strokes), _step; !(_step = _iterator()).done;){
16705
- var stroke = _step.value;
16706
- var strokeParam = stroke;
16707
- if (strokeParam) {
16708
- this.hasStroke = true;
16709
- this.strokes[0] = this.createPaint(strokeParam);
16710
- }
16711
- }
16712
- //@ts-expect-error
16713
- for(var _iterator1 = _create_for_of_iterator_helper_loose(data.fills), _step1; !(_step1 = _iterator1()).done;){
16714
- var fill = _step1.value;
16715
- var fillParam = fill;
16716
- if (fillParam) {
16717
- this.hasFill = true;
16718
- this.fills[0] = this.createPaint(fillParam);
16719
- }
16720
- }
16720
+ var _data_strokeCap;
16721
+ this.strokeCap = (_data_strokeCap = data.strokeCap) != null ? _data_strokeCap : LineCap.Butt;
16722
+ var _data_strokeWidth;
16723
+ this.strokeWidth = (_data_strokeWidth = data.strokeWidth) != null ? _data_strokeWidth : 1;
16724
+ var _data_strokeJoin;
16725
+ this.strokeJoin = (_data_strokeJoin = data.strokeJoin) != null ? _data_strokeJoin : LineJoin.Miter;
16726
+ this.fills.length = 0;
16727
+ this.fillMaterials.length = 0;
16728
+ for(var _iterator = _create_for_of_iterator_helper_loose(data.fills), _step; !(_step = _iterator()).done;){
16729
+ var fill = _step.value;
16730
+ this.fills.push(this.createPaint(fill));
16731
+ this.fillMaterials.push(this.createMaterialFromRendererOptions(this.rendererOptions));
16732
+ }
16733
+ this.strokes.length = 0;
16734
+ this.strokeMaterials.length = 0;
16735
+ for(var _iterator1 = _create_for_of_iterator_helper_loose(data.strokes), _step1; !(_step1 = _iterator1()).done;){
16736
+ var stroke = _step1.value;
16737
+ this.strokes.push(this.createPaint(stroke));
16738
+ this.strokeMaterials.push(this.createMaterialFromRendererOptions(this.rendererOptions));
16739
+ }
16740
+ this.materials = [].concat(this.fillMaterials, this.strokeMaterials);
16721
16741
  switch(data.type){
16722
16742
  case ShapePrimitiveType.Custom:
16723
16743
  {
@@ -16799,7 +16819,7 @@ exports.ShapeComponent = /*#__PURE__*/ function(RendererComponent) {
16799
16819
  _proto.createPaint = function createPaint(paintData) {
16800
16820
  var paint;
16801
16821
  switch(paintData.type){
16802
- case 0:
16822
+ case FillType.Solid:
16803
16823
  {
16804
16824
  paint = {
16805
16825
  type: paintData.type,
@@ -16807,9 +16827,9 @@ exports.ShapeComponent = /*#__PURE__*/ function(RendererComponent) {
16807
16827
  };
16808
16828
  break;
16809
16829
  }
16810
- case 1:
16811
- case 3:
16812
- case 2:
16830
+ case FillType.GradientLinear:
16831
+ case FillType.GradientAngular:
16832
+ case FillType.GradientRadial:
16813
16833
  {
16814
16834
  paint = {
16815
16835
  type: paintData.type,
@@ -16819,15 +16839,32 @@ exports.ShapeComponent = /*#__PURE__*/ function(RendererComponent) {
16819
16839
  };
16820
16840
  break;
16821
16841
  }
16822
- case 4:
16842
+ case FillType.Texture:
16823
16843
  {
16844
+ var _paintData_textureTransform;
16845
+ var textureTransform = _extends({
16846
+ offset: {
16847
+ x: 0,
16848
+ y: 0
16849
+ },
16850
+ rotation: 0,
16851
+ scale: {
16852
+ x: 1,
16853
+ y: 1
16854
+ }
16855
+ }, (_paintData_textureTransform = paintData.textureTransform) != null ? _paintData_textureTransform : {});
16824
16856
  var _paintData_scalingFactor, _paintData_opacity;
16825
16857
  paint = {
16826
16858
  type: paintData.type,
16827
16859
  texture: this.engine.findObject(paintData.texture),
16828
16860
  scaleMode: paintData.scaleMode,
16829
16861
  scalingFactor: (_paintData_scalingFactor = paintData.scalingFactor) != null ? _paintData_scalingFactor : 1,
16830
- opacity: (_paintData_opacity = paintData.opacity) != null ? _paintData_opacity : 1
16862
+ opacity: (_paintData_opacity = paintData.opacity) != null ? _paintData_opacity : 1,
16863
+ textureTransform: {
16864
+ offset: new Vector2().copyFrom(textureTransform.offset),
16865
+ rotation: textureTransform.rotation,
16866
+ scale: new Vector2().copyFrom(textureTransform.scale)
16867
+ }
16831
16868
  };
16832
16869
  break;
16833
16870
  }
@@ -17218,11 +17255,11 @@ var vertex = "\nprecision highp float;\n\nattribute vec2 aPoint;\nuniform vec4 u
17218
17255
  var fragment = "\nprecision highp float;\n\n#define fragColor gl_FragColor\n\nvarying vec4 vColor;\nvoid main() {\n gl_FragColor = vColor*vColor.a;\n}\n";
17219
17256
  var seed$4 = 1;
17220
17257
  var InteractMesh = /*#__PURE__*/ function() {
17221
- function InteractMesh(props, rendererOptions, transform, engine) {
17258
+ function InteractMesh(props, transform, engine) {
17222
17259
  this.transform = transform;
17223
17260
  this.engine = engine;
17224
17261
  this.color = props.options.previewColor;
17225
- var material = this.createMaterial(rendererOptions);
17262
+ var material = this.createMaterial();
17226
17263
  var geometry = this.createGeometry();
17227
17264
  this.mesh = this.createMesh(geometry, material);
17228
17265
  this.updateMesh();
@@ -17245,7 +17282,7 @@ var InteractMesh = /*#__PURE__*/ function() {
17245
17282
  material.setVector4("uPos", uPos);
17246
17283
  material.setQuaternion("uQuat", tempQuat);
17247
17284
  };
17248
- _proto.createMaterial = function createMaterial(rendererOptions) {
17285
+ _proto.createMaterial = function createMaterial() {
17249
17286
  var _this_engine_renderer;
17250
17287
  var macros = [
17251
17288
  [
@@ -17259,7 +17296,6 @@ var InteractMesh = /*#__PURE__*/ function() {
17259
17296
  vertex: vertex,
17260
17297
  fragment: fragment,
17261
17298
  glslVersion: exports.GLSLVersion.GLSL1,
17262
- cacheId: "" + rendererOptions.cachePrefix + "_effects_interact",
17263
17299
  macros: macros
17264
17300
  }
17265
17301
  };
@@ -17381,19 +17417,33 @@ exports.InteractComponent = /*#__PURE__*/ function(RendererComponent) {
17381
17417
  return _this;
17382
17418
  }
17383
17419
  var _proto = InteractComponent.prototype;
17384
- _proto.getDragRangeX = function getDragRangeX() {
17420
+ /**
17421
+ * 获取拖拽范围 X 轴
17422
+ * @returns 拖拽范围 [min, max]
17423
+ */ _proto.getDragRangeX = function getDragRangeX() {
17385
17424
  return this.dragRange.dxRange;
17386
17425
  };
17387
- _proto.setDragRangeX = function setDragRangeX(min, max) {
17426
+ /**
17427
+ * 设置拖拽范围 X 轴
17428
+ * @param min 最小值
17429
+ * @param max 最大值
17430
+ */ _proto.setDragRangeX = function setDragRangeX(min, max) {
17388
17431
  this.dragRange.dxRange = [
17389
17432
  min,
17390
17433
  max
17391
17434
  ];
17392
17435
  };
17393
- _proto.getDragRangeY = function getDragRangeY() {
17436
+ /**
17437
+ * 获取拖拽范围 Y 轴
17438
+ * @returns 拖拽范围 [min, max]
17439
+ */ _proto.getDragRangeY = function getDragRangeY() {
17394
17440
  return this.dragRange.dyRange;
17395
17441
  };
17396
- _proto.setDragRangeY = function setDragRangeY(min, max) {
17442
+ /**
17443
+ * 设置拖拽范围 Y 轴
17444
+ * @param min 最小值
17445
+ * @param max 最大值
17446
+ */ _proto.setDragRangeY = function setDragRangeY(min, max) {
17397
17447
  this.dragRange.dyRange = [
17398
17448
  min,
17399
17449
  max
@@ -17401,15 +17451,11 @@ exports.InteractComponent = /*#__PURE__*/ function(RendererComponent) {
17401
17451
  };
17402
17452
  _proto.onStart = function onStart() {
17403
17453
  var env = this.item.engine.renderer.env;
17404
- var composition = this.item.composition;
17405
17454
  var _this_interactData_options = this.interactData.options, type = _this_interactData_options.type, showPreview = _this_interactData_options.showPreview;
17406
17455
  if (type === InteractType.CLICK) {
17407
17456
  this.clickable = true;
17408
17457
  if (showPreview && env === PLAYER_OPTIONS_ENV_EDITOR) {
17409
- var rendererOptions = composition == null ? void 0 : composition.getRendererOptions();
17410
- if (rendererOptions !== undefined) {
17411
- this.previewContent = new InteractMesh(this.item.props.content, rendererOptions, this.transform, this.engine);
17412
- }
17458
+ this.previewContent = new InteractMesh(this.item.props.content, this.transform, this.engine);
17413
17459
  }
17414
17460
  }
17415
17461
  if (this.previewContent) {
@@ -17618,7 +17664,10 @@ exports.InteractComponent = /*#__PURE__*/ function(RendererComponent) {
17618
17664
  }
17619
17665
  }
17620
17666
  };
17621
- _proto.canInteract = function canInteract() {
17667
+ /**
17668
+ * 是否可以交互
17669
+ * @returns
17670
+ */ _proto.canInteract = function canInteract() {
17622
17671
  var _this_item_composition;
17623
17672
  return Boolean((_this_item_composition = this.item.composition) == null ? void 0 : _this_item_composition.interactive) && this._interactive;
17624
17673
  };
@@ -17653,7 +17702,9 @@ exports.InteractComponent = /*#__PURE__*/ function(RendererComponent) {
17653
17702
  get: function get() {
17654
17703
  return this._interactive;
17655
17704
  },
17656
- set: function set(enable) {
17705
+ set: /**
17706
+ * 是否响应点击和拖拽交互事件
17707
+ */ function set(enable) {
17657
17708
  this._interactive = enable;
17658
17709
  if (!enable) {
17659
17710
  // 立刻停止惯性滑动
@@ -18410,6 +18461,12 @@ var tmpScale = new Vector3(1, 1, 1);
18410
18461
  this./**
18411
18462
  * @internal
18412
18463
  */ transform = new Transform();
18464
+ this./**
18465
+ * 画布的像素宽度
18466
+ */ pixelWidth = 0;
18467
+ this./**
18468
+ * 画布的像素高度
18469
+ */ pixelHeight = 0;
18413
18470
  this.viewportMatrix = Matrix4.fromIdentity();
18414
18471
  this.viewMatrix = Matrix4.fromIdentity();
18415
18472
  this.projectionMatrix = Matrix4.fromIdentity();
@@ -18424,7 +18481,7 @@ var tmpScale = new Vector3(1, 1, 1);
18424
18481
  0,
18425
18482
  0,
18426
18483
  0
18427
- ] : _options_rotation;
18484
+ ] : _options_rotation, _options_pixelWidth = options.pixelWidth, pixelWidth = _options_pixelWidth === void 0 ? 0 : _options_pixelWidth, _options_pixelHeight = options.pixelHeight, pixelHeight = _options_pixelHeight === void 0 ? 0 : _options_pixelHeight;
18428
18485
  var euler = new Euler(rotation[0], rotation[1], rotation[2]);
18429
18486
  var quat = new Quaternion().setFromEuler(euler);
18430
18487
  this.options = {
@@ -18434,6 +18491,8 @@ var tmpScale = new Vector3(1, 1, 1);
18434
18491
  aspect: aspect,
18435
18492
  clipMode: clipMode
18436
18493
  };
18494
+ this.pixelWidth = pixelWidth;
18495
+ this.pixelHeight = pixelHeight;
18437
18496
  this.transform.setPosition(position[0], position[1], position[2]);
18438
18497
  this.transform.setQuaternion(quat.x, quat.y, quat.z, quat.w);
18439
18498
  this.dirty = true;
@@ -18580,6 +18639,48 @@ var tmpScale = new Vector3(1, 1, 1);
18580
18639
  this.dirty = false;
18581
18640
  }
18582
18641
  };
18642
+ /**
18643
+ * 将世界坐标转换为屏幕像素坐标
18644
+ * @param position - 世界坐标
18645
+ * @param out - 输出的屏幕坐标,如果不传则创建新的 Vector3
18646
+ * @returns 屏幕坐标 (x, y 为像素坐标,左下角为(0,0),右上角为(width,height),z 为深度比例 [0,1],0=近平面,1=远平面)
18647
+ */ _proto.worldToScreenPoint = function worldToScreenPoint(position, out) {
18648
+ this.updateMatrix();
18649
+ var result = out != null ? out : new Vector3();
18650
+ var vpMatrix = this.getViewProjectionMatrix();
18651
+ // 应用视图投影矩阵,得到 NDC 坐标 [-1, 1]
18652
+ result.set(position.x, position.y, position.z);
18653
+ vpMatrix.projectPoint(result, result);
18654
+ // 将 NDC 坐标转换为像素坐标
18655
+ // NDC: x,y in [-1, 1], 其中 (-1,-1) 是左下角,(1,1) 是右上角
18656
+ // Screen: x,y in [0, width/height], 其中 (0,0) 是左下角
18657
+ result.x = (result.x + 1) * 0.5 * this.pixelWidth;
18658
+ result.y = (result.y + 1) * 0.5 * this.pixelHeight;
18659
+ // 将 NDC z 值从 [-1, 1] 转换为深度比例 [0, 1]
18660
+ // -1 (近平面) -> 0, 1 (远平面) -> 1
18661
+ result.z = (result.z + 1) * 0.5;
18662
+ return result;
18663
+ };
18664
+ /**
18665
+ * 将屏幕像素坐标转换为世界坐标
18666
+ * @param position - 屏幕坐标 (x, y 为像素坐标,左下角为(0,0),z 为深度比例 [0,1],0=近平面,1=远平面)
18667
+ * @param out - 输出的世界坐标,如果不传则创建新的 Vector3
18668
+ * @returns 世界坐标
18669
+ */ _proto.screenToWorldPoint = function screenToWorldPoint(position, out) {
18670
+ this.updateMatrix();
18671
+ var result = out != null ? out : new Vector3();
18672
+ var invVPMatrix = this.getInverseViewProjectionMatrix();
18673
+ // 将像素坐标转换为 NDC 坐标 [-1, 1]
18674
+ var ndcX = position.x / this.pixelWidth * 2 - 1;
18675
+ var ndcY = position.y / this.pixelHeight * 2 - 1;
18676
+ // 将深度比例 [0, 1] 转换为 NDC z 值 [-1, 1]
18677
+ // 0 (近平面) -> -1, 1 (远平面) -> 1
18678
+ var ndcZ = position.z * 2 - 1;
18679
+ // 应用逆视图投影矩阵
18680
+ result.set(ndcX, ndcY, ndcZ);
18681
+ invVPMatrix.projectPoint(result, result);
18682
+ return result;
18683
+ };
18583
18684
  _create_class(Camera, [
18584
18685
  {
18585
18686
  key: "near",
@@ -21441,7 +21542,6 @@ function modifyMaxKeyframeShader(shader, maxVertex, maxFrag) {
21441
21542
  var _proto = ParticleSystemRenderer.prototype;
21442
21543
  _proto.onStart = function onStart() {
21443
21544
  this._priority = this.item.renderOrder;
21444
- this.particleMesh.gravityModifier.scaleXCoord(this.item.duration);
21445
21545
  for(var _iterator = _create_for_of_iterator_helper_loose(this.meshes), _step; !(_step = _iterator()).done;){
21446
21546
  var mesh = _step.value;
21447
21547
  mesh.onStart();
@@ -22402,7 +22502,6 @@ exports.ParticleSystem = /*#__PURE__*/ function(Component) {
22402
22502
  };
22403
22503
  }
22404
22504
  this.item.getHitTestParams = this.getHitTestParams;
22405
- this.item._content = this;
22406
22505
  };
22407
22506
  _create_class(ParticleSystem, [
22408
22507
  {
@@ -22927,7 +23026,7 @@ var tempPos = new Vector3();
22927
23026
  */ _proto.sampleAnimation = function sampleAnimation() {
22928
23027
  var _this = this;
22929
23028
  var boundItem = this.boundObject;
22930
- var duration = boundItem.duration;
23029
+ var duration = this.getDuration();
22931
23030
  var life = this.time / duration;
22932
23031
  life = life < 0 ? 0 : life > 1 ? 1 : life;
22933
23032
  if (this.sizeXOverLifetime) {
@@ -23397,41 +23496,45 @@ exports.ObjectBindingTrack = /*#__PURE__*/ function(TrackAsset) {
23397
23496
  if (!_instanceof1(boundItem, exports.VFXItem)) {
23398
23497
  return;
23399
23498
  }
23400
- var hasActiveTrack = false;
23401
23499
  for(var _iterator = _create_for_of_iterator_helper_loose(this.getChildTracks()), _step; !(_step = _iterator()).done;){
23402
23500
  var childTrack = _step.value;
23403
23501
  if (_instanceof1(childTrack, exports.ActivationTrack)) {
23404
- hasActiveTrack = true;
23502
+ // 添加粒子动画 clip // TODO 待移除
23503
+ if (boundItem.getComponent(exports.ParticleSystem)) {
23504
+ var particleTrack = timelineAsset.createTrack(ParticleTrack, this, "ParticleTrack");
23505
+ for(var _iterator1 = _create_for_of_iterator_helper_loose(childTrack.getClips()), _step1; !(_step1 = _iterator1()).done;){
23506
+ var activationClip = _step1.value;
23507
+ var particleClip = particleTrack.createClip(ParticleBehaviourPlayableAsset);
23508
+ particleClip.start = activationClip.start;
23509
+ particleClip.duration = activationClip.duration;
23510
+ particleClip.endBehavior = activationClip.endBehavior;
23511
+ }
23512
+ }
23513
+ // 添加图层帧动画动画时间 clip // TODO 待移除
23514
+ if (boundItem.getComponent(exports.SpriteComponent)) {
23515
+ var componentTimeTrack = timelineAsset.createTrack(SpriteComponentTimeTrack, this, "SpriteComponentTimeTrack");
23516
+ for(var _iterator2 = _create_for_of_iterator_helper_loose(childTrack.getClips()), _step2; !(_step2 = _iterator2()).done;){
23517
+ var activationClip1 = _step2.value;
23518
+ var clip = componentTimeTrack.createClip(ComponentTimePlayableAsset);
23519
+ clip.start = activationClip1.start;
23520
+ clip.duration = activationClip1.duration;
23521
+ clip.endBehavior = activationClip1.endBehavior;
23522
+ }
23523
+ }
23524
+ // 添加图层帧动画动画时间 clip // TODO 待移除
23525
+ if (boundItem.getComponent(exports.EffectComponent)) {
23526
+ var componentTimeTrack1 = timelineAsset.createTrack(EffectComponentTimeTrack, this, "EffectComponentTimeTrack");
23527
+ for(var _iterator3 = _create_for_of_iterator_helper_loose(childTrack.getClips()), _step3; !(_step3 = _iterator3()).done;){
23528
+ var activationClip2 = _step3.value;
23529
+ var clip1 = componentTimeTrack1.createClip(ComponentTimePlayableAsset);
23530
+ clip1.start = activationClip2.start;
23531
+ clip1.duration = activationClip2.duration;
23532
+ clip1.endBehavior = activationClip2.endBehavior;
23533
+ }
23534
+ }
23405
23535
  break;
23406
23536
  }
23407
23537
  }
23408
- if (!hasActiveTrack) {
23409
- return;
23410
- }
23411
- // 添加粒子动画 clip // TODO 待移除
23412
- if (boundItem.getComponent(exports.ParticleSystem)) {
23413
- var particleTrack = timelineAsset.createTrack(ParticleTrack, this, "ParticleTrack");
23414
- var particleClip = particleTrack.createClip(ParticleBehaviourPlayableAsset);
23415
- particleClip.start = boundItem.start;
23416
- particleClip.duration = boundItem.duration;
23417
- particleClip.endBehavior = boundItem.endBehavior;
23418
- }
23419
- // 添加图层帧动画动画时间 clip // TODO 待移除
23420
- if (boundItem.getComponent(exports.SpriteComponent)) {
23421
- var componentTimeTrack = timelineAsset.createTrack(SpriteComponentTimeTrack, this, "SpriteComponentTimeTrack");
23422
- var clip = componentTimeTrack.createClip(ComponentTimePlayableAsset);
23423
- clip.start = boundItem.start;
23424
- clip.duration = boundItem.duration;
23425
- clip.endBehavior = boundItem.endBehavior;
23426
- }
23427
- // 添加图层帧动画动画时间 clip // TODO 待移除
23428
- if (boundItem.getComponent(exports.EffectComponent)) {
23429
- var componentTimeTrack1 = timelineAsset.createTrack(EffectComponentTimeTrack, this, "EffectComponentTimeTrack");
23430
- var clip1 = componentTimeTrack1.createClip(ComponentTimePlayableAsset);
23431
- clip1.start = boundItem.start;
23432
- clip1.duration = boundItem.duration;
23433
- clip1.endBehavior = boundItem.endBehavior;
23434
- }
23435
23538
  };
23436
23539
  return ObjectBindingTrack;
23437
23540
  }(exports.TrackAsset);
@@ -24216,13 +24319,14 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
24216
24319
  _this.pluginSystem = scene.pluginSystem;
24217
24320
  _this.pluginSystem.initializeComposition(_assert_this_initialized(_this), scene);
24218
24321
  _this.camera = new Camera(_this.name, _extends({}, sourceContent == null ? void 0 : sourceContent.camera, {
24219
- aspect: width / height
24322
+ aspect: width / height,
24323
+ pixelWidth: width,
24324
+ pixelHeight: height
24220
24325
  }));
24221
24326
  _this.url = scene.url;
24222
24327
  _this.interactive = true;
24223
24328
  _this.handleItemMessage = handleItemMessage;
24224
24329
  _this.createRenderFrame();
24225
- _this.rendererOptions = null;
24226
24330
  Composition.buildItemTree(_this.rootItem);
24227
24331
  _this.rootComposition.setChildrenRenderOrder(0);
24228
24332
  _this.pluginSystem.resetComposition(_assert_this_initialized(_this), _this.renderFrame);
@@ -24278,9 +24382,11 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
24278
24382
  this.restart();
24279
24383
  }
24280
24384
  if (this.rootComposition.isStartCalled) {
24281
- this.gotoAndPlay(this.time - this.startTime);
24385
+ this.setTime(this.time - this.startTime);
24386
+ this.resume();
24282
24387
  } else {
24283
- this.gotoAndPlay(0);
24388
+ this.setTime(0);
24389
+ this.resume();
24284
24390
  }
24285
24391
  };
24286
24392
  /**
@@ -24312,6 +24418,9 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
24312
24418
  * @param time - 相对 startTime 的时间
24313
24419
  */ _proto.gotoAndPlay = function gotoAndPlay(time) {
24314
24420
  this.setTime(time);
24421
+ this.emit("goto", {
24422
+ time: time
24423
+ });
24315
24424
  this.resume();
24316
24425
  };
24317
24426
  /**
@@ -24319,6 +24428,9 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
24319
24428
  * @param time - 相对 startTime 的时间
24320
24429
  */ _proto.gotoAndStop = function gotoAndStop(time) {
24321
24430
  this.setTime(time);
24431
+ this.emit("goto", {
24432
+ time: time
24433
+ });
24322
24434
  this.pause();
24323
24435
  };
24324
24436
  /**
@@ -24349,9 +24461,6 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
24349
24461
  if (pause) {
24350
24462
  this.paused = true;
24351
24463
  }
24352
- this.emit("goto", {
24353
- time: time
24354
- });
24355
24464
  };
24356
24465
  _proto.addItem = function addItem(item) {
24357
24466
  this.items.push(item);
@@ -24383,7 +24492,6 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
24383
24492
  /**
24384
24493
  * 重置状态函数
24385
24494
  */ _proto.reset = function reset() {
24386
- this.rendererOptions = null;
24387
24495
  this.isEnded = false;
24388
24496
  this.isEndCalled = false;
24389
24497
  this.rootComposition.time = 0;
@@ -24409,9 +24517,9 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
24409
24517
  if (this.getPaused()) {
24410
24518
  return;
24411
24519
  }
24412
- // scene VFXItem components lifetime function.
24520
+ // Scene VFXItem components lifetime function
24413
24521
  if (!this.rootItem.isDuringPlay) {
24414
- this.callAwake(this.rootItem);
24522
+ this.rootItem.awake();
24415
24523
  this.rootItem.beginPlay();
24416
24524
  }
24417
24525
  var previousCompositionTime = this.time;
@@ -24436,19 +24544,6 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
24436
24544
  _proto.shouldDispose = function shouldDispose() {
24437
24545
  return this.isEnded && this.rootItem.endBehavior === EndBehavior.destroy && !this.reusable;
24438
24546
  };
24439
- _proto.callAwake = function callAwake(item) {
24440
- for(var _iterator = _create_for_of_iterator_helper_loose(item.components), _step; !(_step = _iterator()).done;){
24441
- var component = _step.value;
24442
- if (!component.isAwakeCalled) {
24443
- component.onAwake();
24444
- component.isAwakeCalled = true;
24445
- }
24446
- }
24447
- for(var _iterator1 = _create_for_of_iterator_helper_loose(item.children), _step1; !(_step1 = _iterator1()).done;){
24448
- var child = _step1.value;
24449
- this.callAwake(child);
24450
- }
24451
- };
24452
24547
  /**
24453
24548
  * 更新相机
24454
24549
  * @override
@@ -24537,7 +24632,7 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
24537
24632
  return (_this_renderer = this.renderer) == null ? void 0 : _this_renderer.engine;
24538
24633
  };
24539
24634
  /**
24540
- * Item 求交测试,返回求交结果列表,x 和 y 是归一化到[-1, 1]区间的值,原点在左上角
24635
+ * Item 求交测试,返回求交结果列表,x 和 y 是归一化到[-1, 1]区间的值,x 向右,y 向上
24541
24636
  * @param x - 鼠标或触点的 x,已经归一化到[-1, 1]
24542
24637
  * @param y - 鼠标或触点的 y,已经归一化到[-1, 1]
24543
24638
  * @param force - 是否强制求交,没有交互信息的 Item 也要进行求交测试
@@ -24636,7 +24731,7 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
24636
24731
  * 合成对象销毁
24637
24732
  */ _proto.dispose = function dispose() {
24638
24733
  var _this = this;
24639
- var _this_rendererOptions, _this_pluginSystem;
24734
+ var _this_pluginSystem;
24640
24735
  if (this.destroyed) {
24641
24736
  return;
24642
24737
  }
@@ -24656,7 +24751,6 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
24656
24751
  this.rootItem.dispose();
24657
24752
  // FIXME: 注意这里增加了renderFrame销毁
24658
24753
  this.renderFrame.dispose();
24659
- (_this_rendererOptions = this.rendererOptions) == null ? void 0 : _this_rendererOptions.emptyTexture.dispose();
24660
24754
  (_this_pluginSystem = this.pluginSystem) == null ? void 0 : _this_pluginSystem.destroyComposition(this);
24661
24755
  this.update = function() {
24662
24756
  {
@@ -24753,15 +24847,6 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
24753
24847
  this.textureOffloaded = true;
24754
24848
  }
24755
24849
  };
24756
- _proto.getRendererOptions = function getRendererOptions() {
24757
- if (!this.rendererOptions) {
24758
- this.rendererOptions = {
24759
- emptyTexture: this.renderFrame.emptyTexture,
24760
- cachePrefix: "-"
24761
- };
24762
- }
24763
- return this.rendererOptions;
24764
- };
24765
24850
  /**
24766
24851
  * 重新加载纹理
24767
24852
  */ _proto.reloadTexture = function reloadTexture() {
@@ -24875,7 +24960,9 @@ exports.VFXItem = /*#__PURE__*/ function(EffectsObject) {
24875
24960
  function VFXItem(engine, props) {
24876
24961
  var _this;
24877
24962
  _this = EffectsObject.call(this, engine) || this;
24878
- _this.children = [];
24963
+ /**
24964
+ * 元素的子元素列表
24965
+ */ _this.children = [];
24879
24966
  /**
24880
24967
  * 元素的变换包含位置、旋转、缩放。
24881
24968
  */ _this.transform = new Transform();
@@ -24886,9 +24973,6 @@ exports.VFXItem = /*#__PURE__*/ function(EffectsObject) {
24886
24973
  * 元素动画的持续时间
24887
24974
  */ _this.duration = 0;
24888
24975
  /**
24889
- * 元素动画的开始时间
24890
- */ _this.start = 0;
24891
- /**
24892
24976
  * 元素动画结束时行为(如何处理元素)
24893
24977
  */ _this.endBehavior = EndBehavior.forward;
24894
24978
  _this.type = ItemType.base;
@@ -25008,6 +25092,7 @@ exports.VFXItem = /*#__PURE__*/ function(EffectsObject) {
25008
25092
  this.composition = vfxItem.composition;
25009
25093
  }
25010
25094
  if (!this.isDuringPlay && vfxItem.isDuringPlay) {
25095
+ this.awake();
25011
25096
  this.beginPlay();
25012
25097
  }
25013
25098
  };
@@ -25183,6 +25268,21 @@ exports.VFXItem = /*#__PURE__*/ function(EffectsObject) {
25183
25268
  };
25184
25269
  /**
25185
25270
  * @internal
25271
+ */ _proto.awake = function awake() {
25272
+ for(var _iterator = _create_for_of_iterator_helper_loose(this.components), _step; !(_step = _iterator()).done;){
25273
+ var component = _step.value;
25274
+ if (!component.isAwakeCalled) {
25275
+ component.onAwake();
25276
+ component.isAwakeCalled = true;
25277
+ }
25278
+ }
25279
+ for(var _iterator1 = _create_for_of_iterator_helper_loose(this.children), _step1; !(_step1 = _iterator1()).done;){
25280
+ var child = _step1.value;
25281
+ child.awake();
25282
+ }
25283
+ };
25284
+ /**
25285
+ * @internal
25186
25286
  */ _proto.onActiveChanged = function onActiveChanged() {
25187
25287
  if (!this.isEnabled) {
25188
25288
  this.onEnable();
@@ -25221,12 +25321,11 @@ exports.VFXItem = /*#__PURE__*/ function(EffectsObject) {
25221
25321
  };
25222
25322
  _proto.fromData = function fromData(data) {
25223
25323
  EffectsObject.prototype.fromData.call(this, data);
25224
- var id = data.id, name = data.name, delay = data.delay, parentId = data.parentId, endBehavior = data.endBehavior, transform = data.transform, _data_duration = data.duration, duration = _data_duration === void 0 ? 0 : _data_duration;
25324
+ var id = data.id, name = data.name, parentId = data.parentId, endBehavior = data.endBehavior, transform = data.transform, _data_duration = data.duration, duration = _data_duration === void 0 ? 0 : _data_duration;
25225
25325
  this.props = data;
25226
25326
  this.type = data.type;
25227
25327
  this.id = id.toString(); // TODO 老数据 id 是 number,需要转换
25228
25328
  this.name = name;
25229
- this.start = delay ? delay : this.start;
25230
25329
  if (transform) {
25231
25330
  this.transform.fromData(transform);
25232
25331
  }
@@ -25303,10 +25402,10 @@ exports.VFXItem = /*#__PURE__*/ function(EffectsObject) {
25303
25402
  component.dispose();
25304
25403
  }
25305
25404
  this.components = [];
25306
- this._content = undefined;
25307
25405
  this._composition = null;
25308
25406
  this.transform.setValid(false);
25309
25407
  }
25408
+ EffectsObject.prototype.dispose.call(this);
25310
25409
  };
25311
25410
  _proto.resetChildrenParent = function resetChildrenParent() {
25312
25411
  // GE 父元素销毁子元素继承逻辑
@@ -25446,14 +25545,6 @@ exports.VFXItem = /*#__PURE__*/ function(EffectsObject) {
25446
25545
  return false;
25447
25546
  };
25448
25547
  _create_class(VFXItem, [
25449
- {
25450
- key: "content",
25451
- get: /**
25452
- * 返回元素创建的数据
25453
- */ function get() {
25454
- return this._content;
25455
- }
25456
- },
25457
25548
  {
25458
25549
  key: "composition",
25459
25550
  get: /**
@@ -25587,7 +25678,7 @@ var ColorPlayable = /*#__PURE__*/ function(Playable) {
25587
25678
  }
25588
25679
  var colorInc = vecFill(tempColor, 1);
25589
25680
  var colorChanged;
25590
- var life = this.time / boundObject.duration;
25681
+ var life = this.time / this.getDuration();
25591
25682
  var opacityOverLifetime = this.opacityOverLifetime;
25592
25683
  var colorOverLifetime = this.colorOverLifetime;
25593
25684
  if (colorOverLifetime) {
@@ -25871,7 +25962,7 @@ exports.SpriteComponent = /*#__PURE__*/ function(MaskableGraphic) {
25871
25962
  _this = MaskableGraphic.call(this, engine) || this;
25872
25963
  _this.time = 0;
25873
25964
  _this.duration = 0;
25874
- _this.frameAnimationLoop = true;
25965
+ _this.loop = true;
25875
25966
  /**
25876
25967
  * @internal
25877
25968
  */ _this.splits = singleSplits;
@@ -25886,7 +25977,7 @@ exports.SpriteComponent = /*#__PURE__*/ function(MaskableGraphic) {
25886
25977
  var _this = this;
25887
25978
  var time = this.time;
25888
25979
  var duration = this.duration;
25889
- if (time > duration && this.frameAnimationLoop) {
25980
+ if (time > duration && this.loop) {
25890
25981
  time = time % duration;
25891
25982
  }
25892
25983
  var life = Math.min(Math.max(time / duration, 0.0), 1.0);
@@ -26126,6 +26217,8 @@ exports.SpriteComponent = /*#__PURE__*/ function(MaskableGraphic) {
26126
26217
  var _data_duration;
26127
26218
  //@ts-expect-error
26128
26219
  this.duration = (_data_duration = data.duration) != null ? _data_duration : this.item.duration;
26220
+ var _data_loop;
26221
+ this.loop = (_data_loop = data.loop) != null ? _data_loop : true;
26129
26222
  };
26130
26223
  return SpriteComponent;
26131
26224
  }(MaskableGraphic);
@@ -28878,7 +28971,8 @@ var TextLayout = /*#__PURE__*/ function() {
28878
28971
  function TextLayout(options) {
28879
28972
  this.width = 0;
28880
28973
  this.height = 0;
28881
- var _options_textHeight = options.textHeight, textHeight = _options_textHeight === void 0 ? 100 : _options_textHeight, _options_textWidth = options.textWidth, textWidth = _options_textWidth === void 0 ? 100 : _options_textWidth, _options_textOverflow = options.textOverflow, textOverflow = _options_textOverflow === void 0 ? TextOverflow.clip : _options_textOverflow, _options_textBaseline = options.textBaseline, textBaseline = _options_textBaseline === void 0 ? TextBaseline.top : _options_textBaseline, _options_textAlign = options.textAlign, textAlign = _options_textAlign === void 0 ? TextAlignment.left : _options_textAlign, _options_text = options.text, text = _options_text === void 0 ? " " : _options_text, _options_letterSpace = options.letterSpace, letterSpace = _options_letterSpace === void 0 ? 0 : _options_letterSpace, _options_lineGap = options.lineGap, lineGap = _options_lineGap === void 0 ? 0.571 : _options_lineGap, _options_autoWidth = options.autoWidth, autoWidth = _options_autoWidth === void 0 ? false : _options_autoWidth, fontSize = options.fontSize, _options_lineHeight = options.lineHeight, lineHeight = _options_lineHeight === void 0 ? fontSize : _options_lineHeight;
28974
+ var fontSize = options.fontSize, _options_textHeight = options.textHeight, textHeight = _options_textHeight === void 0 ? 100 : _options_textHeight, _options_textWidth = options.textWidth, textWidth = _options_textWidth === void 0 ? 100 : _options_textWidth, _options_textOverflow = options.textOverflow, textOverflow = _options_textOverflow === void 0 ? TextOverflow.clip : _options_textOverflow, _options_textBaseline = options.textBaseline, textBaseline = _options_textBaseline === void 0 ? TextBaseline.top : _options_textBaseline, _options_textAlign = options.textAlign, textAlign = _options_textAlign === void 0 ? TextAlignment.left : _options_textAlign, _options_text = options.text, text = _options_text === void 0 ? " " : _options_text, _options_letterSpace = options.letterSpace, letterSpace = _options_letterSpace === void 0 ? 0 : _options_letterSpace, _options_lineGap = options.lineGap, lineGap = _options_lineGap === void 0 ? 0.571 : _options_lineGap, _options_autoWidth = options.autoWidth, autoWidth = _options_autoWidth === void 0 ? false : _options_autoWidth, _options_lineHeight = options.lineHeight, lineHeight = _options_lineHeight === void 0 ? fontSize : _options_lineHeight, _options_useLegacyRichText = options.// @ts-expect-error
28975
+ useLegacyRichText, useLegacyRichText = _options_useLegacyRichText === void 0 ? false : _options_useLegacyRichText;
28882
28976
  var tempWidth = fontSize + letterSpace;
28883
28977
  this.autoWidth = autoWidth;
28884
28978
  this.maxTextWidth = text.length * tempWidth;
@@ -28886,6 +28980,7 @@ var TextLayout = /*#__PURE__*/ function() {
28886
28980
  this.height = textHeight;
28887
28981
  this.letterSpace = letterSpace;
28888
28982
  this.lineGap = lineGap;
28983
+ this.useLegacyRichText = useLegacyRichText;
28889
28984
  this.overflow = textOverflow;
28890
28985
  this.textBaseline = textBaseline;
28891
28986
  this.textAlign = textAlign;
@@ -28936,6 +29031,38 @@ var TextLayout = /*#__PURE__*/ function() {
28936
29031
  return offsetX;
28937
29032
  };
28938
29033
  /**
29034
+ * 富文本垂直对齐计算
29035
+ * @param style - 字体样式
29036
+ * @param lineHeights - 每行高度数组
29037
+ * @param fontSize - 字体大小
29038
+ * @returns 第一行基线的 Y 坐标
29039
+ */ _proto.getOffsetYRich = function getOffsetYRich(style, lineHeights, fontSize) {
29040
+ var outlineWidth = style.outlineWidth, fontScale = style.fontScale;
29041
+ var total = lineHeights.reduce(function(a, b) {
29042
+ return a + b;
29043
+ }, 0);
29044
+ // 使用与原始 getOffsetY 相同的经验值计算
29045
+ // /3 计算 Y 轴偏移量,以匹配编辑器行为
29046
+ var offsetY = (lineHeights[0] - fontSize) / 3;
29047
+ // 计算基础偏移量(从画布顶部到第一行基线的距离)
29048
+ var baseOffset = fontSize + outlineWidth * fontScale;
29049
+ // 除第一行外的所有行的总高度
29050
+ var commonCalculation = total - lineHeights[0]; // 使用实际总高度减去第一行高度
29051
+ var offsetResult = 0;
29052
+ switch(this.textBaseline){
29053
+ case TextBaseline.top:
29054
+ offsetResult = baseOffset + offsetY;
29055
+ break;
29056
+ case TextBaseline.middle:
29057
+ offsetResult = (this.height * fontScale - total + this.lineGap * fontScale) / 2 + baseOffset;
29058
+ break;
29059
+ case TextBaseline.bottom:
29060
+ offsetResult = this.height * fontScale - commonCalculation - offsetY;
29061
+ break;
29062
+ }
29063
+ return offsetResult;
29064
+ };
29065
+ /**
28939
29066
  * 设置文本框的宽度和高度
28940
29067
  * @param width 文本框宽度
28941
29068
  * @param height 文本框高度
@@ -29066,6 +29193,10 @@ exports.TextComponent = /*#__PURE__*/ function(MaskableGraphic) {
29066
29193
  MaskableGraphic.prototype.onUpdate.call(this, dt);
29067
29194
  this.updateTexture();
29068
29195
  };
29196
+ _proto.onDestroy = function onDestroy() {
29197
+ MaskableGraphic.prototype.onDestroy.call(this);
29198
+ this.disposeTextTexture();
29199
+ };
29069
29200
  _proto.fromData = function fromData(data) {
29070
29201
  MaskableGraphic.prototype.fromData.call(this, data);
29071
29202
  var interaction = data.interaction, options = data.options;
@@ -29106,10 +29237,10 @@ var TextComponentBase = /*#__PURE__*/ function() {
29106
29237
  var width = this.textLayout.width + this.textStyle.fontOffset;
29107
29238
  var lineCount = 1;
29108
29239
  var x = 0;
29109
- //设置context.font的字号
29110
- // if (context) {
29111
- // context.font = this.getFontDesc(this.textStyle.fontSize);
29112
- // }
29240
+ // 设置context.font的字号,确保measureText能正确计算字宽
29241
+ if (context) {
29242
+ context.font = this.getFontDesc(this.textStyle.fontSize);
29243
+ }
29113
29244
  for(var i = 0; i < text.length; i++){
29114
29245
  var _context_measureText;
29115
29246
  var str = text[i];
@@ -29439,10 +29570,17 @@ var TextComponentBase = /*#__PURE__*/ function() {
29439
29570
  wrapS: glContext.CLAMP_TO_EDGE,
29440
29571
  wrapT: glContext.CLAMP_TO_EDGE
29441
29572
  });
29573
+ this.disposeTextTexture();
29442
29574
  this.renderer.texture = texture;
29443
29575
  this.material.setTexture("_MainTex", texture);
29444
29576
  this.isDirty = false;
29445
29577
  };
29578
+ _proto.disposeTextTexture = function disposeTextTexture() {
29579
+ var texture = this.renderer.texture;
29580
+ if (texture && texture !== this.engine.whiteTexture) {
29581
+ texture.dispose();
29582
+ }
29583
+ };
29446
29584
  _proto.getFontDesc = function getFontDesc(size) {
29447
29585
  var _this_textStyle = this.textStyle, fontSize = _this_textStyle.fontSize, fontScale = _this_textStyle.fontScale, fontFamily = _this_textStyle.fontFamily, textWeight = _this_textStyle.textWeight, fontStyle = _this_textStyle.fontStyle;
29448
29586
  var fontDesc = "" + (size || fontSize * fontScale).toString() + "px ";
@@ -30483,35 +30621,75 @@ function version34Migration(json) {
30483
30621
  }
30484
30622
  if (componentData1.dataType === DataType.ShapeComponent) {
30485
30623
  var shapeComponentData = componentData1;
30486
- //@ts-expect-error
30487
30624
  shapeComponentData.fills = [];
30625
+ //@ts-expect-error
30488
30626
  if (shapeComponentData.fill) {
30489
30627
  var solidPaintData = {
30490
- type: exports.FillType.Solid,
30628
+ type: FillType.Solid,
30629
+ //@ts-expect-error
30491
30630
  color: shapeComponentData.fill.color
30492
30631
  };
30493
- //@ts-expect-error
30494
30632
  shapeComponentData.fills.push(solidPaintData);
30495
30633
  }
30496
- delete shapeComponentData.fill;
30497
30634
  //@ts-expect-error
30635
+ delete shapeComponentData.fill;
30498
30636
  shapeComponentData.strokes = [];
30637
+ //@ts-expect-error
30499
30638
  if (shapeComponentData.stroke) {
30500
30639
  var solidPaintData1 = {
30501
- type: exports.FillType.Solid,
30640
+ type: FillType.Solid,
30641
+ //@ts-expect-error
30502
30642
  color: shapeComponentData.stroke.color
30503
30643
  };
30504
- //@ts-expect-error
30505
30644
  shapeComponentData.strokes.push(solidPaintData1);
30506
30645
  //@ts-expect-error
30507
- shapeComponentData.stroke.color = undefined;
30646
+ shapeComponentData.strokeWidth = shapeComponentData.stroke.width;
30647
+ //@ts-expect-error
30648
+ shapeComponentData.strokeCap = shapeComponentData.stroke.cap;
30649
+ //@ts-expect-error
30650
+ shapeComponentData.strokeJoin = shapeComponentData.stroke.join;
30651
+ //@ts-expect-error
30652
+ delete shapeComponentData.stroke;
30508
30653
  }
30509
30654
  }
30510
30655
  }
30656
+ // 处理富文本lineGap兼容性
30657
+ processRichTextLineGapCompatibility(json);
30511
30658
  //@ts-expect-error
30512
30659
  json.version = "3.5";
30513
30660
  return json;
30514
30661
  }
30662
+ /**
30663
+ * 处理富文本 lineGap 兼容性
30664
+ */ function processRichTextLineGapCompatibility(json) {
30665
+ if (!json.components) {
30666
+ return;
30667
+ }
30668
+ // 遍历所有组件,处理富文本组件
30669
+ for(var _iterator = _create_for_of_iterator_helper_loose(json.components), _step; !(_step = _iterator()).done;){
30670
+ var component = _step.value;
30671
+ // 识别富文本组件并处理 lineGap 兼容性
30672
+ if (component.dataType === DataType.RichTextComponent && component.options) {
30673
+ ensureRichTextLineGap(component.options);
30674
+ }
30675
+ }
30676
+ }
30677
+ /**
30678
+ * 确保富文本组件有版本标识字段
30679
+ */ function ensureRichTextLineGap(options) {
30680
+ // 检查是否已经处理过
30681
+ if (!options || options.useLegacyRichText !== undefined) {
30682
+ return;
30683
+ }
30684
+ // 根据是否存在 lineGap 字段来判断版本
30685
+ if (options.lineGap === undefined) {
30686
+ // 旧版本(没有 lineGap 字段)
30687
+ options.useLegacyRichText = true;
30688
+ } else {
30689
+ // 新版本(有 lineGap 字段)
30690
+ options.useLegacyRichText = false;
30691
+ }
30692
+ }
30515
30693
  /**
30516
30694
  * 根据形状获取形状几何体数据
30517
30695
  * @param shape - 形状
@@ -31434,7 +31612,7 @@ function getStandardSpriteContent(sprite, transform) {
31434
31612
  return ret;
31435
31613
  }
31436
31614
 
31437
- var version$1 = "2.7.0-alpha.1";
31615
+ var version$1 = "2.7.0-beta.0";
31438
31616
  var v0 = /^(\d+)\.(\d+)\.(\d+)(-(\w+)\.\d+)?$/;
31439
31617
  var standardVersion = /^(\d+)\.(\d+)$/;
31440
31618
  var reverseParticle = false;
@@ -32670,7 +32848,7 @@ function createTextureOptionsBySource(image, sourceFrom, id) {
32670
32848
  function AssetService(engine) {
32671
32849
  this.engine = engine;
32672
32850
  this.builtinObjects = [];
32673
- this.builtinObjects.push(generateWhiteTexture(engine));
32851
+ this.builtinObjects.push(engine.whiteTexture);
32674
32852
  }
32675
32853
  var _proto = AssetService.prototype;
32676
32854
  /**
@@ -34346,7 +34524,7 @@ var FBGeometryDataT = /*#__PURE__*/ function() {
34346
34524
  this.jsonSceneData = {};
34347
34525
  this.objectInstance = {};
34348
34526
  this.assetLoader = new AssetLoader(this);
34349
- this.emptyTexture = generateWhiteTexture(this);
34527
+ this.whiteTexture = generateWhiteTexture(this);
34350
34528
  this.transparentTexture = generateTransparentTexture(this);
34351
34529
  }
34352
34530
  var _proto = Engine.prototype;
@@ -34707,7 +34885,7 @@ registerPlugin("sprite", SpriteLoader, exports.VFXItem);
34707
34885
  registerPlugin("particle", ParticleLoader, exports.VFXItem);
34708
34886
  registerPlugin("cal", CalculateLoader, exports.VFXItem);
34709
34887
  registerPlugin("interact", InteractLoader, exports.VFXItem);
34710
- var version = "2.7.0-alpha.1";
34888
+ var version = "2.7.0-beta.0";
34711
34889
  logger.info("Core version: " + version + ".");
34712
34890
 
34713
34891
  exports.AbstractPlugin = AbstractPlugin;