@galacean/effects-core 2.7.0-alpha.2 → 2.7.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.2
6
+ * Version: v2.7.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
  /**
@@ -4012,6 +4027,7 @@ var index$1 = /*#__PURE__*/Object.freeze({
4012
4027
  get MaterialBlending () { return MaterialBlending; },
4013
4028
  get RenderMode3D () { return RenderMode3D; },
4014
4029
  get TextOverflow () { return TextOverflow; },
4030
+ get TextSizeMode () { return TextSizeMode; },
4015
4031
  get TextBaseline () { return TextBaseline; },
4016
4032
  get TextAlignment () { return TextAlignment; },
4017
4033
  get TextWeight () { return TextWeight; },
@@ -4126,10 +4142,16 @@ function getDirectStore(target) {
4126
4142
  * 反序列化函数
4127
4143
  *
4128
4144
  * @param data - 对象的序列化的数据
4129
- */ _proto.fromData = function fromData(data) {};
4145
+ */ _proto.fromData = function fromData(data) {
4146
+ if (data.id !== undefined) {
4147
+ this.setInstanceId(data.id);
4148
+ }
4149
+ };
4130
4150
  /**
4131
- *
4132
- */ _proto.dispose = function dispose() {};
4151
+ * 销毁当前对象
4152
+ */ _proto.dispose = function dispose() {
4153
+ this.engine.removeInstance(this.guid);
4154
+ };
4133
4155
  /**
4134
4156
  *
4135
4157
  * @param obj
@@ -5223,7 +5245,7 @@ var Pose = /*#__PURE__*/ function() {
5223
5245
  }
5224
5246
  for(var _iterator2 = _create_for_of_iterator_helper_loose(skeleton.defaultColorPropertyValues), _step2; !(_step2 = _iterator2()).done;){
5225
5247
  var defaultColor = _step2.value;
5226
- this.colorPropertyValues.push(defaultColor);
5248
+ this.colorPropertyValues.push(new Color().copyFrom(defaultColor));
5227
5249
  }
5228
5250
  }
5229
5251
  var _proto = Pose.prototype;
@@ -6698,7 +6720,7 @@ var Skeleton = /*#__PURE__*/ function() {
6698
6720
  break;
6699
6721
  case 1:
6700
6722
  this.colorAnimatedObjects.push(animatedObject);
6701
- this.defaultColorPropertyValues.push(directTarget[lastPropertyName]);
6723
+ this.defaultColorPropertyValues.push(new Color().copyFrom(directTarget[lastPropertyName]));
6702
6724
  this.pathToObjectIndex.set(totalPath, this.colorAnimatedObjects.length - 1);
6703
6725
  }
6704
6726
  };
@@ -6995,6 +7017,7 @@ function _create_class(Constructor, protoProps, staticProps) {
6995
7017
  if (this.item) {
6996
7018
  removeItem(this.item.components, this);
6997
7019
  }
7020
+ EffectsObject.prototype.dispose.call(this);
6998
7021
  };
6999
7022
  _proto.start = function start() {
7000
7023
  if (this.isStartCalled) {
@@ -12185,9 +12208,8 @@ var seed$7 = 1;
12185
12208
  this.destroyed = true;
12186
12209
  if (this.engine !== undefined) {
12187
12210
  this.engine.removeMesh(this);
12188
- // @ts-expect-error
12189
- this.engine = undefined;
12190
12211
  }
12212
+ RendererComponent.prototype.dispose.call(this);
12191
12213
  };
12192
12214
  _create_class(Mesh, [
12193
12215
  {
@@ -13343,8 +13365,6 @@ var seed$5 = 1;
13343
13365
  this.clearAction = clearAction;
13344
13366
  this.name = "RenderFrame" + seed$5++;
13345
13367
  var firstRP = renderPasses[0];
13346
- this.emptyTexture = generateWhiteTexture(engine);
13347
- this.transparentTexture = generateTransparentTexture(engine);
13348
13368
  this.camera = camera;
13349
13369
  this.keepColorBuffer = keepColorBuffer;
13350
13370
  this.renderPassInfoMap.set(firstRP, {
@@ -13393,8 +13413,6 @@ var seed$5 = 1;
13393
13413
  }
13394
13414
  this.passTextureCache.dispose();
13395
13415
  this._renderPasses.length = 0;
13396
- this.emptyTexture.dispose();
13397
- this.transparentTexture.dispose();
13398
13416
  if (this.resource) {
13399
13417
  var _this_resource_depthStencil_texture, _this_resource_depthStencil;
13400
13418
  this.resource.color_a.dispose();
@@ -14054,7 +14072,7 @@ var Renderer = /*#__PURE__*/ function() {
14054
14072
  _this.renderer = {
14055
14073
  renderMode: RenderMode.MESH,
14056
14074
  blending: BlendingMode.ALPHA,
14057
- texture: _this.engine.emptyTexture,
14075
+ texture: _this.engine.whiteTexture,
14058
14076
  occlusion: false,
14059
14077
  transparentOcclusion: false,
14060
14078
  side: SideMode.DOUBLE,
@@ -14262,7 +14280,7 @@ var Renderer = /*#__PURE__*/ function() {
14262
14280
  this.renderer = {
14263
14281
  renderMode: (_renderer_renderMode = renderer.renderMode) != null ? _renderer_renderMode : RenderMode.MESH,
14264
14282
  blending: (_renderer_blending = renderer.blending) != null ? _renderer_blending : BlendingMode.ALPHA,
14265
- texture: renderer.texture ? this.engine.findObject(renderer.texture) : this.engine.emptyTexture,
14283
+ texture: renderer.texture ? this.engine.findObject(renderer.texture) : this.engine.whiteTexture,
14266
14284
  occlusion: !!renderer.occlusion,
14267
14285
  transparentOcclusion: !!renderer.transparentOcclusion || this.maskManager.maskMode === exports.MaskMode.MASK,
14268
14286
  side: (_renderer_side = renderer.side) != null ? _renderer_side : SideMode.DOUBLE,
@@ -16106,20 +16124,26 @@ function oldBezierKeyFramesToNew(props) {
16106
16124
  keyDatas.push(keyData);
16107
16125
  lastControl = p2;
16108
16126
  }
16109
- var calculateSlop = function(p0, p1) {
16127
+ var calculateSlope = function(p0, p1) {
16110
16128
  return (p1.y - p0.y) / (p1.x - p0.x + NumberEpsilon);
16111
16129
  };
16112
16130
  for(var i1 = 0; i1 < keyDatas.length; i1++){
16113
16131
  var leftControl = keyDatas[i1].leftControl;
16114
16132
  var value = keyDatas[i1].value;
16115
16133
  var rightControl = keyDatas[i1].rightControl;
16116
- var outSlop = calculateSlop(value, rightControl);
16117
- 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
+ }
16118
16142
  var keyframe = {
16119
16143
  time: value.x,
16120
16144
  value: value.y,
16121
- inSlope: inSlop,
16122
- outSlope: outSlop,
16145
+ inSlope: inSlope,
16146
+ outSlope: outSlope,
16123
16147
  inWeight: 0,
16124
16148
  outWeight: 0,
16125
16149
  tangentMode: keyDatas[i1].tangentMode,
@@ -16256,8 +16280,6 @@ exports.ShapeComponent = /*#__PURE__*/ function(RendererComponent) {
16256
16280
  function ShapeComponent(engine) {
16257
16281
  var _this;
16258
16282
  _this = RendererComponent.call(this, engine) || this;
16259
- _this.hasStroke = false;
16260
- _this.hasFill = false;
16261
16283
  _this.shapeDirty = true;
16262
16284
  _this.materialDirty = true;
16263
16285
  _this.graphicsPath = new GraphicsPath();
@@ -16276,6 +16298,8 @@ exports.ShapeComponent = /*#__PURE__*/ function(RendererComponent) {
16276
16298
  /**
16277
16299
  * 用于点击测试的碰撞器
16278
16300
  */ _this.meshCollider = new MeshCollider();
16301
+ _this.fillMaterials = [];
16302
+ _this.strokeMaterials = [];
16279
16303
  _this.getHitTestParams = function(force) {
16280
16304
  var sizeMatrix = Matrix4.fromScale(_this.transform.size.x, _this.transform.size.y, 1);
16281
16305
  var worldMatrix = sizeMatrix.premultiply(_this.transform.getWorldMatrix());
@@ -16287,15 +16311,15 @@ exports.ShapeComponent = /*#__PURE__*/ function(RendererComponent) {
16287
16311
  behavior: 0,
16288
16312
  type: area.type,
16289
16313
  triangles: area.area,
16290
- backfaceCulling: _this.renderer.side === SideMode.FRONT
16314
+ backfaceCulling: _this.rendererOptions.side === SideMode.FRONT
16291
16315
  };
16292
16316
  }
16293
16317
  }
16294
16318
  };
16295
- _this.renderer = {
16319
+ _this.rendererOptions = {
16296
16320
  renderMode: RenderMode.MESH,
16297
16321
  blending: BlendingMode.ALPHA,
16298
- texture: _this.engine.emptyTexture,
16322
+ texture: _this.engine.whiteTexture,
16299
16323
  occlusion: false,
16300
16324
  transparentOcclusion: false,
16301
16325
  side: SideMode.DOUBLE,
@@ -16383,25 +16407,6 @@ exports.ShapeComponent = /*#__PURE__*/ function(RendererComponent) {
16383
16407
  indexCount: 0,
16384
16408
  vertexCount: 0
16385
16409
  });
16386
- // Create Material
16387
- //-------------------------------------------------------------------------
16388
- var materialProps = {
16389
- shader: {
16390
- vertex: vert,
16391
- fragment: frag,
16392
- glslVersion: exports.GLSLVersion.GLSL1
16393
- }
16394
- };
16395
- var fillMaterial = Material.create(engine, materialProps);
16396
- var strokeMaterial = Material.create(engine, materialProps);
16397
- fillMaterial.depthMask = false;
16398
- fillMaterial.depthTest = true;
16399
- fillMaterial.blending = true;
16400
- _this.material = fillMaterial;
16401
- strokeMaterial.depthMask = false;
16402
- strokeMaterial.depthTest = true;
16403
- strokeMaterial.blending = true;
16404
- _this.materials[1] = strokeMaterial;
16405
16410
  return _this;
16406
16411
  }
16407
16412
  var _proto = ShapeComponent.prototype;
@@ -16429,18 +16434,26 @@ exports.ShapeComponent = /*#__PURE__*/ function(RendererComponent) {
16429
16434
  if (!this.isActiveAndEnabled) {
16430
16435
  return;
16431
16436
  }
16432
- var previousColorMask0 = this.material.colorMask;
16433
- var previousColorMask1 = this.materials[1].colorMask;
16434
- this.material.colorMask = false;
16435
- this.materials[1].colorMask = false;
16436
- this.draw(renderer);
16437
- this.material.colorMask = previousColorMask0;
16438
- 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
+ }
16439
16450
  };
16440
16451
  _proto.draw = function draw(renderer) {
16441
- for(var i = 0; i < this.materials.length; i++){
16442
- var material = this.materials[i];
16443
- 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);
16444
16457
  }
16445
16458
  };
16446
16459
  _proto.getBoundingBox = function getBoundingBox() {
@@ -16454,7 +16467,7 @@ exports.ShapeComponent = /*#__PURE__*/ function(RendererComponent) {
16454
16467
  var vertices = [];
16455
16468
  var indices = [];
16456
16469
  // Triangulate shapePrimitives, build fill and stroke shape geometry
16457
- if (this.hasFill) {
16470
+ if (this.fills.length > 0) {
16458
16471
  for(var _iterator = _create_for_of_iterator_helper_loose(shapePrimitives), _step; !(_step = _iterator()).done;){
16459
16472
  var shapePrimitive = _step.value;
16460
16473
  var shape = shapePrimitive.shape;
@@ -16466,7 +16479,7 @@ exports.ShapeComponent = /*#__PURE__*/ function(RendererComponent) {
16466
16479
  }
16467
16480
  }
16468
16481
  var fillIndexCount = indices.length;
16469
- if (this.hasStroke) {
16482
+ if (this.strokes.length > 0) {
16470
16483
  for(var _iterator1 = _create_for_of_iterator_helper_loose(shapePrimitives), _step1; !(_step1 = _iterator1()).done;){
16471
16484
  var shapePrimitive1 = _step1.value;
16472
16485
  var shape1 = shapePrimitive1.shape;
@@ -16604,40 +16617,12 @@ 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);
@@ -16674,6 +16659,46 @@ exports.ShapeComponent = /*#__PURE__*/ function(RendererComponent) {
16674
16659
  material.setVector2("_StartPoint", startPoint);
16675
16660
  material.setVector2("_EndPoint", endPoint);
16676
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
+ };
16677
16702
  _proto.fromData = function fromData(data) {
16678
16703
  RendererComponent.prototype.fromData.call(this, data);
16679
16704
  this.shapeDirty = true;
@@ -16682,11 +16707,11 @@ exports.ShapeComponent = /*#__PURE__*/ function(RendererComponent) {
16682
16707
  }
16683
16708
  var _data_renderer;
16684
16709
  var renderer = (_data_renderer = data.renderer) != null ? _data_renderer : {};
16685
- var _renderer_renderMode, _renderer_blending, _renderer_side;
16686
- this.renderer = {
16687
- renderMode: (_renderer_renderMode = renderer.renderMode) != null ? _renderer_renderMode : RenderMode.MESH,
16710
+ var _renderer_blending, _renderer_side;
16711
+ this.rendererOptions = {
16712
+ renderMode: RenderMode.MESH,
16688
16713
  blending: (_renderer_blending = renderer.blending) != null ? _renderer_blending : BlendingMode.ALPHA,
16689
- texture: renderer.texture ? this.engine.findObject(renderer.texture) : this.engine.emptyTexture,
16714
+ texture: renderer.texture ? this.engine.findObject(renderer.texture) : this.engine.whiteTexture,
16690
16715
  occlusion: !!renderer.occlusion,
16691
16716
  transparentOcclusion: !!renderer.transparentOcclusion || this.maskManager.maskMode === exports.MaskMode.MASK,
16692
16717
  side: (_renderer_side = renderer.side) != null ? _renderer_side : SideMode.DOUBLE,
@@ -16698,22 +16723,21 @@ exports.ShapeComponent = /*#__PURE__*/ function(RendererComponent) {
16698
16723
  this.strokeWidth = (_data_strokeWidth = data.strokeWidth) != null ? _data_strokeWidth : 1;
16699
16724
  var _data_strokeJoin;
16700
16725
  this.strokeJoin = (_data_strokeJoin = data.strokeJoin) != null ? _data_strokeJoin : LineJoin.Miter;
16701
- for(var _iterator = _create_for_of_iterator_helper_loose(data.strokes), _step; !(_step = _iterator()).done;){
16702
- var stroke = _step.value;
16703
- var strokeParam = stroke;
16704
- if (strokeParam) {
16705
- this.hasStroke = true;
16706
- this.strokes[0] = this.createPaint(strokeParam);
16707
- }
16708
- }
16709
- for(var _iterator1 = _create_for_of_iterator_helper_loose(data.fills), _step1; !(_step1 = _iterator1()).done;){
16710
- var fill = _step1.value;
16711
- var fillParam = fill;
16712
- if (fillParam) {
16713
- this.hasFill = true;
16714
- this.fills[0] = this.createPaint(fillParam);
16715
- }
16716
- }
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);
16717
16741
  switch(data.type){
16718
16742
  case ShapePrimitiveType.Custom:
16719
16743
  {
@@ -17231,11 +17255,11 @@ var vertex = "\nprecision highp float;\n\nattribute vec2 aPoint;\nuniform vec4 u
17231
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";
17232
17256
  var seed$4 = 1;
17233
17257
  var InteractMesh = /*#__PURE__*/ function() {
17234
- function InteractMesh(props, rendererOptions, transform, engine) {
17258
+ function InteractMesh(props, transform, engine) {
17235
17259
  this.transform = transform;
17236
17260
  this.engine = engine;
17237
17261
  this.color = props.options.previewColor;
17238
- var material = this.createMaterial(rendererOptions);
17262
+ var material = this.createMaterial();
17239
17263
  var geometry = this.createGeometry();
17240
17264
  this.mesh = this.createMesh(geometry, material);
17241
17265
  this.updateMesh();
@@ -17258,7 +17282,7 @@ var InteractMesh = /*#__PURE__*/ function() {
17258
17282
  material.setVector4("uPos", uPos);
17259
17283
  material.setQuaternion("uQuat", tempQuat);
17260
17284
  };
17261
- _proto.createMaterial = function createMaterial(rendererOptions) {
17285
+ _proto.createMaterial = function createMaterial() {
17262
17286
  var _this_engine_renderer;
17263
17287
  var macros = [
17264
17288
  [
@@ -17272,7 +17296,6 @@ var InteractMesh = /*#__PURE__*/ function() {
17272
17296
  vertex: vertex,
17273
17297
  fragment: fragment,
17274
17298
  glslVersion: exports.GLSLVersion.GLSL1,
17275
- cacheId: "" + rendererOptions.cachePrefix + "_effects_interact",
17276
17299
  macros: macros
17277
17300
  }
17278
17301
  };
@@ -17394,19 +17417,33 @@ exports.InteractComponent = /*#__PURE__*/ function(RendererComponent) {
17394
17417
  return _this;
17395
17418
  }
17396
17419
  var _proto = InteractComponent.prototype;
17397
- _proto.getDragRangeX = function getDragRangeX() {
17420
+ /**
17421
+ * 获取拖拽范围 X 轴
17422
+ * @returns 拖拽范围 [min, max]
17423
+ */ _proto.getDragRangeX = function getDragRangeX() {
17398
17424
  return this.dragRange.dxRange;
17399
17425
  };
17400
- _proto.setDragRangeX = function setDragRangeX(min, max) {
17426
+ /**
17427
+ * 设置拖拽范围 X 轴
17428
+ * @param min 最小值
17429
+ * @param max 最大值
17430
+ */ _proto.setDragRangeX = function setDragRangeX(min, max) {
17401
17431
  this.dragRange.dxRange = [
17402
17432
  min,
17403
17433
  max
17404
17434
  ];
17405
17435
  };
17406
- _proto.getDragRangeY = function getDragRangeY() {
17436
+ /**
17437
+ * 获取拖拽范围 Y 轴
17438
+ * @returns 拖拽范围 [min, max]
17439
+ */ _proto.getDragRangeY = function getDragRangeY() {
17407
17440
  return this.dragRange.dyRange;
17408
17441
  };
17409
- _proto.setDragRangeY = function setDragRangeY(min, max) {
17442
+ /**
17443
+ * 设置拖拽范围 Y 轴
17444
+ * @param min 最小值
17445
+ * @param max 最大值
17446
+ */ _proto.setDragRangeY = function setDragRangeY(min, max) {
17410
17447
  this.dragRange.dyRange = [
17411
17448
  min,
17412
17449
  max
@@ -17414,15 +17451,11 @@ exports.InteractComponent = /*#__PURE__*/ function(RendererComponent) {
17414
17451
  };
17415
17452
  _proto.onStart = function onStart() {
17416
17453
  var env = this.item.engine.renderer.env;
17417
- var composition = this.item.composition;
17418
17454
  var _this_interactData_options = this.interactData.options, type = _this_interactData_options.type, showPreview = _this_interactData_options.showPreview;
17419
17455
  if (type === InteractType.CLICK) {
17420
17456
  this.clickable = true;
17421
17457
  if (showPreview && env === PLAYER_OPTIONS_ENV_EDITOR) {
17422
- var rendererOptions = composition == null ? void 0 : composition.getRendererOptions();
17423
- if (rendererOptions !== undefined) {
17424
- this.previewContent = new InteractMesh(this.item.props.content, rendererOptions, this.transform, this.engine);
17425
- }
17458
+ this.previewContent = new InteractMesh(this.item.props.content, this.transform, this.engine);
17426
17459
  }
17427
17460
  }
17428
17461
  if (this.previewContent) {
@@ -17631,7 +17664,10 @@ exports.InteractComponent = /*#__PURE__*/ function(RendererComponent) {
17631
17664
  }
17632
17665
  }
17633
17666
  };
17634
- _proto.canInteract = function canInteract() {
17667
+ /**
17668
+ * 是否可以交互
17669
+ * @returns
17670
+ */ _proto.canInteract = function canInteract() {
17635
17671
  var _this_item_composition;
17636
17672
  return Boolean((_this_item_composition = this.item.composition) == null ? void 0 : _this_item_composition.interactive) && this._interactive;
17637
17673
  };
@@ -17666,7 +17702,9 @@ exports.InteractComponent = /*#__PURE__*/ function(RendererComponent) {
17666
17702
  get: function get() {
17667
17703
  return this._interactive;
17668
17704
  },
17669
- set: function set(enable) {
17705
+ set: /**
17706
+ * 是否响应点击和拖拽交互事件
17707
+ */ function set(enable) {
17670
17708
  this._interactive = enable;
17671
17709
  if (!enable) {
17672
17710
  // 立刻停止惯性滑动
@@ -18423,6 +18461,12 @@ var tmpScale = new Vector3(1, 1, 1);
18423
18461
  this./**
18424
18462
  * @internal
18425
18463
  */ transform = new Transform();
18464
+ this./**
18465
+ * 画布的像素宽度
18466
+ */ pixelWidth = 0;
18467
+ this./**
18468
+ * 画布的像素高度
18469
+ */ pixelHeight = 0;
18426
18470
  this.viewportMatrix = Matrix4.fromIdentity();
18427
18471
  this.viewMatrix = Matrix4.fromIdentity();
18428
18472
  this.projectionMatrix = Matrix4.fromIdentity();
@@ -18437,7 +18481,7 @@ var tmpScale = new Vector3(1, 1, 1);
18437
18481
  0,
18438
18482
  0,
18439
18483
  0
18440
- ] : _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;
18441
18485
  var euler = new Euler(rotation[0], rotation[1], rotation[2]);
18442
18486
  var quat = new Quaternion().setFromEuler(euler);
18443
18487
  this.options = {
@@ -18447,6 +18491,8 @@ var tmpScale = new Vector3(1, 1, 1);
18447
18491
  aspect: aspect,
18448
18492
  clipMode: clipMode
18449
18493
  };
18494
+ this.pixelWidth = pixelWidth;
18495
+ this.pixelHeight = pixelHeight;
18450
18496
  this.transform.setPosition(position[0], position[1], position[2]);
18451
18497
  this.transform.setQuaternion(quat.x, quat.y, quat.z, quat.w);
18452
18498
  this.dirty = true;
@@ -18593,6 +18639,48 @@ var tmpScale = new Vector3(1, 1, 1);
18593
18639
  this.dirty = false;
18594
18640
  }
18595
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
+ };
18596
18684
  _create_class(Camera, [
18597
18685
  {
18598
18686
  key: "near",
@@ -21454,7 +21542,6 @@ function modifyMaxKeyframeShader(shader, maxVertex, maxFrag) {
21454
21542
  var _proto = ParticleSystemRenderer.prototype;
21455
21543
  _proto.onStart = function onStart() {
21456
21544
  this._priority = this.item.renderOrder;
21457
- this.particleMesh.gravityModifier.scaleXCoord(this.item.duration);
21458
21545
  for(var _iterator = _create_for_of_iterator_helper_loose(this.meshes), _step; !(_step = _iterator()).done;){
21459
21546
  var mesh = _step.value;
21460
21547
  mesh.onStart();
@@ -22415,7 +22502,6 @@ exports.ParticleSystem = /*#__PURE__*/ function(Component) {
22415
22502
  };
22416
22503
  }
22417
22504
  this.item.getHitTestParams = this.getHitTestParams;
22418
- this.item._content = this;
22419
22505
  };
22420
22506
  _create_class(ParticleSystem, [
22421
22507
  {
@@ -22940,7 +23026,7 @@ var tempPos = new Vector3();
22940
23026
  */ _proto.sampleAnimation = function sampleAnimation() {
22941
23027
  var _this = this;
22942
23028
  var boundItem = this.boundObject;
22943
- var duration = boundItem.duration;
23029
+ var duration = this.getDuration();
22944
23030
  var life = this.time / duration;
22945
23031
  life = life < 0 ? 0 : life > 1 ? 1 : life;
22946
23032
  if (this.sizeXOverLifetime) {
@@ -23410,41 +23496,45 @@ exports.ObjectBindingTrack = /*#__PURE__*/ function(TrackAsset) {
23410
23496
  if (!_instanceof1(boundItem, exports.VFXItem)) {
23411
23497
  return;
23412
23498
  }
23413
- var hasActiveTrack = false;
23414
23499
  for(var _iterator = _create_for_of_iterator_helper_loose(this.getChildTracks()), _step; !(_step = _iterator()).done;){
23415
23500
  var childTrack = _step.value;
23416
23501
  if (_instanceof1(childTrack, exports.ActivationTrack)) {
23417
- 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
+ }
23418
23535
  break;
23419
23536
  }
23420
23537
  }
23421
- if (!hasActiveTrack) {
23422
- return;
23423
- }
23424
- // 添加粒子动画 clip // TODO 待移除
23425
- if (boundItem.getComponent(exports.ParticleSystem)) {
23426
- var particleTrack = timelineAsset.createTrack(ParticleTrack, this, "ParticleTrack");
23427
- var particleClip = particleTrack.createClip(ParticleBehaviourPlayableAsset);
23428
- particleClip.start = boundItem.start;
23429
- particleClip.duration = boundItem.duration;
23430
- particleClip.endBehavior = boundItem.endBehavior;
23431
- }
23432
- // 添加图层帧动画动画时间 clip // TODO 待移除
23433
- if (boundItem.getComponent(exports.SpriteComponent)) {
23434
- var componentTimeTrack = timelineAsset.createTrack(SpriteComponentTimeTrack, this, "SpriteComponentTimeTrack");
23435
- var clip = componentTimeTrack.createClip(ComponentTimePlayableAsset);
23436
- clip.start = boundItem.start;
23437
- clip.duration = boundItem.duration;
23438
- clip.endBehavior = boundItem.endBehavior;
23439
- }
23440
- // 添加图层帧动画动画时间 clip // TODO 待移除
23441
- if (boundItem.getComponent(exports.EffectComponent)) {
23442
- var componentTimeTrack1 = timelineAsset.createTrack(EffectComponentTimeTrack, this, "EffectComponentTimeTrack");
23443
- var clip1 = componentTimeTrack1.createClip(ComponentTimePlayableAsset);
23444
- clip1.start = boundItem.start;
23445
- clip1.duration = boundItem.duration;
23446
- clip1.endBehavior = boundItem.endBehavior;
23447
- }
23448
23538
  };
23449
23539
  return ObjectBindingTrack;
23450
23540
  }(exports.TrackAsset);
@@ -24229,13 +24319,14 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
24229
24319
  _this.pluginSystem = scene.pluginSystem;
24230
24320
  _this.pluginSystem.initializeComposition(_assert_this_initialized(_this), scene);
24231
24321
  _this.camera = new Camera(_this.name, _extends({}, sourceContent == null ? void 0 : sourceContent.camera, {
24232
- aspect: width / height
24322
+ aspect: width / height,
24323
+ pixelWidth: width,
24324
+ pixelHeight: height
24233
24325
  }));
24234
24326
  _this.url = scene.url;
24235
24327
  _this.interactive = true;
24236
24328
  _this.handleItemMessage = handleItemMessage;
24237
24329
  _this.createRenderFrame();
24238
- _this.rendererOptions = null;
24239
24330
  Composition.buildItemTree(_this.rootItem);
24240
24331
  _this.rootComposition.setChildrenRenderOrder(0);
24241
24332
  _this.pluginSystem.resetComposition(_assert_this_initialized(_this), _this.renderFrame);
@@ -24291,9 +24382,11 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
24291
24382
  this.restart();
24292
24383
  }
24293
24384
  if (this.rootComposition.isStartCalled) {
24294
- this.gotoAndPlay(this.time - this.startTime);
24385
+ this.setTime(this.time - this.startTime);
24386
+ this.resume();
24295
24387
  } else {
24296
- this.gotoAndPlay(0);
24388
+ this.setTime(0);
24389
+ this.resume();
24297
24390
  }
24298
24391
  };
24299
24392
  /**
@@ -24325,6 +24418,9 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
24325
24418
  * @param time - 相对 startTime 的时间
24326
24419
  */ _proto.gotoAndPlay = function gotoAndPlay(time) {
24327
24420
  this.setTime(time);
24421
+ this.emit("goto", {
24422
+ time: time
24423
+ });
24328
24424
  this.resume();
24329
24425
  };
24330
24426
  /**
@@ -24332,6 +24428,9 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
24332
24428
  * @param time - 相对 startTime 的时间
24333
24429
  */ _proto.gotoAndStop = function gotoAndStop(time) {
24334
24430
  this.setTime(time);
24431
+ this.emit("goto", {
24432
+ time: time
24433
+ });
24335
24434
  this.pause();
24336
24435
  };
24337
24436
  /**
@@ -24362,9 +24461,6 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
24362
24461
  if (pause) {
24363
24462
  this.paused = true;
24364
24463
  }
24365
- this.emit("goto", {
24366
- time: time
24367
- });
24368
24464
  };
24369
24465
  _proto.addItem = function addItem(item) {
24370
24466
  this.items.push(item);
@@ -24396,7 +24492,6 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
24396
24492
  /**
24397
24493
  * 重置状态函数
24398
24494
  */ _proto.reset = function reset() {
24399
- this.rendererOptions = null;
24400
24495
  this.isEnded = false;
24401
24496
  this.isEndCalled = false;
24402
24497
  this.rootComposition.time = 0;
@@ -24422,9 +24517,9 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
24422
24517
  if (this.getPaused()) {
24423
24518
  return;
24424
24519
  }
24425
- // scene VFXItem components lifetime function.
24520
+ // Scene VFXItem components lifetime function
24426
24521
  if (!this.rootItem.isDuringPlay) {
24427
- this.callAwake(this.rootItem);
24522
+ this.rootItem.awake();
24428
24523
  this.rootItem.beginPlay();
24429
24524
  }
24430
24525
  var previousCompositionTime = this.time;
@@ -24449,19 +24544,6 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
24449
24544
  _proto.shouldDispose = function shouldDispose() {
24450
24545
  return this.isEnded && this.rootItem.endBehavior === EndBehavior.destroy && !this.reusable;
24451
24546
  };
24452
- _proto.callAwake = function callAwake(item) {
24453
- for(var _iterator = _create_for_of_iterator_helper_loose(item.components), _step; !(_step = _iterator()).done;){
24454
- var component = _step.value;
24455
- if (!component.isAwakeCalled) {
24456
- component.onAwake();
24457
- component.isAwakeCalled = true;
24458
- }
24459
- }
24460
- for(var _iterator1 = _create_for_of_iterator_helper_loose(item.children), _step1; !(_step1 = _iterator1()).done;){
24461
- var child = _step1.value;
24462
- this.callAwake(child);
24463
- }
24464
- };
24465
24547
  /**
24466
24548
  * 更新相机
24467
24549
  * @override
@@ -24550,7 +24632,7 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
24550
24632
  return (_this_renderer = this.renderer) == null ? void 0 : _this_renderer.engine;
24551
24633
  };
24552
24634
  /**
24553
- * Item 求交测试,返回求交结果列表,x 和 y 是归一化到[-1, 1]区间的值,原点在左上角
24635
+ * Item 求交测试,返回求交结果列表,x 和 y 是归一化到[-1, 1]区间的值,x 向右,y 向上
24554
24636
  * @param x - 鼠标或触点的 x,已经归一化到[-1, 1]
24555
24637
  * @param y - 鼠标或触点的 y,已经归一化到[-1, 1]
24556
24638
  * @param force - 是否强制求交,没有交互信息的 Item 也要进行求交测试
@@ -24649,7 +24731,7 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
24649
24731
  * 合成对象销毁
24650
24732
  */ _proto.dispose = function dispose() {
24651
24733
  var _this = this;
24652
- var _this_rendererOptions, _this_pluginSystem;
24734
+ var _this_pluginSystem;
24653
24735
  if (this.destroyed) {
24654
24736
  return;
24655
24737
  }
@@ -24669,7 +24751,6 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
24669
24751
  this.rootItem.dispose();
24670
24752
  // FIXME: 注意这里增加了renderFrame销毁
24671
24753
  this.renderFrame.dispose();
24672
- (_this_rendererOptions = this.rendererOptions) == null ? void 0 : _this_rendererOptions.emptyTexture.dispose();
24673
24754
  (_this_pluginSystem = this.pluginSystem) == null ? void 0 : _this_pluginSystem.destroyComposition(this);
24674
24755
  this.update = function() {
24675
24756
  {
@@ -24766,15 +24847,6 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
24766
24847
  this.textureOffloaded = true;
24767
24848
  }
24768
24849
  };
24769
- _proto.getRendererOptions = function getRendererOptions() {
24770
- if (!this.rendererOptions) {
24771
- this.rendererOptions = {
24772
- emptyTexture: this.renderFrame.emptyTexture,
24773
- cachePrefix: "-"
24774
- };
24775
- }
24776
- return this.rendererOptions;
24777
- };
24778
24850
  /**
24779
24851
  * 重新加载纹理
24780
24852
  */ _proto.reloadTexture = function reloadTexture() {
@@ -24888,7 +24960,9 @@ exports.VFXItem = /*#__PURE__*/ function(EffectsObject) {
24888
24960
  function VFXItem(engine, props) {
24889
24961
  var _this;
24890
24962
  _this = EffectsObject.call(this, engine) || this;
24891
- _this.children = [];
24963
+ /**
24964
+ * 元素的子元素列表
24965
+ */ _this.children = [];
24892
24966
  /**
24893
24967
  * 元素的变换包含位置、旋转、缩放。
24894
24968
  */ _this.transform = new Transform();
@@ -24899,9 +24973,6 @@ exports.VFXItem = /*#__PURE__*/ function(EffectsObject) {
24899
24973
  * 元素动画的持续时间
24900
24974
  */ _this.duration = 0;
24901
24975
  /**
24902
- * 元素动画的开始时间
24903
- */ _this.start = 0;
24904
- /**
24905
24976
  * 元素动画结束时行为(如何处理元素)
24906
24977
  */ _this.endBehavior = EndBehavior.forward;
24907
24978
  _this.type = ItemType.base;
@@ -25021,6 +25092,7 @@ exports.VFXItem = /*#__PURE__*/ function(EffectsObject) {
25021
25092
  this.composition = vfxItem.composition;
25022
25093
  }
25023
25094
  if (!this.isDuringPlay && vfxItem.isDuringPlay) {
25095
+ this.awake();
25024
25096
  this.beginPlay();
25025
25097
  }
25026
25098
  };
@@ -25196,6 +25268,21 @@ exports.VFXItem = /*#__PURE__*/ function(EffectsObject) {
25196
25268
  };
25197
25269
  /**
25198
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
25199
25286
  */ _proto.onActiveChanged = function onActiveChanged() {
25200
25287
  if (!this.isEnabled) {
25201
25288
  this.onEnable();
@@ -25234,12 +25321,11 @@ exports.VFXItem = /*#__PURE__*/ function(EffectsObject) {
25234
25321
  };
25235
25322
  _proto.fromData = function fromData(data) {
25236
25323
  EffectsObject.prototype.fromData.call(this, data);
25237
- 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, _data_visible = data.visible, visible = _data_visible === void 0 ? true : _data_visible;
25238
25325
  this.props = data;
25239
25326
  this.type = data.type;
25240
25327
  this.id = id.toString(); // TODO 老数据 id 是 number,需要转换
25241
25328
  this.name = name;
25242
- this.start = delay ? delay : this.start;
25243
25329
  if (transform) {
25244
25330
  this.transform.fromData(transform);
25245
25331
  }
@@ -25273,6 +25359,7 @@ exports.VFXItem = /*#__PURE__*/ function(EffectsObject) {
25273
25359
  if (VFXItem.isComposition(this)) {
25274
25360
  this.instantiatePreComposition();
25275
25361
  }
25362
+ this.setVisible(visible);
25276
25363
  };
25277
25364
  _proto.toData = function toData() {
25278
25365
  var _this_parent;
@@ -25316,10 +25403,10 @@ exports.VFXItem = /*#__PURE__*/ function(EffectsObject) {
25316
25403
  component.dispose();
25317
25404
  }
25318
25405
  this.components = [];
25319
- this._content = undefined;
25320
25406
  this._composition = null;
25321
25407
  this.transform.setValid(false);
25322
25408
  }
25409
+ EffectsObject.prototype.dispose.call(this);
25323
25410
  };
25324
25411
  _proto.resetChildrenParent = function resetChildrenParent() {
25325
25412
  // GE 父元素销毁子元素继承逻辑
@@ -25459,14 +25546,6 @@ exports.VFXItem = /*#__PURE__*/ function(EffectsObject) {
25459
25546
  return false;
25460
25547
  };
25461
25548
  _create_class(VFXItem, [
25462
- {
25463
- key: "content",
25464
- get: /**
25465
- * 返回元素创建的数据
25466
- */ function get() {
25467
- return this._content;
25468
- }
25469
- },
25470
25549
  {
25471
25550
  key: "composition",
25472
25551
  get: /**
@@ -25600,7 +25679,7 @@ var ColorPlayable = /*#__PURE__*/ function(Playable) {
25600
25679
  }
25601
25680
  var colorInc = vecFill(tempColor, 1);
25602
25681
  var colorChanged;
25603
- var life = this.time / boundObject.duration;
25682
+ var life = this.time / this.getDuration();
25604
25683
  var opacityOverLifetime = this.opacityOverLifetime;
25605
25684
  var colorOverLifetime = this.colorOverLifetime;
25606
25685
  if (colorOverLifetime) {
@@ -25884,7 +25963,7 @@ exports.SpriteComponent = /*#__PURE__*/ function(MaskableGraphic) {
25884
25963
  _this = MaskableGraphic.call(this, engine) || this;
25885
25964
  _this.time = 0;
25886
25965
  _this.duration = 0;
25887
- _this.frameAnimationLoop = true;
25966
+ _this.loop = true;
25888
25967
  /**
25889
25968
  * @internal
25890
25969
  */ _this.splits = singleSplits;
@@ -25899,7 +25978,7 @@ exports.SpriteComponent = /*#__PURE__*/ function(MaskableGraphic) {
25899
25978
  var _this = this;
25900
25979
  var time = this.time;
25901
25980
  var duration = this.duration;
25902
- if (time > duration && this.frameAnimationLoop) {
25981
+ if (time > duration && this.loop) {
25903
25982
  time = time % duration;
25904
25983
  }
25905
25984
  var life = Math.min(Math.max(time / duration, 0.0), 1.0);
@@ -26139,6 +26218,8 @@ exports.SpriteComponent = /*#__PURE__*/ function(MaskableGraphic) {
26139
26218
  var _data_duration;
26140
26219
  //@ts-expect-error
26141
26220
  this.duration = (_data_duration = data.duration) != null ? _data_duration : this.item.duration;
26221
+ var _data_loop;
26222
+ this.loop = (_data_loop = data.loop) != null ? _data_loop : true;
26142
26223
  };
26143
26224
  return SpriteComponent;
26144
26225
  }(MaskableGraphic);
@@ -28891,7 +28972,8 @@ var TextLayout = /*#__PURE__*/ function() {
28891
28972
  function TextLayout(options) {
28892
28973
  this.width = 0;
28893
28974
  this.height = 0;
28894
- 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;
28975
+ 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
28976
+ useLegacyRichText, useLegacyRichText = _options_useLegacyRichText === void 0 ? false : _options_useLegacyRichText;
28895
28977
  var tempWidth = fontSize + letterSpace;
28896
28978
  this.autoWidth = autoWidth;
28897
28979
  this.maxTextWidth = text.length * tempWidth;
@@ -28899,6 +28981,7 @@ var TextLayout = /*#__PURE__*/ function() {
28899
28981
  this.height = textHeight;
28900
28982
  this.letterSpace = letterSpace;
28901
28983
  this.lineGap = lineGap;
28984
+ this.useLegacyRichText = useLegacyRichText;
28902
28985
  this.overflow = textOverflow;
28903
28986
  this.textBaseline = textBaseline;
28904
28987
  this.textAlign = textAlign;
@@ -28949,6 +29032,38 @@ var TextLayout = /*#__PURE__*/ function() {
28949
29032
  return offsetX;
28950
29033
  };
28951
29034
  /**
29035
+ * 富文本垂直对齐计算
29036
+ * @param style - 字体样式
29037
+ * @param lineHeights - 每行高度数组
29038
+ * @param fontSize - 字体大小
29039
+ * @returns 第一行基线的 Y 坐标
29040
+ */ _proto.getOffsetYRich = function getOffsetYRich(style, lineHeights, fontSize) {
29041
+ var outlineWidth = style.outlineWidth, fontScale = style.fontScale;
29042
+ var total = lineHeights.reduce(function(a, b) {
29043
+ return a + b;
29044
+ }, 0);
29045
+ // 使用与原始 getOffsetY 相同的经验值计算
29046
+ // /3 计算 Y 轴偏移量,以匹配编辑器行为
29047
+ var offsetY = (lineHeights[0] - fontSize) / 3;
29048
+ // 计算基础偏移量(从画布顶部到第一行基线的距离)
29049
+ var baseOffset = fontSize + outlineWidth * fontScale;
29050
+ // 除第一行外的所有行的总高度
29051
+ var commonCalculation = total - lineHeights[0]; // 使用实际总高度减去第一行高度
29052
+ var offsetResult = 0;
29053
+ switch(this.textBaseline){
29054
+ case TextBaseline.top:
29055
+ offsetResult = baseOffset + offsetY;
29056
+ break;
29057
+ case TextBaseline.middle:
29058
+ offsetResult = (this.height * fontScale - total + this.lineGap * fontScale) / 2 + baseOffset;
29059
+ break;
29060
+ case TextBaseline.bottom:
29061
+ offsetResult = this.height * fontScale - commonCalculation - offsetY;
29062
+ break;
29063
+ }
29064
+ return offsetResult;
29065
+ };
29066
+ /**
28952
29067
  * 设置文本框的宽度和高度
28953
29068
  * @param width 文本框宽度
28954
29069
  * @param height 文本框高度
@@ -29079,6 +29194,10 @@ exports.TextComponent = /*#__PURE__*/ function(MaskableGraphic) {
29079
29194
  MaskableGraphic.prototype.onUpdate.call(this, dt);
29080
29195
  this.updateTexture();
29081
29196
  };
29197
+ _proto.onDestroy = function onDestroy() {
29198
+ MaskableGraphic.prototype.onDestroy.call(this);
29199
+ this.disposeTextTexture();
29200
+ };
29082
29201
  _proto.fromData = function fromData(data) {
29083
29202
  MaskableGraphic.prototype.fromData.call(this, data);
29084
29203
  var interaction = data.interaction, options = data.options;
@@ -29115,19 +29234,20 @@ var TextComponentBase = /*#__PURE__*/ function() {
29115
29234
  _proto.getLineCount = function getLineCount(text, init) {
29116
29235
  var context = this.context;
29117
29236
  var _this_textLayout = this.textLayout, letterSpace = _this_textLayout.letterSpace, overflow = _this_textLayout.overflow;
29118
- var fontScale = init ? this.textStyle.fontSize / 10 : 1 / this.textStyle.fontScale;
29237
+ // const fontScale = init ? this.textStyle.fontSize / 10 : 1 / this.textStyle.fontScale;
29238
+ this.maxLineWidth = 0;
29119
29239
  var width = this.textLayout.width + this.textStyle.fontOffset;
29120
29240
  var lineCount = 1;
29121
29241
  var x = 0;
29122
- //设置context.font的字号
29123
- // if (context) {
29124
- // context.font = this.getFontDesc(this.textStyle.fontSize);
29125
- // }
29242
+ // 设置context.font的字号,确保measureText能正确计算字宽
29243
+ if (context) {
29244
+ context.font = this.getFontDesc(this.textStyle.fontSize);
29245
+ }
29126
29246
  for(var i = 0; i < text.length; i++){
29127
29247
  var _context_measureText;
29128
29248
  var str = text[i];
29129
29249
  var _context_measureText_width;
29130
- var textMetrics = ((_context_measureText_width = context == null ? void 0 : (_context_measureText = context.measureText(str)) == null ? void 0 : _context_measureText.width) != null ? _context_measureText_width : 0) * fontScale;
29250
+ var textMetrics = (_context_measureText_width = context == null ? void 0 : (_context_measureText = context.measureText(str)) == null ? void 0 : _context_measureText.width) != null ? _context_measureText_width : 0;
29131
29251
  // 和浏览器行为保持一致
29132
29252
  x += letterSpace;
29133
29253
  // 处理文本结束行为
@@ -29452,10 +29572,17 @@ var TextComponentBase = /*#__PURE__*/ function() {
29452
29572
  wrapS: glContext.CLAMP_TO_EDGE,
29453
29573
  wrapT: glContext.CLAMP_TO_EDGE
29454
29574
  });
29575
+ this.disposeTextTexture();
29455
29576
  this.renderer.texture = texture;
29456
29577
  this.material.setTexture("_MainTex", texture);
29457
29578
  this.isDirty = false;
29458
29579
  };
29580
+ _proto.disposeTextTexture = function disposeTextTexture() {
29581
+ var texture = this.renderer.texture;
29582
+ if (texture && texture !== this.engine.whiteTexture) {
29583
+ texture.dispose();
29584
+ }
29585
+ };
29459
29586
  _proto.getFontDesc = function getFontDesc(size) {
29460
29587
  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;
29461
29588
  var fontDesc = "" + (size || fontSize * fontScale).toString() + "px ";
@@ -30528,10 +30655,43 @@ function version34Migration(json) {
30528
30655
  }
30529
30656
  }
30530
30657
  }
30658
+ // 处理富文本lineGap兼容性
30659
+ processRichTextLineGapCompatibility(json);
30531
30660
  //@ts-expect-error
30532
30661
  json.version = "3.5";
30533
30662
  return json;
30534
30663
  }
30664
+ /**
30665
+ * 处理富文本 lineGap 兼容性
30666
+ */ function processRichTextLineGapCompatibility(json) {
30667
+ if (!json.components) {
30668
+ return;
30669
+ }
30670
+ // 遍历所有组件,处理富文本组件
30671
+ for(var _iterator = _create_for_of_iterator_helper_loose(json.components), _step; !(_step = _iterator()).done;){
30672
+ var component = _step.value;
30673
+ // 识别富文本组件并处理 lineGap 兼容性
30674
+ if (component.dataType === DataType.RichTextComponent && component.options) {
30675
+ ensureRichTextLineGap(component.options);
30676
+ }
30677
+ }
30678
+ }
30679
+ /**
30680
+ * 确保富文本组件有版本标识字段
30681
+ */ function ensureRichTextLineGap(options) {
30682
+ // 检查是否已经处理过
30683
+ if (!options || options.useLegacyRichText !== undefined) {
30684
+ return;
30685
+ }
30686
+ // 根据是否存在 lineGap 字段来判断版本
30687
+ if (options.lineGap === undefined) {
30688
+ // 旧版本(没有 lineGap 字段)
30689
+ options.useLegacyRichText = true;
30690
+ } else {
30691
+ // 新版本(有 lineGap 字段)
30692
+ options.useLegacyRichText = false;
30693
+ }
30694
+ }
30535
30695
  /**
30536
30696
  * 根据形状获取形状几何体数据
30537
30697
  * @param shape - 形状
@@ -31454,7 +31614,7 @@ function getStandardSpriteContent(sprite, transform) {
31454
31614
  return ret;
31455
31615
  }
31456
31616
 
31457
- var version$1 = "2.7.0-alpha.2";
31617
+ var version$1 = "2.7.0";
31458
31618
  var v0 = /^(\d+)\.(\d+)\.(\d+)(-(\w+)\.\d+)?$/;
31459
31619
  var standardVersion = /^(\d+)\.(\d+)$/;
31460
31620
  var reverseParticle = false;
@@ -32690,7 +32850,7 @@ function createTextureOptionsBySource(image, sourceFrom, id) {
32690
32850
  function AssetService(engine) {
32691
32851
  this.engine = engine;
32692
32852
  this.builtinObjects = [];
32693
- this.builtinObjects.push(generateWhiteTexture(engine));
32853
+ this.builtinObjects.push(engine.whiteTexture);
32694
32854
  }
32695
32855
  var _proto = AssetService.prototype;
32696
32856
  /**
@@ -34366,7 +34526,7 @@ var FBGeometryDataT = /*#__PURE__*/ function() {
34366
34526
  this.jsonSceneData = {};
34367
34527
  this.objectInstance = {};
34368
34528
  this.assetLoader = new AssetLoader(this);
34369
- this.emptyTexture = generateWhiteTexture(this);
34529
+ this.whiteTexture = generateWhiteTexture(this);
34370
34530
  this.transparentTexture = generateTransparentTexture(this);
34371
34531
  }
34372
34532
  var _proto = Engine.prototype;
@@ -34727,7 +34887,7 @@ registerPlugin("sprite", SpriteLoader, exports.VFXItem);
34727
34887
  registerPlugin("particle", ParticleLoader, exports.VFXItem);
34728
34888
  registerPlugin("cal", CalculateLoader, exports.VFXItem);
34729
34889
  registerPlugin("interact", InteractLoader, exports.VFXItem);
34730
- var version = "2.7.0-alpha.2";
34890
+ var version = "2.7.0";
34731
34891
  logger.info("Core version: " + version + ".");
34732
34892
 
34733
34893
  exports.AbstractPlugin = AbstractPlugin;