@galacean/effects-threejs 2.7.0-alpha.2 → 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 threejs plugin 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-beta.0
7
7
  */
8
8
 
9
9
  'use strict';
@@ -3684,15 +3684,30 @@ var MaterialBlending;
3684
3684
  var TextOverflow;
3685
3685
  (function(TextOverflow) {
3686
3686
  /**
3687
- * display 模式下,会显示所有文本,文本大小会根据边界框调整。
3688
- */ TextOverflow[TextOverflow["display"] = 0] = "display";
3687
+ * visible 模式下,文本内容超出边界框时,会继续显示内容,不进行裁剪或缩放。
3688
+ */ TextOverflow[TextOverflow["visible"] = 0] = "visible";
3689
+ /**
3690
+ * display 模式下,会显示所有文本,文本字号大小会根据边界框调整。
3691
+ */ TextOverflow[TextOverflow["display"] = 1] = "display";
3689
3692
  /**
3690
3693
  * clip 模式下,当文本内容超出边界框时,多余的会被截断。
3691
- */ TextOverflow[TextOverflow["clip"] = 1] = "clip";
3694
+ */ TextOverflow[TextOverflow["clip"] = 2] = "clip";
3692
3695
  /**
3693
3696
  * ellipsis 模式下,会使用(...)来代替超出边界框的内容。
3694
- */ TextOverflow[TextOverflow["ellipsis"] = 2] = "ellipsis";
3697
+ */ TextOverflow[TextOverflow["ellipsis"] = 3] = "ellipsis";
3695
3698
  })(TextOverflow || (TextOverflow = {}));
3699
+ var TextSizeMode;
3700
+ (function(TextSizeMode) {
3701
+ /**
3702
+ * 自适应宽度
3703
+ */ TextSizeMode[TextSizeMode["autoWidth"] = 0] = "autoWidth";
3704
+ /**
3705
+ * 自适应高度
3706
+ */ TextSizeMode[TextSizeMode["autoHeight"] = 1] = "autoHeight";
3707
+ /**
3708
+ * 固定宽高
3709
+ */ TextSizeMode[TextSizeMode["fixed"] = 2] = "fixed";
3710
+ })(TextSizeMode || (TextSizeMode = {}));
3696
3711
  var TextBaseline;
3697
3712
  (function(TextBaseline) {
3698
3713
  /**
@@ -4034,6 +4049,7 @@ var index$1 = /*#__PURE__*/Object.freeze({
4034
4049
  get MaterialBlending () { return MaterialBlending; },
4035
4050
  get RenderMode3D () { return RenderMode3D; },
4036
4051
  get TextOverflow () { return TextOverflow; },
4052
+ get TextSizeMode () { return TextSizeMode; },
4037
4053
  get TextBaseline () { return TextBaseline; },
4038
4054
  get TextAlignment () { return TextAlignment; },
4039
4055
  get TextWeight () { return TextWeight; },
@@ -4148,10 +4164,16 @@ function getDirectStore(target) {
4148
4164
  * 反序列化函数
4149
4165
  *
4150
4166
  * @param data - 对象的序列化的数据
4151
- */ _proto.fromData = function fromData(data) {};
4167
+ */ _proto.fromData = function fromData(data) {
4168
+ if (data.id !== undefined) {
4169
+ this.setInstanceId(data.id);
4170
+ }
4171
+ };
4152
4172
  /**
4153
- *
4154
- */ _proto.dispose = function dispose() {};
4173
+ * 销毁当前对象
4174
+ */ _proto.dispose = function dispose() {
4175
+ this.engine.removeInstance(this.guid);
4176
+ };
4155
4177
  /**
4156
4178
  *
4157
4179
  * @param obj
@@ -5245,7 +5267,7 @@ var Pose = /*#__PURE__*/ function() {
5245
5267
  }
5246
5268
  for(var _iterator2 = _create_for_of_iterator_helper_loose(skeleton.defaultColorPropertyValues), _step2; !(_step2 = _iterator2()).done;){
5247
5269
  var defaultColor = _step2.value;
5248
- this.colorPropertyValues.push(defaultColor);
5270
+ this.colorPropertyValues.push(new Color().copyFrom(defaultColor));
5249
5271
  }
5250
5272
  }
5251
5273
  var _proto = Pose.prototype;
@@ -6720,7 +6742,7 @@ var Skeleton = /*#__PURE__*/ function() {
6720
6742
  break;
6721
6743
  case 1:
6722
6744
  this.colorAnimatedObjects.push(animatedObject);
6723
- this.defaultColorPropertyValues.push(directTarget[lastPropertyName]);
6745
+ this.defaultColorPropertyValues.push(new Color().copyFrom(directTarget[lastPropertyName]));
6724
6746
  this.pathToObjectIndex.set(totalPath, this.colorAnimatedObjects.length - 1);
6725
6747
  }
6726
6748
  };
@@ -7017,6 +7039,7 @@ function _create_class(Constructor, protoProps, staticProps) {
7017
7039
  if (this.item) {
7018
7040
  removeItem(this.item.components, this);
7019
7041
  }
7042
+ EffectsObject.prototype.dispose.call(this);
7020
7043
  };
7021
7044
  _proto.start = function start() {
7022
7045
  if (this.isStartCalled) {
@@ -12207,9 +12230,8 @@ var seed$8 = 1;
12207
12230
  this.destroyed = true;
12208
12231
  if (this.engine !== undefined) {
12209
12232
  this.engine.removeMesh(this);
12210
- // @ts-expect-error
12211
- this.engine = undefined;
12212
12233
  }
12234
+ RendererComponent.prototype.dispose.call(this);
12213
12235
  };
12214
12236
  _create_class(Mesh, [
12215
12237
  {
@@ -13365,8 +13387,6 @@ var seed$6 = 1;
13365
13387
  this.clearAction = clearAction;
13366
13388
  this.name = "RenderFrame" + seed$6++;
13367
13389
  var firstRP = renderPasses[0];
13368
- this.emptyTexture = generateWhiteTexture(engine);
13369
- this.transparentTexture = generateTransparentTexture(engine);
13370
13390
  this.camera = camera;
13371
13391
  this.keepColorBuffer = keepColorBuffer;
13372
13392
  this.renderPassInfoMap.set(firstRP, {
@@ -13415,8 +13435,6 @@ var seed$6 = 1;
13415
13435
  }
13416
13436
  this.passTextureCache.dispose();
13417
13437
  this._renderPasses.length = 0;
13418
- this.emptyTexture.dispose();
13419
- this.transparentTexture.dispose();
13420
13438
  if (this.resource) {
13421
13439
  var _this_resource_depthStencil_texture, _this_resource_depthStencil;
13422
13440
  this.resource.color_a.dispose();
@@ -14076,7 +14094,7 @@ var Renderer = /*#__PURE__*/ function() {
14076
14094
  _this.renderer = {
14077
14095
  renderMode: RenderMode.MESH,
14078
14096
  blending: BlendingMode.ALPHA,
14079
- texture: _this.engine.emptyTexture,
14097
+ texture: _this.engine.whiteTexture,
14080
14098
  occlusion: false,
14081
14099
  transparentOcclusion: false,
14082
14100
  side: SideMode.DOUBLE,
@@ -14284,7 +14302,7 @@ var Renderer = /*#__PURE__*/ function() {
14284
14302
  this.renderer = {
14285
14303
  renderMode: (_renderer_renderMode = renderer.renderMode) != null ? _renderer_renderMode : RenderMode.MESH,
14286
14304
  blending: (_renderer_blending = renderer.blending) != null ? _renderer_blending : BlendingMode.ALPHA,
14287
- texture: renderer.texture ? this.engine.findObject(renderer.texture) : this.engine.emptyTexture,
14305
+ texture: renderer.texture ? this.engine.findObject(renderer.texture) : this.engine.whiteTexture,
14288
14306
  occlusion: !!renderer.occlusion,
14289
14307
  transparentOcclusion: !!renderer.transparentOcclusion || this.maskManager.maskMode === exports.MaskMode.MASK,
14290
14308
  side: (_renderer_side = renderer.side) != null ? _renderer_side : SideMode.DOUBLE,
@@ -16128,20 +16146,26 @@ function oldBezierKeyFramesToNew(props) {
16128
16146
  keyDatas.push(keyData);
16129
16147
  lastControl = p2;
16130
16148
  }
16131
- var calculateSlop = function(p0, p1) {
16149
+ var calculateSlope = function(p0, p1) {
16132
16150
  return (p1.y - p0.y) / (p1.x - p0.x + NumberEpsilon);
16133
16151
  };
16134
16152
  for(var i1 = 0; i1 < keyDatas.length; i1++){
16135
16153
  var leftControl = keyDatas[i1].leftControl;
16136
16154
  var value = keyDatas[i1].value;
16137
16155
  var rightControl = keyDatas[i1].rightControl;
16138
- var outSlop = calculateSlop(value, rightControl);
16139
- var inSlop = calculateSlop(leftControl, value);
16156
+ var inSlope = 0;
16157
+ var outSlope = 0;
16158
+ if (i1 > 0) {
16159
+ inSlope = calculateSlope(leftControl, value);
16160
+ }
16161
+ if (i1 < keyDatas.length - 1) {
16162
+ outSlope = calculateSlope(value, rightControl);
16163
+ }
16140
16164
  var keyframe = {
16141
16165
  time: value.x,
16142
16166
  value: value.y,
16143
- inSlope: inSlop,
16144
- outSlope: outSlop,
16167
+ inSlope: inSlope,
16168
+ outSlope: outSlope,
16145
16169
  inWeight: 0,
16146
16170
  outWeight: 0,
16147
16171
  tangentMode: keyDatas[i1].tangentMode,
@@ -16278,8 +16302,6 @@ exports.ShapeComponent = /*#__PURE__*/ function(RendererComponent) {
16278
16302
  function ShapeComponent(engine) {
16279
16303
  var _this;
16280
16304
  _this = RendererComponent.call(this, engine) || this;
16281
- _this.hasStroke = false;
16282
- _this.hasFill = false;
16283
16305
  _this.shapeDirty = true;
16284
16306
  _this.materialDirty = true;
16285
16307
  _this.graphicsPath = new GraphicsPath();
@@ -16298,6 +16320,8 @@ exports.ShapeComponent = /*#__PURE__*/ function(RendererComponent) {
16298
16320
  /**
16299
16321
  * 用于点击测试的碰撞器
16300
16322
  */ _this.meshCollider = new MeshCollider();
16323
+ _this.fillMaterials = [];
16324
+ _this.strokeMaterials = [];
16301
16325
  _this.getHitTestParams = function(force) {
16302
16326
  var sizeMatrix = Matrix4.fromScale(_this.transform.size.x, _this.transform.size.y, 1);
16303
16327
  var worldMatrix = sizeMatrix.premultiply(_this.transform.getWorldMatrix());
@@ -16309,15 +16333,15 @@ exports.ShapeComponent = /*#__PURE__*/ function(RendererComponent) {
16309
16333
  behavior: 0,
16310
16334
  type: area.type,
16311
16335
  triangles: area.area,
16312
- backfaceCulling: _this.renderer.side === SideMode.FRONT
16336
+ backfaceCulling: _this.rendererOptions.side === SideMode.FRONT
16313
16337
  };
16314
16338
  }
16315
16339
  }
16316
16340
  };
16317
- _this.renderer = {
16341
+ _this.rendererOptions = {
16318
16342
  renderMode: RenderMode.MESH,
16319
16343
  blending: BlendingMode.ALPHA,
16320
- texture: _this.engine.emptyTexture,
16344
+ texture: _this.engine.whiteTexture,
16321
16345
  occlusion: false,
16322
16346
  transparentOcclusion: false,
16323
16347
  side: SideMode.DOUBLE,
@@ -16405,25 +16429,6 @@ exports.ShapeComponent = /*#__PURE__*/ function(RendererComponent) {
16405
16429
  indexCount: 0,
16406
16430
  vertexCount: 0
16407
16431
  });
16408
- // Create Material
16409
- //-------------------------------------------------------------------------
16410
- var materialProps = {
16411
- shader: {
16412
- vertex: vert,
16413
- fragment: frag,
16414
- glslVersion: exports.GLSLVersion.GLSL1
16415
- }
16416
- };
16417
- var fillMaterial = Material.create(engine, materialProps);
16418
- var strokeMaterial = Material.create(engine, materialProps);
16419
- fillMaterial.depthMask = false;
16420
- fillMaterial.depthTest = true;
16421
- fillMaterial.blending = true;
16422
- _this.material = fillMaterial;
16423
- strokeMaterial.depthMask = false;
16424
- strokeMaterial.depthTest = true;
16425
- strokeMaterial.blending = true;
16426
- _this.materials[1] = strokeMaterial;
16427
16432
  return _this;
16428
16433
  }
16429
16434
  var _proto = ShapeComponent.prototype;
@@ -16451,18 +16456,26 @@ exports.ShapeComponent = /*#__PURE__*/ function(RendererComponent) {
16451
16456
  if (!this.isActiveAndEnabled) {
16452
16457
  return;
16453
16458
  }
16454
- var previousColorMask0 = this.material.colorMask;
16455
- var previousColorMask1 = this.materials[1].colorMask;
16456
- this.material.colorMask = false;
16457
- this.materials[1].colorMask = false;
16458
- this.draw(renderer);
16459
- this.material.colorMask = previousColorMask0;
16460
- this.materials[1].colorMask = previousColorMask1;
16459
+ var previousColorMask = false;
16460
+ for(var i = 0; i < this.fillMaterials.length; i++){
16461
+ previousColorMask = this.fillMaterials[i].colorMask;
16462
+ this.fillMaterials[i].colorMask = false;
16463
+ renderer.drawGeometry(this.geometry, this.transform.getWorldMatrix(), this.fillMaterials[i], 0);
16464
+ this.fillMaterials[i].colorMask = previousColorMask;
16465
+ }
16466
+ for(var i1 = 0; i1 < this.strokeMaterials.length; i1++){
16467
+ previousColorMask = this.strokeMaterials[i1].colorMask;
16468
+ this.strokeMaterials[i1].colorMask = false;
16469
+ renderer.drawGeometry(this.geometry, this.transform.getWorldMatrix(), this.strokeMaterials[i1], 1);
16470
+ this.strokeMaterials[i1].colorMask = previousColorMask;
16471
+ }
16461
16472
  };
16462
16473
  _proto.draw = function draw(renderer) {
16463
- for(var i = 0; i < this.materials.length; i++){
16464
- var material = this.materials[i];
16465
- renderer.drawGeometry(this.geometry, this.transform.getWorldMatrix(), material, i);
16474
+ for(var i = 0; i < this.fillMaterials.length; i++){
16475
+ renderer.drawGeometry(this.geometry, this.transform.getWorldMatrix(), this.fillMaterials[i], 0);
16476
+ }
16477
+ for(var i1 = 0; i1 < this.strokeMaterials.length; i1++){
16478
+ renderer.drawGeometry(this.geometry, this.transform.getWorldMatrix(), this.strokeMaterials[i1], 1);
16466
16479
  }
16467
16480
  };
16468
16481
  _proto.getBoundingBox = function getBoundingBox() {
@@ -16476,7 +16489,7 @@ exports.ShapeComponent = /*#__PURE__*/ function(RendererComponent) {
16476
16489
  var vertices = [];
16477
16490
  var indices = [];
16478
16491
  // Triangulate shapePrimitives, build fill and stroke shape geometry
16479
- if (this.hasFill) {
16492
+ if (this.fills.length > 0) {
16480
16493
  for(var _iterator = _create_for_of_iterator_helper_loose(shapePrimitives), _step; !(_step = _iterator()).done;){
16481
16494
  var shapePrimitive = _step.value;
16482
16495
  var shape = shapePrimitive.shape;
@@ -16488,7 +16501,7 @@ exports.ShapeComponent = /*#__PURE__*/ function(RendererComponent) {
16488
16501
  }
16489
16502
  }
16490
16503
  var fillIndexCount = indices.length;
16491
- if (this.hasStroke) {
16504
+ if (this.strokes.length > 0) {
16492
16505
  for(var _iterator1 = _create_for_of_iterator_helper_loose(shapePrimitives), _step1; !(_step1 = _iterator1()).done;){
16493
16506
  var shapePrimitive1 = _step1.value;
16494
16507
  var shape1 = shapePrimitive1.shape;
@@ -16626,40 +16639,12 @@ exports.ShapeComponent = /*#__PURE__*/ function(RendererComponent) {
16626
16639
  }
16627
16640
  };
16628
16641
  _proto.updateMaterials = function updateMaterials() {
16629
- for(var _iterator = _create_for_of_iterator_helper_loose(this.materials), _step; !(_step = _iterator()).done;){
16630
- var material = _step.value;
16631
- var renderer = this.renderer;
16632
- var side = renderer.side, occlusion = renderer.occlusion, blendMode = renderer.blending, mask = renderer.mask, texture = renderer.texture;
16633
- var maskMode = this.maskManager.maskMode;
16634
- material.blending = true;
16635
- material.depthTest = true;
16636
- material.depthMask = occlusion;
16637
- material.stencilRef = mask !== undefined ? [
16638
- mask,
16639
- mask
16640
- ] : undefined;
16641
- setBlendMode(material, blendMode);
16642
- // 兼容旧数据中模板需要渲染的情况
16643
- setMaskMode(material, maskMode);
16644
- setSideMode(material, side);
16645
- material.shader.shaderData.properties = '_MainTex("_MainTex",2D) = "white" {}';
16646
- material.setVector4("_TexOffset", new Vector4(0, 0, 1, 1));
16647
- material.setTexture("_MainTex", texture);
16648
- var preMultiAlpha = getPreMultiAlpha(blendMode);
16649
- var texParams = new Vector4();
16650
- texParams.x = renderer.occlusion ? +renderer.transparentOcclusion : 1;
16651
- texParams.y = preMultiAlpha;
16652
- texParams.z = renderer.renderMode;
16653
- texParams.w = maskMode;
16654
- material.setVector4("_TexParams", texParams);
16655
- if (texParams.x === 0 || this.maskManager.alphaMaskEnabled) {
16656
- material.enableMacro("ALPHA_CLIP");
16657
- } else {
16658
- material.disableMacro("ALPHA_CLIP");
16659
- }
16642
+ for(var i = 0; i < this.fills.length; i++){
16643
+ this.updatePaintMaterial(this.fillMaterials[i], this.fills[i]);
16644
+ }
16645
+ for(var i1 = 0; i1 < this.strokes.length; i1++){
16646
+ this.updatePaintMaterial(this.strokeMaterials[i1], this.strokes[i1]);
16660
16647
  }
16661
- this.updatePaintMaterial(this.material, this.fills[0]);
16662
- this.updatePaintMaterial(this.materials[1], this.strokes[0]);
16663
16648
  };
16664
16649
  _proto.updatePaintMaterial = function updatePaintMaterial(material, paint) {
16665
16650
  material.setFloat("_FillType", paint.type);
@@ -16696,6 +16681,46 @@ exports.ShapeComponent = /*#__PURE__*/ function(RendererComponent) {
16696
16681
  material.setVector2("_StartPoint", startPoint);
16697
16682
  material.setVector2("_EndPoint", endPoint);
16698
16683
  };
16684
+ _proto.createMaterialFromRendererOptions = function createMaterialFromRendererOptions(rendererOptions) {
16685
+ var materialProps = {
16686
+ shader: {
16687
+ vertex: vert,
16688
+ fragment: frag,
16689
+ glslVersion: exports.GLSLVersion.GLSL1
16690
+ }
16691
+ };
16692
+ var material = Material.create(this.engine, materialProps);
16693
+ var renderer = rendererOptions;
16694
+ var side = renderer.side, occlusion = renderer.occlusion, blendMode = renderer.blending, mask = renderer.mask, texture = renderer.texture;
16695
+ var maskMode = this.maskManager.maskMode;
16696
+ material.blending = true;
16697
+ material.depthTest = true;
16698
+ material.depthMask = occlusion;
16699
+ material.stencilRef = mask !== undefined ? [
16700
+ mask,
16701
+ mask
16702
+ ] : undefined;
16703
+ setBlendMode(material, blendMode);
16704
+ // 兼容旧数据中模板需要渲染的情况
16705
+ setMaskMode(material, maskMode);
16706
+ setSideMode(material, side);
16707
+ material.shader.shaderData.properties = '_ImageTex("_ImageTex",2D) = "white" {}';
16708
+ material.setVector4("_TexOffset", new Vector4(0, 0, 1, 1));
16709
+ material.setTexture("_ImageTex", texture);
16710
+ var preMultiAlpha = getPreMultiAlpha(blendMode);
16711
+ var texParams = new Vector4();
16712
+ texParams.x = renderer.occlusion ? +renderer.transparentOcclusion : 1;
16713
+ texParams.y = preMultiAlpha;
16714
+ texParams.z = renderer.renderMode;
16715
+ texParams.w = maskMode;
16716
+ material.setVector4("_TexParams", texParams);
16717
+ if (texParams.x === 0 || this.maskManager.alphaMaskEnabled) {
16718
+ material.enableMacro("ALPHA_CLIP");
16719
+ } else {
16720
+ material.disableMacro("ALPHA_CLIP");
16721
+ }
16722
+ return material;
16723
+ };
16699
16724
  _proto.fromData = function fromData(data) {
16700
16725
  RendererComponent.prototype.fromData.call(this, data);
16701
16726
  this.shapeDirty = true;
@@ -16704,11 +16729,11 @@ exports.ShapeComponent = /*#__PURE__*/ function(RendererComponent) {
16704
16729
  }
16705
16730
  var _data_renderer;
16706
16731
  var renderer = (_data_renderer = data.renderer) != null ? _data_renderer : {};
16707
- var _renderer_renderMode, _renderer_blending, _renderer_side;
16708
- this.renderer = {
16709
- renderMode: (_renderer_renderMode = renderer.renderMode) != null ? _renderer_renderMode : RenderMode.MESH,
16732
+ var _renderer_blending, _renderer_side;
16733
+ this.rendererOptions = {
16734
+ renderMode: RenderMode.MESH,
16710
16735
  blending: (_renderer_blending = renderer.blending) != null ? _renderer_blending : BlendingMode.ALPHA,
16711
- texture: renderer.texture ? this.engine.findObject(renderer.texture) : this.engine.emptyTexture,
16736
+ texture: renderer.texture ? this.engine.findObject(renderer.texture) : this.engine.whiteTexture,
16712
16737
  occlusion: !!renderer.occlusion,
16713
16738
  transparentOcclusion: !!renderer.transparentOcclusion || this.maskManager.maskMode === exports.MaskMode.MASK,
16714
16739
  side: (_renderer_side = renderer.side) != null ? _renderer_side : SideMode.DOUBLE,
@@ -16720,22 +16745,21 @@ exports.ShapeComponent = /*#__PURE__*/ function(RendererComponent) {
16720
16745
  this.strokeWidth = (_data_strokeWidth = data.strokeWidth) != null ? _data_strokeWidth : 1;
16721
16746
  var _data_strokeJoin;
16722
16747
  this.strokeJoin = (_data_strokeJoin = data.strokeJoin) != null ? _data_strokeJoin : LineJoin.Miter;
16723
- for(var _iterator = _create_for_of_iterator_helper_loose(data.strokes), _step; !(_step = _iterator()).done;){
16724
- var stroke = _step.value;
16725
- var strokeParam = stroke;
16726
- if (strokeParam) {
16727
- this.hasStroke = true;
16728
- this.strokes[0] = this.createPaint(strokeParam);
16729
- }
16730
- }
16731
- for(var _iterator1 = _create_for_of_iterator_helper_loose(data.fills), _step1; !(_step1 = _iterator1()).done;){
16732
- var fill = _step1.value;
16733
- var fillParam = fill;
16734
- if (fillParam) {
16735
- this.hasFill = true;
16736
- this.fills[0] = this.createPaint(fillParam);
16737
- }
16738
- }
16748
+ this.fills.length = 0;
16749
+ this.fillMaterials.length = 0;
16750
+ for(var _iterator = _create_for_of_iterator_helper_loose(data.fills), _step; !(_step = _iterator()).done;){
16751
+ var fill = _step.value;
16752
+ this.fills.push(this.createPaint(fill));
16753
+ this.fillMaterials.push(this.createMaterialFromRendererOptions(this.rendererOptions));
16754
+ }
16755
+ this.strokes.length = 0;
16756
+ this.strokeMaterials.length = 0;
16757
+ for(var _iterator1 = _create_for_of_iterator_helper_loose(data.strokes), _step1; !(_step1 = _iterator1()).done;){
16758
+ var stroke = _step1.value;
16759
+ this.strokes.push(this.createPaint(stroke));
16760
+ this.strokeMaterials.push(this.createMaterialFromRendererOptions(this.rendererOptions));
16761
+ }
16762
+ this.materials = [].concat(this.fillMaterials, this.strokeMaterials);
16739
16763
  switch(data.type){
16740
16764
  case ShapePrimitiveType.Custom:
16741
16765
  {
@@ -17253,11 +17277,11 @@ var vertex = "\nprecision highp float;\n\nattribute vec2 aPoint;\nuniform vec4 u
17253
17277
  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";
17254
17278
  var seed$5 = 1;
17255
17279
  var InteractMesh = /*#__PURE__*/ function() {
17256
- function InteractMesh(props, rendererOptions, transform, engine) {
17280
+ function InteractMesh(props, transform, engine) {
17257
17281
  this.transform = transform;
17258
17282
  this.engine = engine;
17259
17283
  this.color = props.options.previewColor;
17260
- var material = this.createMaterial(rendererOptions);
17284
+ var material = this.createMaterial();
17261
17285
  var geometry = this.createGeometry();
17262
17286
  this.mesh = this.createMesh(geometry, material);
17263
17287
  this.updateMesh();
@@ -17280,7 +17304,7 @@ var InteractMesh = /*#__PURE__*/ function() {
17280
17304
  material.setVector4("uPos", uPos);
17281
17305
  material.setQuaternion("uQuat", tempQuat);
17282
17306
  };
17283
- _proto.createMaterial = function createMaterial(rendererOptions) {
17307
+ _proto.createMaterial = function createMaterial() {
17284
17308
  var _this_engine_renderer;
17285
17309
  var macros = [
17286
17310
  [
@@ -17294,7 +17318,6 @@ var InteractMesh = /*#__PURE__*/ function() {
17294
17318
  vertex: vertex,
17295
17319
  fragment: fragment,
17296
17320
  glslVersion: exports.GLSLVersion.GLSL1,
17297
- cacheId: "" + rendererOptions.cachePrefix + "_effects_interact",
17298
17321
  macros: macros
17299
17322
  }
17300
17323
  };
@@ -17416,19 +17439,33 @@ exports.InteractComponent = /*#__PURE__*/ function(RendererComponent) {
17416
17439
  return _this;
17417
17440
  }
17418
17441
  var _proto = InteractComponent.prototype;
17419
- _proto.getDragRangeX = function getDragRangeX() {
17442
+ /**
17443
+ * 获取拖拽范围 X 轴
17444
+ * @returns 拖拽范围 [min, max]
17445
+ */ _proto.getDragRangeX = function getDragRangeX() {
17420
17446
  return this.dragRange.dxRange;
17421
17447
  };
17422
- _proto.setDragRangeX = function setDragRangeX(min, max) {
17448
+ /**
17449
+ * 设置拖拽范围 X 轴
17450
+ * @param min 最小值
17451
+ * @param max 最大值
17452
+ */ _proto.setDragRangeX = function setDragRangeX(min, max) {
17423
17453
  this.dragRange.dxRange = [
17424
17454
  min,
17425
17455
  max
17426
17456
  ];
17427
17457
  };
17428
- _proto.getDragRangeY = function getDragRangeY() {
17458
+ /**
17459
+ * 获取拖拽范围 Y 轴
17460
+ * @returns 拖拽范围 [min, max]
17461
+ */ _proto.getDragRangeY = function getDragRangeY() {
17429
17462
  return this.dragRange.dyRange;
17430
17463
  };
17431
- _proto.setDragRangeY = function setDragRangeY(min, max) {
17464
+ /**
17465
+ * 设置拖拽范围 Y 轴
17466
+ * @param min 最小值
17467
+ * @param max 最大值
17468
+ */ _proto.setDragRangeY = function setDragRangeY(min, max) {
17432
17469
  this.dragRange.dyRange = [
17433
17470
  min,
17434
17471
  max
@@ -17436,15 +17473,11 @@ exports.InteractComponent = /*#__PURE__*/ function(RendererComponent) {
17436
17473
  };
17437
17474
  _proto.onStart = function onStart() {
17438
17475
  var env = this.item.engine.renderer.env;
17439
- var composition = this.item.composition;
17440
17476
  var _this_interactData_options = this.interactData.options, type = _this_interactData_options.type, showPreview = _this_interactData_options.showPreview;
17441
17477
  if (type === InteractType.CLICK) {
17442
17478
  this.clickable = true;
17443
17479
  if (showPreview && env === PLAYER_OPTIONS_ENV_EDITOR) {
17444
- var rendererOptions = composition == null ? void 0 : composition.getRendererOptions();
17445
- if (rendererOptions !== undefined) {
17446
- this.previewContent = new InteractMesh(this.item.props.content, rendererOptions, this.transform, this.engine);
17447
- }
17480
+ this.previewContent = new InteractMesh(this.item.props.content, this.transform, this.engine);
17448
17481
  }
17449
17482
  }
17450
17483
  if (this.previewContent) {
@@ -17653,7 +17686,10 @@ exports.InteractComponent = /*#__PURE__*/ function(RendererComponent) {
17653
17686
  }
17654
17687
  }
17655
17688
  };
17656
- _proto.canInteract = function canInteract() {
17689
+ /**
17690
+ * 是否可以交互
17691
+ * @returns
17692
+ */ _proto.canInteract = function canInteract() {
17657
17693
  var _this_item_composition;
17658
17694
  return Boolean((_this_item_composition = this.item.composition) == null ? void 0 : _this_item_composition.interactive) && this._interactive;
17659
17695
  };
@@ -17688,7 +17724,9 @@ exports.InteractComponent = /*#__PURE__*/ function(RendererComponent) {
17688
17724
  get: function get() {
17689
17725
  return this._interactive;
17690
17726
  },
17691
- set: function set(enable) {
17727
+ set: /**
17728
+ * 是否响应点击和拖拽交互事件
17729
+ */ function set(enable) {
17692
17730
  this._interactive = enable;
17693
17731
  if (!enable) {
17694
17732
  // 立刻停止惯性滑动
@@ -18445,6 +18483,12 @@ var tmpScale = new Vector3(1, 1, 1);
18445
18483
  this./**
18446
18484
  * @internal
18447
18485
  */ transform = new Transform();
18486
+ this./**
18487
+ * 画布的像素宽度
18488
+ */ pixelWidth = 0;
18489
+ this./**
18490
+ * 画布的像素高度
18491
+ */ pixelHeight = 0;
18448
18492
  this.viewportMatrix = Matrix4.fromIdentity();
18449
18493
  this.viewMatrix = Matrix4.fromIdentity();
18450
18494
  this.projectionMatrix = Matrix4.fromIdentity();
@@ -18459,7 +18503,7 @@ var tmpScale = new Vector3(1, 1, 1);
18459
18503
  0,
18460
18504
  0,
18461
18505
  0
18462
- ] : _options_rotation;
18506
+ ] : _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;
18463
18507
  var euler = new Euler(rotation[0], rotation[1], rotation[2]);
18464
18508
  var quat = new Quaternion().setFromEuler(euler);
18465
18509
  this.options = {
@@ -18469,6 +18513,8 @@ var tmpScale = new Vector3(1, 1, 1);
18469
18513
  aspect: aspect,
18470
18514
  clipMode: clipMode
18471
18515
  };
18516
+ this.pixelWidth = pixelWidth;
18517
+ this.pixelHeight = pixelHeight;
18472
18518
  this.transform.setPosition(position[0], position[1], position[2]);
18473
18519
  this.transform.setQuaternion(quat.x, quat.y, quat.z, quat.w);
18474
18520
  this.dirty = true;
@@ -18615,6 +18661,48 @@ var tmpScale = new Vector3(1, 1, 1);
18615
18661
  this.dirty = false;
18616
18662
  }
18617
18663
  };
18664
+ /**
18665
+ * 将世界坐标转换为屏幕像素坐标
18666
+ * @param position - 世界坐标
18667
+ * @param out - 输出的屏幕坐标,如果不传则创建新的 Vector3
18668
+ * @returns 屏幕坐标 (x, y 为像素坐标,左下角为(0,0),右上角为(width,height),z 为深度比例 [0,1],0=近平面,1=远平面)
18669
+ */ _proto.worldToScreenPoint = function worldToScreenPoint(position, out) {
18670
+ this.updateMatrix();
18671
+ var result = out != null ? out : new Vector3();
18672
+ var vpMatrix = this.getViewProjectionMatrix();
18673
+ // 应用视图投影矩阵,得到 NDC 坐标 [-1, 1]
18674
+ result.set(position.x, position.y, position.z);
18675
+ vpMatrix.projectPoint(result, result);
18676
+ // 将 NDC 坐标转换为像素坐标
18677
+ // NDC: x,y in [-1, 1], 其中 (-1,-1) 是左下角,(1,1) 是右上角
18678
+ // Screen: x,y in [0, width/height], 其中 (0,0) 是左下角
18679
+ result.x = (result.x + 1) * 0.5 * this.pixelWidth;
18680
+ result.y = (result.y + 1) * 0.5 * this.pixelHeight;
18681
+ // 将 NDC z 值从 [-1, 1] 转换为深度比例 [0, 1]
18682
+ // -1 (近平面) -> 0, 1 (远平面) -> 1
18683
+ result.z = (result.z + 1) * 0.5;
18684
+ return result;
18685
+ };
18686
+ /**
18687
+ * 将屏幕像素坐标转换为世界坐标
18688
+ * @param position - 屏幕坐标 (x, y 为像素坐标,左下角为(0,0),z 为深度比例 [0,1],0=近平面,1=远平面)
18689
+ * @param out - 输出的世界坐标,如果不传则创建新的 Vector3
18690
+ * @returns 世界坐标
18691
+ */ _proto.screenToWorldPoint = function screenToWorldPoint(position, out) {
18692
+ this.updateMatrix();
18693
+ var result = out != null ? out : new Vector3();
18694
+ var invVPMatrix = this.getInverseViewProjectionMatrix();
18695
+ // 将像素坐标转换为 NDC 坐标 [-1, 1]
18696
+ var ndcX = position.x / this.pixelWidth * 2 - 1;
18697
+ var ndcY = position.y / this.pixelHeight * 2 - 1;
18698
+ // 将深度比例 [0, 1] 转换为 NDC z 值 [-1, 1]
18699
+ // 0 (近平面) -> -1, 1 (远平面) -> 1
18700
+ var ndcZ = position.z * 2 - 1;
18701
+ // 应用逆视图投影矩阵
18702
+ result.set(ndcX, ndcY, ndcZ);
18703
+ invVPMatrix.projectPoint(result, result);
18704
+ return result;
18705
+ };
18618
18706
  _create_class(Camera, [
18619
18707
  {
18620
18708
  key: "near",
@@ -21476,7 +21564,6 @@ function modifyMaxKeyframeShader(shader, maxVertex, maxFrag) {
21476
21564
  var _proto = ParticleSystemRenderer.prototype;
21477
21565
  _proto.onStart = function onStart() {
21478
21566
  this._priority = this.item.renderOrder;
21479
- this.particleMesh.gravityModifier.scaleXCoord(this.item.duration);
21480
21567
  for(var _iterator = _create_for_of_iterator_helper_loose(this.meshes), _step; !(_step = _iterator()).done;){
21481
21568
  var mesh = _step.value;
21482
21569
  mesh.onStart();
@@ -22437,7 +22524,6 @@ exports.ParticleSystem = /*#__PURE__*/ function(Component) {
22437
22524
  };
22438
22525
  }
22439
22526
  this.item.getHitTestParams = this.getHitTestParams;
22440
- this.item._content = this;
22441
22527
  };
22442
22528
  _create_class(ParticleSystem, [
22443
22529
  {
@@ -22962,7 +23048,7 @@ var tempPos = new Vector3();
22962
23048
  */ _proto.sampleAnimation = function sampleAnimation() {
22963
23049
  var _this = this;
22964
23050
  var boundItem = this.boundObject;
22965
- var duration = boundItem.duration;
23051
+ var duration = this.getDuration();
22966
23052
  var life = this.time / duration;
22967
23053
  life = life < 0 ? 0 : life > 1 ? 1 : life;
22968
23054
  if (this.sizeXOverLifetime) {
@@ -23432,41 +23518,45 @@ exports.ObjectBindingTrack = /*#__PURE__*/ function(TrackAsset) {
23432
23518
  if (!_instanceof1(boundItem, exports.VFXItem)) {
23433
23519
  return;
23434
23520
  }
23435
- var hasActiveTrack = false;
23436
23521
  for(var _iterator = _create_for_of_iterator_helper_loose(this.getChildTracks()), _step; !(_step = _iterator()).done;){
23437
23522
  var childTrack = _step.value;
23438
23523
  if (_instanceof1(childTrack, exports.ActivationTrack)) {
23439
- hasActiveTrack = true;
23524
+ // 添加粒子动画 clip // TODO 待移除
23525
+ if (boundItem.getComponent(exports.ParticleSystem)) {
23526
+ var particleTrack = timelineAsset.createTrack(ParticleTrack, this, "ParticleTrack");
23527
+ for(var _iterator1 = _create_for_of_iterator_helper_loose(childTrack.getClips()), _step1; !(_step1 = _iterator1()).done;){
23528
+ var activationClip = _step1.value;
23529
+ var particleClip = particleTrack.createClip(ParticleBehaviourPlayableAsset);
23530
+ particleClip.start = activationClip.start;
23531
+ particleClip.duration = activationClip.duration;
23532
+ particleClip.endBehavior = activationClip.endBehavior;
23533
+ }
23534
+ }
23535
+ // 添加图层帧动画动画时间 clip // TODO 待移除
23536
+ if (boundItem.getComponent(exports.SpriteComponent)) {
23537
+ var componentTimeTrack = timelineAsset.createTrack(SpriteComponentTimeTrack, this, "SpriteComponentTimeTrack");
23538
+ for(var _iterator2 = _create_for_of_iterator_helper_loose(childTrack.getClips()), _step2; !(_step2 = _iterator2()).done;){
23539
+ var activationClip1 = _step2.value;
23540
+ var clip = componentTimeTrack.createClip(ComponentTimePlayableAsset);
23541
+ clip.start = activationClip1.start;
23542
+ clip.duration = activationClip1.duration;
23543
+ clip.endBehavior = activationClip1.endBehavior;
23544
+ }
23545
+ }
23546
+ // 添加图层帧动画动画时间 clip // TODO 待移除
23547
+ if (boundItem.getComponent(exports.EffectComponent)) {
23548
+ var componentTimeTrack1 = timelineAsset.createTrack(EffectComponentTimeTrack, this, "EffectComponentTimeTrack");
23549
+ for(var _iterator3 = _create_for_of_iterator_helper_loose(childTrack.getClips()), _step3; !(_step3 = _iterator3()).done;){
23550
+ var activationClip2 = _step3.value;
23551
+ var clip1 = componentTimeTrack1.createClip(ComponentTimePlayableAsset);
23552
+ clip1.start = activationClip2.start;
23553
+ clip1.duration = activationClip2.duration;
23554
+ clip1.endBehavior = activationClip2.endBehavior;
23555
+ }
23556
+ }
23440
23557
  break;
23441
23558
  }
23442
23559
  }
23443
- if (!hasActiveTrack) {
23444
- return;
23445
- }
23446
- // 添加粒子动画 clip // TODO 待移除
23447
- if (boundItem.getComponent(exports.ParticleSystem)) {
23448
- var particleTrack = timelineAsset.createTrack(ParticleTrack, this, "ParticleTrack");
23449
- var particleClip = particleTrack.createClip(ParticleBehaviourPlayableAsset);
23450
- particleClip.start = boundItem.start;
23451
- particleClip.duration = boundItem.duration;
23452
- particleClip.endBehavior = boundItem.endBehavior;
23453
- }
23454
- // 添加图层帧动画动画时间 clip // TODO 待移除
23455
- if (boundItem.getComponent(exports.SpriteComponent)) {
23456
- var componentTimeTrack = timelineAsset.createTrack(SpriteComponentTimeTrack, this, "SpriteComponentTimeTrack");
23457
- var clip = componentTimeTrack.createClip(ComponentTimePlayableAsset);
23458
- clip.start = boundItem.start;
23459
- clip.duration = boundItem.duration;
23460
- clip.endBehavior = boundItem.endBehavior;
23461
- }
23462
- // 添加图层帧动画动画时间 clip // TODO 待移除
23463
- if (boundItem.getComponent(exports.EffectComponent)) {
23464
- var componentTimeTrack1 = timelineAsset.createTrack(EffectComponentTimeTrack, this, "EffectComponentTimeTrack");
23465
- var clip1 = componentTimeTrack1.createClip(ComponentTimePlayableAsset);
23466
- clip1.start = boundItem.start;
23467
- clip1.duration = boundItem.duration;
23468
- clip1.endBehavior = boundItem.endBehavior;
23469
- }
23470
23560
  };
23471
23561
  return ObjectBindingTrack;
23472
23562
  }(exports.TrackAsset);
@@ -24251,13 +24341,14 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
24251
24341
  _this.pluginSystem = scene.pluginSystem;
24252
24342
  _this.pluginSystem.initializeComposition(_assert_this_initialized(_this), scene);
24253
24343
  _this.camera = new Camera(_this.name, _extends({}, sourceContent == null ? void 0 : sourceContent.camera, {
24254
- aspect: width / height
24344
+ aspect: width / height,
24345
+ pixelWidth: width,
24346
+ pixelHeight: height
24255
24347
  }));
24256
24348
  _this.url = scene.url;
24257
24349
  _this.interactive = true;
24258
24350
  _this.handleItemMessage = handleItemMessage;
24259
24351
  _this.createRenderFrame();
24260
- _this.rendererOptions = null;
24261
24352
  Composition.buildItemTree(_this.rootItem);
24262
24353
  _this.rootComposition.setChildrenRenderOrder(0);
24263
24354
  _this.pluginSystem.resetComposition(_assert_this_initialized(_this), _this.renderFrame);
@@ -24313,9 +24404,11 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
24313
24404
  this.restart();
24314
24405
  }
24315
24406
  if (this.rootComposition.isStartCalled) {
24316
- this.gotoAndPlay(this.time - this.startTime);
24407
+ this.setTime(this.time - this.startTime);
24408
+ this.resume();
24317
24409
  } else {
24318
- this.gotoAndPlay(0);
24410
+ this.setTime(0);
24411
+ this.resume();
24319
24412
  }
24320
24413
  };
24321
24414
  /**
@@ -24347,6 +24440,9 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
24347
24440
  * @param time - 相对 startTime 的时间
24348
24441
  */ _proto.gotoAndPlay = function gotoAndPlay(time) {
24349
24442
  this.setTime(time);
24443
+ this.emit("goto", {
24444
+ time: time
24445
+ });
24350
24446
  this.resume();
24351
24447
  };
24352
24448
  /**
@@ -24354,6 +24450,9 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
24354
24450
  * @param time - 相对 startTime 的时间
24355
24451
  */ _proto.gotoAndStop = function gotoAndStop(time) {
24356
24452
  this.setTime(time);
24453
+ this.emit("goto", {
24454
+ time: time
24455
+ });
24357
24456
  this.pause();
24358
24457
  };
24359
24458
  /**
@@ -24384,9 +24483,6 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
24384
24483
  if (pause) {
24385
24484
  this.paused = true;
24386
24485
  }
24387
- this.emit("goto", {
24388
- time: time
24389
- });
24390
24486
  };
24391
24487
  _proto.addItem = function addItem(item) {
24392
24488
  this.items.push(item);
@@ -24418,7 +24514,6 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
24418
24514
  /**
24419
24515
  * 重置状态函数
24420
24516
  */ _proto.reset = function reset() {
24421
- this.rendererOptions = null;
24422
24517
  this.isEnded = false;
24423
24518
  this.isEndCalled = false;
24424
24519
  this.rootComposition.time = 0;
@@ -24444,9 +24539,9 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
24444
24539
  if (this.getPaused()) {
24445
24540
  return;
24446
24541
  }
24447
- // scene VFXItem components lifetime function.
24542
+ // Scene VFXItem components lifetime function
24448
24543
  if (!this.rootItem.isDuringPlay) {
24449
- this.callAwake(this.rootItem);
24544
+ this.rootItem.awake();
24450
24545
  this.rootItem.beginPlay();
24451
24546
  }
24452
24547
  var previousCompositionTime = this.time;
@@ -24471,19 +24566,6 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
24471
24566
  _proto.shouldDispose = function shouldDispose() {
24472
24567
  return this.isEnded && this.rootItem.endBehavior === EndBehavior.destroy && !this.reusable;
24473
24568
  };
24474
- _proto.callAwake = function callAwake(item) {
24475
- for(var _iterator = _create_for_of_iterator_helper_loose(item.components), _step; !(_step = _iterator()).done;){
24476
- var component = _step.value;
24477
- if (!component.isAwakeCalled) {
24478
- component.onAwake();
24479
- component.isAwakeCalled = true;
24480
- }
24481
- }
24482
- for(var _iterator1 = _create_for_of_iterator_helper_loose(item.children), _step1; !(_step1 = _iterator1()).done;){
24483
- var child = _step1.value;
24484
- this.callAwake(child);
24485
- }
24486
- };
24487
24569
  /**
24488
24570
  * 更新相机
24489
24571
  * @override
@@ -24572,7 +24654,7 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
24572
24654
  return (_this_renderer = this.renderer) == null ? void 0 : _this_renderer.engine;
24573
24655
  };
24574
24656
  /**
24575
- * Item 求交测试,返回求交结果列表,x 和 y 是归一化到[-1, 1]区间的值,原点在左上角
24657
+ * Item 求交测试,返回求交结果列表,x 和 y 是归一化到[-1, 1]区间的值,x 向右,y 向上
24576
24658
  * @param x - 鼠标或触点的 x,已经归一化到[-1, 1]
24577
24659
  * @param y - 鼠标或触点的 y,已经归一化到[-1, 1]
24578
24660
  * @param force - 是否强制求交,没有交互信息的 Item 也要进行求交测试
@@ -24671,7 +24753,7 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
24671
24753
  * 合成对象销毁
24672
24754
  */ _proto.dispose = function dispose() {
24673
24755
  var _this = this;
24674
- var _this_rendererOptions, _this_pluginSystem;
24756
+ var _this_pluginSystem;
24675
24757
  if (this.destroyed) {
24676
24758
  return;
24677
24759
  }
@@ -24691,7 +24773,6 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
24691
24773
  this.rootItem.dispose();
24692
24774
  // FIXME: 注意这里增加了renderFrame销毁
24693
24775
  this.renderFrame.dispose();
24694
- (_this_rendererOptions = this.rendererOptions) == null ? void 0 : _this_rendererOptions.emptyTexture.dispose();
24695
24776
  (_this_pluginSystem = this.pluginSystem) == null ? void 0 : _this_pluginSystem.destroyComposition(this);
24696
24777
  this.update = function() {
24697
24778
  {
@@ -24788,15 +24869,6 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
24788
24869
  this.textureOffloaded = true;
24789
24870
  }
24790
24871
  };
24791
- _proto.getRendererOptions = function getRendererOptions() {
24792
- if (!this.rendererOptions) {
24793
- this.rendererOptions = {
24794
- emptyTexture: this.renderFrame.emptyTexture,
24795
- cachePrefix: "-"
24796
- };
24797
- }
24798
- return this.rendererOptions;
24799
- };
24800
24872
  /**
24801
24873
  * 重新加载纹理
24802
24874
  */ _proto.reloadTexture = function reloadTexture() {
@@ -24910,7 +24982,9 @@ exports.VFXItem = /*#__PURE__*/ function(EffectsObject) {
24910
24982
  function VFXItem(engine, props) {
24911
24983
  var _this;
24912
24984
  _this = EffectsObject.call(this, engine) || this;
24913
- _this.children = [];
24985
+ /**
24986
+ * 元素的子元素列表
24987
+ */ _this.children = [];
24914
24988
  /**
24915
24989
  * 元素的变换包含位置、旋转、缩放。
24916
24990
  */ _this.transform = new Transform();
@@ -24921,9 +24995,6 @@ exports.VFXItem = /*#__PURE__*/ function(EffectsObject) {
24921
24995
  * 元素动画的持续时间
24922
24996
  */ _this.duration = 0;
24923
24997
  /**
24924
- * 元素动画的开始时间
24925
- */ _this.start = 0;
24926
- /**
24927
24998
  * 元素动画结束时行为(如何处理元素)
24928
24999
  */ _this.endBehavior = EndBehavior.forward;
24929
25000
  _this.type = ItemType.base;
@@ -25043,6 +25114,7 @@ exports.VFXItem = /*#__PURE__*/ function(EffectsObject) {
25043
25114
  this.composition = vfxItem.composition;
25044
25115
  }
25045
25116
  if (!this.isDuringPlay && vfxItem.isDuringPlay) {
25117
+ this.awake();
25046
25118
  this.beginPlay();
25047
25119
  }
25048
25120
  };
@@ -25218,6 +25290,21 @@ exports.VFXItem = /*#__PURE__*/ function(EffectsObject) {
25218
25290
  };
25219
25291
  /**
25220
25292
  * @internal
25293
+ */ _proto.awake = function awake() {
25294
+ for(var _iterator = _create_for_of_iterator_helper_loose(this.components), _step; !(_step = _iterator()).done;){
25295
+ var component = _step.value;
25296
+ if (!component.isAwakeCalled) {
25297
+ component.onAwake();
25298
+ component.isAwakeCalled = true;
25299
+ }
25300
+ }
25301
+ for(var _iterator1 = _create_for_of_iterator_helper_loose(this.children), _step1; !(_step1 = _iterator1()).done;){
25302
+ var child = _step1.value;
25303
+ child.awake();
25304
+ }
25305
+ };
25306
+ /**
25307
+ * @internal
25221
25308
  */ _proto.onActiveChanged = function onActiveChanged() {
25222
25309
  if (!this.isEnabled) {
25223
25310
  this.onEnable();
@@ -25256,12 +25343,11 @@ exports.VFXItem = /*#__PURE__*/ function(EffectsObject) {
25256
25343
  };
25257
25344
  _proto.fromData = function fromData(data) {
25258
25345
  EffectsObject.prototype.fromData.call(this, data);
25259
- 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;
25346
+ 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;
25260
25347
  this.props = data;
25261
25348
  this.type = data.type;
25262
25349
  this.id = id.toString(); // TODO 老数据 id 是 number,需要转换
25263
25350
  this.name = name;
25264
- this.start = delay ? delay : this.start;
25265
25351
  if (transform) {
25266
25352
  this.transform.fromData(transform);
25267
25353
  }
@@ -25338,10 +25424,10 @@ exports.VFXItem = /*#__PURE__*/ function(EffectsObject) {
25338
25424
  component.dispose();
25339
25425
  }
25340
25426
  this.components = [];
25341
- this._content = undefined;
25342
25427
  this._composition = null;
25343
25428
  this.transform.setValid(false);
25344
25429
  }
25430
+ EffectsObject.prototype.dispose.call(this);
25345
25431
  };
25346
25432
  _proto.resetChildrenParent = function resetChildrenParent() {
25347
25433
  // GE 父元素销毁子元素继承逻辑
@@ -25481,14 +25567,6 @@ exports.VFXItem = /*#__PURE__*/ function(EffectsObject) {
25481
25567
  return false;
25482
25568
  };
25483
25569
  _create_class(VFXItem, [
25484
- {
25485
- key: "content",
25486
- get: /**
25487
- * 返回元素创建的数据
25488
- */ function get() {
25489
- return this._content;
25490
- }
25491
- },
25492
25570
  {
25493
25571
  key: "composition",
25494
25572
  get: /**
@@ -25622,7 +25700,7 @@ var ColorPlayable = /*#__PURE__*/ function(Playable) {
25622
25700
  }
25623
25701
  var colorInc = vecFill(tempColor, 1);
25624
25702
  var colorChanged;
25625
- var life = this.time / boundObject.duration;
25703
+ var life = this.time / this.getDuration();
25626
25704
  var opacityOverLifetime = this.opacityOverLifetime;
25627
25705
  var colorOverLifetime = this.colorOverLifetime;
25628
25706
  if (colorOverLifetime) {
@@ -25906,7 +25984,7 @@ exports.SpriteComponent = /*#__PURE__*/ function(MaskableGraphic) {
25906
25984
  _this = MaskableGraphic.call(this, engine) || this;
25907
25985
  _this.time = 0;
25908
25986
  _this.duration = 0;
25909
- _this.frameAnimationLoop = true;
25987
+ _this.loop = true;
25910
25988
  /**
25911
25989
  * @internal
25912
25990
  */ _this.splits = singleSplits;
@@ -25921,7 +25999,7 @@ exports.SpriteComponent = /*#__PURE__*/ function(MaskableGraphic) {
25921
25999
  var _this = this;
25922
26000
  var time = this.time;
25923
26001
  var duration = this.duration;
25924
- if (time > duration && this.frameAnimationLoop) {
26002
+ if (time > duration && this.loop) {
25925
26003
  time = time % duration;
25926
26004
  }
25927
26005
  var life = Math.min(Math.max(time / duration, 0.0), 1.0);
@@ -26161,6 +26239,8 @@ exports.SpriteComponent = /*#__PURE__*/ function(MaskableGraphic) {
26161
26239
  var _data_duration;
26162
26240
  //@ts-expect-error
26163
26241
  this.duration = (_data_duration = data.duration) != null ? _data_duration : this.item.duration;
26242
+ var _data_loop;
26243
+ this.loop = (_data_loop = data.loop) != null ? _data_loop : true;
26164
26244
  };
26165
26245
  return SpriteComponent;
26166
26246
  }(MaskableGraphic);
@@ -28913,7 +28993,8 @@ var TextLayout = /*#__PURE__*/ function() {
28913
28993
  function TextLayout(options) {
28914
28994
  this.width = 0;
28915
28995
  this.height = 0;
28916
- 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;
28996
+ 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
28997
+ useLegacyRichText, useLegacyRichText = _options_useLegacyRichText === void 0 ? false : _options_useLegacyRichText;
28917
28998
  var tempWidth = fontSize + letterSpace;
28918
28999
  this.autoWidth = autoWidth;
28919
29000
  this.maxTextWidth = text.length * tempWidth;
@@ -28921,6 +29002,7 @@ var TextLayout = /*#__PURE__*/ function() {
28921
29002
  this.height = textHeight;
28922
29003
  this.letterSpace = letterSpace;
28923
29004
  this.lineGap = lineGap;
29005
+ this.useLegacyRichText = useLegacyRichText;
28924
29006
  this.overflow = textOverflow;
28925
29007
  this.textBaseline = textBaseline;
28926
29008
  this.textAlign = textAlign;
@@ -28971,6 +29053,38 @@ var TextLayout = /*#__PURE__*/ function() {
28971
29053
  return offsetX;
28972
29054
  };
28973
29055
  /**
29056
+ * 富文本垂直对齐计算
29057
+ * @param style - 字体样式
29058
+ * @param lineHeights - 每行高度数组
29059
+ * @param fontSize - 字体大小
29060
+ * @returns 第一行基线的 Y 坐标
29061
+ */ _proto.getOffsetYRich = function getOffsetYRich(style, lineHeights, fontSize) {
29062
+ var outlineWidth = style.outlineWidth, fontScale = style.fontScale;
29063
+ var total = lineHeights.reduce(function(a, b) {
29064
+ return a + b;
29065
+ }, 0);
29066
+ // 使用与原始 getOffsetY 相同的经验值计算
29067
+ // /3 计算 Y 轴偏移量,以匹配编辑器行为
29068
+ var offsetY = (lineHeights[0] - fontSize) / 3;
29069
+ // 计算基础偏移量(从画布顶部到第一行基线的距离)
29070
+ var baseOffset = fontSize + outlineWidth * fontScale;
29071
+ // 除第一行外的所有行的总高度
29072
+ var commonCalculation = total - lineHeights[0]; // 使用实际总高度减去第一行高度
29073
+ var offsetResult = 0;
29074
+ switch(this.textBaseline){
29075
+ case TextBaseline.top:
29076
+ offsetResult = baseOffset + offsetY;
29077
+ break;
29078
+ case TextBaseline.middle:
29079
+ offsetResult = (this.height * fontScale - total + this.lineGap * fontScale) / 2 + baseOffset;
29080
+ break;
29081
+ case TextBaseline.bottom:
29082
+ offsetResult = this.height * fontScale - commonCalculation - offsetY;
29083
+ break;
29084
+ }
29085
+ return offsetResult;
29086
+ };
29087
+ /**
28974
29088
  * 设置文本框的宽度和高度
28975
29089
  * @param width 文本框宽度
28976
29090
  * @param height 文本框高度
@@ -29101,6 +29215,10 @@ exports.TextComponent = /*#__PURE__*/ function(MaskableGraphic) {
29101
29215
  MaskableGraphic.prototype.onUpdate.call(this, dt);
29102
29216
  this.updateTexture();
29103
29217
  };
29218
+ _proto.onDestroy = function onDestroy() {
29219
+ MaskableGraphic.prototype.onDestroy.call(this);
29220
+ this.disposeTextTexture();
29221
+ };
29104
29222
  _proto.fromData = function fromData(data) {
29105
29223
  MaskableGraphic.prototype.fromData.call(this, data);
29106
29224
  var interaction = data.interaction, options = data.options;
@@ -29141,10 +29259,10 @@ var TextComponentBase = /*#__PURE__*/ function() {
29141
29259
  var width = this.textLayout.width + this.textStyle.fontOffset;
29142
29260
  var lineCount = 1;
29143
29261
  var x = 0;
29144
- //设置context.font的字号
29145
- // if (context) {
29146
- // context.font = this.getFontDesc(this.textStyle.fontSize);
29147
- // }
29262
+ // 设置context.font的字号,确保measureText能正确计算字宽
29263
+ if (context) {
29264
+ context.font = this.getFontDesc(this.textStyle.fontSize);
29265
+ }
29148
29266
  for(var i = 0; i < text.length; i++){
29149
29267
  var _context_measureText;
29150
29268
  var str = text[i];
@@ -29474,10 +29592,17 @@ var TextComponentBase = /*#__PURE__*/ function() {
29474
29592
  wrapS: glContext.CLAMP_TO_EDGE,
29475
29593
  wrapT: glContext.CLAMP_TO_EDGE
29476
29594
  });
29595
+ this.disposeTextTexture();
29477
29596
  this.renderer.texture = texture;
29478
29597
  this.material.setTexture("_MainTex", texture);
29479
29598
  this.isDirty = false;
29480
29599
  };
29600
+ _proto.disposeTextTexture = function disposeTextTexture() {
29601
+ var texture = this.renderer.texture;
29602
+ if (texture && texture !== this.engine.whiteTexture) {
29603
+ texture.dispose();
29604
+ }
29605
+ };
29481
29606
  _proto.getFontDesc = function getFontDesc(size) {
29482
29607
  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;
29483
29608
  var fontDesc = "" + (size || fontSize * fontScale).toString() + "px ";
@@ -30550,10 +30675,43 @@ function version34Migration(json) {
30550
30675
  }
30551
30676
  }
30552
30677
  }
30678
+ // 处理富文本lineGap兼容性
30679
+ processRichTextLineGapCompatibility(json);
30553
30680
  //@ts-expect-error
30554
30681
  json.version = "3.5";
30555
30682
  return json;
30556
30683
  }
30684
+ /**
30685
+ * 处理富文本 lineGap 兼容性
30686
+ */ function processRichTextLineGapCompatibility(json) {
30687
+ if (!json.components) {
30688
+ return;
30689
+ }
30690
+ // 遍历所有组件,处理富文本组件
30691
+ for(var _iterator = _create_for_of_iterator_helper_loose(json.components), _step; !(_step = _iterator()).done;){
30692
+ var component = _step.value;
30693
+ // 识别富文本组件并处理 lineGap 兼容性
30694
+ if (component.dataType === DataType.RichTextComponent && component.options) {
30695
+ ensureRichTextLineGap(component.options);
30696
+ }
30697
+ }
30698
+ }
30699
+ /**
30700
+ * 确保富文本组件有版本标识字段
30701
+ */ function ensureRichTextLineGap(options) {
30702
+ // 检查是否已经处理过
30703
+ if (!options || options.useLegacyRichText !== undefined) {
30704
+ return;
30705
+ }
30706
+ // 根据是否存在 lineGap 字段来判断版本
30707
+ if (options.lineGap === undefined) {
30708
+ // 旧版本(没有 lineGap 字段)
30709
+ options.useLegacyRichText = true;
30710
+ } else {
30711
+ // 新版本(有 lineGap 字段)
30712
+ options.useLegacyRichText = false;
30713
+ }
30714
+ }
30557
30715
  /**
30558
30716
  * 根据形状获取形状几何体数据
30559
30717
  * @param shape - 形状
@@ -31476,7 +31634,7 @@ function getStandardSpriteContent(sprite, transform) {
31476
31634
  return ret;
31477
31635
  }
31478
31636
 
31479
- var version$2 = "2.7.0-alpha.2";
31637
+ var version$2 = "2.7.0-beta.0";
31480
31638
  var v0 = /^(\d+)\.(\d+)\.(\d+)(-(\w+)\.\d+)?$/;
31481
31639
  var standardVersion = /^(\d+)\.(\d+)$/;
31482
31640
  var reverseParticle = false;
@@ -32712,7 +32870,7 @@ function createTextureOptionsBySource(image, sourceFrom, id) {
32712
32870
  function AssetService(engine) {
32713
32871
  this.engine = engine;
32714
32872
  this.builtinObjects = [];
32715
- this.builtinObjects.push(generateWhiteTexture(engine));
32873
+ this.builtinObjects.push(engine.whiteTexture);
32716
32874
  }
32717
32875
  var _proto = AssetService.prototype;
32718
32876
  /**
@@ -34388,7 +34546,7 @@ var FBGeometryDataT = /*#__PURE__*/ function() {
34388
34546
  this.jsonSceneData = {};
34389
34547
  this.objectInstance = {};
34390
34548
  this.assetLoader = new AssetLoader(this);
34391
- this.emptyTexture = generateWhiteTexture(this);
34549
+ this.whiteTexture = generateWhiteTexture(this);
34392
34550
  this.transparentTexture = generateTransparentTexture(this);
34393
34551
  }
34394
34552
  var _proto = Engine.prototype;
@@ -34749,7 +34907,7 @@ registerPlugin("sprite", SpriteLoader, exports.VFXItem);
34749
34907
  registerPlugin("particle", ParticleLoader, exports.VFXItem);
34750
34908
  registerPlugin("cal", CalculateLoader, exports.VFXItem);
34751
34909
  registerPlugin("interact", InteractLoader, exports.VFXItem);
34752
- var version$1 = "2.7.0-alpha.2";
34910
+ var version$1 = "2.7.0-beta.0";
34753
34911
  logger.info("Core version: " + version$1 + ".");
34754
34912
 
34755
34913
  var _obj;
@@ -35068,12 +35226,13 @@ var _obj3;
35068
35226
  //FIXME: 暂时不实现
35069
35227
  throw new Error("Method not implemented.");
35070
35228
  };
35071
- _proto.dispose = function dispose(destroyOptions) {
35072
- if (!this.destroyed) {
35229
+ _proto.dispose = function dispose() {
35230
+ if (this.destroyed) {
35073
35231
  return;
35074
35232
  }
35075
35233
  this.material.dispose();
35076
35234
  this.destroyed = true;
35235
+ Material.prototype.dispose.call(this);
35077
35236
  };
35078
35237
  _create_class(ThreeMaterial, [
35079
35238
  {
@@ -35560,6 +35719,7 @@ var seed = 1;
35560
35719
  }
35561
35720
  this.geometry.dispose();
35562
35721
  this.destroyed = true;
35722
+ Geometry.prototype.dispose.call(this);
35563
35723
  };
35564
35724
  _proto.setAttributeType = function setAttributeType(name, attr, geometry, attributes, maxCount) {
35565
35725
  var _attr_stride = attr.stride, stride = _attr_stride === void 0 ? 0 : _attr_stride, size = attr.size, offset = attr.offset, normalize = attr.normalize, _attr_type = attr.type, type = _attr_type === void 0 ? glContext.FLOAT : _attr_type;
@@ -35701,6 +35861,7 @@ var seed = 1;
35701
35861
  this.mesh.clear();
35702
35862
  this.destroyed = true;
35703
35863
  }
35864
+ Mesh.prototype.dispose.call(this);
35704
35865
  };
35705
35866
  _create_class(ThreeMesh, [
35706
35867
  {
@@ -35788,6 +35949,7 @@ var seed = 1;
35788
35949
  * 释放纹理占用的内存
35789
35950
  */ _proto.dispose = function dispose() {
35790
35951
  this.texture.dispose();
35952
+ Texture.prototype.dispose.call(this);
35791
35953
  };
35792
35954
  /**
35793
35955
  * 通过图层设置创建贴图
@@ -35927,25 +36089,6 @@ var seed = 1;
35927
36089
  }
35928
36090
  }
35929
36091
  };
35930
- /**
35931
- * 获取 render 参数
35932
- *
35933
- * @returns
35934
- */ _proto.getRendererOptions = function getRendererOptions() {
35935
- var emptyTexture = ThreeTexture.createWithData(this.renderer.engine, {
35936
- data: new Uint8Array(4).fill(255),
35937
- width: 1,
35938
- height: 1
35939
- });
35940
- emptyTexture.texture.needsUpdate = true;
35941
- if (!this.rendererOptions) {
35942
- this.rendererOptions = {
35943
- emptyTexture: emptyTexture,
35944
- cachePrefix: "-"
35945
- };
35946
- }
35947
- return this.rendererOptions;
35948
- };
35949
36092
  return ThreeComposition;
35950
36093
  }(Composition);
35951
36094
  /**
@@ -36187,10 +36330,10 @@ exports.ThreeSpriteComponent = /*#__PURE__*/ function(SpriteComponent) {
36187
36330
  * 销毁方法
36188
36331
  *
36189
36332
  */ _proto.dispose = function dispose() {
36190
- SpriteComponent.prototype.dispose.call(this);
36191
36333
  if (!this.isActiveAndEnabled) {
36192
36334
  this.threeMesh.clear();
36193
36335
  }
36336
+ SpriteComponent.prototype.dispose.call(this);
36194
36337
  };
36195
36338
  _proto.fromData = function fromData(data) {
36196
36339
  SpriteComponent.prototype.fromData.call(this, data);
@@ -36345,7 +36488,7 @@ setMaxSpriteMeshItemCount(8);
36345
36488
  */ Mesh.create = function(engine, props) {
36346
36489
  return new ThreeMesh(engine, props);
36347
36490
  };
36348
- var version = "2.7.0-alpha.2";
36491
+ var version = "2.7.0-beta.0";
36349
36492
  logger.info("THREEJS plugin version: " + version + ".");
36350
36493
 
36351
36494
  exports.AbstractPlugin = AbstractPlugin;