@galacean/effects-threejs 2.10.0-alpha.0 → 2.10.0-alpha.1

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.mjs 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.10.0-alpha.0
6
+ * Version: v2.10.0-alpha.1
7
7
  */
8
8
 
9
9
  import * as THREE from 'three';
@@ -702,6 +702,26 @@ function clamp$1(value, min, max) {
702
702
  array[offset] = this.x;
703
703
  array[offset + 1] = this.y;
704
704
  };
705
+ /**
706
+ * 计算向量相对于正 x 轴的角度(弧度)
707
+ * @returns 弧度值
708
+ */ _proto.angle = function angle() {
709
+ var angle = Math.atan2(-this.y, -this.x) + Math.PI;
710
+ return angle;
711
+ };
712
+ /**
713
+ * 绕指定中心点旋转向量
714
+ * @param center - 旋转中心
715
+ * @param angle - 旋转角度(弧度)
716
+ * @returns 旋转结果
717
+ */ _proto.rotateAround = function rotateAround(center, angle) {
718
+ var c = Math.cos(angle), s = Math.sin(angle);
719
+ var x = this.x - center.x;
720
+ var y = this.y - center.y;
721
+ this.x = x * c - y * s + center.x;
722
+ this.y = x * s + y * c + center.y;
723
+ return this;
724
+ };
705
725
  /**
706
726
  * 随机生成向量
707
727
  * @returns 向量
@@ -1255,6 +1275,25 @@ Vector2.ZERO = new Vector2(0.0, 0.0);
1255
1275
  */ _proto.applyProjectionMatrix = function applyProjectionMatrix(m, out) {
1256
1276
  return m.projectPoint(this, out);
1257
1277
  };
1278
+ /**
1279
+ * 从四维矩阵提取平移分量
1280
+ * @param m - 四维矩阵
1281
+ * @returns 向量
1282
+ */ _proto.setFromMatrixPosition = function setFromMatrixPosition(m) {
1283
+ var e = m.elements;
1284
+ this.x = e[12];
1285
+ this.y = e[13];
1286
+ this.z = e[14];
1287
+ return this;
1288
+ };
1289
+ /**
1290
+ * 从四维矩阵提取指定列的三维分量
1291
+ * @param m - 四维矩阵
1292
+ * @param index - 列下标
1293
+ * @returns 向量
1294
+ */ _proto.setFromMatrixColumn = function setFromMatrixColumn(m, index) {
1295
+ return this.setFromArray(m.elements, index * 4);
1296
+ };
1258
1297
  /**
1259
1298
  * 通过标量数值创建向量
1260
1299
  * @param num - 数值
@@ -2895,17 +2934,27 @@ var PluginSystem = /*#__PURE__*/ function() {
2895
2934
  PluginSystem.getPlugins = function getPlugins() {
2896
2935
  return plugins;
2897
2936
  };
2898
- PluginSystem.initializeComposition = function initializeComposition(composition, scene) {
2899
- plugins.forEach(function(loader) {
2900
- return loader.onCompositionCreated(composition, scene);
2937
+ PluginSystem.notifyCompositionCreated = function notifyCompositionCreated(composition, scene) {
2938
+ plugins.forEach(function(plugin) {
2939
+ return plugin.onCompositionCreated(composition, scene);
2940
+ });
2941
+ };
2942
+ PluginSystem.notifyCompositionDestroy = function notifyCompositionDestroy(composition) {
2943
+ plugins.forEach(function(plugin) {
2944
+ return plugin.onCompositionDestroy(composition);
2945
+ });
2946
+ };
2947
+ PluginSystem.notifyEngineCreated = function notifyEngineCreated(engine) {
2948
+ plugins.forEach(function(plugin) {
2949
+ return plugin.onEngineCreated(engine);
2901
2950
  });
2902
2951
  };
2903
- PluginSystem.destroyComposition = function destroyComposition(comp) {
2904
- plugins.forEach(function(loader) {
2905
- return loader.onCompositionDestroy(comp);
2952
+ PluginSystem.notifyEngineDestroy = function notifyEngineDestroy(engine) {
2953
+ plugins.forEach(function(plugin) {
2954
+ return plugin.onEngineDestroy(engine);
2906
2955
  });
2907
2956
  };
2908
- PluginSystem.onAssetsLoadStart = function onAssetsLoadStart(scene, options) {
2957
+ PluginSystem.notifyAssetsLoadStart = function notifyAssetsLoadStart(scene, options) {
2909
2958
  return _async_to_generator(function() {
2910
2959
  return __generator(this, function(_state) {
2911
2960
  return [
@@ -2917,9 +2966,9 @@ var PluginSystem = /*#__PURE__*/ function() {
2917
2966
  });
2918
2967
  })();
2919
2968
  };
2920
- PluginSystem.onAssetsLoadFinish = function onAssetsLoadFinish(scene, options, engine) {
2921
- plugins.forEach(function(loader) {
2922
- return loader.onAssetsLoadFinish(scene, options, engine);
2969
+ PluginSystem.notifyAssetsLoadFinish = function notifyAssetsLoadFinish(scene, options, engine) {
2970
+ plugins.forEach(function(plugin) {
2971
+ return plugin.onAssetsLoadFinish(scene, options, engine);
2923
2972
  });
2924
2973
  };
2925
2974
  return PluginSystem;
@@ -2985,6 +3034,18 @@ function getPluginUsageInfo(name) {
2985
3034
  * 合成销毁时触发。
2986
3035
  * @param composition - 合成对象
2987
3036
  */ _proto.onCompositionDestroy = function onCompositionDestroy(composition) {};
3037
+ /**
3038
+ * 引擎创建完成后触发。
3039
+ * 适用于注册引擎级单例、建立以引擎为键的映射、绑定全局监听等场景。
3040
+ * @param engine - 引擎实例
3041
+ * @since 2.10.0
3042
+ */ _proto.onEngineCreated = function onEngineCreated(engine) {};
3043
+ /**
3044
+ * 引擎销毁时触发。
3045
+ * 适合解绑监听、释放引擎级资源或清理以引擎为键的映射。
3046
+ * @param engine - 引擎实例
3047
+ * @since 2.10.0
3048
+ */ _proto.onEngineDestroy = function onEngineDestroy(engine) {};
2988
3049
  return Plugin;
2989
3050
  }();
2990
3051
 
@@ -4972,7 +5033,7 @@ var Animatable = /*#__PURE__*/ function() {
4972
5033
  * @param qb - 四元数
4973
5034
  * @param t - 插值比
4974
5035
  */ _proto.slerpQuaternions = function slerpQuaternions(qa, qb, t) {
4975
- this.copyFrom(qa).slerp(qb, t);
5036
+ return this.copyFrom(qa).slerp(qb, t);
4976
5037
  };
4977
5038
  /**
4978
5039
  * 通过四元数旋转向量
@@ -7530,7 +7591,10 @@ function setSideMode(material, side) {
7530
7591
  material.cullFace = side === SideMode.BACK ? glContext.BACK : glContext.FRONT;
7531
7592
  }
7532
7593
  }
7533
- function setMaskMode(material, maskMode) {
7594
+ /**
7595
+ * @deprecated 2.10 起 runtime 内部已不再通过 `MaskMode` 设置模板测试参数。
7596
+ * 仅为兼容旧版本对外导出的接口而保留,新代码请勿使用。
7597
+ */ function setMaskMode(material, maskMode) {
7534
7598
  switch(maskMode){
7535
7599
  case undefined:
7536
7600
  material.stencilTest = false;
@@ -9415,6 +9479,13 @@ function isUniformStructArray(value) {
9415
9479
  translation.x = te[12];
9416
9480
  translation.y = te[13];
9417
9481
  translation.z = te[14];
9482
+ scale.x = sx;
9483
+ scale.y = sy;
9484
+ scale.z = sz;
9485
+ if (Math.abs(sx) < 1e-8 || Math.abs(sy) < 1e-8 || Math.abs(sz) < 1e-8) {
9486
+ rotation.set(0, 0, 0, 1);
9487
+ return this;
9488
+ }
9418
9489
  // scale the rotation part
9419
9490
  var m = Matrix4.tempMat0;
9420
9491
  m.copyFrom(this);
@@ -9431,9 +9502,6 @@ function isUniformStructArray(value) {
9431
9502
  m.elements[9] *= invSZ;
9432
9503
  m.elements[10] *= invSZ;
9433
9504
  rotation.setFromRotationMatrix(m);
9434
- scale.x = sx;
9435
- scale.y = sy;
9436
- scale.z = sz;
9437
9505
  return this;
9438
9506
  };
9439
9507
  _proto.getTranslation = function getTranslation(translation) {
@@ -9444,6 +9512,45 @@ function isUniformStructArray(value) {
9444
9512
  var te = this.elements;
9445
9513
  return scale.set(Math.hypot(te[0], te[1], te[2]), Math.hypot(te[4], te[5], te[6]), Math.hypot(te[8], te[9], te[10]));
9446
9514
  };
9515
+ /**
9516
+ * 提取矩阵的旋转部分(去除缩放)
9517
+ * @param m - 源矩阵
9518
+ * @returns 矩阵
9519
+ */ _proto.extractRotation = function extractRotation(m) {
9520
+ var v = Matrix4.tempVec0;
9521
+ var me = m.elements;
9522
+ var te = this.elements;
9523
+ var scaleX = 1 / v.set(me[0], me[1], me[2]).length();
9524
+ var scaleY = 1 / v.set(me[4], me[5], me[6]).length();
9525
+ var scaleZ = 1 / v.set(me[8], me[9], me[10]).length();
9526
+ te[0] = me[0] * scaleX;
9527
+ te[1] = me[1] * scaleX;
9528
+ te[2] = me[2] * scaleX;
9529
+ te[3] = 0;
9530
+ te[4] = me[4] * scaleY;
9531
+ te[5] = me[5] * scaleY;
9532
+ te[6] = me[6] * scaleY;
9533
+ te[7] = 0;
9534
+ te[8] = me[8] * scaleZ;
9535
+ te[9] = me[9] * scaleZ;
9536
+ te[10] = me[10] * scaleZ;
9537
+ te[11] = 0;
9538
+ te[12] = 0;
9539
+ te[13] = 0;
9540
+ te[14] = 0;
9541
+ te[15] = 1;
9542
+ return this;
9543
+ };
9544
+ /**
9545
+ * 设置矩阵的平移部分(不影响旋转和缩放)
9546
+ * @param v - 平移向量
9547
+ * @returns 矩阵
9548
+ */ _proto.setPosition = function setPosition(v) {
9549
+ this.elements[12] = v.x;
9550
+ this.elements[13] = v.y;
9551
+ this.elements[14] = v.z;
9552
+ return this;
9553
+ };
9447
9554
  /**
9448
9555
  * 获得矩阵分解的结果
9449
9556
  * @returns 分解的结果
@@ -10737,6 +10844,23 @@ Euler.tempMat0 = new Matrix4();
10737
10844
  */ _proto.equals = function equals(other) {
10738
10845
  return this.origin.equals(other.origin) && this.direction.equals(other.direction);
10739
10846
  };
10847
+ /**
10848
+ * 光线到平面的距离
10849
+ * @param plane - 平面
10850
+ * @returns 距离值,平行且不在平面上时返回 null,平行且在平面上时返回 0
10851
+ */ _proto.distanceToPlane = function distanceToPlane(plane) {
10852
+ var normal = plane.normal;
10853
+ var denominator = normal.dot(this.direction);
10854
+ if (denominator === 0) {
10855
+ // 光线与平面平行
10856
+ if (normal.dot(this.origin) + plane.distance === 0) {
10857
+ return 0;
10858
+ }
10859
+ return null;
10860
+ }
10861
+ var t = -(this.origin.dot(normal) + plane.distance) / denominator;
10862
+ return t >= 0 ? t : null;
10863
+ };
10740
10864
  /**
10741
10865
  * 根据矩阵对光线进行变换
10742
10866
  * @param m - 变换矩阵
@@ -12597,65 +12721,70 @@ var MaterialRenderType;
12597
12721
  return new Material(engine, props);
12598
12722
  };
12599
12723
 
12724
+ // 8 位 stencil buffer 上限为 255;为反向蒙版的 INCR 预留 1 的递增余量,
12725
+ // 否则当正向蒙版填满到 255 时,反向 INCR 会饱和、无法排除任何像素。
12726
+ var MAX_MASK_REFERENCE_COUNT = 254;
12600
12727
  /**
12601
12728
  * @internal
12602
12729
  */ var MaskProcessor = /*#__PURE__*/ function() {
12603
12730
  function MaskProcessor() {
12604
12731
  this.alphaMaskEnabled = false;
12605
12732
  this.isMask = false;
12606
- this.inverted = false;
12607
- this.maskMode = MaskMode.NONE;
12608
12733
  /**
12609
12734
  * 多个蒙版引用列表,支持正面和反面蒙版
12610
12735
  */ this.maskReferences = [];
12611
12736
  /**
12612
12737
  * 期望的 stencil 值(等于正向蒙版的数量)
12613
12738
  */ this.expectedStencilValue = 0;
12614
- this.prevStencilFunc = [
12615
- 0,
12616
- 0
12617
- ];
12618
- this.prevStencilOpZPass = [
12619
- 0,
12620
- 0
12621
- ];
12622
- this.prevStencilRef = [
12623
- 0,
12624
- 0
12625
- ];
12626
- this.prevStencilMask = [
12627
- 0,
12628
- 0
12629
- ];
12630
12739
  this.stencilClearAction = {
12631
12740
  stencilAction: TextureLoadAction.clear
12632
12741
  };
12633
12742
  }
12634
12743
  var _proto = MaskProcessor.prototype;
12635
12744
  /**
12636
- * @deprecated
12637
- */ _proto.getRefValue = function getRefValue() {
12638
- return 1;
12639
- };
12640
- /**
12641
- * 设置蒙版选项(兼容旧版单蒙版 API)
12745
+ * 设置蒙版选项。
12746
+ *
12747
+ * @param data.references - 蒙版引用列表。
12748
+ * 传入空数组等价于无蒙版。
12749
+ * 超过 254 个引用时,多余部分将被忽略并打印警告。
12642
12750
  */ _proto.setMaskOptions = function setMaskOptions(engine, data) {
12643
- var _data_isMask = data.isMask, isMask = _data_isMask === void 0 ? false : _data_isMask, _data_inverted = data.inverted, inverted = _data_inverted === void 0 ? false : _data_inverted, reference = data.reference, _data_alphaMaskEnabled = data.alphaMaskEnabled, alphaMaskEnabled = _data_alphaMaskEnabled === void 0 ? false : _data_alphaMaskEnabled;
12751
+ var _data_isMask = data.isMask, isMask = _data_isMask === void 0 ? false : _data_isMask, _data_references = data.references, references = _data_references === void 0 ? [] : _data_references, _data_alphaMaskEnabled = data.alphaMaskEnabled, alphaMaskEnabled = _data_alphaMaskEnabled === void 0 ? false : _data_alphaMaskEnabled;
12644
12752
  this.alphaMaskEnabled = alphaMaskEnabled;
12645
12753
  this.isMask = isMask;
12646
- this.inverted = inverted;
12647
12754
  this.maskReferences = [];
12648
- if (isMask) {
12649
- this.maskMode = MaskMode.MASK;
12650
- } else {
12651
- this.maskMode = inverted ? MaskMode.REVERSE_OBSCURED : MaskMode.OBSCURED;
12652
- var maskable = engine.findObject(reference);
12653
- if (maskable) {
12654
- this.maskReferences.push({
12655
- maskable: maskable,
12656
- inverted: inverted
12657
- });
12755
+ if (isMask || references.length === 0) {
12756
+ return;
12757
+ }
12758
+ var seen = new Map();
12759
+ for(var _iterator = _create_for_of_iterator_helper_loose(references), _step; !(_step = _iterator()).done;){
12760
+ var ref = _step.value;
12761
+ var maskPath = ref.mask;
12762
+ if (!maskPath) {
12763
+ continue;
12658
12764
  }
12765
+ var maskable = engine.findObject(maskPath);
12766
+ if (!maskable) {
12767
+ console.warn("Mask reference not found: " + JSON.stringify(maskPath) + ". Skipping.");
12768
+ continue;
12769
+ }
12770
+ var _ref_inverted;
12771
+ var inverted = (_ref_inverted = ref.inverted) != null ? _ref_inverted : false;
12772
+ var existingInverted = seen.get(maskable);
12773
+ if (existingInverted !== undefined) {
12774
+ if (existingInverted !== inverted) {
12775
+ console.warn("Same maskable referenced with conflicting inverted flags; keeping the first occurrence.");
12776
+ }
12777
+ continue;
12778
+ }
12779
+ if (this.maskReferences.length >= MAX_MASK_REFERENCE_COUNT) {
12780
+ console.warn("Maximum of " + MAX_MASK_REFERENCE_COUNT + " mask references exceeded. Additional masks will be ignored.");
12781
+ break;
12782
+ }
12783
+ seen.set(maskable, inverted);
12784
+ this.maskReferences.push({
12785
+ maskable: maskable,
12786
+ inverted: inverted
12787
+ });
12659
12788
  }
12660
12789
  };
12661
12790
  /**
@@ -12668,8 +12797,8 @@ var MaterialRenderType;
12668
12797
  return ref.maskable === maskable;
12669
12798
  });
12670
12799
  if (!exists) {
12671
- if (this.maskReferences.length >= 255) {
12672
- console.warn("Maximum of 255 mask references exceeded. Additional masks will be ignored.");
12800
+ if (this.maskReferences.length >= MAX_MASK_REFERENCE_COUNT) {
12801
+ console.warn("Maximum of " + MAX_MASK_REFERENCE_COUNT + " mask references exceeded. Additional masks will be ignored.");
12673
12802
  return;
12674
12803
  }
12675
12804
  this.maskReferences.push({
@@ -12695,6 +12824,11 @@ var MaterialRenderType;
12695
12824
  this.maskReferences = [];
12696
12825
  };
12697
12826
  /**
12827
+ * 获取当前蒙版引用列表的浅拷贝。
12828
+ */ _proto.getMaskReferences = function getMaskReferences() {
12829
+ return this.maskReferences.slice();
12830
+ };
12831
+ /**
12698
12832
  * 绘制所有蒙版,被蒙版的元素调用。
12699
12833
  *
12700
12834
  * 使用递增 stencil 计数法实现任意数量蒙版的交集:
@@ -12702,12 +12836,17 @@ var MaterialRenderType;
12702
12836
  * 2. 反向蒙版渲染,将已通过所有正向蒙版的像素标记为无效
12703
12837
  * 3. 最终只有 stencil == 正向蒙版数量 的像素才通过测试
12704
12838
  *
12705
- * 最多支持 255 个蒙版引用(受 8 位 stencil buffer 限制)
12839
+ * 最多支持 254 个蒙版引用(8 位 stencil buffer 上限 255,需为反向 INCR 预留 1)
12706
12840
  */ _proto.drawStencilMask = function drawStencilMask(renderer, maskedComponent) {
12707
12841
  var frameClipMasks = maskedComponent.frameClipMasks;
12842
+ var addedFrameClipMasks = [];
12708
12843
  for(var _iterator = _create_for_of_iterator_helper_loose(frameClipMasks), _step; !(_step = _iterator()).done;){
12709
12844
  var frameClipMask = _step.value;
12845
+ var referenceCount = this.maskReferences.length;
12710
12846
  this.addMaskReference(frameClipMask, false);
12847
+ if (this.maskReferences.length > referenceCount) {
12848
+ addedFrameClipMasks.push(frameClipMask);
12849
+ }
12711
12850
  }
12712
12851
  if (this.maskReferences.length > 0) {
12713
12852
  renderer.clear(this.stencilClearAction);
@@ -12743,7 +12882,7 @@ var MaterialRenderType;
12743
12882
  var material = _step3.value;
12744
12883
  this.setupMaskedMaterial(material);
12745
12884
  }
12746
- for(var _iterator4 = _create_for_of_iterator_helper_loose(frameClipMasks), _step4; !(_step4 = _iterator4()).done;){
12885
+ for(var _iterator4 = _create_for_of_iterator_helper_loose(addedFrameClipMasks), _step4; !(_step4 = _iterator4()).done;){
12747
12886
  var frameClipMask1 = _step4.value;
12748
12887
  this.removeMaskReference(frameClipMask1);
12749
12888
  }
@@ -12752,24 +12891,24 @@ var MaterialRenderType;
12752
12891
  * 绘制几何体蒙版,蒙版元素绘制时调用
12753
12892
  */ _proto.drawGeometryMask = function drawGeometryMask(renderer, geometry, worldMatrix, material, maskRef, subMeshIndex) {
12754
12893
  if (subMeshIndex === void 0) subMeshIndex = 0;
12755
- var previousColorMask = material.colorMask;
12894
+ var prevColorMask = material.colorMask;
12756
12895
  var prevStencilTest = material.stencilTest;
12757
- this.copyStencilArrayValue(this.prevStencilFunc, material.stencilFunc);
12758
- this.copyStencilArrayValue(this.prevStencilOpZPass, material.stencilOpZPass);
12759
- this.copyStencilArrayValue(this.prevStencilRef, material.stencilRef);
12760
- this.copyStencilArrayValue(this.prevStencilMask, material.stencilMask);
12761
- // const prevStencilOpFail = material.stencilOpFail;
12762
- // const prevStencilOpZFail = material.stencilOpZFail;
12896
+ var prevStencilFunc = material.stencilFunc;
12897
+ var prevStencilOpFail = material.stencilOpFail;
12898
+ var prevStencilOpZFail = material.stencilOpZFail;
12899
+ var prevStencilOpZPass = material.stencilOpZPass;
12900
+ var prevStencilRef = material.stencilRef;
12901
+ var prevStencilMask = material.stencilMask;
12763
12902
  this.setupMaskMaterial(material, maskRef);
12764
12903
  renderer.drawGeometry(geometry, worldMatrix, material, subMeshIndex);
12765
- material.colorMask = previousColorMask;
12904
+ material.colorMask = prevColorMask;
12766
12905
  material.stencilTest = prevStencilTest;
12767
- material.stencilFunc = this.prevStencilFunc;
12768
- material.stencilOpZPass = this.prevStencilOpZPass;
12769
- // material.stencilOpFail = prevStencilOpFail;
12770
- // material.stencilOpZFail = prevStencilOpZFail;
12771
- material.stencilRef = this.prevStencilRef;
12772
- material.stencilMask = this.prevStencilMask;
12906
+ material.stencilFunc = prevStencilFunc;
12907
+ material.stencilOpFail = prevStencilOpFail;
12908
+ material.stencilOpZFail = prevStencilOpZFail;
12909
+ material.stencilOpZPass = prevStencilOpZPass;
12910
+ material.stencilRef = prevStencilRef;
12911
+ material.stencilMask = prevStencilMask;
12773
12912
  };
12774
12913
  /**
12775
12914
  * 设置蒙版材质的 stencil 属性(写入蒙版)
@@ -12797,12 +12936,18 @@ var MaterialRenderType;
12797
12936
  0xFF
12798
12937
  ];
12799
12938
  // 通过时递增 stencil 值,不通过时保持不变
12939
+ material.stencilOpFail = [
12940
+ glContext.KEEP,
12941
+ glContext.KEEP
12942
+ ];
12943
+ material.stencilOpZFail = [
12944
+ glContext.KEEP,
12945
+ glContext.KEEP
12946
+ ];
12800
12947
  material.stencilOpZPass = [
12801
12948
  glContext.INCR,
12802
12949
  glContext.INCR
12803
12950
  ];
12804
- // material.stencilOpFail = [glContext.KEEP, glContext.KEEP];
12805
- // material.stencilOpZFail = [glContext.KEEP, glContext.KEEP];
12806
12951
  material.colorMask = false; // 不写入颜色
12807
12952
  };
12808
12953
  /**
@@ -12837,13 +12982,6 @@ var MaterialRenderType;
12837
12982
  material.stencilTest = false;
12838
12983
  }
12839
12984
  };
12840
- _proto.copyStencilArrayValue = function copyStencilArrayValue(target, source) {
12841
- if (!source) {
12842
- return;
12843
- }
12844
- target[0] = source[0];
12845
- target[1] = source[1];
12846
- };
12847
12985
  _create_class(MaskProcessor, [
12848
12986
  {
12849
12987
  key: "maskable",
@@ -12859,7 +12997,7 @@ var MaterialRenderType;
12859
12997
  if (value) {
12860
12998
  this.maskReferences.push({
12861
12999
  maskable: value,
12862
- inverted: this.maskMode === MaskMode.REVERSE_OBSCURED
13000
+ inverted: false
12863
13001
  });
12864
13002
  }
12865
13003
  }
@@ -16644,19 +16782,15 @@ function buildBezierEasing(leftKeyframe, rightKeyframe) {
16644
16782
  y2 = numberToFix((p2.y - p0.y) / valueInterval, 5);
16645
16783
  }
16646
16784
  if (x1 < 0) {
16647
- console.error("Invalid bezier points, x1 < 0", p0, p1, p2, p3);
16648
16785
  x1 = 0;
16649
16786
  }
16650
16787
  if (x2 < 0) {
16651
- console.error("Invalid bezier points, x2 < 0", p0, p1, p2, p3);
16652
16788
  x2 = 0;
16653
16789
  }
16654
16790
  if (x1 > 1) {
16655
- console.error("Invalid bezier points, x1 >= 1", p0, p1, p2, p3);
16656
16791
  x1 = 1;
16657
16792
  }
16658
16793
  if (x2 > 1) {
16659
- console.error("Invalid bezier points, x2 >= 1", p0, p1, p2, p3);
16660
16794
  x2 = 1;
16661
16795
  }
16662
16796
  var str = ("bez_" + x1 + "_" + y1 + "_" + x2 + "_" + y2).replace(/\./g, "p");
@@ -16747,10 +16881,49 @@ function oldBezierKeyFramesToNew(props) {
16747
16881
  return keyframes;
16748
16882
  }
16749
16883
 
16884
+ /**
16885
+ * 通用对象引用阶梯曲线(不插值)。对象引用不可插值,
16886
+ * 按时间阶梯采样取 time ≤ t 的最近关键帧。
16887
+ *
16888
+ * 继承 ValueGetter 以复用 PropertyClipPlayable<T>;数值相关方法
16889
+ * (toUniform/toData/getIntegrate*)保留基类 NOT_IMPLEMENT——对象引用 curve
16890
+ * 不走 shader 通路。典型用例:T = Sprite(sprite 属性 K 帧切图)。
16891
+ */ var ReferenceCurve = /*#__PURE__*/ function(ValueGetter) {
16892
+ _inherits(ReferenceCurve, ValueGetter);
16893
+ function ReferenceCurve() {
16894
+ return ValueGetter.apply(this, arguments);
16895
+ }
16896
+ var _proto = ReferenceCurve.prototype;
16897
+ _proto.onCreate = function onCreate(props) {
16898
+ this.keyframes = props;
16899
+ };
16900
+ _proto.getValue = function getValue(time) {
16901
+ var keys = this.keyframes;
16902
+ if (keys.length === 0) {
16903
+ return undefined;
16904
+ }
16905
+ // 阶梯采样:取 time ≤ t 的最大关键帧;t < 首帧取首帧。无插值。
16906
+ var result = keys[0][1];
16907
+ for(var i = 0; i < keys.length; i++){
16908
+ if (keys[i][0] <= (time != null ? time : 0)) {
16909
+ result = keys[i][1];
16910
+ } else {
16911
+ break;
16912
+ }
16913
+ }
16914
+ return result;
16915
+ };
16916
+ return ReferenceCurve;
16917
+ }(ValueGetter);
16918
+
16750
16919
  /**
16751
16920
  * Vector2 曲线
16752
16921
  * TODO: add spec
16753
16922
  */ var VECTOR3_CURVE = 27;
16923
+ /**
16924
+ * 对象引用阶梯曲线(spec ValueType.REFERENCE_CURVE)。
16925
+ * props 为 [[time, value], ...],value 为已解析的对象引用实例。
16926
+ */ var REFERENCE_CURVE = 28;
16754
16927
  var _obj$5;
16755
16928
  var map$1 = (_obj$5 = {}, _obj$5[ValueType.RANDOM] = function(props) {
16756
16929
  if (_instanceof1(props[0], Array)) {
@@ -16807,6 +16980,9 @@ var map$1 = (_obj$5 = {}, _obj$5[ValueType.RANDOM] = function(props) {
16807
16980
  }, // TODO: add spec
16808
16981
  _obj$5[VECTOR3_CURVE] = function(props) {
16809
16982
  return new Vector3Curve(props);
16983
+ }, // 对象引用阶梯曲线(不插值):props.data 为 [time, value][],value 已解析为 EffectsObject
16984
+ _obj$5[REFERENCE_CURVE] = function(props) {
16985
+ return new ReferenceCurve(props);
16810
16986
  }, _obj$5);
16811
16987
  function createValueGetter(args) {
16812
16988
  if (!args || !isNaN(+args)) {
@@ -21869,16 +22045,26 @@ var canvasPool = new CanvasPool();
21869
22045
  * 单张字符 atlas 的边长(像素,scale 后的实际像素,非逻辑尺寸)。
21870
22046
  * 512×512 在 24px 字号下约可容纳 250+ 字形,常见 demo 文本足够
21871
22047
  */ var ATLAS_SIZE = 512;
22048
+ /**
22049
+ * 字体度量探针字符串。带重音符的 É/Å 把墨水顶推到接近字体真实 ascent,
22050
+ * 单字 'M' 只有 cap height(~0.7em) 太矮,会让 CJK / 带重音字顶部越过 cell 上界被裁
22051
+ */ var METRICS_STRING = "|\xc9q\xc5";
22052
+ /** 字体度量基线符号 */ var BASELINE_SYMBOL = "M";
22053
+ /**
22054
+ * 字形 cell 四周留白(逻辑像素)。ink 略超字体度量、或 italic 斜体越界时由它吸收,
22055
+ * 保证 cell 采样矩形内不裁切字形
22056
+ */ var GLYPH_PADDING = 4;
21872
22057
  /**
21873
22058
  * 一种字体(family + weight + style + size 唯一确定)对应一张 atlas。
21874
22059
  *
21875
- * Skyline 风格 packer:行内堆字,行尾换行,行高 = (ascent+descent) * FONT_SCALE。
22060
+ * Skyline 风格 packer:行内堆字,行尾换行,cell = ceil((fontHeight + padding*2) * 1),
22061
+ * 所有字共用同一 cell 高与 baseline,实现同行 baseline 对齐。
21876
22062
  * atlas 满后 `ensureChar` 返回 null,调用方应跳过该字(不再扩页,v1 范围)。
21877
22063
  *
21878
22064
  * canvas 内容变更后需要 `uploadIfDirty` 重新上传到纹理 — 由调用方在使用纹理前主动触发,
21879
22065
  * 避免每加一字都 upload 一次造成的 GL 开销
21880
22066
  */ var GlyphAtlas = /*#__PURE__*/ function() {
21881
- function GlyphAtlas(engine, scaledFontString, ascent, descent) {
22067
+ function GlyphAtlas(engine, scaledFontString, /** baseline 距 cell 顶距离(像素,scale 后,仅 ascent 部分,不含 padding) */ ascentPx, /** baseline 距 cell 底距离(像素,scale 后,仅 descent 部分) */ descentPx, fontStyle) {
21882
22068
  this.engine = engine;
21883
22069
  this.scaledFontString = scaledFontString;
21884
22070
  this.glyphs = new Map();
@@ -21899,11 +22085,14 @@ var canvasPool = new CanvasPool();
21899
22085
  ctx.font = scaledFontString;
21900
22086
  ctx.textBaseline = "alphabetic";
21901
22087
  ctx.fillStyle = "#ffffff";
21902
- this.ascent = ascent;
21903
- this.descent = descent;
21904
- this.lineHeight = ascent + descent;
21905
- this.ascentPx = Math.ceil(ascent * FONT_SCALE);
21906
- this.lineHeightPx = Math.ceil((ascent + descent) * FONT_SCALE);
22088
+ this.paddingPx = GLYPH_PADDING * FONT_SCALE;
22089
+ this.italicScale = fontStyle === "italic" ? 2 : 1;
22090
+ // ascent/descent 由探针 '|ÉqÅM' 测得 actualBoundingBox(重音字已抬高 ink 顶),
22091
+ // 两者内部保持浮点,仅 cell 高做一次外层 ceil 与 padding 共同保证 cell 内不裁切
22092
+ var fontHeightPx = ascentPx + descentPx;
22093
+ this.baselinePx = this.paddingPx + ascentPx;
22094
+ this.cellHPx = Math.ceil(fontHeightPx + this.paddingPx * 2);
22095
+ this.lineHeight = this.cellHPx / FONT_SCALE;
21907
22096
  this.texture = Texture.create(engine, {
21908
22097
  sourceType: TextureSourceType.image,
21909
22098
  image: this.canvas,
@@ -21932,10 +22121,12 @@ var canvasPool = new CanvasPool();
21932
22121
  ctx.font = this.scaledFontString;
21933
22122
  // measureText 用的是 scaledFontString,advance 已经是 scale 后的像素,不能再乘 FONT_SCALE
21934
22123
  var advancePx = ctx.measureText(char).width;
21935
- var cellW = Math.max(1, Math.ceil(advancePx));
21936
- var cellH = this.lineHeightPx;
22124
+ // italic 放大 cell 宽防斜体越界;ceil 对齐像素网格避免相邻字采样重叠
22125
+ var widthPx = Math.max(1, Math.ceil(advancePx * this.italicScale));
22126
+ var paddedWidthPx = widthPx + this.paddingPx * 2;
22127
+ var cellH = this.cellHPx;
21937
22128
  // 行尾换行
21938
- if (this.currentX + cellW > ATLAS_SIZE) {
22129
+ if (this.currentX + paddedWidthPx > ATLAS_SIZE) {
21939
22130
  this.currentX = 0;
21940
22131
  this.currentY += cellH;
21941
22132
  }
@@ -21947,15 +22138,17 @@ var canvasPool = new CanvasPool();
21947
22138
  }
21948
22139
  var px = this.currentX;
21949
22140
  var py = this.currentY;
21950
- ctx.fillText(char, px, py + this.ascentPx);
21951
- this.currentX += cellW;
22141
+ // baseline 落在 cell 顶部下方 paddingPx + ascentPx 处,四周 padding 吸收越界 ink
22142
+ ctx.fillText(char, px + this.paddingPx, py + this.baselinePx);
22143
+ this.currentX += paddedWidthPx;
21952
22144
  this.dirty = true;
21953
22145
  var info = {
21954
22146
  px: px,
21955
22147
  py: py,
21956
- pw: cellW,
22148
+ pw: paddedWidthPx,
21957
22149
  ph: cellH,
21958
- width: cellW / FONT_SCALE
22150
+ advance: advancePx / FONT_SCALE,
22151
+ paddingLeft: this.paddingPx / FONT_SCALE
21959
22152
  };
21960
22153
  this.glyphs.set(char, info);
21961
22154
  return info;
@@ -22007,22 +22200,25 @@ var canvasPool = new CanvasPool();
22007
22200
  if (cached) {
22008
22201
  return cached;
22009
22202
  }
22010
- var fontString = fontStyle + " " + fontWeight + " " + fontSize + "px " + fontFamily;
22011
22203
  var scaledFontString = fontStyle + " " + fontWeight + " " + fontSize * FONT_SCALE + "px " + fontFamily;
22012
- // 用 'M' 探一次得到字体级 ascent/descent(整张 atlas 共享行高,各字 baseline 对齐)
22204
+ // 探一次得到字体级 ascent/descent(整张 atlas 共享 cell 高与 baseline,各字对齐)。
22205
+ // 直接在 scaledFontString 下测,得到的就是 scale 后像素,无需再乘 FONT_SCALE。
22206
+ // 探针用 '|ÉqÅ' + 'M':带重音符的 ÉÅ 把 ink 顶推到接近字体真实 ascent,
22207
+ // 单字 'M' 只有 cap height(~0.7em) 太矮,CJK / 带重音字顶部会越过 cell 上界被裁。
22208
+ // 取 actualBoundingBoxAscent/Descent 度量 ink 边界,跨平台语义稳定
22013
22209
  var probeCanvasAndContext = canvasPool.getCanvasAndContext(1, 1);
22014
22210
  var probeCtx = probeCanvasAndContext.context;
22015
- var ascent = fontSize * 0.8;
22016
- var descent = fontSize * 0.2;
22211
+ var ascentPx = fontSize * 0.8 * FONT_SCALE;
22212
+ var descentPx = fontSize * 0.2 * FONT_SCALE;
22017
22213
  try {
22018
- probeCtx.font = fontString;
22019
- var m = probeCtx.measureText("M");
22020
- ascent = m.actualBoundingBoxAscent || ascent;
22021
- descent = m.actualBoundingBoxDescent || descent;
22214
+ probeCtx.font = scaledFontString;
22215
+ var m = probeCtx.measureText(METRICS_STRING + BASELINE_SYMBOL);
22216
+ ascentPx = m.actualBoundingBoxAscent || ascentPx;
22217
+ descentPx = m.actualBoundingBoxDescent || descentPx;
22022
22218
  } finally{
22023
22219
  canvasPool.releaseCanvasAndContext(probeCanvasAndContext);
22024
22220
  }
22025
- var atlas = new GlyphAtlas(this.engine, scaledFontString, ascent, descent);
22221
+ var atlas = new GlyphAtlas(this.engine, scaledFontString, ascentPx, descentPx, fontStyle);
22026
22222
  this.atlases.set(fontKey, atlas);
22027
22223
  return atlas;
22028
22224
  };
@@ -22426,8 +22622,8 @@ var Graphics = /*#__PURE__*/ function() {
22426
22622
  * `color` 作为乘色与白色字形 alpha 相乘,任意颜色都不会污染 atlas。
22427
22623
  *
22428
22624
  * 字体参数全部展开,避免调用方每帧创建临时 style 对象触发 GC
22429
- * @param x - 文本左下角 X 坐标
22430
- * @param y - 文本左下角 Y 坐标(对齐 baseline 上方 ascent 处)
22625
+ * @param x - 文本左下角 X 坐标(首字 ink 起始处,含 padding 的 quad 会向左延伸)
22626
+ * @param y - 文本左下角 Y 坐标(cell 底,含底部 padding;字形 ink 在其上方 padding+ascent 处)
22431
22627
  * @param text - 要绘制的文本内容,空串直接 return
22432
22628
  * @param fontSize - 字号(逻辑像素)
22433
22629
  * @param color - 乘色,默认白色,范围 0-1
@@ -22458,13 +22654,15 @@ var Graphics = /*#__PURE__*/ function() {
22458
22654
  var u1 = (info.px + info.pw) / ATLAS_SIZE;
22459
22655
  var v0 = 1 - (info.py + info.ph) / ATLAS_SIZE;
22460
22656
  var v1 = 1 - info.py / ATLAS_SIZE;
22461
- this.pushQuad(cursorX, y, info.width, lineHeight, color, {
22657
+ // quad 宽与采样区都含四周 padding(cell 留白透明);但光标只按 advance 前进,
22658
+ // quad 起点左偏 paddingLeft 使字形 ink 落在 cursorX — padding 区重叠无妨
22659
+ this.pushQuad(cursorX - info.paddingLeft, y, info.pw / FONT_SCALE, lineHeight, color, {
22462
22660
  u0: u0,
22463
22661
  v0: v0,
22464
22662
  u1: u1,
22465
22663
  v1: v1
22466
22664
  });
22467
- cursorX += info.width;
22665
+ cursorX += info.advance;
22468
22666
  }
22469
22667
  };
22470
22668
  _proto.dispose = function dispose() {
@@ -22681,7 +22879,6 @@ var Graphics = /*#__PURE__*/ function() {
22681
22879
  aUV: {
22682
22880
  size: 2,
22683
22881
  offset: 0,
22684
- releasable: true,
22685
22882
  type: glContext.FLOAT,
22686
22883
  data: new Float32Array([
22687
22884
  0,
@@ -22829,7 +23026,6 @@ var Graphics = /*#__PURE__*/ function() {
22829
23026
  };
22830
23027
  _proto.configureMaterial = function configureMaterial(renderer) {
22831
23028
  var side = renderer.side, occlusion = renderer.occlusion, blendMode = renderer.blending, texture = renderer.texture;
22832
- var maskMode = this.maskManager.maskMode;
22833
23029
  var material = this.material;
22834
23030
  material.blending = true;
22835
23031
  material.depthTest = true;
@@ -22844,7 +23040,6 @@ var Graphics = /*#__PURE__*/ function() {
22844
23040
  texParams.x = renderer.occlusion ? +renderer.transparentOcclusion : 1;
22845
23041
  texParams.y = preMultiAlpha;
22846
23042
  texParams.z = renderer.renderMode;
22847
- texParams.w = maskMode;
22848
23043
  material.setVector4("_TexParams", texParams);
22849
23044
  if (texParams.x === 0 || this.maskManager.alphaMaskEnabled) {
22850
23045
  material.enableMacro("ALPHA_CLIP");
@@ -22872,9 +23067,9 @@ var Graphics = /*#__PURE__*/ function() {
22872
23067
  blending: (_renderer_blending = renderer.blending) != null ? _renderer_blending : BlendingMode.ALPHA,
22873
23068
  texture: renderer.texture ? this.engine.findObject(renderer.texture) : this.engine.whiteTexture,
22874
23069
  occlusion: !!renderer.occlusion,
22875
- transparentOcclusion: !!renderer.transparentOcclusion || this.maskManager.maskMode === MaskMode.MASK,
23070
+ transparentOcclusion: !!renderer.transparentOcclusion || this.maskManager.isMask,
22876
23071
  side: (_renderer_side = renderer.side) != null ? _renderer_side : SideMode.DOUBLE,
22877
- mask: this.maskManager.getRefValue()
23072
+ mask: 1
22878
23073
  };
22879
23074
  this.configureMaterial(this.renderer);
22880
23075
  };
@@ -24941,6 +25136,50 @@ var SpriteLoader = /*#__PURE__*/ function(Plugin) {
24941
25136
  return SpriteLoader;
24942
25137
  }(_wrap_native_super(Plugin));
24943
25138
 
25139
+ var SpriteRotation;
25140
+ (function(SpriteRotation) {
25141
+ /** 不旋转 */ SpriteRotation[SpriteRotation["None"] = 0] = "None";
25142
+ /** UV 旋转 90°(对应老 splits flip=1) */ SpriteRotation[SpriteRotation["Rotate90"] = 1] = "Rotate90";
25143
+ })(SpriteRotation || (SpriteRotation = {}));
25144
+ var Sprite = /*#__PURE__*/ function(EffectsObject) {
25145
+ _inherits(Sprite, EffectsObject);
25146
+ function Sprite(engine, props) {
25147
+ var _this;
25148
+ _this = EffectsObject.call(this, engine) || this;
25149
+ /** 归一化 UV 矩形 [x, y, w, h],默认整张纹理 */ _this.rect = [
25150
+ 0,
25151
+ 0,
25152
+ 1,
25153
+ 1
25154
+ ];
25155
+ /** UV 旋转方式(对应老 splits 的 flip 0/1) */ _this.rotation = 0;
25156
+ if (props) {
25157
+ _this.fromData(props);
25158
+ }
25159
+ return _this;
25160
+ }
25161
+ var _proto = Sprite.prototype;
25162
+ _proto.fromData = function fromData(data) {
25163
+ EffectsObject.prototype.fromData.call(this, data);
25164
+ // findObject 对 Texture 实例原样返回,对 {id} 解析为 Texture 实例,
25165
+ // 兼容反序列化(data.texture 为 {id})与手动构造(data.texture 为 Texture 实例)两条路径。
25166
+ this.texture = data.texture ? this.engine.findObject(data.texture) : this.engine.whiteTexture;
25167
+ var _data_rect;
25168
+ this.rect = (_data_rect = data.rect) != null ? _data_rect : [
25169
+ 0,
25170
+ 0,
25171
+ 1,
25172
+ 1
25173
+ ];
25174
+ var _data_rotation;
25175
+ this.rotation = (_data_rotation = data.rotation) != null ? _data_rotation : 0;
25176
+ };
25177
+ return Sprite;
25178
+ }(EffectsObject);
25179
+ Sprite = __decorate([
25180
+ effectsClass("Sprite")
25181
+ ], Sprite);
25182
+
24944
25183
  /**
24945
25184
  * 动画图可播放节点对象
24946
25185
  * @since 2.0.0
@@ -25527,6 +25766,36 @@ var SpriteColorMixerPlayable = /*#__PURE__*/ function(TrackMixerPlayable) {
25527
25766
  return SpriteColorMixerPlayable;
25528
25767
  }(TrackMixerPlayable);
25529
25768
 
25769
+ /**
25770
+ * Sprite 属性 K 帧 mixer。对象引用不混合:取首个激活 clip 的阶梯采样值,
25771
+ * 赋值 boundObject.sprite 触发 setter(同步纹理 + 重建 UV)。
25772
+ * 不继承 PropertyMixerPlayable(其 evaluate 开头"读当前值为 null 则 return"
25773
+ * 会阻断无初始 sprite 组件的 K 帧)。
25774
+ */ var SpritePropertyMixerPlayable = /*#__PURE__*/ function(TrackMixerPlayable) {
25775
+ _inherits(SpritePropertyMixerPlayable, TrackMixerPlayable);
25776
+ function SpritePropertyMixerPlayable() {
25777
+ return TrackMixerPlayable.apply(this, arguments);
25778
+ }
25779
+ var _proto = SpritePropertyMixerPlayable.prototype;
25780
+ _proto.evaluate = function evaluate(context) {
25781
+ var boundObject = context.output.getUserData();
25782
+ if (!boundObject) {
25783
+ return;
25784
+ }
25785
+ // 对象引用不混合:取首个激活 clip 的采样值
25786
+ for(var i = 0; i < this.clipPlayables.length; i++){
25787
+ if (this.getClipWeight(i) > 0) {
25788
+ var clip = this.getClipPlayable(i);
25789
+ if (_instanceof1(clip, PropertyClipPlayable) && clip.value) {
25790
+ boundObject.sprite = clip.value;
25791
+ }
25792
+ break;
25793
+ }
25794
+ }
25795
+ };
25796
+ return SpritePropertyMixerPlayable;
25797
+ }(TrackMixerPlayable);
25798
+
25530
25799
  var SubCompositionClipPlayable = /*#__PURE__*/ function(Playable) {
25531
25800
  _inherits(SubCompositionClipPlayable, Playable);
25532
25801
  function SubCompositionClipPlayable() {
@@ -25570,94 +25839,148 @@ var SubCompositionMixerPlayable = /*#__PURE__*/ function(TrackMixerPlayable) {
25570
25839
  return SubCompositionMixerPlayable;
25571
25840
  }(TrackMixerPlayable);
25572
25841
 
25573
- var TransformMixerPlayable = /*#__PURE__*/ function(TrackMixerPlayable) {
25574
- _inherits(TransformMixerPlayable, TrackMixerPlayable);
25575
- function TransformMixerPlayable() {
25576
- return TrackMixerPlayable.apply(this, arguments);
25577
- }
25578
- var _proto = TransformMixerPlayable.prototype;
25579
- _proto.evaluate = function evaluate(context) {};
25580
- return TransformMixerPlayable;
25581
- }(TrackMixerPlayable);
25582
-
25583
- var Vector4PropertyMixerPlayable = /*#__PURE__*/ function(PropertyMixerPlayable) {
25584
- _inherits(Vector4PropertyMixerPlayable, PropertyMixerPlayable);
25585
- function Vector4PropertyMixerPlayable() {
25586
- return PropertyMixerPlayable.apply(this, arguments);
25587
- }
25588
- var _proto = Vector4PropertyMixerPlayable.prototype;
25589
- _proto.resetPropertyValue = function resetPropertyValue() {
25590
- this.propertyValue.x = 0;
25591
- this.propertyValue.y = 0;
25592
- this.propertyValue.z = 0;
25593
- this.propertyValue.w = 0;
25594
- };
25595
- _proto.addWeightedValue = function addWeightedValue(curveValue, weight) {
25596
- var result = this.propertyValue;
25597
- result.x += curveValue.x * weight;
25598
- result.y += curveValue.y * weight;
25599
- result.z += curveValue.z * weight;
25600
- result.w += curveValue.w * weight;
25601
- };
25602
- return Vector4PropertyMixerPlayable;
25603
- }(PropertyMixerPlayable);
25604
- var Vector3PropertyMixerPlayable = /*#__PURE__*/ function(PropertyMixerPlayable) {
25605
- _inherits(Vector3PropertyMixerPlayable, PropertyMixerPlayable);
25606
- function Vector3PropertyMixerPlayable() {
25607
- return PropertyMixerPlayable.apply(this, arguments);
25608
- }
25609
- var _proto = Vector3PropertyMixerPlayable.prototype;
25610
- _proto.resetPropertyValue = function resetPropertyValue() {
25611
- this.propertyValue.x = 0;
25612
- this.propertyValue.y = 0;
25613
- this.propertyValue.z = 0;
25614
- };
25615
- _proto.addWeightedValue = function addWeightedValue(curveValue, weight) {
25616
- var result = this.propertyValue;
25617
- result.x += curveValue.x * weight;
25618
- result.y += curveValue.y * weight;
25619
- result.z += curveValue.z * weight;
25620
- };
25621
- return Vector3PropertyMixerPlayable;
25622
- }(PropertyMixerPlayable);
25623
- var Vector2PropertyMixerPlayable = /*#__PURE__*/ function(PropertyMixerPlayable) {
25624
- _inherits(Vector2PropertyMixerPlayable, PropertyMixerPlayable);
25625
- function Vector2PropertyMixerPlayable() {
25626
- return PropertyMixerPlayable.apply(this, arguments);
25627
- }
25628
- var _proto = Vector2PropertyMixerPlayable.prototype;
25629
- _proto.resetPropertyValue = function resetPropertyValue() {
25630
- this.propertyValue.x = 0;
25631
- this.propertyValue.y = 0;
25842
+ /**
25843
+ * 对 TransformTrack 当前激活的 Transform clip contribution 做帧内合成。
25844
+ * position 与 rotation 使用增量语义,scale 使用乘子语义;结果由 flush 统一写回。
25845
+ */ var TransformClipMixer = /*#__PURE__*/ function() {
25846
+ function TransformClipMixer() {
25847
+ this.hasContribution = false;
25848
+ this.hasPosition = false;
25849
+ this.hasRotation = false;
25850
+ this.hasScale = false;
25851
+ this.appliedPosition = false;
25852
+ this.appliedRotation = false;
25853
+ this.appliedScale = false;
25854
+ this.outPos = new Vector3();
25855
+ this.outRot = new Euler();
25856
+ this.outScale = new Vector3(1, 1, 1);
25857
+ this.weightedRot = new Euler();
25858
+ }
25859
+ var _proto = TransformClipMixer.prototype;
25860
+ _proto.captureBasePose = function captureBasePose(item) {
25861
+ this.ensureBasePose(item);
25862
+ };
25863
+ /**
25864
+ * orbital position contribution 依赖 base position。
25865
+ * 这里返回 mixer 持有的 base,确保采样和合成使用同一份参考姿态。
25866
+ */ _proto.getBasePosition = function getBasePosition() {
25867
+ var _this_basePose;
25868
+ return (_this_basePose = this.basePose) == null ? void 0 : _this_basePose.position;
25869
+ };
25870
+ _proto.resetFrame = function resetFrame() {
25871
+ this.hasContribution = false;
25872
+ this.hasPosition = false;
25873
+ this.hasRotation = false;
25874
+ this.hasScale = false;
25875
+ };
25876
+ _proto.addContribution = function addContribution(item, contribution, weight) {
25877
+ if (weight <= 0) {
25878
+ return;
25879
+ }
25880
+ this.ensureBasePose(item);
25881
+ if (!this.hasContribution) {
25882
+ var base = this.basePose;
25883
+ this.outPos.copyFrom(base.position);
25884
+ this.outRot.copyFrom(base.rotation);
25885
+ this.outScale.copyFrom(base.scale);
25886
+ this.hasContribution = true;
25887
+ }
25888
+ if (contribution.hasPosition) {
25889
+ this.hasPosition = true;
25890
+ this.outPos.x += contribution.position.x * weight;
25891
+ this.outPos.y += contribution.position.y * weight;
25892
+ this.outPos.z += contribution.position.z * weight;
25893
+ }
25894
+ if (contribution.hasRotation) {
25895
+ this.hasRotation = true;
25896
+ this.weightedRot.set(contribution.rotation.x * weight, contribution.rotation.y * weight, contribution.rotation.z * weight, contribution.rotation.order);
25897
+ this.outRot.addEulers(this.outRot, this.weightedRot);
25898
+ }
25899
+ if (contribution.hasScale) {
25900
+ this.hasScale = true;
25901
+ // Scale contribution 使用乘子语义,weight 用于支持 clip blend/crossfade。
25902
+ this.outScale.x *= Math.pow(contribution.scale.x, weight);
25903
+ this.outScale.y *= Math.pow(contribution.scale.y, weight);
25904
+ this.outScale.z *= Math.pow(contribution.scale.z, weight);
25905
+ }
25906
+ };
25907
+ _proto.flush = function flush(item) {
25908
+ var base = this.basePose;
25909
+ if (!base || !this.hasContribution && !this.appliedPosition && !this.appliedRotation && !this.appliedScale) {
25910
+ return;
25911
+ }
25912
+ if (this.hasPosition) {
25913
+ item.transform.setPosition(this.outPos.x, this.outPos.y, this.outPos.z);
25914
+ this.appliedPosition = true;
25915
+ } else if (this.appliedPosition) {
25916
+ item.transform.setPosition(base.position.x, base.position.y, base.position.z);
25917
+ this.appliedPosition = false;
25918
+ }
25919
+ if (this.hasRotation) {
25920
+ item.transform.setRotation(this.outRot.x, this.outRot.y, this.outRot.z);
25921
+ this.appliedRotation = true;
25922
+ } else if (this.appliedRotation) {
25923
+ item.transform.setRotation(base.rotation.x, base.rotation.y, base.rotation.z);
25924
+ this.appliedRotation = false;
25925
+ }
25926
+ if (this.hasScale) {
25927
+ item.transform.setScale(this.outScale.x, this.outScale.y, this.outScale.z);
25928
+ this.appliedScale = true;
25929
+ } else if (this.appliedScale) {
25930
+ item.transform.setScale(base.scale.x, base.scale.y, base.scale.z);
25931
+ this.appliedScale = false;
25932
+ }
25632
25933
  };
25633
- _proto.addWeightedValue = function addWeightedValue(curveValue, weight) {
25634
- var result = this.propertyValue;
25635
- result.x += curveValue.x * weight;
25636
- result.y += curveValue.y * weight;
25934
+ _proto.dispose = function dispose() {
25935
+ this.basePose = undefined;
25936
+ this.boundInstanceId = undefined;
25937
+ this.appliedPosition = false;
25938
+ this.appliedRotation = false;
25939
+ this.appliedScale = false;
25940
+ this.resetFrame();
25941
+ };
25942
+ _proto.ensureBasePose = function ensureBasePose(item) {
25943
+ if (!this.basePose || this.boundInstanceId !== item.getInstanceId()) {
25944
+ var scale = item.transform.scale;
25945
+ this.basePose = {
25946
+ position: item.transform.position.clone(),
25947
+ rotation: item.transform.getRotation().clone(),
25948
+ scale: new Vector3(scale.x, scale.y, scale.x)
25949
+ };
25950
+ this.boundInstanceId = item.getInstanceId();
25951
+ this.appliedPosition = false;
25952
+ this.appliedRotation = false;
25953
+ this.appliedScale = false;
25954
+ }
25637
25955
  };
25638
- return Vector2PropertyMixerPlayable;
25639
- }(PropertyMixerPlayable);
25956
+ return TransformClipMixer;
25957
+ }();
25640
25958
 
25641
25959
  var tempRot$1 = new Euler();
25642
- var tempSize$1 = new Vector3(1, 1, 1);
25643
25960
  var tempPos = new Vector3();
25961
+ var createEmptyContribution = function() {
25962
+ return {
25963
+ hasPosition: false,
25964
+ position: new Vector3(),
25965
+ hasRotation: false,
25966
+ rotation: new Euler(),
25967
+ hasScale: false,
25968
+ scale: new Vector3(1, 1, 1)
25969
+ };
25970
+ };
25644
25971
  /**
25645
25972
  * @since 2.0.0
25646
25973
  */ var TransformPlayable = /*#__PURE__*/ function(Playable) {
25647
25974
  _inherits(TransformPlayable, Playable);
25648
25975
  function TransformPlayable() {
25649
- return Playable.apply(this, arguments);
25976
+ var _this;
25977
+ _this = Playable.apply(this, arguments) || this;
25978
+ _this.started = false;
25979
+ _this.contribution = createEmptyContribution();
25980
+ return _this;
25650
25981
  }
25651
25982
  var _proto = TransformPlayable.prototype;
25652
25983
  _proto.start = function start() {
25653
- var boundItem = this.boundObject;
25654
- var scale = boundItem.transform.scale;
25655
- this.originalTransform = {
25656
- position: boundItem.transform.position.clone(),
25657
- rotation: boundItem.transform.getRotation().clone(),
25658
- // TODO 编辑器 scale 没有z轴控制
25659
- scale: new Vector3(scale.x, scale.y, scale.x)
25660
- };
25661
25984
  var positionOverLifetime = this.data.positionOverLifetime;
25662
25985
  var rotationOverLifetime = this.data.rotationOverLifetime;
25663
25986
  var sizeOverLifetime = this.data.sizeOverLifetime;
@@ -25665,7 +25988,7 @@ var tempPos = new Vector3();
25665
25988
  if (positionOverLifetime && Object.keys(positionOverLifetime).length !== 0) {
25666
25989
  this.positionOverLifetime = positionOverLifetime;
25667
25990
  if (positionOverLifetime.path) {
25668
- this.originalTransform.path = createValueGetter(positionOverLifetime.path);
25991
+ this.pathGetter = createValueGetter(positionOverLifetime.path);
25669
25992
  }
25670
25993
  var linearVelEnable = positionOverLifetime.linearX || positionOverLifetime.linearY || positionOverLifetime.linearZ;
25671
25994
  if (linearVelEnable) {
@@ -25721,37 +26044,53 @@ var tempPos = new Vector3();
25721
26044
  this.velocity.multiply(this.startSpeed);
25722
26045
  };
25723
26046
  _proto.processFrame = function processFrame(context) {
25724
- if (!this.boundObject) {
25725
- var boundObject = context.output.getUserData();
25726
- if (_instanceof1(boundObject, VFXItem)) {
25727
- this.boundObject = boundObject;
25728
- this.start();
25729
- }
25730
- }
25731
- if (this.boundObject && this.boundObject.composition) {
25732
- this.sampleAnimation();
26047
+ this.ensureStarted();
26048
+ var boundObject = context.output.getUserData();
26049
+ if (!this.originalTransform && _instanceof1(boundObject, VFXItem)) {
26050
+ this.captureOriginalTransform(boundObject);
25733
26051
  }
25734
26052
  };
25735
26053
  /**
25736
- * 应用时间轴K帧数据到对象
25737
- */ _proto.sampleAnimation = function sampleAnimation() {
26054
+ * 采样当前帧相对 base pose 的 transform contribution。
26055
+ * 返回值为内部复用对象,调用方应在当前帧同步消费,不应缓存。
26056
+ * @param basePosition - orbital position 计算 contribution 时使用的参考位置。
26057
+ */ _proto.getContribution = function getContribution(basePosition) {
26058
+ this.ensureStarted();
26059
+ this.sampleAnimation(basePosition);
26060
+ return this.contribution;
26061
+ };
26062
+ _proto.ensureStarted = function ensureStarted() {
26063
+ if (!this.started) {
26064
+ this.start();
26065
+ this.started = true;
26066
+ }
26067
+ };
26068
+ _proto.sampleAnimation = function sampleAnimation(basePosition) {
25738
26069
  var _this = this;
25739
- var boundItem = this.boundObject;
26070
+ var out = this.contribution;
26071
+ out.hasPosition = false;
26072
+ out.hasRotation = false;
26073
+ out.hasScale = false;
25740
26074
  var duration = this.getDuration();
26075
+ if (duration <= 0) {
26076
+ return;
26077
+ }
25741
26078
  var life = this.time / duration;
25742
26079
  life = life < 0 ? 0 : life;
25743
26080
  if (this.sizeXOverLifetime) {
25744
- tempSize$1.x = this.sizeXOverLifetime.getValue(life);
26081
+ out.hasScale = true;
26082
+ out.scale.x = this.sizeXOverLifetime.getValue(life);
25745
26083
  if (this.sizeSeparateAxes) {
25746
- tempSize$1.y = this.sizeYOverLifetime.getValue(life);
25747
- tempSize$1.z = this.sizeZOverLifetime.getValue(life);
26084
+ out.scale.y = this.sizeYOverLifetime.getValue(life);
26085
+ out.scale.z = this.sizeZOverLifetime.getValue(life);
25748
26086
  } else {
25749
- tempSize$1.z = tempSize$1.y = tempSize$1.x;
26087
+ out.scale.z = out.scale.y = out.scale.x;
25750
26088
  }
25751
- var startSize = this.originalTransform.scale;
25752
- boundItem.transform.setScale(tempSize$1.x * startSize.x, tempSize$1.y * startSize.y, tempSize$1.z * startSize.z);
26089
+ } else {
26090
+ out.hasScale = false;
25753
26091
  }
25754
26092
  if (this.rotationOverLifetime) {
26093
+ out.hasRotation = true;
25755
26094
  var func = function(v) {
25756
26095
  return _this.rotationOverLifetime.asRotation ? v.getValue(life) : v.getIntegrateValue(0, life, duration);
25757
26096
  };
@@ -25760,16 +26099,42 @@ var tempPos = new Vector3();
25760
26099
  tempRot$1.x = separateAxes ? func(this.rotationOverLifetime.x) : 0;
25761
26100
  tempRot$1.y = separateAxes ? func(this.rotationOverLifetime.y) : 0;
25762
26101
  tempRot$1.z = incZ;
25763
- var rot = tempRot$1.addEulers(this.originalTransform.rotation, tempRot$1);
25764
- boundItem.transform.setRotation(rot.x, rot.y, rot.z);
26102
+ out.rotation.copyFrom(tempRot$1);
26103
+ } else {
26104
+ out.hasRotation = false;
25765
26105
  }
25766
26106
  if (this.positionOverLifetime) {
25767
- var pos = tempPos;
25768
- calculateTranslation(pos, this, this.gravity, this.time, duration, this.originalTransform.position, this.velocity);
25769
- if (this.originalTransform.path) {
25770
- pos.add(this.originalTransform.path.getValue(life));
26107
+ var _this_orbitalVelOverLifetime;
26108
+ out.hasPosition = true;
26109
+ // Orbital position 依赖参考位置;普通 position 可直接从零向量采样位移贡献。
26110
+ var orbitalEnabled = !!((_this_orbitalVelOverLifetime = this.orbitalVelOverLifetime) == null ? void 0 : _this_orbitalVelOverLifetime.enabled);
26111
+ if (orbitalEnabled && basePosition) {
26112
+ calculateTranslation(out.position, this, this.gravity, this.time, duration, basePosition, this.velocity);
26113
+ if (this.pathGetter) {
26114
+ out.position.add(this.pathGetter.getValue(life));
26115
+ }
26116
+ out.position.subtract(basePosition);
26117
+ } else {
26118
+ tempPos.set(0, 0, 0);
26119
+ calculateTranslation(out.position, this, this.gravity, this.time, duration, tempPos, this.velocity);
26120
+ if (this.pathGetter) {
26121
+ out.position.add(this.pathGetter.getValue(life));
26122
+ }
25771
26123
  }
25772
- boundItem.transform.setPosition(pos.x, pos.y, pos.z);
26124
+ } else {
26125
+ out.hasPosition = false;
26126
+ }
26127
+ };
26128
+ _proto.captureOriginalTransform = function captureOriginalTransform(boundItem) {
26129
+ var scale = boundItem.transform.scale;
26130
+ this.originalTransform = {
26131
+ position: boundItem.transform.position.clone(),
26132
+ rotation: boundItem.transform.getRotation().clone(),
26133
+ // TODO 编辑器 scale 没有z轴控制
26134
+ scale: new Vector3(scale.x, scale.y, scale.x)
26135
+ };
26136
+ if (this.pathGetter) {
26137
+ this.originalTransform.path = this.pathGetter;
25773
26138
  }
25774
26139
  };
25775
26140
  return TransformPlayable;
@@ -25794,6 +26159,104 @@ TransformPlayableAsset = __decorate([
25794
26159
  effectsClass(DataType.TransformPlayableAsset)
25795
26160
  ], TransformPlayableAsset);
25796
26161
 
26162
+ /**
26163
+ * TransformTrack 的 mixer。
26164
+ * 收集当前激活的 Transform clip contribution,并委托 TransformClipMixer 合成当前帧输出。
26165
+ */ var TransformMixerPlayable = /*#__PURE__*/ function(TrackMixerPlayable) {
26166
+ _inherits(TransformMixerPlayable, TrackMixerPlayable);
26167
+ function TransformMixerPlayable() {
26168
+ var _this;
26169
+ _this = TrackMixerPlayable.apply(this, arguments) || this;
26170
+ _this.clipMixer = new TransformClipMixer();
26171
+ return _this;
26172
+ }
26173
+ var _proto = TransformMixerPlayable.prototype;
26174
+ _proto.dispose = function dispose() {
26175
+ this.clipMixer.dispose();
26176
+ TrackMixerPlayable.prototype.dispose.call(this);
26177
+ };
26178
+ _proto.evaluate = function evaluate(context) {
26179
+ var item = context.output.getUserData();
26180
+ if (!_instanceof1(item, VFXItem)) {
26181
+ return;
26182
+ }
26183
+ this.clipMixer.captureBasePose(item);
26184
+ this.clipMixer.resetFrame();
26185
+ for(var i = 0; i < this.clipPlayables.length; i++){
26186
+ var weight = this.clipWeights[i];
26187
+ // RuntimeClip 会把已结束且 destroy 的 clip 权重置 0,这类 clip 不参与当前帧合成。
26188
+ if (!weight || weight <= 0) {
26189
+ continue;
26190
+ }
26191
+ var playable = this.clipPlayables[i];
26192
+ if (!_instanceof1(playable, TransformPlayable)) {
26193
+ continue;
26194
+ }
26195
+ this.clipMixer.addContribution(item, playable.getContribution(this.clipMixer.getBasePosition()), weight);
26196
+ }
26197
+ this.clipMixer.flush(item);
26198
+ };
26199
+ return TransformMixerPlayable;
26200
+ }(TrackMixerPlayable);
26201
+
26202
+ var Vector4PropertyMixerPlayable = /*#__PURE__*/ function(PropertyMixerPlayable) {
26203
+ _inherits(Vector4PropertyMixerPlayable, PropertyMixerPlayable);
26204
+ function Vector4PropertyMixerPlayable() {
26205
+ return PropertyMixerPlayable.apply(this, arguments);
26206
+ }
26207
+ var _proto = Vector4PropertyMixerPlayable.prototype;
26208
+ _proto.resetPropertyValue = function resetPropertyValue() {
26209
+ this.propertyValue.x = 0;
26210
+ this.propertyValue.y = 0;
26211
+ this.propertyValue.z = 0;
26212
+ this.propertyValue.w = 0;
26213
+ };
26214
+ _proto.addWeightedValue = function addWeightedValue(curveValue, weight) {
26215
+ var result = this.propertyValue;
26216
+ result.x += curveValue.x * weight;
26217
+ result.y += curveValue.y * weight;
26218
+ result.z += curveValue.z * weight;
26219
+ result.w += curveValue.w * weight;
26220
+ };
26221
+ return Vector4PropertyMixerPlayable;
26222
+ }(PropertyMixerPlayable);
26223
+ var Vector3PropertyMixerPlayable = /*#__PURE__*/ function(PropertyMixerPlayable) {
26224
+ _inherits(Vector3PropertyMixerPlayable, PropertyMixerPlayable);
26225
+ function Vector3PropertyMixerPlayable() {
26226
+ return PropertyMixerPlayable.apply(this, arguments);
26227
+ }
26228
+ var _proto = Vector3PropertyMixerPlayable.prototype;
26229
+ _proto.resetPropertyValue = function resetPropertyValue() {
26230
+ this.propertyValue.x = 0;
26231
+ this.propertyValue.y = 0;
26232
+ this.propertyValue.z = 0;
26233
+ };
26234
+ _proto.addWeightedValue = function addWeightedValue(curveValue, weight) {
26235
+ var result = this.propertyValue;
26236
+ result.x += curveValue.x * weight;
26237
+ result.y += curveValue.y * weight;
26238
+ result.z += curveValue.z * weight;
26239
+ };
26240
+ return Vector3PropertyMixerPlayable;
26241
+ }(PropertyMixerPlayable);
26242
+ var Vector2PropertyMixerPlayable = /*#__PURE__*/ function(PropertyMixerPlayable) {
26243
+ _inherits(Vector2PropertyMixerPlayable, PropertyMixerPlayable);
26244
+ function Vector2PropertyMixerPlayable() {
26245
+ return PropertyMixerPlayable.apply(this, arguments);
26246
+ }
26247
+ var _proto = Vector2PropertyMixerPlayable.prototype;
26248
+ _proto.resetPropertyValue = function resetPropertyValue() {
26249
+ this.propertyValue.x = 0;
26250
+ this.propertyValue.y = 0;
26251
+ };
26252
+ _proto.addWeightedValue = function addWeightedValue(curveValue, weight) {
26253
+ var result = this.propertyValue;
26254
+ result.x += curveValue.x * weight;
26255
+ result.y += curveValue.y * weight;
26256
+ };
26257
+ return Vector2PropertyMixerPlayable;
26258
+ }(PropertyMixerPlayable);
26259
+
25797
26260
  /**
25798
26261
  * @since 2.0.0
25799
26262
  */ var TimelineClip = /*#__PURE__*/ function() {
@@ -26183,6 +26646,24 @@ ColorPropertyTrack = __decorate([
26183
26646
  effectsClass(DataType.ColorPropertyTrack)
26184
26647
  ], ColorPropertyTrack);
26185
26648
 
26649
+ var SpritePropertyTrack = /*#__PURE__*/ function(PropertyTrack) {
26650
+ _inherits(SpritePropertyTrack, PropertyTrack);
26651
+ function SpritePropertyTrack() {
26652
+ return PropertyTrack.apply(this, arguments);
26653
+ }
26654
+ var _proto = SpritePropertyTrack.prototype;
26655
+ _proto.createTrackMixer = function createTrackMixer() {
26656
+ return new SpritePropertyMixerPlayable();
26657
+ };
26658
+ _proto.updateAnimatedObject = function updateAnimatedObject(boundObject) {
26659
+ return boundObject.getComponent(SpriteComponent);
26660
+ };
26661
+ return SpritePropertyTrack;
26662
+ }(PropertyTrack);
26663
+ SpritePropertyTrack = __decorate([
26664
+ effectsClass("SpritePropertyTrack")
26665
+ ], SpritePropertyTrack);
26666
+
26186
26667
  var Cone = /*#__PURE__*/ function() {
26187
26668
  function Cone(props) {
26188
26669
  var _this = this;
@@ -29687,8 +30168,6 @@ var ParticleSystem = /*#__PURE__*/ function(Component) {
29687
30168
  occlusion: !!renderer.occlusion,
29688
30169
  transparentOcclusion: !!renderer.transparentOcclusion,
29689
30170
  maxCount: options.maxCount,
29690
- mask: this.maskManager.getRefValue(),
29691
- maskMode: this.maskManager.maskMode,
29692
30171
  forceTarget: forceTarget,
29693
30172
  diffuse: renderer.texture ? this.engine.findObject(renderer.texture) : undefined,
29694
30173
  sizeOverLifetime: sizeOverLifetimeGetter,
@@ -29783,9 +30262,7 @@ var ParticleSystem = /*#__PURE__*/ function(Component) {
29783
30262
  shaderCachePrefix: shaderCachePrefix,
29784
30263
  lifetime: this.trails.lifetime,
29785
30264
  occlusion: !!trails.occlusion,
29786
- transparentOcclusion: !!trails.transparentOcclusion,
29787
- mask: this.maskManager.getRefValue(),
29788
- maskMode: this.maskManager.maskMode
30265
+ transparentOcclusion: !!trails.transparentOcclusion
29789
30266
  };
29790
30267
  if (trails.colorOverLifetime && trails.colorOverLifetime[0] === ValueType.GRADIENT_COLOR) {
29791
30268
  trailMeshProps.colorOverLifetime = trails.colorOverLifetime[1];
@@ -30014,6 +30491,44 @@ FloatPropertyPlayableAsset = __decorate([
30014
30491
  effectsClass(DataType.FloatPropertyPlayableAsset)
30015
30492
  ], FloatPropertyPlayableAsset);
30016
30493
 
30494
+ var SpritePropertyPlayableAsset = /*#__PURE__*/ function(PlayableAsset) {
30495
+ _inherits(SpritePropertyPlayableAsset, PlayableAsset);
30496
+ function SpritePropertyPlayableAsset() {
30497
+ var _this;
30498
+ _this = PlayableAsset.apply(this, arguments) || this;
30499
+ _this.curveData = [
30500
+ REFERENCE_CURVE,
30501
+ []
30502
+ ];
30503
+ return _this;
30504
+ }
30505
+ var _proto = SpritePropertyPlayableAsset.prototype;
30506
+ _proto.fromData = function fromData(data) {
30507
+ PlayableAsset.prototype.fromData.call(this, data);
30508
+ var items = data.curveData[1];
30509
+ // 把 DataPath 解析为 Sprite 实例
30510
+ var referenceCurveData = [];
30511
+ for(var i = 0; i < items.length; i++){
30512
+ var _items_i = items[i], t = _items_i[0], ref = _items_i[1];
30513
+ referenceCurveData.push([
30514
+ t,
30515
+ this.engine.findObject(ref)
30516
+ ]);
30517
+ }
30518
+ this.curveData[1] = referenceCurveData;
30519
+ };
30520
+ _proto.createPlayable = function createPlayable() {
30521
+ var clip = new PropertyClipPlayable();
30522
+ clip.curve = createValueGetter(this.curveData);
30523
+ clip.value = clip.curve.getValue(0);
30524
+ return clip;
30525
+ };
30526
+ return SpritePropertyPlayableAsset;
30527
+ }(PlayableAsset);
30528
+ SpritePropertyPlayableAsset = __decorate([
30529
+ effectsClass("SpritePropertyPlayableAsset")
30530
+ ], SpritePropertyPlayableAsset);
30531
+
30017
30532
  var SubCompositionPlayableAsset = /*#__PURE__*/ function(PlayableAsset) {
30018
30533
  _inherits(SubCompositionPlayableAsset, PlayableAsset);
30019
30534
  function SubCompositionPlayableAsset() {
@@ -30261,15 +30776,6 @@ var TimelineInstance = /*#__PURE__*/ function() {
30261
30776
  return TimelineInstance;
30262
30777
  }();
30263
30778
 
30264
- var singleSplits = [
30265
- [
30266
- 0,
30267
- 0,
30268
- 1,
30269
- 1,
30270
- 0
30271
- ]
30272
- ];
30273
30779
  var seed$3 = 0;
30274
30780
  var SpriteColorPlayableAsset = /*#__PURE__*/ function(PlayableAsset) {
30275
30781
  _inherits(SpriteColorPlayableAsset, PlayableAsset);
@@ -30357,9 +30863,6 @@ var SpriteComponent = /*#__PURE__*/ function(MaskableGraphic) {
30357
30863
  _this = MaskableGraphic.call(this, engine) || this;
30358
30864
  _this.time = 0;
30359
30865
  _this.duration = 1;
30360
- /**
30361
- * @internal
30362
- */ _this.splits = singleSplits;
30363
30866
  _this.name = "MSprite" + seed$3++;
30364
30867
  if (props) {
30365
30868
  _this.fromData(props);
@@ -30393,38 +30896,33 @@ var SpriteComponent = /*#__PURE__*/ function(MaskableGraphic) {
30393
30896
  if (textureAnimation) {
30394
30897
  var _this_material_getVector4;
30395
30898
  var total = textureAnimation.total || textureAnimation.row * textureAnimation.col;
30396
- var texRectX = 0;
30397
- var texRectY = 0;
30398
- var texRectW = 1;
30399
- var texRectH = 1;
30400
- var flip;
30401
- if (this.splits) {
30402
- var sp = this.splits[0];
30403
- flip = sp[4];
30404
- texRectX = sp[0];
30405
- texRectY = sp[1];
30406
- if (flip) {
30407
- texRectW = sp[3];
30408
- texRectH = sp[2];
30409
- } else {
30410
- texRectW = sp[2];
30411
- texRectH = sp[3];
30412
- }
30413
- }
30414
- var dx, dy;
30415
- if (flip) {
30416
- dx = 1 / textureAnimation.row * texRectW;
30417
- dy = 1 / textureAnimation.col * texRectH;
30418
- } else {
30419
- dx = 1 / textureAnimation.col * texRectW;
30420
- dy = 1 / textureAnimation.row * texRectH;
30421
- }
30899
+ // 帧动画不与多 split(splits.length>1)同时存在,故此处仅读 sprite 单 rect。
30900
+ // sprite 缺省时按整图 [0,0,1,1] 不旋转处理。
30901
+ var sprite = this.sprite;
30902
+ var _sprite_rect;
30903
+ var rect = (_sprite_rect = sprite == null ? void 0 : sprite.rect) != null ? _sprite_rect : [
30904
+ 0,
30905
+ 0,
30906
+ 1,
30907
+ 1
30908
+ ];
30909
+ var _sprite_rotation;
30910
+ var flip = (_sprite_rotation = sprite == null ? void 0 : sprite.rotation) != null ? _sprite_rotation : SpriteRotation.None;
30911
+ var isRotate90 = flip === SpriteRotation.Rotate90;
30912
+ // rect 在纹理上的归一化矩形 [x, y, w, h];旋转 90° 时宽高互换。
30913
+ var rectX = rect[0];
30914
+ var rectY = rect[1];
30915
+ var rectW = isRotate90 ? rect[3] : rect[2];
30916
+ var rectH = isRotate90 ? rect[2] : rect[3];
30917
+ // 每帧在 rect 内的偏移步长;旋转 90° 时 row/col 对调。
30918
+ var dx = isRotate90 ? 1 / textureAnimation.row * rectW : 1 / textureAnimation.col * rectW;
30919
+ var dy = isRotate90 ? 1 / textureAnimation.col * rectH : 1 / textureAnimation.row * rectH;
30422
30920
  var texOffset;
30423
30921
  if (textureAnimation.animate) {
30424
30922
  var frameIndex = Math.round(life * (total - 1));
30425
30923
  var yIndex = Math.floor(frameIndex / textureAnimation.col);
30426
30924
  var xIndex = frameIndex - yIndex * textureAnimation.col;
30427
- texOffset = flip ? [
30925
+ texOffset = isRotate90 ? [
30428
30926
  dx * yIndex,
30429
30927
  dy * (textureAnimation.col - xIndex)
30430
30928
  ] : [
@@ -30438,8 +30936,8 @@ var SpriteComponent = /*#__PURE__*/ function(MaskableGraphic) {
30438
30936
  ];
30439
30937
  }
30440
30938
  (_this_material_getVector4 = this.material.getVector4("_TexOffset")) == null ? void 0 : _this_material_getVector4.setFromArray([
30441
- texRectX + texOffset[0],
30442
- texRectH + texRectY - texOffset[1],
30939
+ rectX + texOffset[0],
30940
+ rectH + rectY - texOffset[1],
30443
30941
  dx,
30444
30942
  dy
30445
30943
  ]);
@@ -30460,19 +30958,31 @@ var SpriteComponent = /*#__PURE__*/ function(MaskableGraphic) {
30460
30958
  }
30461
30959
  };
30462
30960
  _proto.updateGeometry = function updateGeometry(geometry) {
30463
- var split = this.textureSheetAnimation ? [
30961
+ var sprite = this.sprite;
30962
+ var _sprite_rotation;
30963
+ // sprite 缺省时按整图 [0,0,1,1] 不旋转处理,等价旧默认 splits=[[0,0,1,1,0]]。
30964
+ var flip = (_sprite_rotation = sprite == null ? void 0 : sprite.rotation) != null ? _sprite_rotation : SpriteRotation.None;
30965
+ var _sprite_rect;
30966
+ var rect = (_sprite_rect = sprite == null ? void 0 : sprite.rect) != null ? _sprite_rect : [
30464
30967
  0,
30465
30968
  0,
30466
30969
  1,
30970
+ 1
30971
+ ];
30972
+ var _ref = this.textureSheetAnimation ? [
30973
+ 0,
30974
+ 0,
30467
30975
  1,
30468
- this.splits[0][4]
30469
- ] : this.splits[0];
30470
- var uvTransform = split;
30471
- var x = uvTransform[0];
30472
- var y = uvTransform[1];
30473
- var isRotate90 = Boolean(uvTransform[4]);
30474
- var width = isRotate90 ? uvTransform[3] : uvTransform[2];
30475
- var height = isRotate90 ? uvTransform[2] : uvTransform[3];
30976
+ 1
30977
+ ] : [
30978
+ rect[0],
30979
+ rect[1],
30980
+ rect[2],
30981
+ rect[3]
30982
+ ], x = _ref[0], y = _ref[1], w = _ref[2], h = _ref[3];
30983
+ var isRotate90 = flip === SpriteRotation.Rotate90;
30984
+ var width = isRotate90 ? h : w;
30985
+ var height = isRotate90 ? w : h;
30476
30986
  var angle = isRotate90 ? -Math.PI / 2 : 0;
30477
30987
  var aUV = geometry.getAttributeData("aUV");
30478
30988
  var aPos = geometry.getAttributeData("aPos");
@@ -30509,11 +31019,51 @@ var SpriteComponent = /*#__PURE__*/ function(MaskableGraphic) {
30509
31019
  });
30510
31020
  }
30511
31021
  };
31022
+ _proto.fromData = function fromData(data) {
31023
+ MaskableGraphic.prototype.fromData.call(this, data); // MaskableGraphic: 设 renderer.texture(whiteTexture 或 data.renderer.texture)、_MainTex、_Color
31024
+ // 单 split / 新数据流:引用 Sprite 资产,渲染读 this.sprite
31025
+ if (data.sprite) {
31026
+ var sprite = this.engine.findObject(data.sprite);
31027
+ if (sprite) {
31028
+ this.applySpriteToRenderer(sprite);
31029
+ }
31030
+ }
31031
+ this.textureSheetAnimation = data.textureSheetAnimation;
31032
+ var geometry = data.geometry ? this.engine.findObject(data.geometry) : this.defaultGeometry;
31033
+ var splits = data.splits;
31034
+ if (splits && splits.length > 1) {
31035
+ // 原有打包纹理拆分逻辑(多 split,2x2 纹理打包),保留向后兼容;
31036
+ // 不依赖组件 splits 字段,直接用 data.splits。
31037
+ this.updateGeometryFromMultiSplit(splits);
31038
+ } else {
31039
+ this.updateGeometry(geometry);
31040
+ }
31041
+ this.interaction = data.interaction;
31042
+ var startColor = data.options.startColor || [
31043
+ 1,
31044
+ 1,
31045
+ 1,
31046
+ 1
31047
+ ];
31048
+ this.material.setColor("_Color", new Color().setFromArray(startColor));
31049
+ var _data_duration;
31050
+ //@ts-expect-error
31051
+ this.duration = (_data_duration = data.duration) != null ? _data_duration : this.item.duration;
31052
+ };
31053
+ /**
31054
+ * 应用 Sprite 资产到渲染器:同步纹理并重绑 _MainTex。不重建几何体。
31055
+ * fromData(后续自行 updateGeometry)与 sprite setter(随后 updateGeometry)共用。
31056
+ * 直接写 _sprite,避免经 setter 触发 updateGeometry。
31057
+ */ _proto.applySpriteToRenderer = function applySpriteToRenderer(sprite) {
31058
+ this._sprite = sprite;
31059
+ this.renderer.texture = sprite.texture;
31060
+ this.material.setTexture("_MainTex", sprite.texture);
31061
+ };
30512
31062
  /**
30513
31063
  * @deprecated
30514
- * 原有打包纹理拆分逻辑,待移除
30515
- */ _proto.updateGeometryFromMultiSplit = function updateGeometryFromMultiSplit() {
30516
- var _this = this, splits = _this.splits, textureSheetAnimation = _this.textureSheetAnimation;
31064
+ * 原有打包纹理拆分逻辑,仅在老数据 splits.length>1(2x2 纹理打包)时使用,保留向后兼容。
31065
+ * 不依赖组件状态,splits 由参数传入(同时存在帧动画与多 split 的数据不存在)。
31066
+ */ _proto.updateGeometryFromMultiSplit = function updateGeometryFromMultiSplit(splits) {
30517
31067
  var sx = 1, sy = 1;
30518
31068
  var geometry = this.defaultGeometry;
30519
31069
  var originData = [
@@ -30534,14 +31084,7 @@ var SpriteComponent = /*#__PURE__*/ function(MaskableGraphic) {
30534
31084
  for(var x = 0; x < col; x++){
30535
31085
  for(var y = 0; y < row; y++){
30536
31086
  var base = (y * 2 + x) * 4;
30537
- // @ts-expect-error
30538
- var split = textureSheetAnimation ? [
30539
- 0,
30540
- 0,
30541
- 1,
30542
- 1,
30543
- splits[0][4]
30544
- ] : splits[y * 2 + x];
31087
+ var split = splits[y * 2 + x];
30545
31088
  var texOffset = split[4] ? [
30546
31089
  0,
30547
31090
  0,
@@ -30587,33 +31130,21 @@ var SpriteComponent = /*#__PURE__*/ function(MaskableGraphic) {
30587
31130
  geometry.setAttributeData("aUV", new Float32Array(aUV));
30588
31131
  geometry.setDrawCount(index.length);
30589
31132
  };
30590
- _proto.fromData = function fromData(data) {
30591
- MaskableGraphic.prototype.fromData.call(this, data);
30592
- var _data_splits;
30593
- var splits = (_data_splits = data.splits) != null ? _data_splits : singleSplits;
30594
- var textureSheetAnimation = data.textureSheetAnimation;
30595
- this.splits = splits;
30596
- this.textureSheetAnimation = textureSheetAnimation;
30597
- var geometry = data.geometry ? this.engine.findObject(data.geometry) : this.defaultGeometry;
30598
- if (splits.length === 1) {
30599
- this.updateGeometry(geometry);
30600
- } else {
30601
- // TODO: 原有打包纹理拆分逻辑,待移除
30602
- //-------------------------------------------------------------------------
30603
- this.updateGeometryFromMultiSplit();
31133
+ _create_class(SpriteComponent, [
31134
+ {
31135
+ key: "sprite",
31136
+ get: /**
31137
+ * 当前 Sprite 资产。设置时同步纹理、重绑 _MainTex 并重建几何体 UV。
31138
+ * @since 2.10.0
31139
+ */ function get() {
31140
+ return this._sprite;
31141
+ },
31142
+ set: function set(sprite) {
31143
+ this.applySpriteToRenderer(sprite);
31144
+ this.updateGeometry(this.geometry);
31145
+ }
30604
31146
  }
30605
- this.interaction = data.interaction;
30606
- var startColor = data.options.startColor || [
30607
- 1,
30608
- 1,
30609
- 1,
30610
- 1
30611
- ];
30612
- this.material.setColor("_Color", new Color().setFromArray(startColor));
30613
- var _data_duration;
30614
- //@ts-expect-error
30615
- this.duration = (_data_duration = data.duration) != null ? _data_duration : this.item.duration;
30616
- };
31147
+ ]);
30617
31148
  return SpriteComponent;
30618
31149
  }(MaskableGraphic);
30619
31150
  SpriteComponent = __decorate([
@@ -30628,6 +31159,54 @@ var ParticleLoader = /*#__PURE__*/ function(Plugin) {
30628
31159
  return ParticleLoader;
30629
31160
  }(_wrap_native_super(Plugin));
30630
31161
 
31162
+ /**
31163
+ * 文本换行机会判定:UAX #14 风格的"换行机会"模型。
31164
+ *
31165
+ * - CJK 表意字 / 假名 / 韩文音节:任意两个字之间都是合法断点(字符级)
31166
+ * - 空格 / 制表符 / NBSP:可断,且断行时被吞掉(不留在行尾 / 行首)
31167
+ * - 西文字母 / 数字:词内不可断;整体超宽时由调用方退化到字符级断(overflow-wrap)
31168
+ *
31169
+ * 不含 kinsoku 禁则(句号 / 逗号不进行首等留作后续)。
31170
+ */ /** 换行机会类型(断点字符之后):决定断点字符归属及断行时是否吞掉 */ /**
31171
+ * 是否为可换行断点字符(空格 / 制表符 / NBSP)。
31172
+ * 断在此字符之前,且断行时该字符被吞掉(不进旧行也不进新行)。
31173
+ * @param ch - 当前字符
31174
+ */ function isBreakChar(ch) {
31175
+ return ch === " " || ch === " " || ch === "\xa0";
31176
+ }
31177
+ /**
31178
+ * 是否为 CJK 类字符(中文表意字 / 假名 / 韩文音节)。可在其与相邻字符之间换行。
31179
+ * 用码点判定以支持 CJK 扩展 B 等代理对字符(不能用 /u 正则,browserslist 为 iOS 9)。
31180
+ * @param ch - 当前字符(须为完整码点,调用方应使用 Array.from 遍历)
31181
+ */ function isCJKLike(ch) {
31182
+ var _ch_codePointAt;
31183
+ var cp = (_ch_codePointAt = ch.codePointAt(0)) != null ? _ch_codePointAt : 0;
31184
+ return cp >= 0x3400 && cp <= 0x4DBF || // CJK 统一表意扩展 A
31185
+ cp >= 0x4E00 && cp <= 0x9FFF || // CJK 统一表意
31186
+ cp >= 0xF900 && cp <= 0xFAFF || // CJK 兼容表意
31187
+ cp >= 0x20000 && cp <= 0x2FA1F || // CJK 扩展 B~F + 兼容增补(代理对)
31188
+ cp >= 0x3040 && cp <= 0x309F || // 平假名
31189
+ cp >= 0x30A0 && cp <= 0x30FF || // 片假名
31190
+ cp >= 0x31F0 && cp <= 0x31FF || // 片假名语音扩展
31191
+ cp >= 0xAC00 && cp <= 0xD7AF // 韩文音节
31192
+ ;
31193
+ }
31194
+ /**
31195
+ * 计算 prev(已推入的字符)之后是否为换行机会。只看 prev,不看后续字符。
31196
+ * @param prev - 前一字符(已推入旧行)
31197
+ * @returns 'swallow'=prev 是空格类,断行时吞掉 prev;'keep'=prev 是 CJK,prev 留本行末、下行从其后起;false=不可断
31198
+ */ function breakOpportunityAfter(prev) {
31199
+ // prev 是空格类 → 断在 prev 处,断行时吞掉 prev(不进旧行也不进新行)
31200
+ if (isBreakChar(prev)) {
31201
+ return "swallow";
31202
+ }
31203
+ // prev 是 CJK → prev 留本行末,下行从 prev 之后起(字符级断点,不吞)
31204
+ if (isCJKLike(prev)) {
31205
+ return "keep";
31206
+ }
31207
+ return false;
31208
+ }
31209
+
30631
31210
  var TextLayout = /*#__PURE__*/ function() {
30632
31211
  function TextLayout(options) {
30633
31212
  this.width = 0;
@@ -31076,9 +31655,6 @@ var DEFAULT_FONTS = [
31076
31655
  "courier"
31077
31656
  ];
31078
31657
  /** 检测字符串是否包含需要 RTL 和连写排版的字符(阿拉伯语等) */ var HAS_RTL_OR_JOINING = /[\u0600-\u06FF\u0750-\u077F\u08A0-\u08FF\uFB50-\uFDFF\uFE70-\uFEFF]/;
31079
- /** 可换行断点:空格、制表符等 */ var IS_BREAK_CHAR = function(ch) {
31080
- return ch === " " || ch === " " || ch === "\xa0";
31081
- };
31082
31658
  var seed$2 = 0;
31083
31659
  var TextComponent = /*#__PURE__*/ function(MaskableGraphic) {
31084
31660
  _inherits(TextComponent, MaskableGraphic);
@@ -31178,13 +31754,15 @@ var TextComponent = /*#__PURE__*/ function(MaskableGraphic) {
31178
31754
  var lineCount = 1;
31179
31755
  var x = 0;
31180
31756
  var charCountInLine = 0;
31757
+ // 使用码点遍历,正确处理 emoji 与 CJK 扩展 B 等代理对字符
31758
+ var chars = Array.from(text);
31181
31759
  if (context) {
31182
31760
  context.font = this.getFontDesc(this.textStyle.fontSize);
31183
31761
  }
31184
31762
  if (overflow === TextOverflow.display) {
31185
- for(var i = 0; i < text.length; i++){
31763
+ for(var _iterator = _create_for_of_iterator_helper_loose(chars), _step; !(_step = _iterator()).done;){
31764
+ var str = _step.value;
31186
31765
  var _context_measureText;
31187
- var str = text[i];
31188
31766
  var _context_measureText_width;
31189
31767
  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;
31190
31768
  if (str === "\n") {
@@ -31203,12 +31781,12 @@ var TextComponent = /*#__PURE__*/ function(MaskableGraphic) {
31203
31781
  return lineCount;
31204
31782
  }
31205
31783
  if (this.textLayout.keepWordIntact) {
31206
- // 单词完整换行:优先在空格处断行,避免从单词中间断开
31784
+ // 单词完整换行:优先在换行机会处断行(空格吞断 / CJK 字间可断),避免从西文词中间断开
31207
31785
  var lastBreakX = 0;
31208
31786
  var countAtBreak = 0;
31209
- for(var i1 = 0; i1 < text.length; i1++){
31787
+ for(var _iterator1 = _create_for_of_iterator_helper_loose(chars), _step1; !(_step1 = _iterator1()).done;){
31788
+ var str1 = _step1.value;
31210
31789
  var _context_measureText1;
31211
- var str1 = text[i1];
31212
31790
  var _context_measureText_width1;
31213
31791
  var textMetrics1 = (_context_measureText_width1 = context == null ? void 0 : (_context_measureText1 = context.measureText(str1)) == null ? void 0 : _context_measureText1.width) != null ? _context_measureText_width1 : 0;
31214
31792
  if (str1 === "\n") {
@@ -31241,22 +31819,23 @@ var TextComponent = /*#__PURE__*/ function(MaskableGraphic) {
31241
31819
  }
31242
31820
  x += textMetrics1;
31243
31821
  charCountInLine++;
31244
- if (IS_BREAK_CHAR(str1)) {
31822
+ // 记换行机会:str 之后可断(空格 swallow / CJK keep)。lastBreakX 含 str 宽度(str 留本行末)
31823
+ if (breakOpportunityAfter(str1) !== false) {
31245
31824
  lastBreakX = x;
31246
31825
  countAtBreak = charCountInLine;
31247
31826
  }
31248
31827
  }
31249
31828
  } else {
31250
31829
  // 逐字符换行:允许在任意字符处断开
31251
- for(var i2 = 0; i2 < text.length; i2++){
31830
+ for(var i = 0; i < chars.length; i++){
31252
31831
  var _context_measureText2;
31253
- var str2 = text[i2];
31832
+ var str2 = chars[i];
31254
31833
  var _context_measureText_width2;
31255
31834
  var textMetrics2 = (_context_measureText_width2 = context == null ? void 0 : (_context_measureText2 = context.measureText(str2)) == null ? void 0 : _context_measureText2.width) != null ? _context_measureText_width2 : 0;
31256
31835
  if (charCountInLine > 0) {
31257
31836
  x += letterSpace;
31258
31837
  }
31259
- if (x + textMetrics2 > width && i2 > 0 || str2 === "\n") {
31838
+ if (x + textMetrics2 > width && i > 0 || str2 === "\n") {
31260
31839
  lineCount++;
31261
31840
  this.maxLineWidth = Math.max(this.maxLineWidth, x);
31262
31841
  x = 0;
@@ -31349,8 +31928,11 @@ var TextComponent = /*#__PURE__*/ function(MaskableGraphic) {
31349
31928
  var charsArray = [];
31350
31929
  var charOffsetX = [];
31351
31930
  if (layout.keepWordIntact) {
31352
- // 单词完整换行:优先在空格处断行,避免从单词中间断开
31931
+ // 单词完整换行:优先在换行机会处断行(空格吞断 / CJK 字间可断),避免从西文词中间断开。
31932
+ // lastBreakIdx 指向断点字符在 charsArray 中的索引;breakSwallow=true 时该字符被吞(空格),
31933
+ // false 时该字符留本行末(CJK),下行均从 lastBreakIdx+1 起。
31353
31934
  var lastBreakIdx = -1;
31935
+ var breakSwallow = false;
31354
31936
  for(var i = 0; i < char.length; i++){
31355
31937
  var str = char[i];
31356
31938
  var textMetrics = context.measureText(str);
@@ -31366,15 +31948,18 @@ var TextComponent = /*#__PURE__*/ function(MaskableGraphic) {
31366
31948
  charsArray = [];
31367
31949
  charOffsetX = [];
31368
31950
  lastBreakIdx = -1;
31951
+ breakSwallow = false;
31369
31952
  continue;
31370
31953
  }
31371
31954
  var spacing = charsArray.length > 0 ? layout.letterSpace : 0;
31372
31955
  var willWidth = x + spacing + textMetrics.width;
31373
31956
  if (willWidth > baseWidth && charsArray.length > 0) {
31374
31957
  if (lastBreakIdx > 0) {
31375
- // 在空格处换行
31376
- var lineChars = charsArray.slice(0, lastBreakIdx);
31377
- var lineOffsets = charOffsetX.slice(0, lastBreakIdx);
31958
+ // 在换行机会处断行:swallow 取 [0,lastBreakIdx)(吞掉断点字符),
31959
+ // keep [0,lastBreakIdx](断点字符留本行末),下行均从 lastBreakIdx+1 起。
31960
+ var endIdx = breakSwallow ? lastBreakIdx : lastBreakIdx + 1;
31961
+ var lineChars = charsArray.slice(0, endIdx);
31962
+ var lineOffsets = charOffsetX.slice(0, endIdx);
31378
31963
  var lineWidth = lineChars.length > 0 ? lineOffsets[lineOffsets.length - 1] + context.measureText(lineChars[lineChars.length - 1]).width : 0;
31379
31964
  charsInfo.push({
31380
31965
  y: y,
@@ -31395,6 +31980,7 @@ var TextComponent = /*#__PURE__*/ function(MaskableGraphic) {
31395
31980
  x += context.measureText(charsArray[j]).width;
31396
31981
  }
31397
31982
  lastBreakIdx = -1;
31983
+ breakSwallow = false;
31398
31984
  } else {
31399
31985
  charsInfo.push({
31400
31986
  y: y,
@@ -31407,6 +31993,7 @@ var TextComponent = /*#__PURE__*/ function(MaskableGraphic) {
31407
31993
  charsArray = [];
31408
31994
  charOffsetX = [];
31409
31995
  lastBreakIdx = -1;
31996
+ breakSwallow = false;
31410
31997
  }
31411
31998
  }
31412
31999
  if (charsArray.length > 0) {
@@ -31415,8 +32002,12 @@ var TextComponent = /*#__PURE__*/ function(MaskableGraphic) {
31415
32002
  charOffsetX.push(x);
31416
32003
  charsArray.push(str);
31417
32004
  x += textMetrics.width;
31418
- if (IS_BREAK_CHAR(str)) {
32005
+ // 记换行机会:str 之后可断。lastBreakIdx 指向 str(charsArray 末尾),
32006
+ // swallow=吞 str(空格),keep=str 留本行末(CJK)。
32007
+ var opp = breakOpportunityAfter(str);
32008
+ if (opp !== false) {
31419
32009
  lastBreakIdx = charsArray.length - 1;
32010
+ breakSwallow = opp === "swallow";
31420
32011
  }
31421
32012
  }
31422
32013
  } else {
@@ -33366,7 +33957,6 @@ var ShapeComponent = /*#__PURE__*/ function(RendererComponent) {
33366
33957
  var material = Material.create(this.engine, materialProps);
33367
33958
  var renderer = rendererOptions;
33368
33959
  var side = renderer.side, occlusion = renderer.occlusion, blendMode = renderer.blending, texture = renderer.texture;
33369
- var maskMode = this.maskManager.maskMode;
33370
33960
  material.blending = true;
33371
33961
  material.depthTest = true;
33372
33962
  material.depthMask = occlusion;
@@ -33380,7 +33970,6 @@ var ShapeComponent = /*#__PURE__*/ function(RendererComponent) {
33380
33970
  texParams.x = renderer.occlusion ? +renderer.transparentOcclusion : 1;
33381
33971
  texParams.y = preMultiAlpha;
33382
33972
  texParams.z = renderer.renderMode;
33383
- texParams.w = maskMode;
33384
33973
  material.setVector4("_TexParams", texParams);
33385
33974
  if (texParams.x === 0 || this.maskManager.alphaMaskEnabled) {
33386
33975
  material.enableMacro("ALPHA_CLIP");
@@ -33403,9 +33992,9 @@ var ShapeComponent = /*#__PURE__*/ function(RendererComponent) {
33403
33992
  blending: (_renderer_blending = renderer.blending) != null ? _renderer_blending : BlendingMode.ALPHA,
33404
33993
  texture: renderer.texture ? this.engine.findObject(renderer.texture) : this.engine.whiteTexture,
33405
33994
  occlusion: !!renderer.occlusion,
33406
- transparentOcclusion: !!renderer.transparentOcclusion || this.maskManager.maskMode === MaskMode.MASK,
33995
+ transparentOcclusion: !!renderer.transparentOcclusion || this.maskManager.isMask,
33407
33996
  side: (_renderer_side = renderer.side) != null ? _renderer_side : SideMode.DOUBLE,
33408
- mask: this.maskManager.getRefValue()
33997
+ mask: 1
33409
33998
  };
33410
33999
  var _data_strokeCap;
33411
34000
  this.strokeCap = (_data_strokeCap = data.strokeCap) != null ? _data_strokeCap : LineCap.Butt;
@@ -34387,7 +34976,7 @@ function getStandardInteractContent(ui) {
34387
34976
  return ret;
34388
34977
  }
34389
34978
 
34390
- var currentMaskComponent;
34979
+ var currentMaskComponentId;
34391
34980
  var componentMap = new Map();
34392
34981
  var itemMap = new Map();
34393
34982
  /**
@@ -35049,12 +35638,21 @@ function version36Migration(json) {
35049
35638
  for(var _iterator3 = _create_for_of_iterator_helper_loose(json.compositions), _step3; !(_step3 = _iterator3()).done;){
35050
35639
  var composition = _step3.value;
35051
35640
  composition.children = [];
35641
+ currentMaskComponentId = undefined;
35642
+ //@ts-expect-error
35643
+ var legacyCompositionItems = composition.items;
35644
+ if (Array.isArray(legacyCompositionItems)) {
35645
+ processMaskReferenceItems(legacyCompositionItems, itemMap, componentMap);
35646
+ }
35052
35647
  for(var _iterator4 = _create_for_of_iterator_helper_loose(composition.components), _step4; !(_step4 = _iterator4()).done;){
35053
35648
  var componentDataPath = _step4.value;
35054
35649
  var componentData = componentMap.get(componentDataPath.id);
35055
35650
  if (componentData.dataType === DataType.CompositionComponent) {
35056
35651
  var compositionComponent = componentData;
35057
- for(var _iterator5 = _create_for_of_iterator_helper_loose(compositionComponent.items), _step5; !(_step5 = _iterator5()).done;){
35652
+ var _compositionComponent_items;
35653
+ var compositionItems = (_compositionComponent_items = compositionComponent.items) != null ? _compositionComponent_items : [];
35654
+ processMaskReferenceItems(compositionItems, itemMap, componentMap);
35655
+ for(var _iterator5 = _create_for_of_iterator_helper_loose(compositionItems), _step5; !(_step5 = _iterator5()).done;){
35058
35656
  var itemPath = _step5.value;
35059
35657
  var item1 = itemMap.get(itemPath.id);
35060
35658
  if (item1.parentId === undefined) {
@@ -35084,6 +35682,72 @@ function version36Migration(json) {
35084
35682
  json.version = JSONSceneVersion["3_7"];
35085
35683
  return json;
35086
35684
  }
35685
+ /**
35686
+ * 3.8 数据适配:SpriteComponent 的 renderer.texture + splits 迁移为独立 Sprite 资产。
35687
+ *
35688
+ * - 遍历所有未引用 sprite 的 SpriteComponentData,按 splits[0](无则整图 [0,0,1,1])生成
35689
+ * Sprite 资产对象放入 miscs,并把组件的 sprite 指向它。
35690
+ * - 删除组件的 splits 与 renderer.texture(纹理归属 sprite,renderer 仅保留渲染状态)。
35691
+ * - 卫语句 `if (sc.sprite) continue` 处理混合数据(部分组件已用 sprite)。
35692
+ * - 多 split(splits.length>1,2x2 纹理打包)保留原 splits 不迁移,仍走 updateGeometryFromMultiSplit 旧路径。
35693
+ *
35694
+ * 由 getStandardJSON 以 `minorVersion < 8` 守卫调用,数据生命周期内只跑一次。
35695
+ * version 字段设为字符串 '3.8'(JSONSceneVersion 枚举无此值,运行时不依赖枚举)。
35696
+ */ function version37Migration(json) {
35697
+ var _json;
35698
+ var _miscs;
35699
+ (_miscs = (_json = json).miscs) != null ? _miscs : _json.miscs = [];
35700
+ for(var _iterator = _create_for_of_iterator_helper_loose(json.components), _step; !(_step = _iterator()).done;){
35701
+ var component = _step.value;
35702
+ var _sc_renderer;
35703
+ if (component.dataType !== DataType.SpriteComponent) {
35704
+ continue;
35705
+ }
35706
+ // 本地扩展 sprite 字段(spec 包不可改)。ComponentData 是 SpriteComponentData 的超集,
35707
+ // 故直接当 SpriteComponentData 用;sprite 需要写到对象上,用宽松类型承载。
35708
+ var sc = component;
35709
+ if (sc.sprite) {
35710
+ continue; // 已迁移/新数据
35711
+ }
35712
+ var splits = sc.splits;
35713
+ if (splits && splits.length > 1) {
35714
+ continue;
35715
+ }
35716
+ var first = splits == null ? void 0 : splits[0];
35717
+ var rect = first ? [
35718
+ first[0],
35719
+ first[1],
35720
+ first[2],
35721
+ first[3]
35722
+ ] : [
35723
+ 0,
35724
+ 0,
35725
+ 1,
35726
+ 1
35727
+ ];
35728
+ var _first_;
35729
+ // rotation: 0=None 不旋转, 1=Rotate90(值与 Sprite.SpriteRotation 枚举一致,序列化兼容)
35730
+ var rotation = (_first_ = first == null ? void 0 : first[4]) != null ? _first_ : 0;
35731
+ var spriteData = {
35732
+ id: generateGUID(),
35733
+ dataType: "Sprite",
35734
+ // 可能为 undefined(纯色元素)→ Sprite.fromData 兜底 whiteTexture
35735
+ texture: (_sc_renderer = sc.renderer) == null ? void 0 : _sc_renderer.texture,
35736
+ rect: rect,
35737
+ rotation: rotation
35738
+ };
35739
+ json.miscs.push(spriteData);
35740
+ sc.sprite = {
35741
+ id: spriteData.id
35742
+ };
35743
+ delete sc.splits;
35744
+ if (sc.renderer) {
35745
+ delete sc.renderer.texture; // 纹理归属 sprite,renderer 仅保留渲染状态
35746
+ }
35747
+ }
35748
+ json.version = "3.8";
35749
+ return json;
35750
+ }
35087
35751
  /**
35088
35752
  * 确保文本组件有版本标识字段
35089
35753
  */ function ensureTextVerticalAlign(options) {
@@ -35194,6 +35858,21 @@ function processContent(composition) {
35194
35858
  }
35195
35859
  }
35196
35860
  }
35861
+ function processMaskReferenceItems(items, itemMap, componentMap) {
35862
+ for(var _iterator = _create_for_of_iterator_helper_loose(items), _step; !(_step = _iterator()).done;){
35863
+ var item = _step.value;
35864
+ var itemProps = itemMap.get(item.id);
35865
+ if (!itemProps) {
35866
+ continue;
35867
+ }
35868
+ if (itemProps.type === ItemType.sprite || itemProps.type === ItemType.particle || itemProps.type === ItemType.spine || itemProps.type === ItemType.text || itemProps.type === ItemType.richtext || itemProps.type === ItemType.video || itemProps.type === ItemType.shape || itemProps.type === ItemType.mesh) {
35869
+ var component = componentMap.get(itemProps.components[0].id);
35870
+ if (component) {
35871
+ processMaskReference(component);
35872
+ }
35873
+ }
35874
+ }
35875
+ }
35197
35876
  function processMask(renderContent) {
35198
35877
  var renderer = renderContent.renderer;
35199
35878
  var maskMode = renderer == null ? void 0 : renderer.maskMode;
@@ -35204,16 +35883,34 @@ function processMask(renderContent) {
35204
35883
  renderContent.mask = {
35205
35884
  isMask: true
35206
35885
  };
35207
- currentMaskComponent = renderContent.id;
35886
+ currentMaskComponentId = renderContent.id;
35208
35887
  } else if (maskMode === ObscuredMode.OBSCURED || maskMode === ObscuredMode.REVERSE_OBSCURED) {
35209
35888
  renderContent.mask = {
35210
35889
  inverted: maskMode === ObscuredMode.REVERSE_OBSCURED ? true : false,
35211
35890
  reference: {
35212
- "id": currentMaskComponent
35891
+ "id": currentMaskComponentId
35213
35892
  }
35214
35893
  };
35215
35894
  }
35216
35895
  }
35896
+ function processMaskReference(renderContent) {
35897
+ var mask = renderContent.mask;
35898
+ if (mask && !mask.references && mask.reference) {
35899
+ var _mask_isMask, _mask_alphaMaskEnabled, _mask_inverted;
35900
+ // 处理旧版 mask 格式(mask.reference 和 mask.inverted 字段)
35901
+ // 将旧版单蒙版格式转换为 references 数组
35902
+ renderContent.mask = {
35903
+ isMask: (_mask_isMask = mask.isMask) != null ? _mask_isMask : false,
35904
+ alphaMaskEnabled: (_mask_alphaMaskEnabled = mask.alphaMaskEnabled) != null ? _mask_alphaMaskEnabled : false,
35905
+ references: [
35906
+ {
35907
+ mask: mask.reference,
35908
+ inverted: (_mask_inverted = mask.inverted) != null ? _mask_inverted : false
35909
+ }
35910
+ ]
35911
+ };
35912
+ }
35913
+ }
35217
35914
  function convertParam(content) {
35218
35915
  if (!content) {
35219
35916
  return;
@@ -35888,7 +36585,7 @@ function getStandardSpriteContent(sprite, transform) {
35888
36585
  return ret;
35889
36586
  }
35890
36587
 
35891
- var version$2 = "2.10.0-alpha.0";
36588
+ var version$2 = "2.10.0-alpha.1";
35892
36589
  var v0 = /^(\d+)\.(\d+)\.(\d+)(-(\w+)\.\d+)?$/;
35893
36590
  var standardVersion = /^(\d+)\.(\d+)$/;
35894
36591
  var reverseParticle = false;
@@ -35906,7 +36603,7 @@ function getStandardJSON(json) {
35906
36603
  if (v0.test(json.version)) {
35907
36604
  var _exec;
35908
36605
  reverseParticle = ((_exec = /^(\d+)/.exec(json.version)) == null ? void 0 : _exec[0]) === "0";
35909
- return version36Migration(version35Migration(version34Migration(version33Migration(version32Migration(version31Migration(version30Migration(version21Migration(getStandardJSONFromV0(json)))))))));
36606
+ return version37Migration(version36Migration(version35Migration(version34Migration(version33Migration(version32Migration(version31Migration(version30Migration(version21Migration(getStandardJSONFromV0(json))))))))));
35910
36607
  }
35911
36608
  reverseParticle = false;
35912
36609
  var vs = standardVersion.exec(json.version) || [];
@@ -35943,6 +36640,9 @@ function getStandardJSON(json) {
35943
36640
  if (minorVersion < 7) {
35944
36641
  json = version36Migration(json);
35945
36642
  }
36643
+ if (minorVersion < 8) {
36644
+ json = version37Migration(json);
36645
+ }
35946
36646
  }
35947
36647
  return json;
35948
36648
  }
@@ -36401,11 +37101,15 @@ var seed$1 = 1;
36401
37101
  var _proto = AssetManager.prototype;
36402
37102
  _proto.updateOptions = function updateOptions(options) {
36403
37103
  if (options === void 0) options = {};
36404
- this.options = options;
36405
- if (!options.pluginData) {
36406
- options.pluginData = {};
37104
+ var _options_useCompressedTexture, _options_useHevcVideo;
37105
+ this.options = _extends({}, options, {
37106
+ useCompressedTexture: (_options_useCompressedTexture = options.useCompressedTexture) != null ? _options_useCompressedTexture : true,
37107
+ useHevcVideo: (_options_useHevcVideo = options.useHevcVideo) != null ? _options_useHevcVideo : true
37108
+ });
37109
+ if (!this.options.pluginData) {
37110
+ this.options.pluginData = {};
36407
37111
  }
36408
- var _options_timeout = options.timeout, timeout = _options_timeout === void 0 ? 10 : _options_timeout;
37112
+ var _this_options = this.options, _this_options_timeout = _this_options.timeout, timeout = _this_options_timeout === void 0 ? 10 : _this_options_timeout;
36409
37113
  this.timeout = timeout;
36410
37114
  };
36411
37115
  /**
@@ -36663,12 +37367,19 @@ var seed$1 = 1;
36663
37367
  if (canUseKTX2 === void 0) canUseKTX2 = false;
36664
37368
  var _this = this;
36665
37369
  return _async_to_generator(function() {
36666
- var _this_options, useCompressedTexture, variables, disableWebP, disableAVIF, baseUrl, jobs, loadedImages;
37370
+ var _this_options, useCompressedTexture, variables, disableWebP, disableAVIF, isKTX2PluginRegistered, canUseCompressedTexture, baseUrl, jobs, loadedImages;
36667
37371
  return __generator(this, function(_state) {
36668
37372
  switch(_state.label){
36669
37373
  case 0:
36670
37374
  _this_options = _this.options, useCompressedTexture = _this_options.useCompressedTexture, variables = _this_options.variables, disableWebP = _this_options.disableWebP, disableAVIF = _this_options.disableAVIF;
37375
+ isKTX2PluginRegistered = !!pluginLoaderMap.ktx2;
37376
+ canUseCompressedTexture = useCompressedTexture && canUseKTX2 && isKTX2PluginRegistered;
36671
37377
  baseUrl = _this.baseUrl;
37378
+ if (useCompressedTexture && canUseKTX2 && !isKTX2PluginRegistered && images.some(function(img) {
37379
+ return "ktx2" in img && img.ktx2;
37380
+ })) {
37381
+ logger.warn("The plugin 'ktx2' is not found, unable to use compressed textures." + getPluginUsageInfo("ktx2"));
37382
+ }
36672
37383
  jobs = images.map(/*#__PURE__*/ _async_to_generator(function(img, idx) {
36673
37384
  var png, webp, avif, ktx2, imageURL, webpURL, avifURL, ktx2URL, id, template, background, url, isVideo, loadFn, resultImage, e, _ref, url1, image, _tmp;
36674
37385
  return __generator(this, function(_state) {
@@ -36683,7 +37394,7 @@ var seed$1 = 1;
36683
37394
  // eslint-disable-next-line compat/compat
36684
37395
  avifURL = !disableAVIF && avif ? new URL(avif, baseUrl).href : undefined;
36685
37396
  // eslint-disable-next-line compat/compat
36686
- ktx2URL = ktx2 && useCompressedTexture && canUseKTX2 ? new URL(ktx2, baseUrl).href : undefined;
37397
+ ktx2URL = ktx2 && canUseCompressedTexture ? new URL(ktx2, baseUrl).href : undefined;
36687
37398
  id = img.id;
36688
37399
  if (!("template" in img)) return [
36689
37400
  3,
@@ -36835,7 +37546,7 @@ var seed$1 = 1;
36835
37546
  case 0:
36836
37547
  return [
36837
37548
  4,
36838
- PluginSystem.onAssetsLoadStart(scene, _this.options)
37549
+ PluginSystem.notifyAssetsLoadStart(scene, _this.options)
36839
37550
  ];
36840
37551
  case 1:
36841
37552
  _state.sent();
@@ -37917,7 +38628,7 @@ var PreRenderTickData = /*#__PURE__*/ function(TickData) {
37917
38628
  _this.onItemMessage = onItemMessage;
37918
38629
  }
37919
38630
  _this.createRenderFrame();
37920
- PluginSystem.initializeComposition(_assert_this_initialized(_this), scene);
38631
+ PluginSystem.notifyCompositionCreated(_assert_this_initialized(_this), scene);
37921
38632
  return _this;
37922
38633
  }
37923
38634
  var _proto = Composition.prototype;
@@ -38281,18 +38992,13 @@ var PreRenderTickData = /*#__PURE__*/ function(TickData) {
38281
38992
  // }
38282
38993
  };
38283
38994
  _proto.lost = function lost(e) {
38284
- this.videoState = this.textures.map(function(tex) {
38285
- if ("video" in tex.source) {
38286
- tex.source.video.pause();
38287
- return tex.source.video.currentTime;
38288
- }
38289
- });
38290
- this.textures.map(function(tex) {
38291
- return tex.dispose();
38292
- });
38293
- this.dispose();
38995
+ // GPU 资源由引擎统一 rebuild,合成仅保留纯 JS 运行时状态,此处无需处理。
38294
38996
  };
38295
38997
  /**
38998
+ * 上下文恢复后的空操作。
38999
+ * GPU 资源已由引擎统一重建,视频纹理会在下次渲染时自然更新,不自动重新播放。
39000
+ */ _proto.restore = function restore() {};
39001
+ /**
38296
39002
  * 合成对象销毁
38297
39003
  */ _proto.dispose = function dispose() {
38298
39004
  var _this = this;
@@ -38317,7 +39023,7 @@ var PreRenderTickData = /*#__PURE__*/ function(TickData) {
38317
39023
  this.root.dispose();
38318
39024
  // FIXME: 注意这里增加了renderFrame销毁
38319
39025
  this.renderFrame.dispose();
38320
- PluginSystem.destroyComposition(this);
39026
+ PluginSystem.notifyCompositionDestroy(this);
38321
39027
  this.update = function() {
38322
39028
  {
38323
39029
  logger.error("Update disposed composition: " + _this.name + ".");
@@ -40231,12 +40937,20 @@ var DEFAULT_FPS = 60;
40231
40937
  * 计时器
40232
40938
  * 手动渲染 `manualRender=true` 时不创建计时器
40233
40939
  */ _this.ticker = null;
40940
+ /**
40941
+ * 是否不处理上下文丢失恢复(构造期配置,默认 true)
40942
+ */ _this.doNotHandleContextLost = true;
40943
+ /**
40944
+ * WebGL 上下文是否处于丢失状态
40945
+ */ _this.contextWasLost = false;
40234
40946
  _this._disposed = false;
40235
40947
  _this.textures = [];
40236
40948
  _this.materials = [];
40237
40949
  _this.geometries = [];
40238
40950
  _this.meshes = [];
40239
40951
  _this.renderPasses = [];
40952
+ _this.framebuffers = [];
40953
+ _this.renderbuffers = [];
40240
40954
  _this.clearAction = {
40241
40955
  stencilAction: TextureLoadAction.clear,
40242
40956
  clearStencil: 0,
@@ -40253,6 +40967,8 @@ var DEFAULT_FPS = 60;
40253
40967
  _this.canvas = canvas;
40254
40968
  var _options_env;
40255
40969
  _this.env = (_options_env = options == null ? void 0 : options.env) != null ? _options_env : "";
40970
+ var _options_doNotHandleContextLost;
40971
+ _this.doNotHandleContextLost = (_options_doNotHandleContextLost = options == null ? void 0 : options.doNotHandleContextLost) != null ? _options_doNotHandleContextLost : true;
40256
40972
  var _options_name;
40257
40973
  _this.name = (_options_name = options == null ? void 0 : options.name) != null ? _options_name : _this.name;
40258
40974
  var _options_pixelRatio;
@@ -40278,6 +40994,7 @@ var DEFAULT_FPS = 60;
40278
40994
  // @ts-expect-error
40279
40995
  currentFrame: {}
40280
40996
  };
40997
+ PluginSystem.notifyEngineCreated(_assert_this_initialized(_this));
40281
40998
  return _this;
40282
40999
  }
40283
41000
  var _proto = Engine.prototype;
@@ -40377,6 +41094,10 @@ var DEFAULT_FPS = 60;
40377
41094
  (_this_ticker = this.ticker) == null ? void 0 : _this_ticker.add(renderFunction);
40378
41095
  };
40379
41096
  _proto.mainLoop = function mainLoop(dt) {
41097
+ // 上下文丢失/恢复期间跳过渲染,避免打到失效的 GL 上下文。
41098
+ if (this.contextWasLost) {
41099
+ return;
41100
+ }
40380
41101
  var renderErrors = this.renderErrors;
40381
41102
  if (renderErrors.size > 0) {
40382
41103
  var // 有渲染错误时暂停播放
@@ -40589,6 +41310,30 @@ var DEFAULT_FPS = 60;
40589
41310
  }
40590
41311
  removeItem(this.renderPasses, pass);
40591
41312
  };
41313
+ _proto.addFramebuffer = function addFramebuffer(framebuffer) {
41314
+ if (this.disposed) {
41315
+ return;
41316
+ }
41317
+ addItem(this.framebuffers, framebuffer);
41318
+ };
41319
+ _proto.removeFramebuffer = function removeFramebuffer(framebuffer) {
41320
+ if (this.disposed) {
41321
+ return;
41322
+ }
41323
+ removeItem(this.framebuffers, framebuffer);
41324
+ };
41325
+ _proto.addRenderbuffer = function addRenderbuffer(renderbuffer) {
41326
+ if (this.disposed) {
41327
+ return;
41328
+ }
41329
+ addItem(this.renderbuffers, renderbuffer);
41330
+ };
41331
+ _proto.removeRenderbuffer = function removeRenderbuffer(renderbuffer) {
41332
+ if (this.disposed) {
41333
+ return;
41334
+ }
41335
+ removeItem(this.renderbuffers, renderbuffer);
41336
+ };
40592
41337
  _proto.addComposition = function addComposition(composition) {
40593
41338
  if (this.disposed) {
40594
41339
  return;
@@ -40698,6 +41443,7 @@ var DEFAULT_FPS = 60;
40698
41443
  return;
40699
41444
  }
40700
41445
  this._disposed = true;
41446
+ PluginSystem.notifyEngineDestroy(this);
40701
41447
  var info = [];
40702
41448
  if (this.renderPasses.length > 0) {
40703
41449
  info.push("Pass " + this.renderPasses.length);
@@ -40873,8 +41619,8 @@ var PassTextureCache = /*#__PURE__*/ function() {
40873
41619
  case 1:
40874
41620
  loadedScene = _state.sent();
40875
41621
  engine.clearResources();
40876
- // 触发插件系统 pluginSystem 的回调 onAssetsLoadFinish
40877
- PluginSystem.onAssetsLoadFinish(loadedScene, assetManager.options, engine);
41622
+ // 通过 PluginSystem.notifyAssetsLoadFinish 通知所有插件的 onAssetsLoadFinish 回调
41623
+ PluginSystem.notifyAssetsLoadFinish(loadedScene, assetManager.options, engine);
40878
41624
  engine.assetService.prepareAssets(loadedScene, loadedScene.assets);
40879
41625
  engine.assetService.updateTextVariables(loadedScene, options.variables);
40880
41626
  composition = _this.createComposition(loadedScene, engine, options);
@@ -40935,8 +41681,8 @@ var PrecompositionManager = /*#__PURE__*/ function() {
40935
41681
  var options = precomposition.options;
40936
41682
  var engine = composition.engine;
40937
41683
  engine.clearResources();
40938
- // 触发插件系统 pluginSystem 的回调 onAssetsLoadFinish
40939
- PluginSystem.onAssetsLoadFinish(scene, options, engine);
41684
+ // 通过 PluginSystem.notifyAssetsLoadFinish 通知所有插件的 onAssetsLoadFinish 回调
41685
+ PluginSystem.notifyAssetsLoadFinish(scene, options, engine);
40940
41686
  engine.assetService.prepareAssets(scene, scene.assets);
40941
41687
  engine.assetService.updateTextVariables(scene, options.variables);
40942
41688
  composition.createTexturesFromData(scene.textureOptions);
@@ -40976,7 +41722,7 @@ registerPlugin("text", TextLoader);
40976
41722
  registerPlugin("sprite", SpriteLoader);
40977
41723
  registerPlugin("particle", ParticleLoader);
40978
41724
  registerPlugin("interact", InteractLoader);
40979
- var version$1 = "2.10.0-alpha.0";
41725
+ var version$1 = "2.10.0-alpha.1";
40980
41726
  logger.info("Core version: " + version$1 + ".");
40981
41727
 
40982
41728
  var _obj;
@@ -42260,8 +43006,8 @@ var ThreeRenderer = /*#__PURE__*/ function(Renderer) {
42260
43006
  _$scene = _state.sent();
42261
43007
  engine = _this.engine;
42262
43008
  engine.clearResources();
42263
- // 触发插件系统 pluginSystem 的回调 onAssetsLoadFinish
42264
- PluginSystem.onAssetsLoadFinish(_$scene, assetManager.options, engine);
43009
+ // 通过 PluginSystem.notifyAssetsLoadFinish 通知所有插件的 onAssetsLoadFinish 回调
43010
+ PluginSystem.notifyAssetsLoadFinish(_$scene, assetManager.options, engine);
42265
43011
  _this.assetService.prepareAssets(_$scene, assetManager.getAssets());
42266
43012
  _this.assetService.updateTextVariables(_$scene, assetManager.options.variables);
42267
43013
  composition = _this.createComposition(_$scene, opts);
@@ -42556,8 +43302,8 @@ applyMixins(ThreeTextComponent, [
42556
43302
  */ Mesh.create = function(engine, props) {
42557
43303
  return new ThreeMesh(engine, props);
42558
43304
  };
42559
- var version = "2.10.0-alpha.0";
43305
+ var version = "2.10.0-alpha.1";
42560
43306
  logger.info("THREEJS plugin version: " + version + ".");
42561
43307
 
42562
- export { ATLAS_SIZE, ActivationMixerPlayable, ActivationPlayable, ActivationPlayableAsset, ActivationTrack, AndNode, AndNodeData, Animatable, AnimationClip, AnimationClipNode, AnimationClipNodeData, AnimationEvent, AnimationGraphAsset, Animator, ApplyAdditiveNode, ApplyAdditiveNodeData, Asset, AssetLoader, AssetManager, AssetService, BYTES_TYPE_MAP, Behaviour, BezierCurve, BezierCurvePath, BezierCurveQuat, BezierDataMap, BezierEasing, BezierLengthData, BezierMap, BezierPath, BezierQuat, BinaryAsset, BlendNode, BlendNodeData, BoolValueNode, BoundingBoxInfo, CONSTANT_MAP_BLEND, CONSTANT_MAP_DEPTH, CONSTANT_MAP_STENCIL_FUNC, CONSTANT_MAP_STENCIL_OP, COPY_FRAGMENT_SHADER, COPY_MESH_SHADER_ID, COPY_VERTEX_SHADER, Camera, CameraController, CameraVFXItemLoader, CanvasItem, CanvasLayer, Circle$1 as Circle, ColorCurve, ColorPlayable, ColorPropertyMixerPlayable, ColorPropertyPlayableAsset, ColorPropertyTrack, Component, ComponentTimePlayable, ComponentTimePlayableAsset, ComponentTimeTrack, Composition, CompositionComponent, CompressTextureCapabilityType, ConstBoolNode, ConstBoolNodeData, ConstFloatNode, ConstFloatNodeData, ConstraintTarget, Control, ControlParameterBoolNode, ControlParameterBoolNodeData, ControlParameterFloatNode, ControlParameterFloatNodeData, ControlParameterTriggerNode, ControlParameterTriggerNodeData, DEFAULT_FONTS, DEFAULT_FPS, Database, Deferred, DestroyOptions, Downloader, DrawObjectPass, EFFECTS_COPY_MESH_NAME, EVENT_TYPE_CLICK, EVENT_TYPE_TOUCH_END, EVENT_TYPE_TOUCH_MOVE, EVENT_TYPE_TOUCH_START, EffectComponent, EffectComponentTimeTrack, EffectsObject, EffectsPackage, Ellipse, Engine, EqualNodeData, EventEmitter, EventSystem, FONT_SCALE, Fake3DAnimationMode, Fake3DComponent, FilterMode, Float16ArrayWrapper, FloatComparisonNode, FloatComparisonNodeData, FloatPropertyMixerPlayable, FloatPropertyPlayableAsset, FloatPropertyTrack, FloatValueNode, FrameComponent, Framebuffer, GLSLVersion, GPUCapability, Geometry, GlobalUniforms, GlyphAtlas, GradientValue, GraphInstance, GraphNode, GraphNodeData, Graphics, GreaterNodeData, HELP_LINK, HitTestType, InteractComponent, InteractLoader, InteractMesh, InvalidIndex, Item, LayerBlendNode, LayerBlendNodeData, LessNodeData, LineSegments, LinearValue, MaskMode, MaskProcessor, MaskableGraphic, Material, MaterialDataBlock, MaterialRenderType, MaterialState, MaterialTrack, Mesh, NodeTransform, NotNode, NotNodeData, NotifyEvent, ObjectBindingTrack, OrNode, OrNodeData, OrderType, PLAYER_OPTIONS_ENV_EDITOR, POST_PROCESS_SETTINGS, ParticleBehaviourPlayable, ParticleBehaviourPlayableAsset, ParticleLoader, ParticleMesh, ParticleMixerPlayable, ParticleSystem, ParticleSystemRenderer, ParticleTrack, PassTextureCache, PathSegments, PlayState, Playable, PlayableAsset, PlayableOutput, Plugin, PluginSystem, PointerEventData, PointerEventType, PolyStar, Polygon, Pose, PoseNode, PositionConstraint, PostProcessVolume, Precomposition, PrecompositionManager, PropertyClipPlayable, PropertyTrack, RENDER_PREFER_LOOKUP_TEXTURE, RUNTIME_ENV, RandomSetValue, RandomValue, RandomVectorValue, RaycastResult, RectTransform, Rectangle$1 as Rectangle, RenderFrame, RenderPass, RenderPassAttachmentStorageType, RenderPassDestroyAttachmentType, RenderPassPriorityNormal, RenderPassPriorityPostprocess, RenderPassPriorityPrepare, RenderTargetHandle, RenderTargetPool, RenderTextureFormat, Renderbuffer, Renderer, RendererComponent, RuntimeClip, SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_0, SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_SIZE_0, SEMANTIC_PRE_COLOR_ATTACHMENT_0, SEMANTIC_PRE_COLOR_ATTACHMENT_SIZE_0, SPRITE_VERTEX_STRIDE, Scene, SceneLoader, SerializationHelper, Shader, ShaderCompileResultStatus, ShaderFactory, ShaderType, ShaderVariant, ShapeComponent, SourceType, SpriteColorMixerPlayable, SpriteColorPlayableAsset, SpriteColorTrack, SpriteComponent, SpriteComponentTimeTrack, SpriteLoader, StarType, StateMachineNode, StateMachineNodeData, StateNode, StateNodeData, StaticValue, SubCompositionClipPlayable, SubCompositionMixerPlayable, SubCompositionPlayableAsset, SubCompositionTrack, TEMPLATE_USE_OFFSCREEN_CANVAS, TEXTURE_UNIFORM_MAP, TangentMode, TextCache, TextComponent, TextComponentBase, TextLayout, TextLoader, TextStyle, Texture, TextureFactory, TextureLoadAction, TexturePaintScaleMode, TextureSourceType, TextureStoreAction, ThreeComposition, ThreeDisplayObject, ThreeEngine, ThreeMaterial, ThreeSpriteComponent, ThreeTextComponent, ThreeTexture, Ticker, TimelineAsset, TimelineClip, TimelineInstance, TrackAsset, TrackMixerPlayable, TrackType, Transform, TransformMixerPlayable, TransformPlayable, TransformPlayableAsset, TransformTrack, TransitionNode, TransitionNodeData, TransitionState, Triangle, TrimPath, TrimPathMode, UpdateModes, VFXItem, ValueGetter, ValueNode, Vector2Curve, Vector2PropertyMixerPlayable, Vector2PropertyPlayableAsset, Vector2PropertyTrack, Vector3Curve, Vector3PropertyMixerPlayable, Vector3PropertyTrack, Vector3ropertyPlayableAsset, Vector4Curve, Vector4PropertyMixerPlayable, Vector4PropertyPlayableAsset, Vector4PropertyTrack, WeightedMode, addByOrder, addItem, addItemWithOrder, applyMixins, assertExist, asserts, base64ToFile, buildBezierData, buildEasingCurve, buildLine, calculateTranslation, canUseBOM, canvasPool, closePointEps, colorGradingFrag, colorStopsFromGradient, colorToArr$1 as colorToArr, combineImageTemplate, createGLContext, createKeyFrameMeta, createShape, createValueGetter, curveEps, decimalEqual, deserializeMipmapTexture, earcut, effectsClass, effectsClassStore, enlargeBuffer, ensureFixedNumber, ensureVec3, extractMinAndMax, gaussianDownHFrag, gaussianDownVFrag, gaussianUpFrag, generateEmptyTexture, generateEmptyTypedArray, generateGUID, generateHalfFloatTexture, generateWhiteTexture, getBackgroundImage, getClass, getColorFromGradientStops, getConfig, getControlPoints, getDefaultTextureFactory, getGeometryByShape, getGeometryTriangles, getKeyFrameMetaByRawValue, getMergedStore, getNodeDataClass, getParticleMeshShader, getPixelRatio, getPluginUsageInfo, getPreMultiAlpha, getStandardComposition, getStandardImage, getStandardItem, getStandardJSON, getTextureSize, glContext, glType2VertexFormatType, gpuTimer, imageDataFromColor, imageDataFromGradient, initErrors, initGLContext, integrate, interpolateColor, isAlipayMiniApp, isAndroid, isArray, isCanvas, isFunction, isIOS, isIOSByUA, isMiniProgram, isObject, isOpenHarmony, isPlainObject, isPowerOfTwo, isSafeFontFamily, isSimulatorCellPhone, isString, isUniformStruct, isUniformStructArray, isValidFontFamily, isWebGL2, isWechatMiniApp, itemFrag, itemVert, loadAVIFOptional, loadBinary, loadBlob, loadImage, loadMedia, loadVideo, loadWebPOptional, logger, index as math, modifyMaxKeyframeShader, nearestPowerOfTwo, nodeDataClass, noop, normalizeColor, numberToFix, oldBezierKeyFramesToNew, parsePercent$1 as parsePercent, particleFrag, particleOriginTranslateMap$1 as particleOriginTranslateMap, particleUniformTypeMap, particleVert, passRenderLevel, pluginLoaderMap, randomInRange, registerPlugin, removeItem, rotateVec2, screenMeshVert, serialize, setBlendMode, setConfig, setDefaultTextureFactory, setMaskMode, setRayFromCamera, setSideMode, setUniformValue, sortByOrder, index$1 as spec, textureLoaderRegistry, thresholdFrag, throwDestroyedError, trailVert, translatePoint, trianglesFromRect, unregisterPlugin, valIfUndefined, value, valueDefine, vecFill, vecMulCombine, version, vertexFormatType2GLType };
43308
+ export { ATLAS_SIZE, ActivationMixerPlayable, ActivationPlayable, ActivationPlayableAsset, ActivationTrack, AndNode, AndNodeData, Animatable, AnimationClip, AnimationClipNode, AnimationClipNodeData, AnimationEvent, AnimationGraphAsset, Animator, ApplyAdditiveNode, ApplyAdditiveNodeData, Asset, AssetLoader, AssetManager, AssetService, BYTES_TYPE_MAP, Behaviour, BezierCurve, BezierCurvePath, BezierCurveQuat, BezierDataMap, BezierEasing, BezierLengthData, BezierMap, BezierPath, BezierQuat, BinaryAsset, BlendNode, BlendNodeData, BoolValueNode, BoundingBoxInfo, CONSTANT_MAP_BLEND, CONSTANT_MAP_DEPTH, CONSTANT_MAP_STENCIL_FUNC, CONSTANT_MAP_STENCIL_OP, COPY_FRAGMENT_SHADER, COPY_MESH_SHADER_ID, COPY_VERTEX_SHADER, Camera, CameraController, CameraVFXItemLoader, CanvasItem, CanvasLayer, Circle$1 as Circle, ColorCurve, ColorPlayable, ColorPropertyMixerPlayable, ColorPropertyPlayableAsset, ColorPropertyTrack, Component, ComponentTimePlayable, ComponentTimePlayableAsset, ComponentTimeTrack, Composition, CompositionComponent, CompressTextureCapabilityType, ConstBoolNode, ConstBoolNodeData, ConstFloatNode, ConstFloatNodeData, ConstraintTarget, Control, ControlParameterBoolNode, ControlParameterBoolNodeData, ControlParameterFloatNode, ControlParameterFloatNodeData, ControlParameterTriggerNode, ControlParameterTriggerNodeData, DEFAULT_FONTS, DEFAULT_FPS, Database, Deferred, DestroyOptions, Downloader, DrawObjectPass, EFFECTS_COPY_MESH_NAME, EVENT_TYPE_CLICK, EVENT_TYPE_TOUCH_END, EVENT_TYPE_TOUCH_MOVE, EVENT_TYPE_TOUCH_START, EffectComponent, EffectComponentTimeTrack, EffectsObject, EffectsPackage, Ellipse, Engine, EqualNodeData, EventEmitter, EventSystem, FONT_SCALE, Fake3DAnimationMode, Fake3DComponent, FilterMode, Float16ArrayWrapper, FloatComparisonNode, FloatComparisonNodeData, FloatPropertyMixerPlayable, FloatPropertyPlayableAsset, FloatPropertyTrack, FloatValueNode, FrameComponent, Framebuffer, GLSLVersion, GPUCapability, Geometry, GlobalUniforms, GlyphAtlas, GradientValue, GraphInstance, GraphNode, GraphNodeData, Graphics, GreaterNodeData, HELP_LINK, HitTestType, InteractComponent, InteractLoader, InteractMesh, InvalidIndex, Item, LayerBlendNode, LayerBlendNodeData, LessNodeData, LineSegments, LinearValue, MaskMode, MaskProcessor, MaskableGraphic, Material, MaterialDataBlock, MaterialRenderType, MaterialState, MaterialTrack, Mesh, NodeTransform, NotNode, NotNodeData, NotifyEvent, ObjectBindingTrack, OrNode, OrNodeData, OrderType, PLAYER_OPTIONS_ENV_EDITOR, POST_PROCESS_SETTINGS, ParticleBehaviourPlayable, ParticleBehaviourPlayableAsset, ParticleLoader, ParticleMesh, ParticleMixerPlayable, ParticleSystem, ParticleSystemRenderer, ParticleTrack, PassTextureCache, PathSegments, PlayState, Playable, PlayableAsset, PlayableOutput, Plugin, PluginSystem, PointerEventData, PointerEventType, PolyStar, Polygon, Pose, PoseNode, PositionConstraint, PostProcessVolume, Precomposition, PrecompositionManager, PropertyClipPlayable, PropertyTrack, REFERENCE_CURVE, RENDER_PREFER_LOOKUP_TEXTURE, RUNTIME_ENV, RandomSetValue, RandomValue, RandomVectorValue, RaycastResult, RectTransform, Rectangle$1 as Rectangle, ReferenceCurve, RenderFrame, RenderPass, RenderPassAttachmentStorageType, RenderPassDestroyAttachmentType, RenderPassPriorityNormal, RenderPassPriorityPostprocess, RenderPassPriorityPrepare, RenderTargetHandle, RenderTargetPool, RenderTextureFormat, Renderbuffer, Renderer, RendererComponent, RuntimeClip, SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_0, SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_SIZE_0, SEMANTIC_PRE_COLOR_ATTACHMENT_0, SEMANTIC_PRE_COLOR_ATTACHMENT_SIZE_0, SPRITE_VERTEX_STRIDE, Scene, SceneLoader, SerializationHelper, Shader, ShaderCompileResultStatus, ShaderFactory, ShaderType, ShaderVariant, ShapeComponent, SourceType, Sprite, SpriteColorMixerPlayable, SpriteColorPlayableAsset, SpriteColorTrack, SpriteComponent, SpriteComponentTimeTrack, SpriteLoader, SpritePropertyMixerPlayable, SpritePropertyPlayableAsset, SpritePropertyTrack, SpriteRotation, StarType, StateMachineNode, StateMachineNodeData, StateNode, StateNodeData, StaticValue, SubCompositionClipPlayable, SubCompositionMixerPlayable, SubCompositionPlayableAsset, SubCompositionTrack, TEMPLATE_USE_OFFSCREEN_CANVAS, TEXTURE_UNIFORM_MAP, TangentMode, TextCache, TextComponent, TextComponentBase, TextLayout, TextLoader, TextStyle, Texture, TextureFactory, TextureLoadAction, TexturePaintScaleMode, TextureSourceType, TextureStoreAction, ThreeComposition, ThreeDisplayObject, ThreeEngine, ThreeMaterial, ThreeSpriteComponent, ThreeTextComponent, ThreeTexture, Ticker, TimelineAsset, TimelineClip, TimelineInstance, TrackAsset, TrackMixerPlayable, TrackType, Transform, TransformMixerPlayable, TransformPlayable, TransformPlayableAsset, TransformTrack, TransitionNode, TransitionNodeData, TransitionState, Triangle, TrimPath, TrimPathMode, UpdateModes, VFXItem, ValueGetter, ValueNode, Vector2Curve, Vector2PropertyMixerPlayable, Vector2PropertyPlayableAsset, Vector2PropertyTrack, Vector3Curve, Vector3PropertyMixerPlayable, Vector3PropertyTrack, Vector3ropertyPlayableAsset, Vector4Curve, Vector4PropertyMixerPlayable, Vector4PropertyPlayableAsset, Vector4PropertyTrack, WeightedMode, addByOrder, addItem, addItemWithOrder, applyMixins, assertExist, asserts, base64ToFile, breakOpportunityAfter, buildBezierData, buildEasingCurve, buildLine, calculateTranslation, canUseBOM, canvasPool, closePointEps, colorGradingFrag, colorStopsFromGradient, colorToArr$1 as colorToArr, combineImageTemplate, createGLContext, createKeyFrameMeta, createShape, createValueGetter, curveEps, decimalEqual, deserializeMipmapTexture, earcut, effectsClass, effectsClassStore, enlargeBuffer, ensureFixedNumber, ensureVec3, extractMinAndMax, gaussianDownHFrag, gaussianDownVFrag, gaussianUpFrag, generateEmptyTexture, generateEmptyTypedArray, generateGUID, generateHalfFloatTexture, generateWhiteTexture, getBackgroundImage, getClass, getColorFromGradientStops, getConfig, getControlPoints, getDefaultTextureFactory, getGeometryByShape, getGeometryTriangles, getKeyFrameMetaByRawValue, getMergedStore, getNodeDataClass, getParticleMeshShader, getPixelRatio, getPluginUsageInfo, getPreMultiAlpha, getStandardComposition, getStandardImage, getStandardItem, getStandardJSON, getTextureSize, glContext, glType2VertexFormatType, gpuTimer, imageDataFromColor, imageDataFromGradient, initErrors, initGLContext, integrate, interpolateColor, isAlipayMiniApp, isAndroid, isArray, isBreakChar, isCJKLike, isCanvas, isFunction, isIOS, isIOSByUA, isMiniProgram, isObject, isOpenHarmony, isPlainObject, isPowerOfTwo, isSafeFontFamily, isSimulatorCellPhone, isString, isUniformStruct, isUniformStructArray, isValidFontFamily, isWebGL2, isWechatMiniApp, itemFrag, itemVert, loadAVIFOptional, loadBinary, loadBlob, loadImage, loadMedia, loadVideo, loadWebPOptional, logger, index as math, modifyMaxKeyframeShader, nearestPowerOfTwo, nodeDataClass, noop, normalizeColor, numberToFix, oldBezierKeyFramesToNew, parsePercent$1 as parsePercent, particleFrag, particleOriginTranslateMap$1 as particleOriginTranslateMap, particleUniformTypeMap, particleVert, passRenderLevel, pluginLoaderMap, randomInRange, registerPlugin, removeItem, rotateVec2, screenMeshVert, serialize, setBlendMode, setConfig, setDefaultTextureFactory, setMaskMode, setRayFromCamera, setSideMode, setUniformValue, sortByOrder, index$1 as spec, textureLoaderRegistry, thresholdFrag, throwDestroyedError, trailVert, translatePoint, trianglesFromRect, unregisterPlugin, valIfUndefined, value, valueDefine, vecFill, vecMulCombine, version, vertexFormatType2GLType };
42563
43309
  //# sourceMappingURL=index.mjs.map