@galacean/effects-core 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.
Files changed (36) hide show
  1. package/dist/components/base-render-component.d.ts +4 -0
  2. package/dist/composition.d.ts +5 -0
  3. package/dist/engine.d.ts +23 -0
  4. package/dist/fallback/migration.d.ts +13 -0
  5. package/dist/index.js +1112 -360
  6. package/dist/index.js.map +1 -1
  7. package/dist/index.mjs +1107 -361
  8. package/dist/index.mjs.map +1 -1
  9. package/dist/material/types.d.ts +4 -0
  10. package/dist/material/utils.d.ts +4 -0
  11. package/dist/math/value-getters/index.d.ts +1 -0
  12. package/dist/math/value-getters/reference-curve.d.ts +19 -0
  13. package/dist/math/value-getters/value-getter-map.d.ts +5 -0
  14. package/dist/plugin-system.d.ts +6 -4
  15. package/dist/plugins/index.d.ts +1 -0
  16. package/dist/plugins/particle/particle-mesh.d.ts +0 -2
  17. package/dist/plugins/particle/trail-mesh.d.ts +0 -2
  18. package/dist/plugins/plugin.d.ts +14 -0
  19. package/dist/plugins/sprite/sprite-item.d.ts +31 -5
  20. package/dist/plugins/sprite/sprite.d.ts +42 -0
  21. package/dist/plugins/text/index.d.ts +1 -0
  22. package/dist/plugins/text/line-break.d.ts +29 -0
  23. package/dist/plugins/timeline/playable-assets/index.d.ts +1 -0
  24. package/dist/plugins/timeline/playable-assets/sprite-property-playable-asset.d.ts +23 -0
  25. package/dist/plugins/timeline/playables/index.d.ts +1 -0
  26. package/dist/plugins/timeline/playables/sprite-property-mixer-playable.d.ts +11 -0
  27. package/dist/plugins/timeline/playables/transform-mixer-playable.d.ts +6 -0
  28. package/dist/plugins/timeline/playables/transform-playable.d.ts +17 -2
  29. package/dist/plugins/timeline/tracks/index.d.ts +1 -0
  30. package/dist/plugins/timeline/tracks/sprite-property-track.d.ts +11 -0
  31. package/dist/plugins/timeline/transform-clip-mixer.d.ts +33 -0
  32. package/dist/render/graphics.d.ts +2 -2
  33. package/dist/render/text-cache.d.ts +22 -14
  34. package/dist/scene.d.ts +7 -4
  35. package/dist/utils/index.d.ts +1 -1
  36. package/package.json +2 -2
package/dist/index.mjs CHANGED
@@ -3,7 +3,7 @@
3
3
  * Description: Galacean Effects runtime core for the web
4
4
  * Author: Ant Group CO., Ltd.
5
5
  * Contributors: 燃然,飂兮,十弦,云垣,茂安,意绮
6
- * Version: v2.10.0-alpha.0
6
+ * Version: v2.10.0-alpha.1
7
7
  */
8
8
 
9
9
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
@@ -695,6 +695,26 @@ function clamp$1(value, min, max) {
695
695
  array[offset] = this.x;
696
696
  array[offset + 1] = this.y;
697
697
  };
698
+ /**
699
+ * 计算向量相对于正 x 轴的角度(弧度)
700
+ * @returns 弧度值
701
+ */ _proto.angle = function angle() {
702
+ var angle = Math.atan2(-this.y, -this.x) + Math.PI;
703
+ return angle;
704
+ };
705
+ /**
706
+ * 绕指定中心点旋转向量
707
+ * @param center - 旋转中心
708
+ * @param angle - 旋转角度(弧度)
709
+ * @returns 旋转结果
710
+ */ _proto.rotateAround = function rotateAround(center, angle) {
711
+ var c = Math.cos(angle), s = Math.sin(angle);
712
+ var x = this.x - center.x;
713
+ var y = this.y - center.y;
714
+ this.x = x * c - y * s + center.x;
715
+ this.y = x * s + y * c + center.y;
716
+ return this;
717
+ };
698
718
  /**
699
719
  * 随机生成向量
700
720
  * @returns 向量
@@ -1248,6 +1268,25 @@ Vector2.ZERO = new Vector2(0.0, 0.0);
1248
1268
  */ _proto.applyProjectionMatrix = function applyProjectionMatrix(m, out) {
1249
1269
  return m.projectPoint(this, out);
1250
1270
  };
1271
+ /**
1272
+ * 从四维矩阵提取平移分量
1273
+ * @param m - 四维矩阵
1274
+ * @returns 向量
1275
+ */ _proto.setFromMatrixPosition = function setFromMatrixPosition(m) {
1276
+ var e = m.elements;
1277
+ this.x = e[12];
1278
+ this.y = e[13];
1279
+ this.z = e[14];
1280
+ return this;
1281
+ };
1282
+ /**
1283
+ * 从四维矩阵提取指定列的三维分量
1284
+ * @param m - 四维矩阵
1285
+ * @param index - 列下标
1286
+ * @returns 向量
1287
+ */ _proto.setFromMatrixColumn = function setFromMatrixColumn(m, index) {
1288
+ return this.setFromArray(m.elements, index * 4);
1289
+ };
1251
1290
  /**
1252
1291
  * 通过标量数值创建向量
1253
1292
  * @param num - 数值
@@ -2888,17 +2927,27 @@ var PluginSystem = /*#__PURE__*/ function() {
2888
2927
  PluginSystem.getPlugins = function getPlugins() {
2889
2928
  return plugins;
2890
2929
  };
2891
- PluginSystem.initializeComposition = function initializeComposition(composition, scene) {
2892
- plugins.forEach(function(loader) {
2893
- return loader.onCompositionCreated(composition, scene);
2930
+ PluginSystem.notifyCompositionCreated = function notifyCompositionCreated(composition, scene) {
2931
+ plugins.forEach(function(plugin) {
2932
+ return plugin.onCompositionCreated(composition, scene);
2933
+ });
2934
+ };
2935
+ PluginSystem.notifyCompositionDestroy = function notifyCompositionDestroy(composition) {
2936
+ plugins.forEach(function(plugin) {
2937
+ return plugin.onCompositionDestroy(composition);
2938
+ });
2939
+ };
2940
+ PluginSystem.notifyEngineCreated = function notifyEngineCreated(engine) {
2941
+ plugins.forEach(function(plugin) {
2942
+ return plugin.onEngineCreated(engine);
2894
2943
  });
2895
2944
  };
2896
- PluginSystem.destroyComposition = function destroyComposition(comp) {
2897
- plugins.forEach(function(loader) {
2898
- return loader.onCompositionDestroy(comp);
2945
+ PluginSystem.notifyEngineDestroy = function notifyEngineDestroy(engine) {
2946
+ plugins.forEach(function(plugin) {
2947
+ return plugin.onEngineDestroy(engine);
2899
2948
  });
2900
2949
  };
2901
- PluginSystem.onAssetsLoadStart = function onAssetsLoadStart(scene, options) {
2950
+ PluginSystem.notifyAssetsLoadStart = function notifyAssetsLoadStart(scene, options) {
2902
2951
  return _async_to_generator(function() {
2903
2952
  return __generator(this, function(_state) {
2904
2953
  return [
@@ -2910,9 +2959,9 @@ var PluginSystem = /*#__PURE__*/ function() {
2910
2959
  });
2911
2960
  })();
2912
2961
  };
2913
- PluginSystem.onAssetsLoadFinish = function onAssetsLoadFinish(scene, options, engine) {
2914
- plugins.forEach(function(loader) {
2915
- return loader.onAssetsLoadFinish(scene, options, engine);
2962
+ PluginSystem.notifyAssetsLoadFinish = function notifyAssetsLoadFinish(scene, options, engine) {
2963
+ plugins.forEach(function(plugin) {
2964
+ return plugin.onAssetsLoadFinish(scene, options, engine);
2916
2965
  });
2917
2966
  };
2918
2967
  return PluginSystem;
@@ -2978,6 +3027,18 @@ function getPluginUsageInfo(name) {
2978
3027
  * 合成销毁时触发。
2979
3028
  * @param composition - 合成对象
2980
3029
  */ _proto.onCompositionDestroy = function onCompositionDestroy(composition) {};
3030
+ /**
3031
+ * 引擎创建完成后触发。
3032
+ * 适用于注册引擎级单例、建立以引擎为键的映射、绑定全局监听等场景。
3033
+ * @param engine - 引擎实例
3034
+ * @since 2.10.0
3035
+ */ _proto.onEngineCreated = function onEngineCreated(engine) {};
3036
+ /**
3037
+ * 引擎销毁时触发。
3038
+ * 适合解绑监听、释放引擎级资源或清理以引擎为键的映射。
3039
+ * @param engine - 引擎实例
3040
+ * @since 2.10.0
3041
+ */ _proto.onEngineDestroy = function onEngineDestroy(engine) {};
2981
3042
  return Plugin;
2982
3043
  }();
2983
3044
 
@@ -4965,7 +5026,7 @@ var Animatable = /*#__PURE__*/ function() {
4965
5026
  * @param qb - 四元数
4966
5027
  * @param t - 插值比
4967
5028
  */ _proto.slerpQuaternions = function slerpQuaternions(qa, qb, t) {
4968
- this.copyFrom(qa).slerp(qb, t);
5029
+ return this.copyFrom(qa).slerp(qb, t);
4969
5030
  };
4970
5031
  /**
4971
5032
  * 通过四元数旋转向量
@@ -7523,7 +7584,10 @@ function setSideMode(material, side) {
7523
7584
  material.cullFace = side === SideMode.BACK ? glContext.BACK : glContext.FRONT;
7524
7585
  }
7525
7586
  }
7526
- function setMaskMode(material, maskMode) {
7587
+ /**
7588
+ * @deprecated 2.10 起 runtime 内部已不再通过 `MaskMode` 设置模板测试参数。
7589
+ * 仅为兼容旧版本对外导出的接口而保留,新代码请勿使用。
7590
+ */ function setMaskMode(material, maskMode) {
7527
7591
  switch(maskMode){
7528
7592
  case undefined:
7529
7593
  material.stencilTest = false;
@@ -9408,6 +9472,13 @@ function isUniformStructArray(value) {
9408
9472
  translation.x = te[12];
9409
9473
  translation.y = te[13];
9410
9474
  translation.z = te[14];
9475
+ scale.x = sx;
9476
+ scale.y = sy;
9477
+ scale.z = sz;
9478
+ if (Math.abs(sx) < 1e-8 || Math.abs(sy) < 1e-8 || Math.abs(sz) < 1e-8) {
9479
+ rotation.set(0, 0, 0, 1);
9480
+ return this;
9481
+ }
9411
9482
  // scale the rotation part
9412
9483
  var m = Matrix4.tempMat0;
9413
9484
  m.copyFrom(this);
@@ -9424,9 +9495,6 @@ function isUniformStructArray(value) {
9424
9495
  m.elements[9] *= invSZ;
9425
9496
  m.elements[10] *= invSZ;
9426
9497
  rotation.setFromRotationMatrix(m);
9427
- scale.x = sx;
9428
- scale.y = sy;
9429
- scale.z = sz;
9430
9498
  return this;
9431
9499
  };
9432
9500
  _proto.getTranslation = function getTranslation(translation) {
@@ -9437,6 +9505,45 @@ function isUniformStructArray(value) {
9437
9505
  var te = this.elements;
9438
9506
  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]));
9439
9507
  };
9508
+ /**
9509
+ * 提取矩阵的旋转部分(去除缩放)
9510
+ * @param m - 源矩阵
9511
+ * @returns 矩阵
9512
+ */ _proto.extractRotation = function extractRotation(m) {
9513
+ var v = Matrix4.tempVec0;
9514
+ var me = m.elements;
9515
+ var te = this.elements;
9516
+ var scaleX = 1 / v.set(me[0], me[1], me[2]).length();
9517
+ var scaleY = 1 / v.set(me[4], me[5], me[6]).length();
9518
+ var scaleZ = 1 / v.set(me[8], me[9], me[10]).length();
9519
+ te[0] = me[0] * scaleX;
9520
+ te[1] = me[1] * scaleX;
9521
+ te[2] = me[2] * scaleX;
9522
+ te[3] = 0;
9523
+ te[4] = me[4] * scaleY;
9524
+ te[5] = me[5] * scaleY;
9525
+ te[6] = me[6] * scaleY;
9526
+ te[7] = 0;
9527
+ te[8] = me[8] * scaleZ;
9528
+ te[9] = me[9] * scaleZ;
9529
+ te[10] = me[10] * scaleZ;
9530
+ te[11] = 0;
9531
+ te[12] = 0;
9532
+ te[13] = 0;
9533
+ te[14] = 0;
9534
+ te[15] = 1;
9535
+ return this;
9536
+ };
9537
+ /**
9538
+ * 设置矩阵的平移部分(不影响旋转和缩放)
9539
+ * @param v - 平移向量
9540
+ * @returns 矩阵
9541
+ */ _proto.setPosition = function setPosition(v) {
9542
+ this.elements[12] = v.x;
9543
+ this.elements[13] = v.y;
9544
+ this.elements[14] = v.z;
9545
+ return this;
9546
+ };
9440
9547
  /**
9441
9548
  * 获得矩阵分解的结果
9442
9549
  * @returns 分解的结果
@@ -10730,6 +10837,23 @@ Euler.tempMat0 = new Matrix4();
10730
10837
  */ _proto.equals = function equals(other) {
10731
10838
  return this.origin.equals(other.origin) && this.direction.equals(other.direction);
10732
10839
  };
10840
+ /**
10841
+ * 光线到平面的距离
10842
+ * @param plane - 平面
10843
+ * @returns 距离值,平行且不在平面上时返回 null,平行且在平面上时返回 0
10844
+ */ _proto.distanceToPlane = function distanceToPlane(plane) {
10845
+ var normal = plane.normal;
10846
+ var denominator = normal.dot(this.direction);
10847
+ if (denominator === 0) {
10848
+ // 光线与平面平行
10849
+ if (normal.dot(this.origin) + plane.distance === 0) {
10850
+ return 0;
10851
+ }
10852
+ return null;
10853
+ }
10854
+ var t = -(this.origin.dot(normal) + plane.distance) / denominator;
10855
+ return t >= 0 ? t : null;
10856
+ };
10733
10857
  /**
10734
10858
  * 根据矩阵对光线进行变换
10735
10859
  * @param m - 变换矩阵
@@ -12590,65 +12714,70 @@ var MaterialRenderType;
12590
12714
  return new Material(engine, props);
12591
12715
  };
12592
12716
 
12717
+ // 8 位 stencil buffer 上限为 255;为反向蒙版的 INCR 预留 1 的递增余量,
12718
+ // 否则当正向蒙版填满到 255 时,反向 INCR 会饱和、无法排除任何像素。
12719
+ var MAX_MASK_REFERENCE_COUNT = 254;
12593
12720
  /**
12594
12721
  * @internal
12595
12722
  */ var MaskProcessor = /*#__PURE__*/ function() {
12596
12723
  function MaskProcessor() {
12597
12724
  this.alphaMaskEnabled = false;
12598
12725
  this.isMask = false;
12599
- this.inverted = false;
12600
- this.maskMode = MaskMode.NONE;
12601
12726
  /**
12602
12727
  * 多个蒙版引用列表,支持正面和反面蒙版
12603
12728
  */ this.maskReferences = [];
12604
12729
  /**
12605
12730
  * 期望的 stencil 值(等于正向蒙版的数量)
12606
12731
  */ this.expectedStencilValue = 0;
12607
- this.prevStencilFunc = [
12608
- 0,
12609
- 0
12610
- ];
12611
- this.prevStencilOpZPass = [
12612
- 0,
12613
- 0
12614
- ];
12615
- this.prevStencilRef = [
12616
- 0,
12617
- 0
12618
- ];
12619
- this.prevStencilMask = [
12620
- 0,
12621
- 0
12622
- ];
12623
12732
  this.stencilClearAction = {
12624
12733
  stencilAction: TextureLoadAction.clear
12625
12734
  };
12626
12735
  }
12627
12736
  var _proto = MaskProcessor.prototype;
12628
12737
  /**
12629
- * @deprecated
12630
- */ _proto.getRefValue = function getRefValue() {
12631
- return 1;
12632
- };
12633
- /**
12634
- * 设置蒙版选项(兼容旧版单蒙版 API)
12738
+ * 设置蒙版选项。
12739
+ *
12740
+ * @param data.references - 蒙版引用列表。
12741
+ * 传入空数组等价于无蒙版。
12742
+ * 超过 254 个引用时,多余部分将被忽略并打印警告。
12635
12743
  */ _proto.setMaskOptions = function setMaskOptions(engine, data) {
12636
- 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;
12744
+ 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;
12637
12745
  this.alphaMaskEnabled = alphaMaskEnabled;
12638
12746
  this.isMask = isMask;
12639
- this.inverted = inverted;
12640
12747
  this.maskReferences = [];
12641
- if (isMask) {
12642
- this.maskMode = MaskMode.MASK;
12643
- } else {
12644
- this.maskMode = inverted ? MaskMode.REVERSE_OBSCURED : MaskMode.OBSCURED;
12645
- var maskable = engine.findObject(reference);
12646
- if (maskable) {
12647
- this.maskReferences.push({
12648
- maskable: maskable,
12649
- inverted: inverted
12650
- });
12748
+ if (isMask || references.length === 0) {
12749
+ return;
12750
+ }
12751
+ var seen = new Map();
12752
+ for(var _iterator = _create_for_of_iterator_helper_loose(references), _step; !(_step = _iterator()).done;){
12753
+ var ref = _step.value;
12754
+ var maskPath = ref.mask;
12755
+ if (!maskPath) {
12756
+ continue;
12651
12757
  }
12758
+ var maskable = engine.findObject(maskPath);
12759
+ if (!maskable) {
12760
+ console.warn("Mask reference not found: " + JSON.stringify(maskPath) + ". Skipping.");
12761
+ continue;
12762
+ }
12763
+ var _ref_inverted;
12764
+ var inverted = (_ref_inverted = ref.inverted) != null ? _ref_inverted : false;
12765
+ var existingInverted = seen.get(maskable);
12766
+ if (existingInverted !== undefined) {
12767
+ if (existingInverted !== inverted) {
12768
+ console.warn("Same maskable referenced with conflicting inverted flags; keeping the first occurrence.");
12769
+ }
12770
+ continue;
12771
+ }
12772
+ if (this.maskReferences.length >= MAX_MASK_REFERENCE_COUNT) {
12773
+ console.warn("Maximum of " + MAX_MASK_REFERENCE_COUNT + " mask references exceeded. Additional masks will be ignored.");
12774
+ break;
12775
+ }
12776
+ seen.set(maskable, inverted);
12777
+ this.maskReferences.push({
12778
+ maskable: maskable,
12779
+ inverted: inverted
12780
+ });
12652
12781
  }
12653
12782
  };
12654
12783
  /**
@@ -12661,8 +12790,8 @@ var MaterialRenderType;
12661
12790
  return ref.maskable === maskable;
12662
12791
  });
12663
12792
  if (!exists) {
12664
- if (this.maskReferences.length >= 255) {
12665
- console.warn("Maximum of 255 mask references exceeded. Additional masks will be ignored.");
12793
+ if (this.maskReferences.length >= MAX_MASK_REFERENCE_COUNT) {
12794
+ console.warn("Maximum of " + MAX_MASK_REFERENCE_COUNT + " mask references exceeded. Additional masks will be ignored.");
12666
12795
  return;
12667
12796
  }
12668
12797
  this.maskReferences.push({
@@ -12688,6 +12817,11 @@ var MaterialRenderType;
12688
12817
  this.maskReferences = [];
12689
12818
  };
12690
12819
  /**
12820
+ * 获取当前蒙版引用列表的浅拷贝。
12821
+ */ _proto.getMaskReferences = function getMaskReferences() {
12822
+ return this.maskReferences.slice();
12823
+ };
12824
+ /**
12691
12825
  * 绘制所有蒙版,被蒙版的元素调用。
12692
12826
  *
12693
12827
  * 使用递增 stencil 计数法实现任意数量蒙版的交集:
@@ -12695,12 +12829,17 @@ var MaterialRenderType;
12695
12829
  * 2. 反向蒙版渲染,将已通过所有正向蒙版的像素标记为无效
12696
12830
  * 3. 最终只有 stencil == 正向蒙版数量 的像素才通过测试
12697
12831
  *
12698
- * 最多支持 255 个蒙版引用(受 8 位 stencil buffer 限制)
12832
+ * 最多支持 254 个蒙版引用(8 位 stencil buffer 上限 255,需为反向 INCR 预留 1)
12699
12833
  */ _proto.drawStencilMask = function drawStencilMask(renderer, maskedComponent) {
12700
12834
  var frameClipMasks = maskedComponent.frameClipMasks;
12835
+ var addedFrameClipMasks = [];
12701
12836
  for(var _iterator = _create_for_of_iterator_helper_loose(frameClipMasks), _step; !(_step = _iterator()).done;){
12702
12837
  var frameClipMask = _step.value;
12838
+ var referenceCount = this.maskReferences.length;
12703
12839
  this.addMaskReference(frameClipMask, false);
12840
+ if (this.maskReferences.length > referenceCount) {
12841
+ addedFrameClipMasks.push(frameClipMask);
12842
+ }
12704
12843
  }
12705
12844
  if (this.maskReferences.length > 0) {
12706
12845
  renderer.clear(this.stencilClearAction);
@@ -12736,7 +12875,7 @@ var MaterialRenderType;
12736
12875
  var material = _step3.value;
12737
12876
  this.setupMaskedMaterial(material);
12738
12877
  }
12739
- for(var _iterator4 = _create_for_of_iterator_helper_loose(frameClipMasks), _step4; !(_step4 = _iterator4()).done;){
12878
+ for(var _iterator4 = _create_for_of_iterator_helper_loose(addedFrameClipMasks), _step4; !(_step4 = _iterator4()).done;){
12740
12879
  var frameClipMask1 = _step4.value;
12741
12880
  this.removeMaskReference(frameClipMask1);
12742
12881
  }
@@ -12745,24 +12884,24 @@ var MaterialRenderType;
12745
12884
  * 绘制几何体蒙版,蒙版元素绘制时调用
12746
12885
  */ _proto.drawGeometryMask = function drawGeometryMask(renderer, geometry, worldMatrix, material, maskRef, subMeshIndex) {
12747
12886
  if (subMeshIndex === void 0) subMeshIndex = 0;
12748
- var previousColorMask = material.colorMask;
12887
+ var prevColorMask = material.colorMask;
12749
12888
  var prevStencilTest = material.stencilTest;
12750
- this.copyStencilArrayValue(this.prevStencilFunc, material.stencilFunc);
12751
- this.copyStencilArrayValue(this.prevStencilOpZPass, material.stencilOpZPass);
12752
- this.copyStencilArrayValue(this.prevStencilRef, material.stencilRef);
12753
- this.copyStencilArrayValue(this.prevStencilMask, material.stencilMask);
12754
- // const prevStencilOpFail = material.stencilOpFail;
12755
- // const prevStencilOpZFail = material.stencilOpZFail;
12889
+ var prevStencilFunc = material.stencilFunc;
12890
+ var prevStencilOpFail = material.stencilOpFail;
12891
+ var prevStencilOpZFail = material.stencilOpZFail;
12892
+ var prevStencilOpZPass = material.stencilOpZPass;
12893
+ var prevStencilRef = material.stencilRef;
12894
+ var prevStencilMask = material.stencilMask;
12756
12895
  this.setupMaskMaterial(material, maskRef);
12757
12896
  renderer.drawGeometry(geometry, worldMatrix, material, subMeshIndex);
12758
- material.colorMask = previousColorMask;
12897
+ material.colorMask = prevColorMask;
12759
12898
  material.stencilTest = prevStencilTest;
12760
- material.stencilFunc = this.prevStencilFunc;
12761
- material.stencilOpZPass = this.prevStencilOpZPass;
12762
- // material.stencilOpFail = prevStencilOpFail;
12763
- // material.stencilOpZFail = prevStencilOpZFail;
12764
- material.stencilRef = this.prevStencilRef;
12765
- material.stencilMask = this.prevStencilMask;
12899
+ material.stencilFunc = prevStencilFunc;
12900
+ material.stencilOpFail = prevStencilOpFail;
12901
+ material.stencilOpZFail = prevStencilOpZFail;
12902
+ material.stencilOpZPass = prevStencilOpZPass;
12903
+ material.stencilRef = prevStencilRef;
12904
+ material.stencilMask = prevStencilMask;
12766
12905
  };
12767
12906
  /**
12768
12907
  * 设置蒙版材质的 stencil 属性(写入蒙版)
@@ -12790,12 +12929,18 @@ var MaterialRenderType;
12790
12929
  0xFF
12791
12930
  ];
12792
12931
  // 通过时递增 stencil 值,不通过时保持不变
12932
+ material.stencilOpFail = [
12933
+ glContext.KEEP,
12934
+ glContext.KEEP
12935
+ ];
12936
+ material.stencilOpZFail = [
12937
+ glContext.KEEP,
12938
+ glContext.KEEP
12939
+ ];
12793
12940
  material.stencilOpZPass = [
12794
12941
  glContext.INCR,
12795
12942
  glContext.INCR
12796
12943
  ];
12797
- // material.stencilOpFail = [glContext.KEEP, glContext.KEEP];
12798
- // material.stencilOpZFail = [glContext.KEEP, glContext.KEEP];
12799
12944
  material.colorMask = false; // 不写入颜色
12800
12945
  };
12801
12946
  /**
@@ -12830,13 +12975,6 @@ var MaterialRenderType;
12830
12975
  material.stencilTest = false;
12831
12976
  }
12832
12977
  };
12833
- _proto.copyStencilArrayValue = function copyStencilArrayValue(target, source) {
12834
- if (!source) {
12835
- return;
12836
- }
12837
- target[0] = source[0];
12838
- target[1] = source[1];
12839
- };
12840
12978
  _create_class(MaskProcessor, [
12841
12979
  {
12842
12980
  key: "maskable",
@@ -12852,7 +12990,7 @@ var MaterialRenderType;
12852
12990
  if (value) {
12853
12991
  this.maskReferences.push({
12854
12992
  maskable: value,
12855
- inverted: this.maskMode === MaskMode.REVERSE_OBSCURED
12993
+ inverted: false
12856
12994
  });
12857
12995
  }
12858
12996
  }
@@ -16637,19 +16775,15 @@ function buildBezierEasing(leftKeyframe, rightKeyframe) {
16637
16775
  y2 = numberToFix((p2.y - p0.y) / valueInterval, 5);
16638
16776
  }
16639
16777
  if (x1 < 0) {
16640
- console.error("Invalid bezier points, x1 < 0", p0, p1, p2, p3);
16641
16778
  x1 = 0;
16642
16779
  }
16643
16780
  if (x2 < 0) {
16644
- console.error("Invalid bezier points, x2 < 0", p0, p1, p2, p3);
16645
16781
  x2 = 0;
16646
16782
  }
16647
16783
  if (x1 > 1) {
16648
- console.error("Invalid bezier points, x1 >= 1", p0, p1, p2, p3);
16649
16784
  x1 = 1;
16650
16785
  }
16651
16786
  if (x2 > 1) {
16652
- console.error("Invalid bezier points, x2 >= 1", p0, p1, p2, p3);
16653
16787
  x2 = 1;
16654
16788
  }
16655
16789
  var str = ("bez_" + x1 + "_" + y1 + "_" + x2 + "_" + y2).replace(/\./g, "p");
@@ -16740,10 +16874,49 @@ function oldBezierKeyFramesToNew(props) {
16740
16874
  return keyframes;
16741
16875
  }
16742
16876
 
16877
+ /**
16878
+ * 通用对象引用阶梯曲线(不插值)。对象引用不可插值,
16879
+ * 按时间阶梯采样取 time ≤ t 的最近关键帧。
16880
+ *
16881
+ * 继承 ValueGetter 以复用 PropertyClipPlayable<T>;数值相关方法
16882
+ * (toUniform/toData/getIntegrate*)保留基类 NOT_IMPLEMENT——对象引用 curve
16883
+ * 不走 shader 通路。典型用例:T = Sprite(sprite 属性 K 帧切图)。
16884
+ */ var ReferenceCurve = /*#__PURE__*/ function(ValueGetter) {
16885
+ _inherits(ReferenceCurve, ValueGetter);
16886
+ function ReferenceCurve() {
16887
+ return ValueGetter.apply(this, arguments);
16888
+ }
16889
+ var _proto = ReferenceCurve.prototype;
16890
+ _proto.onCreate = function onCreate(props) {
16891
+ this.keyframes = props;
16892
+ };
16893
+ _proto.getValue = function getValue(time) {
16894
+ var keys = this.keyframes;
16895
+ if (keys.length === 0) {
16896
+ return undefined;
16897
+ }
16898
+ // 阶梯采样:取 time ≤ t 的最大关键帧;t < 首帧取首帧。无插值。
16899
+ var result = keys[0][1];
16900
+ for(var i = 0; i < keys.length; i++){
16901
+ if (keys[i][0] <= (time != null ? time : 0)) {
16902
+ result = keys[i][1];
16903
+ } else {
16904
+ break;
16905
+ }
16906
+ }
16907
+ return result;
16908
+ };
16909
+ return ReferenceCurve;
16910
+ }(ValueGetter);
16911
+
16743
16912
  /**
16744
16913
  * Vector2 曲线
16745
16914
  * TODO: add spec
16746
16915
  */ var VECTOR3_CURVE = 27;
16916
+ /**
16917
+ * 对象引用阶梯曲线(spec ValueType.REFERENCE_CURVE)。
16918
+ * props 为 [[time, value], ...],value 为已解析的对象引用实例。
16919
+ */ var REFERENCE_CURVE = 28;
16747
16920
  var _obj$4;
16748
16921
  var map$1 = (_obj$4 = {}, _obj$4[ValueType.RANDOM] = function(props) {
16749
16922
  if (_instanceof1(props[0], Array)) {
@@ -16800,6 +16973,9 @@ var map$1 = (_obj$4 = {}, _obj$4[ValueType.RANDOM] = function(props) {
16800
16973
  }, // TODO: add spec
16801
16974
  _obj$4[VECTOR3_CURVE] = function(props) {
16802
16975
  return new Vector3Curve(props);
16976
+ }, // 对象引用阶梯曲线(不插值):props.data 为 [time, value][],value 已解析为 EffectsObject
16977
+ _obj$4[REFERENCE_CURVE] = function(props) {
16978
+ return new ReferenceCurve(props);
16803
16979
  }, _obj$4);
16804
16980
  function createValueGetter(args) {
16805
16981
  if (!args || !isNaN(+args)) {
@@ -21862,16 +22038,26 @@ var canvasPool = new CanvasPool();
21862
22038
  * 单张字符 atlas 的边长(像素,scale 后的实际像素,非逻辑尺寸)。
21863
22039
  * 512×512 在 24px 字号下约可容纳 250+ 字形,常见 demo 文本足够
21864
22040
  */ var ATLAS_SIZE = 512;
22041
+ /**
22042
+ * 字体度量探针字符串。带重音符的 É/Å 把墨水顶推到接近字体真实 ascent,
22043
+ * 单字 'M' 只有 cap height(~0.7em) 太矮,会让 CJK / 带重音字顶部越过 cell 上界被裁
22044
+ */ var METRICS_STRING = "|\xc9q\xc5";
22045
+ /** 字体度量基线符号 */ var BASELINE_SYMBOL = "M";
22046
+ /**
22047
+ * 字形 cell 四周留白(逻辑像素)。ink 略超字体度量、或 italic 斜体越界时由它吸收,
22048
+ * 保证 cell 采样矩形内不裁切字形
22049
+ */ var GLYPH_PADDING = 4;
21865
22050
  /**
21866
22051
  * 一种字体(family + weight + style + size 唯一确定)对应一张 atlas。
21867
22052
  *
21868
- * Skyline 风格 packer:行内堆字,行尾换行,行高 = (ascent+descent) * FONT_SCALE。
22053
+ * Skyline 风格 packer:行内堆字,行尾换行,cell = ceil((fontHeight + padding*2) * 1),
22054
+ * 所有字共用同一 cell 高与 baseline,实现同行 baseline 对齐。
21869
22055
  * atlas 满后 `ensureChar` 返回 null,调用方应跳过该字(不再扩页,v1 范围)。
21870
22056
  *
21871
22057
  * canvas 内容变更后需要 `uploadIfDirty` 重新上传到纹理 — 由调用方在使用纹理前主动触发,
21872
22058
  * 避免每加一字都 upload 一次造成的 GL 开销
21873
22059
  */ var GlyphAtlas = /*#__PURE__*/ function() {
21874
- function GlyphAtlas(engine, scaledFontString, ascent, descent) {
22060
+ function GlyphAtlas(engine, scaledFontString, /** baseline 距 cell 顶距离(像素,scale 后,仅 ascent 部分,不含 padding) */ ascentPx, /** baseline 距 cell 底距离(像素,scale 后,仅 descent 部分) */ descentPx, fontStyle) {
21875
22061
  this.engine = engine;
21876
22062
  this.scaledFontString = scaledFontString;
21877
22063
  this.glyphs = new Map();
@@ -21892,11 +22078,14 @@ var canvasPool = new CanvasPool();
21892
22078
  ctx.font = scaledFontString;
21893
22079
  ctx.textBaseline = "alphabetic";
21894
22080
  ctx.fillStyle = "#ffffff";
21895
- this.ascent = ascent;
21896
- this.descent = descent;
21897
- this.lineHeight = ascent + descent;
21898
- this.ascentPx = Math.ceil(ascent * FONT_SCALE);
21899
- this.lineHeightPx = Math.ceil((ascent + descent) * FONT_SCALE);
22081
+ this.paddingPx = GLYPH_PADDING * FONT_SCALE;
22082
+ this.italicScale = fontStyle === "italic" ? 2 : 1;
22083
+ // ascent/descent 由探针 '|ÉqÅM' 测得 actualBoundingBox(重音字已抬高 ink 顶),
22084
+ // 两者内部保持浮点,仅 cell 高做一次外层 ceil 与 padding 共同保证 cell 内不裁切
22085
+ var fontHeightPx = ascentPx + descentPx;
22086
+ this.baselinePx = this.paddingPx + ascentPx;
22087
+ this.cellHPx = Math.ceil(fontHeightPx + this.paddingPx * 2);
22088
+ this.lineHeight = this.cellHPx / FONT_SCALE;
21900
22089
  this.texture = Texture.create(engine, {
21901
22090
  sourceType: TextureSourceType.image,
21902
22091
  image: this.canvas,
@@ -21925,10 +22114,12 @@ var canvasPool = new CanvasPool();
21925
22114
  ctx.font = this.scaledFontString;
21926
22115
  // measureText 用的是 scaledFontString,advance 已经是 scale 后的像素,不能再乘 FONT_SCALE
21927
22116
  var advancePx = ctx.measureText(char).width;
21928
- var cellW = Math.max(1, Math.ceil(advancePx));
21929
- var cellH = this.lineHeightPx;
22117
+ // italic 放大 cell 宽防斜体越界;ceil 对齐像素网格避免相邻字采样重叠
22118
+ var widthPx = Math.max(1, Math.ceil(advancePx * this.italicScale));
22119
+ var paddedWidthPx = widthPx + this.paddingPx * 2;
22120
+ var cellH = this.cellHPx;
21930
22121
  // 行尾换行
21931
- if (this.currentX + cellW > ATLAS_SIZE) {
22122
+ if (this.currentX + paddedWidthPx > ATLAS_SIZE) {
21932
22123
  this.currentX = 0;
21933
22124
  this.currentY += cellH;
21934
22125
  }
@@ -21940,15 +22131,17 @@ var canvasPool = new CanvasPool();
21940
22131
  }
21941
22132
  var px = this.currentX;
21942
22133
  var py = this.currentY;
21943
- ctx.fillText(char, px, py + this.ascentPx);
21944
- this.currentX += cellW;
22134
+ // baseline 落在 cell 顶部下方 paddingPx + ascentPx 处,四周 padding 吸收越界 ink
22135
+ ctx.fillText(char, px + this.paddingPx, py + this.baselinePx);
22136
+ this.currentX += paddedWidthPx;
21945
22137
  this.dirty = true;
21946
22138
  var info = {
21947
22139
  px: px,
21948
22140
  py: py,
21949
- pw: cellW,
22141
+ pw: paddedWidthPx,
21950
22142
  ph: cellH,
21951
- width: cellW / FONT_SCALE
22143
+ advance: advancePx / FONT_SCALE,
22144
+ paddingLeft: this.paddingPx / FONT_SCALE
21952
22145
  };
21953
22146
  this.glyphs.set(char, info);
21954
22147
  return info;
@@ -22000,22 +22193,25 @@ var canvasPool = new CanvasPool();
22000
22193
  if (cached) {
22001
22194
  return cached;
22002
22195
  }
22003
- var fontString = fontStyle + " " + fontWeight + " " + fontSize + "px " + fontFamily;
22004
22196
  var scaledFontString = fontStyle + " " + fontWeight + " " + fontSize * FONT_SCALE + "px " + fontFamily;
22005
- // 用 'M' 探一次得到字体级 ascent/descent(整张 atlas 共享行高,各字 baseline 对齐)
22197
+ // 探一次得到字体级 ascent/descent(整张 atlas 共享 cell 高与 baseline,各字对齐)。
22198
+ // 直接在 scaledFontString 下测,得到的就是 scale 后像素,无需再乘 FONT_SCALE。
22199
+ // 探针用 '|ÉqÅ' + 'M':带重音符的 ÉÅ 把 ink 顶推到接近字体真实 ascent,
22200
+ // 单字 'M' 只有 cap height(~0.7em) 太矮,CJK / 带重音字顶部会越过 cell 上界被裁。
22201
+ // 取 actualBoundingBoxAscent/Descent 度量 ink 边界,跨平台语义稳定
22006
22202
  var probeCanvasAndContext = canvasPool.getCanvasAndContext(1, 1);
22007
22203
  var probeCtx = probeCanvasAndContext.context;
22008
- var ascent = fontSize * 0.8;
22009
- var descent = fontSize * 0.2;
22204
+ var ascentPx = fontSize * 0.8 * FONT_SCALE;
22205
+ var descentPx = fontSize * 0.2 * FONT_SCALE;
22010
22206
  try {
22011
- probeCtx.font = fontString;
22012
- var m = probeCtx.measureText("M");
22013
- ascent = m.actualBoundingBoxAscent || ascent;
22014
- descent = m.actualBoundingBoxDescent || descent;
22207
+ probeCtx.font = scaledFontString;
22208
+ var m = probeCtx.measureText(METRICS_STRING + BASELINE_SYMBOL);
22209
+ ascentPx = m.actualBoundingBoxAscent || ascentPx;
22210
+ descentPx = m.actualBoundingBoxDescent || descentPx;
22015
22211
  } finally{
22016
22212
  canvasPool.releaseCanvasAndContext(probeCanvasAndContext);
22017
22213
  }
22018
- var atlas = new GlyphAtlas(this.engine, scaledFontString, ascent, descent);
22214
+ var atlas = new GlyphAtlas(this.engine, scaledFontString, ascentPx, descentPx, fontStyle);
22019
22215
  this.atlases.set(fontKey, atlas);
22020
22216
  return atlas;
22021
22217
  };
@@ -22419,8 +22615,8 @@ var Graphics = /*#__PURE__*/ function() {
22419
22615
  * `color` 作为乘色与白色字形 alpha 相乘,任意颜色都不会污染 atlas。
22420
22616
  *
22421
22617
  * 字体参数全部展开,避免调用方每帧创建临时 style 对象触发 GC
22422
- * @param x - 文本左下角 X 坐标
22423
- * @param y - 文本左下角 Y 坐标(对齐 baseline 上方 ascent 处)
22618
+ * @param x - 文本左下角 X 坐标(首字 ink 起始处,含 padding 的 quad 会向左延伸)
22619
+ * @param y - 文本左下角 Y 坐标(cell 底,含底部 padding;字形 ink 在其上方 padding+ascent 处)
22424
22620
  * @param text - 要绘制的文本内容,空串直接 return
22425
22621
  * @param fontSize - 字号(逻辑像素)
22426
22622
  * @param color - 乘色,默认白色,范围 0-1
@@ -22451,13 +22647,15 @@ var Graphics = /*#__PURE__*/ function() {
22451
22647
  var u1 = (info.px + info.pw) / ATLAS_SIZE;
22452
22648
  var v0 = 1 - (info.py + info.ph) / ATLAS_SIZE;
22453
22649
  var v1 = 1 - info.py / ATLAS_SIZE;
22454
- this.pushQuad(cursorX, y, info.width, lineHeight, color, {
22650
+ // quad 宽与采样区都含四周 padding(cell 留白透明);但光标只按 advance 前进,
22651
+ // quad 起点左偏 paddingLeft 使字形 ink 落在 cursorX — padding 区重叠无妨
22652
+ this.pushQuad(cursorX - info.paddingLeft, y, info.pw / FONT_SCALE, lineHeight, color, {
22455
22653
  u0: u0,
22456
22654
  v0: v0,
22457
22655
  u1: u1,
22458
22656
  v1: v1
22459
22657
  });
22460
- cursorX += info.width;
22658
+ cursorX += info.advance;
22461
22659
  }
22462
22660
  };
22463
22661
  _proto.dispose = function dispose() {
@@ -22674,7 +22872,6 @@ var Graphics = /*#__PURE__*/ function() {
22674
22872
  aUV: {
22675
22873
  size: 2,
22676
22874
  offset: 0,
22677
- releasable: true,
22678
22875
  type: glContext.FLOAT,
22679
22876
  data: new Float32Array([
22680
22877
  0,
@@ -22822,7 +23019,6 @@ var Graphics = /*#__PURE__*/ function() {
22822
23019
  };
22823
23020
  _proto.configureMaterial = function configureMaterial(renderer) {
22824
23021
  var side = renderer.side, occlusion = renderer.occlusion, blendMode = renderer.blending, texture = renderer.texture;
22825
- var maskMode = this.maskManager.maskMode;
22826
23022
  var material = this.material;
22827
23023
  material.blending = true;
22828
23024
  material.depthTest = true;
@@ -22837,7 +23033,6 @@ var Graphics = /*#__PURE__*/ function() {
22837
23033
  texParams.x = renderer.occlusion ? +renderer.transparentOcclusion : 1;
22838
23034
  texParams.y = preMultiAlpha;
22839
23035
  texParams.z = renderer.renderMode;
22840
- texParams.w = maskMode;
22841
23036
  material.setVector4("_TexParams", texParams);
22842
23037
  if (texParams.x === 0 || this.maskManager.alphaMaskEnabled) {
22843
23038
  material.enableMacro("ALPHA_CLIP");
@@ -22865,9 +23060,9 @@ var Graphics = /*#__PURE__*/ function() {
22865
23060
  blending: (_renderer_blending = renderer.blending) != null ? _renderer_blending : BlendingMode.ALPHA,
22866
23061
  texture: renderer.texture ? this.engine.findObject(renderer.texture) : this.engine.whiteTexture,
22867
23062
  occlusion: !!renderer.occlusion,
22868
- transparentOcclusion: !!renderer.transparentOcclusion || this.maskManager.maskMode === MaskMode.MASK,
23063
+ transparentOcclusion: !!renderer.transparentOcclusion || this.maskManager.isMask,
22869
23064
  side: (_renderer_side = renderer.side) != null ? _renderer_side : SideMode.DOUBLE,
22870
- mask: this.maskManager.getRefValue()
23065
+ mask: 1
22871
23066
  };
22872
23067
  this.configureMaterial(this.renderer);
22873
23068
  };
@@ -24934,6 +25129,50 @@ var SpriteLoader = /*#__PURE__*/ function(Plugin) {
24934
25129
  return SpriteLoader;
24935
25130
  }(_wrap_native_super(Plugin));
24936
25131
 
25132
+ var SpriteRotation;
25133
+ (function(SpriteRotation) {
25134
+ /** 不旋转 */ SpriteRotation[SpriteRotation["None"] = 0] = "None";
25135
+ /** UV 旋转 90°(对应老 splits flip=1) */ SpriteRotation[SpriteRotation["Rotate90"] = 1] = "Rotate90";
25136
+ })(SpriteRotation || (SpriteRotation = {}));
25137
+ var Sprite = /*#__PURE__*/ function(EffectsObject) {
25138
+ _inherits(Sprite, EffectsObject);
25139
+ function Sprite(engine, props) {
25140
+ var _this;
25141
+ _this = EffectsObject.call(this, engine) || this;
25142
+ /** 归一化 UV 矩形 [x, y, w, h],默认整张纹理 */ _this.rect = [
25143
+ 0,
25144
+ 0,
25145
+ 1,
25146
+ 1
25147
+ ];
25148
+ /** UV 旋转方式(对应老 splits 的 flip 0/1) */ _this.rotation = 0;
25149
+ if (props) {
25150
+ _this.fromData(props);
25151
+ }
25152
+ return _this;
25153
+ }
25154
+ var _proto = Sprite.prototype;
25155
+ _proto.fromData = function fromData(data) {
25156
+ EffectsObject.prototype.fromData.call(this, data);
25157
+ // findObject 对 Texture 实例原样返回,对 {id} 解析为 Texture 实例,
25158
+ // 兼容反序列化(data.texture 为 {id})与手动构造(data.texture 为 Texture 实例)两条路径。
25159
+ this.texture = data.texture ? this.engine.findObject(data.texture) : this.engine.whiteTexture;
25160
+ var _data_rect;
25161
+ this.rect = (_data_rect = data.rect) != null ? _data_rect : [
25162
+ 0,
25163
+ 0,
25164
+ 1,
25165
+ 1
25166
+ ];
25167
+ var _data_rotation;
25168
+ this.rotation = (_data_rotation = data.rotation) != null ? _data_rotation : 0;
25169
+ };
25170
+ return Sprite;
25171
+ }(EffectsObject);
25172
+ Sprite = __decorate([
25173
+ effectsClass("Sprite")
25174
+ ], Sprite);
25175
+
24937
25176
  /**
24938
25177
  * 动画图可播放节点对象
24939
25178
  * @since 2.0.0
@@ -25520,6 +25759,36 @@ var SpriteColorMixerPlayable = /*#__PURE__*/ function(TrackMixerPlayable) {
25520
25759
  return SpriteColorMixerPlayable;
25521
25760
  }(TrackMixerPlayable);
25522
25761
 
25762
+ /**
25763
+ * Sprite 属性 K 帧 mixer。对象引用不混合:取首个激活 clip 的阶梯采样值,
25764
+ * 赋值 boundObject.sprite 触发 setter(同步纹理 + 重建 UV)。
25765
+ * 不继承 PropertyMixerPlayable(其 evaluate 开头"读当前值为 null 则 return"
25766
+ * 会阻断无初始 sprite 组件的 K 帧)。
25767
+ */ var SpritePropertyMixerPlayable = /*#__PURE__*/ function(TrackMixerPlayable) {
25768
+ _inherits(SpritePropertyMixerPlayable, TrackMixerPlayable);
25769
+ function SpritePropertyMixerPlayable() {
25770
+ return TrackMixerPlayable.apply(this, arguments);
25771
+ }
25772
+ var _proto = SpritePropertyMixerPlayable.prototype;
25773
+ _proto.evaluate = function evaluate(context) {
25774
+ var boundObject = context.output.getUserData();
25775
+ if (!boundObject) {
25776
+ return;
25777
+ }
25778
+ // 对象引用不混合:取首个激活 clip 的采样值
25779
+ for(var i = 0; i < this.clipPlayables.length; i++){
25780
+ if (this.getClipWeight(i) > 0) {
25781
+ var clip = this.getClipPlayable(i);
25782
+ if (_instanceof1(clip, PropertyClipPlayable) && clip.value) {
25783
+ boundObject.sprite = clip.value;
25784
+ }
25785
+ break;
25786
+ }
25787
+ }
25788
+ };
25789
+ return SpritePropertyMixerPlayable;
25790
+ }(TrackMixerPlayable);
25791
+
25523
25792
  var SubCompositionClipPlayable = /*#__PURE__*/ function(Playable) {
25524
25793
  _inherits(SubCompositionClipPlayable, Playable);
25525
25794
  function SubCompositionClipPlayable() {
@@ -25563,94 +25832,148 @@ var SubCompositionMixerPlayable = /*#__PURE__*/ function(TrackMixerPlayable) {
25563
25832
  return SubCompositionMixerPlayable;
25564
25833
  }(TrackMixerPlayable);
25565
25834
 
25566
- var TransformMixerPlayable = /*#__PURE__*/ function(TrackMixerPlayable) {
25567
- _inherits(TransformMixerPlayable, TrackMixerPlayable);
25568
- function TransformMixerPlayable() {
25569
- return TrackMixerPlayable.apply(this, arguments);
25570
- }
25571
- var _proto = TransformMixerPlayable.prototype;
25572
- _proto.evaluate = function evaluate(context) {};
25573
- return TransformMixerPlayable;
25574
- }(TrackMixerPlayable);
25575
-
25576
- var Vector4PropertyMixerPlayable = /*#__PURE__*/ function(PropertyMixerPlayable) {
25577
- _inherits(Vector4PropertyMixerPlayable, PropertyMixerPlayable);
25578
- function Vector4PropertyMixerPlayable() {
25579
- return PropertyMixerPlayable.apply(this, arguments);
25580
- }
25581
- var _proto = Vector4PropertyMixerPlayable.prototype;
25582
- _proto.resetPropertyValue = function resetPropertyValue() {
25583
- this.propertyValue.x = 0;
25584
- this.propertyValue.y = 0;
25585
- this.propertyValue.z = 0;
25586
- this.propertyValue.w = 0;
25587
- };
25588
- _proto.addWeightedValue = function addWeightedValue(curveValue, weight) {
25589
- var result = this.propertyValue;
25590
- result.x += curveValue.x * weight;
25591
- result.y += curveValue.y * weight;
25592
- result.z += curveValue.z * weight;
25593
- result.w += curveValue.w * weight;
25594
- };
25595
- return Vector4PropertyMixerPlayable;
25596
- }(PropertyMixerPlayable);
25597
- var Vector3PropertyMixerPlayable = /*#__PURE__*/ function(PropertyMixerPlayable) {
25598
- _inherits(Vector3PropertyMixerPlayable, PropertyMixerPlayable);
25599
- function Vector3PropertyMixerPlayable() {
25600
- return PropertyMixerPlayable.apply(this, arguments);
25601
- }
25602
- var _proto = Vector3PropertyMixerPlayable.prototype;
25603
- _proto.resetPropertyValue = function resetPropertyValue() {
25604
- this.propertyValue.x = 0;
25605
- this.propertyValue.y = 0;
25606
- this.propertyValue.z = 0;
25607
- };
25608
- _proto.addWeightedValue = function addWeightedValue(curveValue, weight) {
25609
- var result = this.propertyValue;
25610
- result.x += curveValue.x * weight;
25611
- result.y += curveValue.y * weight;
25612
- result.z += curveValue.z * weight;
25613
- };
25614
- return Vector3PropertyMixerPlayable;
25615
- }(PropertyMixerPlayable);
25616
- var Vector2PropertyMixerPlayable = /*#__PURE__*/ function(PropertyMixerPlayable) {
25617
- _inherits(Vector2PropertyMixerPlayable, PropertyMixerPlayable);
25618
- function Vector2PropertyMixerPlayable() {
25619
- return PropertyMixerPlayable.apply(this, arguments);
25620
- }
25621
- var _proto = Vector2PropertyMixerPlayable.prototype;
25622
- _proto.resetPropertyValue = function resetPropertyValue() {
25623
- this.propertyValue.x = 0;
25624
- this.propertyValue.y = 0;
25835
+ /**
25836
+ * 对 TransformTrack 当前激活的 Transform clip contribution 做帧内合成。
25837
+ * position 与 rotation 使用增量语义,scale 使用乘子语义;结果由 flush 统一写回。
25838
+ */ var TransformClipMixer = /*#__PURE__*/ function() {
25839
+ function TransformClipMixer() {
25840
+ this.hasContribution = false;
25841
+ this.hasPosition = false;
25842
+ this.hasRotation = false;
25843
+ this.hasScale = false;
25844
+ this.appliedPosition = false;
25845
+ this.appliedRotation = false;
25846
+ this.appliedScale = false;
25847
+ this.outPos = new Vector3();
25848
+ this.outRot = new Euler();
25849
+ this.outScale = new Vector3(1, 1, 1);
25850
+ this.weightedRot = new Euler();
25851
+ }
25852
+ var _proto = TransformClipMixer.prototype;
25853
+ _proto.captureBasePose = function captureBasePose(item) {
25854
+ this.ensureBasePose(item);
25855
+ };
25856
+ /**
25857
+ * orbital position contribution 依赖 base position。
25858
+ * 这里返回 mixer 持有的 base,确保采样和合成使用同一份参考姿态。
25859
+ */ _proto.getBasePosition = function getBasePosition() {
25860
+ var _this_basePose;
25861
+ return (_this_basePose = this.basePose) == null ? void 0 : _this_basePose.position;
25862
+ };
25863
+ _proto.resetFrame = function resetFrame() {
25864
+ this.hasContribution = false;
25865
+ this.hasPosition = false;
25866
+ this.hasRotation = false;
25867
+ this.hasScale = false;
25868
+ };
25869
+ _proto.addContribution = function addContribution(item, contribution, weight) {
25870
+ if (weight <= 0) {
25871
+ return;
25872
+ }
25873
+ this.ensureBasePose(item);
25874
+ if (!this.hasContribution) {
25875
+ var base = this.basePose;
25876
+ this.outPos.copyFrom(base.position);
25877
+ this.outRot.copyFrom(base.rotation);
25878
+ this.outScale.copyFrom(base.scale);
25879
+ this.hasContribution = true;
25880
+ }
25881
+ if (contribution.hasPosition) {
25882
+ this.hasPosition = true;
25883
+ this.outPos.x += contribution.position.x * weight;
25884
+ this.outPos.y += contribution.position.y * weight;
25885
+ this.outPos.z += contribution.position.z * weight;
25886
+ }
25887
+ if (contribution.hasRotation) {
25888
+ this.hasRotation = true;
25889
+ this.weightedRot.set(contribution.rotation.x * weight, contribution.rotation.y * weight, contribution.rotation.z * weight, contribution.rotation.order);
25890
+ this.outRot.addEulers(this.outRot, this.weightedRot);
25891
+ }
25892
+ if (contribution.hasScale) {
25893
+ this.hasScale = true;
25894
+ // Scale contribution 使用乘子语义,weight 用于支持 clip blend/crossfade。
25895
+ this.outScale.x *= Math.pow(contribution.scale.x, weight);
25896
+ this.outScale.y *= Math.pow(contribution.scale.y, weight);
25897
+ this.outScale.z *= Math.pow(contribution.scale.z, weight);
25898
+ }
25899
+ };
25900
+ _proto.flush = function flush(item) {
25901
+ var base = this.basePose;
25902
+ if (!base || !this.hasContribution && !this.appliedPosition && !this.appliedRotation && !this.appliedScale) {
25903
+ return;
25904
+ }
25905
+ if (this.hasPosition) {
25906
+ item.transform.setPosition(this.outPos.x, this.outPos.y, this.outPos.z);
25907
+ this.appliedPosition = true;
25908
+ } else if (this.appliedPosition) {
25909
+ item.transform.setPosition(base.position.x, base.position.y, base.position.z);
25910
+ this.appliedPosition = false;
25911
+ }
25912
+ if (this.hasRotation) {
25913
+ item.transform.setRotation(this.outRot.x, this.outRot.y, this.outRot.z);
25914
+ this.appliedRotation = true;
25915
+ } else if (this.appliedRotation) {
25916
+ item.transform.setRotation(base.rotation.x, base.rotation.y, base.rotation.z);
25917
+ this.appliedRotation = false;
25918
+ }
25919
+ if (this.hasScale) {
25920
+ item.transform.setScale(this.outScale.x, this.outScale.y, this.outScale.z);
25921
+ this.appliedScale = true;
25922
+ } else if (this.appliedScale) {
25923
+ item.transform.setScale(base.scale.x, base.scale.y, base.scale.z);
25924
+ this.appliedScale = false;
25925
+ }
25625
25926
  };
25626
- _proto.addWeightedValue = function addWeightedValue(curveValue, weight) {
25627
- var result = this.propertyValue;
25628
- result.x += curveValue.x * weight;
25629
- result.y += curveValue.y * weight;
25927
+ _proto.dispose = function dispose() {
25928
+ this.basePose = undefined;
25929
+ this.boundInstanceId = undefined;
25930
+ this.appliedPosition = false;
25931
+ this.appliedRotation = false;
25932
+ this.appliedScale = false;
25933
+ this.resetFrame();
25934
+ };
25935
+ _proto.ensureBasePose = function ensureBasePose(item) {
25936
+ if (!this.basePose || this.boundInstanceId !== item.getInstanceId()) {
25937
+ var scale = item.transform.scale;
25938
+ this.basePose = {
25939
+ position: item.transform.position.clone(),
25940
+ rotation: item.transform.getRotation().clone(),
25941
+ scale: new Vector3(scale.x, scale.y, scale.x)
25942
+ };
25943
+ this.boundInstanceId = item.getInstanceId();
25944
+ this.appliedPosition = false;
25945
+ this.appliedRotation = false;
25946
+ this.appliedScale = false;
25947
+ }
25630
25948
  };
25631
- return Vector2PropertyMixerPlayable;
25632
- }(PropertyMixerPlayable);
25949
+ return TransformClipMixer;
25950
+ }();
25633
25951
 
25634
25952
  var tempRot$1 = new Euler();
25635
- var tempSize$1 = new Vector3(1, 1, 1);
25636
25953
  var tempPos = new Vector3();
25954
+ var createEmptyContribution = function() {
25955
+ return {
25956
+ hasPosition: false,
25957
+ position: new Vector3(),
25958
+ hasRotation: false,
25959
+ rotation: new Euler(),
25960
+ hasScale: false,
25961
+ scale: new Vector3(1, 1, 1)
25962
+ };
25963
+ };
25637
25964
  /**
25638
25965
  * @since 2.0.0
25639
25966
  */ var TransformPlayable = /*#__PURE__*/ function(Playable) {
25640
25967
  _inherits(TransformPlayable, Playable);
25641
25968
  function TransformPlayable() {
25642
- return Playable.apply(this, arguments);
25969
+ var _this;
25970
+ _this = Playable.apply(this, arguments) || this;
25971
+ _this.started = false;
25972
+ _this.contribution = createEmptyContribution();
25973
+ return _this;
25643
25974
  }
25644
25975
  var _proto = TransformPlayable.prototype;
25645
25976
  _proto.start = function start() {
25646
- var boundItem = this.boundObject;
25647
- var scale = boundItem.transform.scale;
25648
- this.originalTransform = {
25649
- position: boundItem.transform.position.clone(),
25650
- rotation: boundItem.transform.getRotation().clone(),
25651
- // TODO 编辑器 scale 没有z轴控制
25652
- scale: new Vector3(scale.x, scale.y, scale.x)
25653
- };
25654
25977
  var positionOverLifetime = this.data.positionOverLifetime;
25655
25978
  var rotationOverLifetime = this.data.rotationOverLifetime;
25656
25979
  var sizeOverLifetime = this.data.sizeOverLifetime;
@@ -25658,7 +25981,7 @@ var tempPos = new Vector3();
25658
25981
  if (positionOverLifetime && Object.keys(positionOverLifetime).length !== 0) {
25659
25982
  this.positionOverLifetime = positionOverLifetime;
25660
25983
  if (positionOverLifetime.path) {
25661
- this.originalTransform.path = createValueGetter(positionOverLifetime.path);
25984
+ this.pathGetter = createValueGetter(positionOverLifetime.path);
25662
25985
  }
25663
25986
  var linearVelEnable = positionOverLifetime.linearX || positionOverLifetime.linearY || positionOverLifetime.linearZ;
25664
25987
  if (linearVelEnable) {
@@ -25714,37 +26037,53 @@ var tempPos = new Vector3();
25714
26037
  this.velocity.multiply(this.startSpeed);
25715
26038
  };
25716
26039
  _proto.processFrame = function processFrame(context) {
25717
- if (!this.boundObject) {
25718
- var boundObject = context.output.getUserData();
25719
- if (_instanceof1(boundObject, VFXItem)) {
25720
- this.boundObject = boundObject;
25721
- this.start();
25722
- }
25723
- }
25724
- if (this.boundObject && this.boundObject.composition) {
25725
- this.sampleAnimation();
26040
+ this.ensureStarted();
26041
+ var boundObject = context.output.getUserData();
26042
+ if (!this.originalTransform && _instanceof1(boundObject, VFXItem)) {
26043
+ this.captureOriginalTransform(boundObject);
25726
26044
  }
25727
26045
  };
25728
26046
  /**
25729
- * 应用时间轴K帧数据到对象
25730
- */ _proto.sampleAnimation = function sampleAnimation() {
26047
+ * 采样当前帧相对 base pose 的 transform contribution。
26048
+ * 返回值为内部复用对象,调用方应在当前帧同步消费,不应缓存。
26049
+ * @param basePosition - orbital position 计算 contribution 时使用的参考位置。
26050
+ */ _proto.getContribution = function getContribution(basePosition) {
26051
+ this.ensureStarted();
26052
+ this.sampleAnimation(basePosition);
26053
+ return this.contribution;
26054
+ };
26055
+ _proto.ensureStarted = function ensureStarted() {
26056
+ if (!this.started) {
26057
+ this.start();
26058
+ this.started = true;
26059
+ }
26060
+ };
26061
+ _proto.sampleAnimation = function sampleAnimation(basePosition) {
25731
26062
  var _this = this;
25732
- var boundItem = this.boundObject;
26063
+ var out = this.contribution;
26064
+ out.hasPosition = false;
26065
+ out.hasRotation = false;
26066
+ out.hasScale = false;
25733
26067
  var duration = this.getDuration();
26068
+ if (duration <= 0) {
26069
+ return;
26070
+ }
25734
26071
  var life = this.time / duration;
25735
26072
  life = life < 0 ? 0 : life;
25736
26073
  if (this.sizeXOverLifetime) {
25737
- tempSize$1.x = this.sizeXOverLifetime.getValue(life);
26074
+ out.hasScale = true;
26075
+ out.scale.x = this.sizeXOverLifetime.getValue(life);
25738
26076
  if (this.sizeSeparateAxes) {
25739
- tempSize$1.y = this.sizeYOverLifetime.getValue(life);
25740
- tempSize$1.z = this.sizeZOverLifetime.getValue(life);
26077
+ out.scale.y = this.sizeYOverLifetime.getValue(life);
26078
+ out.scale.z = this.sizeZOverLifetime.getValue(life);
25741
26079
  } else {
25742
- tempSize$1.z = tempSize$1.y = tempSize$1.x;
26080
+ out.scale.z = out.scale.y = out.scale.x;
25743
26081
  }
25744
- var startSize = this.originalTransform.scale;
25745
- boundItem.transform.setScale(tempSize$1.x * startSize.x, tempSize$1.y * startSize.y, tempSize$1.z * startSize.z);
26082
+ } else {
26083
+ out.hasScale = false;
25746
26084
  }
25747
26085
  if (this.rotationOverLifetime) {
26086
+ out.hasRotation = true;
25748
26087
  var func = function(v) {
25749
26088
  return _this.rotationOverLifetime.asRotation ? v.getValue(life) : v.getIntegrateValue(0, life, duration);
25750
26089
  };
@@ -25753,16 +26092,42 @@ var tempPos = new Vector3();
25753
26092
  tempRot$1.x = separateAxes ? func(this.rotationOverLifetime.x) : 0;
25754
26093
  tempRot$1.y = separateAxes ? func(this.rotationOverLifetime.y) : 0;
25755
26094
  tempRot$1.z = incZ;
25756
- var rot = tempRot$1.addEulers(this.originalTransform.rotation, tempRot$1);
25757
- boundItem.transform.setRotation(rot.x, rot.y, rot.z);
26095
+ out.rotation.copyFrom(tempRot$1);
26096
+ } else {
26097
+ out.hasRotation = false;
25758
26098
  }
25759
26099
  if (this.positionOverLifetime) {
25760
- var pos = tempPos;
25761
- calculateTranslation(pos, this, this.gravity, this.time, duration, this.originalTransform.position, this.velocity);
25762
- if (this.originalTransform.path) {
25763
- pos.add(this.originalTransform.path.getValue(life));
26100
+ var _this_orbitalVelOverLifetime;
26101
+ out.hasPosition = true;
26102
+ // Orbital position 依赖参考位置;普通 position 可直接从零向量采样位移贡献。
26103
+ var orbitalEnabled = !!((_this_orbitalVelOverLifetime = this.orbitalVelOverLifetime) == null ? void 0 : _this_orbitalVelOverLifetime.enabled);
26104
+ if (orbitalEnabled && basePosition) {
26105
+ calculateTranslation(out.position, this, this.gravity, this.time, duration, basePosition, this.velocity);
26106
+ if (this.pathGetter) {
26107
+ out.position.add(this.pathGetter.getValue(life));
26108
+ }
26109
+ out.position.subtract(basePosition);
26110
+ } else {
26111
+ tempPos.set(0, 0, 0);
26112
+ calculateTranslation(out.position, this, this.gravity, this.time, duration, tempPos, this.velocity);
26113
+ if (this.pathGetter) {
26114
+ out.position.add(this.pathGetter.getValue(life));
26115
+ }
25764
26116
  }
25765
- boundItem.transform.setPosition(pos.x, pos.y, pos.z);
26117
+ } else {
26118
+ out.hasPosition = false;
26119
+ }
26120
+ };
26121
+ _proto.captureOriginalTransform = function captureOriginalTransform(boundItem) {
26122
+ var scale = boundItem.transform.scale;
26123
+ this.originalTransform = {
26124
+ position: boundItem.transform.position.clone(),
26125
+ rotation: boundItem.transform.getRotation().clone(),
26126
+ // TODO 编辑器 scale 没有z轴控制
26127
+ scale: new Vector3(scale.x, scale.y, scale.x)
26128
+ };
26129
+ if (this.pathGetter) {
26130
+ this.originalTransform.path = this.pathGetter;
25766
26131
  }
25767
26132
  };
25768
26133
  return TransformPlayable;
@@ -25787,6 +26152,104 @@ TransformPlayableAsset = __decorate([
25787
26152
  effectsClass(DataType.TransformPlayableAsset)
25788
26153
  ], TransformPlayableAsset);
25789
26154
 
26155
+ /**
26156
+ * TransformTrack 的 mixer。
26157
+ * 收集当前激活的 Transform clip contribution,并委托 TransformClipMixer 合成当前帧输出。
26158
+ */ var TransformMixerPlayable = /*#__PURE__*/ function(TrackMixerPlayable) {
26159
+ _inherits(TransformMixerPlayable, TrackMixerPlayable);
26160
+ function TransformMixerPlayable() {
26161
+ var _this;
26162
+ _this = TrackMixerPlayable.apply(this, arguments) || this;
26163
+ _this.clipMixer = new TransformClipMixer();
26164
+ return _this;
26165
+ }
26166
+ var _proto = TransformMixerPlayable.prototype;
26167
+ _proto.dispose = function dispose() {
26168
+ this.clipMixer.dispose();
26169
+ TrackMixerPlayable.prototype.dispose.call(this);
26170
+ };
26171
+ _proto.evaluate = function evaluate(context) {
26172
+ var item = context.output.getUserData();
26173
+ if (!_instanceof1(item, VFXItem)) {
26174
+ return;
26175
+ }
26176
+ this.clipMixer.captureBasePose(item);
26177
+ this.clipMixer.resetFrame();
26178
+ for(var i = 0; i < this.clipPlayables.length; i++){
26179
+ var weight = this.clipWeights[i];
26180
+ // RuntimeClip 会把已结束且 destroy 的 clip 权重置 0,这类 clip 不参与当前帧合成。
26181
+ if (!weight || weight <= 0) {
26182
+ continue;
26183
+ }
26184
+ var playable = this.clipPlayables[i];
26185
+ if (!_instanceof1(playable, TransformPlayable)) {
26186
+ continue;
26187
+ }
26188
+ this.clipMixer.addContribution(item, playable.getContribution(this.clipMixer.getBasePosition()), weight);
26189
+ }
26190
+ this.clipMixer.flush(item);
26191
+ };
26192
+ return TransformMixerPlayable;
26193
+ }(TrackMixerPlayable);
26194
+
26195
+ var Vector4PropertyMixerPlayable = /*#__PURE__*/ function(PropertyMixerPlayable) {
26196
+ _inherits(Vector4PropertyMixerPlayable, PropertyMixerPlayable);
26197
+ function Vector4PropertyMixerPlayable() {
26198
+ return PropertyMixerPlayable.apply(this, arguments);
26199
+ }
26200
+ var _proto = Vector4PropertyMixerPlayable.prototype;
26201
+ _proto.resetPropertyValue = function resetPropertyValue() {
26202
+ this.propertyValue.x = 0;
26203
+ this.propertyValue.y = 0;
26204
+ this.propertyValue.z = 0;
26205
+ this.propertyValue.w = 0;
26206
+ };
26207
+ _proto.addWeightedValue = function addWeightedValue(curveValue, weight) {
26208
+ var result = this.propertyValue;
26209
+ result.x += curveValue.x * weight;
26210
+ result.y += curveValue.y * weight;
26211
+ result.z += curveValue.z * weight;
26212
+ result.w += curveValue.w * weight;
26213
+ };
26214
+ return Vector4PropertyMixerPlayable;
26215
+ }(PropertyMixerPlayable);
26216
+ var Vector3PropertyMixerPlayable = /*#__PURE__*/ function(PropertyMixerPlayable) {
26217
+ _inherits(Vector3PropertyMixerPlayable, PropertyMixerPlayable);
26218
+ function Vector3PropertyMixerPlayable() {
26219
+ return PropertyMixerPlayable.apply(this, arguments);
26220
+ }
26221
+ var _proto = Vector3PropertyMixerPlayable.prototype;
26222
+ _proto.resetPropertyValue = function resetPropertyValue() {
26223
+ this.propertyValue.x = 0;
26224
+ this.propertyValue.y = 0;
26225
+ this.propertyValue.z = 0;
26226
+ };
26227
+ _proto.addWeightedValue = function addWeightedValue(curveValue, weight) {
26228
+ var result = this.propertyValue;
26229
+ result.x += curveValue.x * weight;
26230
+ result.y += curveValue.y * weight;
26231
+ result.z += curveValue.z * weight;
26232
+ };
26233
+ return Vector3PropertyMixerPlayable;
26234
+ }(PropertyMixerPlayable);
26235
+ var Vector2PropertyMixerPlayable = /*#__PURE__*/ function(PropertyMixerPlayable) {
26236
+ _inherits(Vector2PropertyMixerPlayable, PropertyMixerPlayable);
26237
+ function Vector2PropertyMixerPlayable() {
26238
+ return PropertyMixerPlayable.apply(this, arguments);
26239
+ }
26240
+ var _proto = Vector2PropertyMixerPlayable.prototype;
26241
+ _proto.resetPropertyValue = function resetPropertyValue() {
26242
+ this.propertyValue.x = 0;
26243
+ this.propertyValue.y = 0;
26244
+ };
26245
+ _proto.addWeightedValue = function addWeightedValue(curveValue, weight) {
26246
+ var result = this.propertyValue;
26247
+ result.x += curveValue.x * weight;
26248
+ result.y += curveValue.y * weight;
26249
+ };
26250
+ return Vector2PropertyMixerPlayable;
26251
+ }(PropertyMixerPlayable);
26252
+
25790
26253
  /**
25791
26254
  * @since 2.0.0
25792
26255
  */ var TimelineClip = /*#__PURE__*/ function() {
@@ -26176,6 +26639,24 @@ ColorPropertyTrack = __decorate([
26176
26639
  effectsClass(DataType.ColorPropertyTrack)
26177
26640
  ], ColorPropertyTrack);
26178
26641
 
26642
+ var SpritePropertyTrack = /*#__PURE__*/ function(PropertyTrack) {
26643
+ _inherits(SpritePropertyTrack, PropertyTrack);
26644
+ function SpritePropertyTrack() {
26645
+ return PropertyTrack.apply(this, arguments);
26646
+ }
26647
+ var _proto = SpritePropertyTrack.prototype;
26648
+ _proto.createTrackMixer = function createTrackMixer() {
26649
+ return new SpritePropertyMixerPlayable();
26650
+ };
26651
+ _proto.updateAnimatedObject = function updateAnimatedObject(boundObject) {
26652
+ return boundObject.getComponent(SpriteComponent);
26653
+ };
26654
+ return SpritePropertyTrack;
26655
+ }(PropertyTrack);
26656
+ SpritePropertyTrack = __decorate([
26657
+ effectsClass("SpritePropertyTrack")
26658
+ ], SpritePropertyTrack);
26659
+
26179
26660
  var Cone = /*#__PURE__*/ function() {
26180
26661
  function Cone(props) {
26181
26662
  var _this = this;
@@ -29680,8 +30161,6 @@ var ParticleSystem = /*#__PURE__*/ function(Component) {
29680
30161
  occlusion: !!renderer.occlusion,
29681
30162
  transparentOcclusion: !!renderer.transparentOcclusion,
29682
30163
  maxCount: options.maxCount,
29683
- mask: this.maskManager.getRefValue(),
29684
- maskMode: this.maskManager.maskMode,
29685
30164
  forceTarget: forceTarget,
29686
30165
  diffuse: renderer.texture ? this.engine.findObject(renderer.texture) : undefined,
29687
30166
  sizeOverLifetime: sizeOverLifetimeGetter,
@@ -29776,9 +30255,7 @@ var ParticleSystem = /*#__PURE__*/ function(Component) {
29776
30255
  shaderCachePrefix: shaderCachePrefix,
29777
30256
  lifetime: this.trails.lifetime,
29778
30257
  occlusion: !!trails.occlusion,
29779
- transparentOcclusion: !!trails.transparentOcclusion,
29780
- mask: this.maskManager.getRefValue(),
29781
- maskMode: this.maskManager.maskMode
30258
+ transparentOcclusion: !!trails.transparentOcclusion
29782
30259
  };
29783
30260
  if (trails.colorOverLifetime && trails.colorOverLifetime[0] === ValueType.GRADIENT_COLOR) {
29784
30261
  trailMeshProps.colorOverLifetime = trails.colorOverLifetime[1];
@@ -30007,6 +30484,44 @@ FloatPropertyPlayableAsset = __decorate([
30007
30484
  effectsClass(DataType.FloatPropertyPlayableAsset)
30008
30485
  ], FloatPropertyPlayableAsset);
30009
30486
 
30487
+ var SpritePropertyPlayableAsset = /*#__PURE__*/ function(PlayableAsset) {
30488
+ _inherits(SpritePropertyPlayableAsset, PlayableAsset);
30489
+ function SpritePropertyPlayableAsset() {
30490
+ var _this;
30491
+ _this = PlayableAsset.apply(this, arguments) || this;
30492
+ _this.curveData = [
30493
+ REFERENCE_CURVE,
30494
+ []
30495
+ ];
30496
+ return _this;
30497
+ }
30498
+ var _proto = SpritePropertyPlayableAsset.prototype;
30499
+ _proto.fromData = function fromData(data) {
30500
+ PlayableAsset.prototype.fromData.call(this, data);
30501
+ var items = data.curveData[1];
30502
+ // 把 DataPath 解析为 Sprite 实例
30503
+ var referenceCurveData = [];
30504
+ for(var i = 0; i < items.length; i++){
30505
+ var _items_i = items[i], t = _items_i[0], ref = _items_i[1];
30506
+ referenceCurveData.push([
30507
+ t,
30508
+ this.engine.findObject(ref)
30509
+ ]);
30510
+ }
30511
+ this.curveData[1] = referenceCurveData;
30512
+ };
30513
+ _proto.createPlayable = function createPlayable() {
30514
+ var clip = new PropertyClipPlayable();
30515
+ clip.curve = createValueGetter(this.curveData);
30516
+ clip.value = clip.curve.getValue(0);
30517
+ return clip;
30518
+ };
30519
+ return SpritePropertyPlayableAsset;
30520
+ }(PlayableAsset);
30521
+ SpritePropertyPlayableAsset = __decorate([
30522
+ effectsClass("SpritePropertyPlayableAsset")
30523
+ ], SpritePropertyPlayableAsset);
30524
+
30010
30525
  var SubCompositionPlayableAsset = /*#__PURE__*/ function(PlayableAsset) {
30011
30526
  _inherits(SubCompositionPlayableAsset, PlayableAsset);
30012
30527
  function SubCompositionPlayableAsset() {
@@ -30254,15 +30769,6 @@ var TimelineInstance = /*#__PURE__*/ function() {
30254
30769
  return TimelineInstance;
30255
30770
  }();
30256
30771
 
30257
- var singleSplits = [
30258
- [
30259
- 0,
30260
- 0,
30261
- 1,
30262
- 1,
30263
- 0
30264
- ]
30265
- ];
30266
30772
  var seed$2 = 0;
30267
30773
  var SpriteColorPlayableAsset = /*#__PURE__*/ function(PlayableAsset) {
30268
30774
  _inherits(SpriteColorPlayableAsset, PlayableAsset);
@@ -30350,9 +30856,6 @@ var SpriteComponent = /*#__PURE__*/ function(MaskableGraphic) {
30350
30856
  _this = MaskableGraphic.call(this, engine) || this;
30351
30857
  _this.time = 0;
30352
30858
  _this.duration = 1;
30353
- /**
30354
- * @internal
30355
- */ _this.splits = singleSplits;
30356
30859
  _this.name = "MSprite" + seed$2++;
30357
30860
  if (props) {
30358
30861
  _this.fromData(props);
@@ -30386,38 +30889,33 @@ var SpriteComponent = /*#__PURE__*/ function(MaskableGraphic) {
30386
30889
  if (textureAnimation) {
30387
30890
  var _this_material_getVector4;
30388
30891
  var total = textureAnimation.total || textureAnimation.row * textureAnimation.col;
30389
- var texRectX = 0;
30390
- var texRectY = 0;
30391
- var texRectW = 1;
30392
- var texRectH = 1;
30393
- var flip;
30394
- if (this.splits) {
30395
- var sp = this.splits[0];
30396
- flip = sp[4];
30397
- texRectX = sp[0];
30398
- texRectY = sp[1];
30399
- if (flip) {
30400
- texRectW = sp[3];
30401
- texRectH = sp[2];
30402
- } else {
30403
- texRectW = sp[2];
30404
- texRectH = sp[3];
30405
- }
30406
- }
30407
- var dx, dy;
30408
- if (flip) {
30409
- dx = 1 / textureAnimation.row * texRectW;
30410
- dy = 1 / textureAnimation.col * texRectH;
30411
- } else {
30412
- dx = 1 / textureAnimation.col * texRectW;
30413
- dy = 1 / textureAnimation.row * texRectH;
30414
- }
30892
+ // 帧动画不与多 split(splits.length>1)同时存在,故此处仅读 sprite 单 rect。
30893
+ // sprite 缺省时按整图 [0,0,1,1] 不旋转处理。
30894
+ var sprite = this.sprite;
30895
+ var _sprite_rect;
30896
+ var rect = (_sprite_rect = sprite == null ? void 0 : sprite.rect) != null ? _sprite_rect : [
30897
+ 0,
30898
+ 0,
30899
+ 1,
30900
+ 1
30901
+ ];
30902
+ var _sprite_rotation;
30903
+ var flip = (_sprite_rotation = sprite == null ? void 0 : sprite.rotation) != null ? _sprite_rotation : SpriteRotation.None;
30904
+ var isRotate90 = flip === SpriteRotation.Rotate90;
30905
+ // rect 在纹理上的归一化矩形 [x, y, w, h];旋转 90° 时宽高互换。
30906
+ var rectX = rect[0];
30907
+ var rectY = rect[1];
30908
+ var rectW = isRotate90 ? rect[3] : rect[2];
30909
+ var rectH = isRotate90 ? rect[2] : rect[3];
30910
+ // 每帧在 rect 内的偏移步长;旋转 90° 时 row/col 对调。
30911
+ var dx = isRotate90 ? 1 / textureAnimation.row * rectW : 1 / textureAnimation.col * rectW;
30912
+ var dy = isRotate90 ? 1 / textureAnimation.col * rectH : 1 / textureAnimation.row * rectH;
30415
30913
  var texOffset;
30416
30914
  if (textureAnimation.animate) {
30417
30915
  var frameIndex = Math.round(life * (total - 1));
30418
30916
  var yIndex = Math.floor(frameIndex / textureAnimation.col);
30419
30917
  var xIndex = frameIndex - yIndex * textureAnimation.col;
30420
- texOffset = flip ? [
30918
+ texOffset = isRotate90 ? [
30421
30919
  dx * yIndex,
30422
30920
  dy * (textureAnimation.col - xIndex)
30423
30921
  ] : [
@@ -30431,8 +30929,8 @@ var SpriteComponent = /*#__PURE__*/ function(MaskableGraphic) {
30431
30929
  ];
30432
30930
  }
30433
30931
  (_this_material_getVector4 = this.material.getVector4("_TexOffset")) == null ? void 0 : _this_material_getVector4.setFromArray([
30434
- texRectX + texOffset[0],
30435
- texRectH + texRectY - texOffset[1],
30932
+ rectX + texOffset[0],
30933
+ rectH + rectY - texOffset[1],
30436
30934
  dx,
30437
30935
  dy
30438
30936
  ]);
@@ -30453,19 +30951,31 @@ var SpriteComponent = /*#__PURE__*/ function(MaskableGraphic) {
30453
30951
  }
30454
30952
  };
30455
30953
  _proto.updateGeometry = function updateGeometry(geometry) {
30456
- var split = this.textureSheetAnimation ? [
30954
+ var sprite = this.sprite;
30955
+ var _sprite_rotation;
30956
+ // sprite 缺省时按整图 [0,0,1,1] 不旋转处理,等价旧默认 splits=[[0,0,1,1,0]]。
30957
+ var flip = (_sprite_rotation = sprite == null ? void 0 : sprite.rotation) != null ? _sprite_rotation : SpriteRotation.None;
30958
+ var _sprite_rect;
30959
+ var rect = (_sprite_rect = sprite == null ? void 0 : sprite.rect) != null ? _sprite_rect : [
30457
30960
  0,
30458
30961
  0,
30459
30962
  1,
30963
+ 1
30964
+ ];
30965
+ var _ref = this.textureSheetAnimation ? [
30966
+ 0,
30967
+ 0,
30460
30968
  1,
30461
- this.splits[0][4]
30462
- ] : this.splits[0];
30463
- var uvTransform = split;
30464
- var x = uvTransform[0];
30465
- var y = uvTransform[1];
30466
- var isRotate90 = Boolean(uvTransform[4]);
30467
- var width = isRotate90 ? uvTransform[3] : uvTransform[2];
30468
- var height = isRotate90 ? uvTransform[2] : uvTransform[3];
30969
+ 1
30970
+ ] : [
30971
+ rect[0],
30972
+ rect[1],
30973
+ rect[2],
30974
+ rect[3]
30975
+ ], x = _ref[0], y = _ref[1], w = _ref[2], h = _ref[3];
30976
+ var isRotate90 = flip === SpriteRotation.Rotate90;
30977
+ var width = isRotate90 ? h : w;
30978
+ var height = isRotate90 ? w : h;
30469
30979
  var angle = isRotate90 ? -Math.PI / 2 : 0;
30470
30980
  var aUV = geometry.getAttributeData("aUV");
30471
30981
  var aPos = geometry.getAttributeData("aPos");
@@ -30502,11 +31012,51 @@ var SpriteComponent = /*#__PURE__*/ function(MaskableGraphic) {
30502
31012
  });
30503
31013
  }
30504
31014
  };
31015
+ _proto.fromData = function fromData(data) {
31016
+ MaskableGraphic.prototype.fromData.call(this, data); // MaskableGraphic: 设 renderer.texture(whiteTexture 或 data.renderer.texture)、_MainTex、_Color
31017
+ // 单 split / 新数据流:引用 Sprite 资产,渲染读 this.sprite
31018
+ if (data.sprite) {
31019
+ var sprite = this.engine.findObject(data.sprite);
31020
+ if (sprite) {
31021
+ this.applySpriteToRenderer(sprite);
31022
+ }
31023
+ }
31024
+ this.textureSheetAnimation = data.textureSheetAnimation;
31025
+ var geometry = data.geometry ? this.engine.findObject(data.geometry) : this.defaultGeometry;
31026
+ var splits = data.splits;
31027
+ if (splits && splits.length > 1) {
31028
+ // 原有打包纹理拆分逻辑(多 split,2x2 纹理打包),保留向后兼容;
31029
+ // 不依赖组件 splits 字段,直接用 data.splits。
31030
+ this.updateGeometryFromMultiSplit(splits);
31031
+ } else {
31032
+ this.updateGeometry(geometry);
31033
+ }
31034
+ this.interaction = data.interaction;
31035
+ var startColor = data.options.startColor || [
31036
+ 1,
31037
+ 1,
31038
+ 1,
31039
+ 1
31040
+ ];
31041
+ this.material.setColor("_Color", new Color().setFromArray(startColor));
31042
+ var _data_duration;
31043
+ //@ts-expect-error
31044
+ this.duration = (_data_duration = data.duration) != null ? _data_duration : this.item.duration;
31045
+ };
31046
+ /**
31047
+ * 应用 Sprite 资产到渲染器:同步纹理并重绑 _MainTex。不重建几何体。
31048
+ * fromData(后续自行 updateGeometry)与 sprite setter(随后 updateGeometry)共用。
31049
+ * 直接写 _sprite,避免经 setter 触发 updateGeometry。
31050
+ */ _proto.applySpriteToRenderer = function applySpriteToRenderer(sprite) {
31051
+ this._sprite = sprite;
31052
+ this.renderer.texture = sprite.texture;
31053
+ this.material.setTexture("_MainTex", sprite.texture);
31054
+ };
30505
31055
  /**
30506
31056
  * @deprecated
30507
- * 原有打包纹理拆分逻辑,待移除
30508
- */ _proto.updateGeometryFromMultiSplit = function updateGeometryFromMultiSplit() {
30509
- var _this = this, splits = _this.splits, textureSheetAnimation = _this.textureSheetAnimation;
31057
+ * 原有打包纹理拆分逻辑,仅在老数据 splits.length>1(2x2 纹理打包)时使用,保留向后兼容。
31058
+ * 不依赖组件状态,splits 由参数传入(同时存在帧动画与多 split 的数据不存在)。
31059
+ */ _proto.updateGeometryFromMultiSplit = function updateGeometryFromMultiSplit(splits) {
30510
31060
  var sx = 1, sy = 1;
30511
31061
  var geometry = this.defaultGeometry;
30512
31062
  var originData = [
@@ -30527,14 +31077,7 @@ var SpriteComponent = /*#__PURE__*/ function(MaskableGraphic) {
30527
31077
  for(var x = 0; x < col; x++){
30528
31078
  for(var y = 0; y < row; y++){
30529
31079
  var base = (y * 2 + x) * 4;
30530
- // @ts-expect-error
30531
- var split = textureSheetAnimation ? [
30532
- 0,
30533
- 0,
30534
- 1,
30535
- 1,
30536
- splits[0][4]
30537
- ] : splits[y * 2 + x];
31080
+ var split = splits[y * 2 + x];
30538
31081
  var texOffset = split[4] ? [
30539
31082
  0,
30540
31083
  0,
@@ -30580,33 +31123,21 @@ var SpriteComponent = /*#__PURE__*/ function(MaskableGraphic) {
30580
31123
  geometry.setAttributeData("aUV", new Float32Array(aUV));
30581
31124
  geometry.setDrawCount(index.length);
30582
31125
  };
30583
- _proto.fromData = function fromData(data) {
30584
- MaskableGraphic.prototype.fromData.call(this, data);
30585
- var _data_splits;
30586
- var splits = (_data_splits = data.splits) != null ? _data_splits : singleSplits;
30587
- var textureSheetAnimation = data.textureSheetAnimation;
30588
- this.splits = splits;
30589
- this.textureSheetAnimation = textureSheetAnimation;
30590
- var geometry = data.geometry ? this.engine.findObject(data.geometry) : this.defaultGeometry;
30591
- if (splits.length === 1) {
30592
- this.updateGeometry(geometry);
30593
- } else {
30594
- // TODO: 原有打包纹理拆分逻辑,待移除
30595
- //-------------------------------------------------------------------------
30596
- this.updateGeometryFromMultiSplit();
31126
+ _create_class(SpriteComponent, [
31127
+ {
31128
+ key: "sprite",
31129
+ get: /**
31130
+ * 当前 Sprite 资产。设置时同步纹理、重绑 _MainTex 并重建几何体 UV。
31131
+ * @since 2.10.0
31132
+ */ function get() {
31133
+ return this._sprite;
31134
+ },
31135
+ set: function set(sprite) {
31136
+ this.applySpriteToRenderer(sprite);
31137
+ this.updateGeometry(this.geometry);
31138
+ }
30597
31139
  }
30598
- this.interaction = data.interaction;
30599
- var startColor = data.options.startColor || [
30600
- 1,
30601
- 1,
30602
- 1,
30603
- 1
30604
- ];
30605
- this.material.setColor("_Color", new Color().setFromArray(startColor));
30606
- var _data_duration;
30607
- //@ts-expect-error
30608
- this.duration = (_data_duration = data.duration) != null ? _data_duration : this.item.duration;
30609
- };
31140
+ ]);
30610
31141
  return SpriteComponent;
30611
31142
  }(MaskableGraphic);
30612
31143
  SpriteComponent = __decorate([
@@ -30621,6 +31152,54 @@ var ParticleLoader = /*#__PURE__*/ function(Plugin) {
30621
31152
  return ParticleLoader;
30622
31153
  }(_wrap_native_super(Plugin));
30623
31154
 
31155
+ /**
31156
+ * 文本换行机会判定:UAX #14 风格的"换行机会"模型。
31157
+ *
31158
+ * - CJK 表意字 / 假名 / 韩文音节:任意两个字之间都是合法断点(字符级)
31159
+ * - 空格 / 制表符 / NBSP:可断,且断行时被吞掉(不留在行尾 / 行首)
31160
+ * - 西文字母 / 数字:词内不可断;整体超宽时由调用方退化到字符级断(overflow-wrap)
31161
+ *
31162
+ * 不含 kinsoku 禁则(句号 / 逗号不进行首等留作后续)。
31163
+ */ /** 换行机会类型(断点字符之后):决定断点字符归属及断行时是否吞掉 */ /**
31164
+ * 是否为可换行断点字符(空格 / 制表符 / NBSP)。
31165
+ * 断在此字符之前,且断行时该字符被吞掉(不进旧行也不进新行)。
31166
+ * @param ch - 当前字符
31167
+ */ function isBreakChar(ch) {
31168
+ return ch === " " || ch === " " || ch === "\xa0";
31169
+ }
31170
+ /**
31171
+ * 是否为 CJK 类字符(中文表意字 / 假名 / 韩文音节)。可在其与相邻字符之间换行。
31172
+ * 用码点判定以支持 CJK 扩展 B 等代理对字符(不能用 /u 正则,browserslist 为 iOS 9)。
31173
+ * @param ch - 当前字符(须为完整码点,调用方应使用 Array.from 遍历)
31174
+ */ function isCJKLike(ch) {
31175
+ var _ch_codePointAt;
31176
+ var cp = (_ch_codePointAt = ch.codePointAt(0)) != null ? _ch_codePointAt : 0;
31177
+ return cp >= 0x3400 && cp <= 0x4DBF || // CJK 统一表意扩展 A
31178
+ cp >= 0x4E00 && cp <= 0x9FFF || // CJK 统一表意
31179
+ cp >= 0xF900 && cp <= 0xFAFF || // CJK 兼容表意
31180
+ cp >= 0x20000 && cp <= 0x2FA1F || // CJK 扩展 B~F + 兼容增补(代理对)
31181
+ cp >= 0x3040 && cp <= 0x309F || // 平假名
31182
+ cp >= 0x30A0 && cp <= 0x30FF || // 片假名
31183
+ cp >= 0x31F0 && cp <= 0x31FF || // 片假名语音扩展
31184
+ cp >= 0xAC00 && cp <= 0xD7AF // 韩文音节
31185
+ ;
31186
+ }
31187
+ /**
31188
+ * 计算 prev(已推入的字符)之后是否为换行机会。只看 prev,不看后续字符。
31189
+ * @param prev - 前一字符(已推入旧行)
31190
+ * @returns 'swallow'=prev 是空格类,断行时吞掉 prev;'keep'=prev 是 CJK,prev 留本行末、下行从其后起;false=不可断
31191
+ */ function breakOpportunityAfter(prev) {
31192
+ // prev 是空格类 → 断在 prev 处,断行时吞掉 prev(不进旧行也不进新行)
31193
+ if (isBreakChar(prev)) {
31194
+ return "swallow";
31195
+ }
31196
+ // prev 是 CJK → prev 留本行末,下行从 prev 之后起(字符级断点,不吞)
31197
+ if (isCJKLike(prev)) {
31198
+ return "keep";
31199
+ }
31200
+ return false;
31201
+ }
31202
+
30624
31203
  var TextLayout = /*#__PURE__*/ function() {
30625
31204
  function TextLayout(options) {
30626
31205
  this.width = 0;
@@ -31069,9 +31648,6 @@ var DEFAULT_FONTS = [
31069
31648
  "courier"
31070
31649
  ];
31071
31650
  /** 检测字符串是否包含需要 RTL 和连写排版的字符(阿拉伯语等) */ var HAS_RTL_OR_JOINING = /[\u0600-\u06FF\u0750-\u077F\u08A0-\u08FF\uFB50-\uFDFF\uFE70-\uFEFF]/;
31072
- /** 可换行断点:空格、制表符等 */ var IS_BREAK_CHAR = function(ch) {
31073
- return ch === " " || ch === " " || ch === "\xa0";
31074
- };
31075
31651
  var seed$1 = 0;
31076
31652
  var TextComponent = /*#__PURE__*/ function(MaskableGraphic) {
31077
31653
  _inherits(TextComponent, MaskableGraphic);
@@ -31171,13 +31747,15 @@ var TextComponent = /*#__PURE__*/ function(MaskableGraphic) {
31171
31747
  var lineCount = 1;
31172
31748
  var x = 0;
31173
31749
  var charCountInLine = 0;
31750
+ // 使用码点遍历,正确处理 emoji 与 CJK 扩展 B 等代理对字符
31751
+ var chars = Array.from(text);
31174
31752
  if (context) {
31175
31753
  context.font = this.getFontDesc(this.textStyle.fontSize);
31176
31754
  }
31177
31755
  if (overflow === TextOverflow.display) {
31178
- for(var i = 0; i < text.length; i++){
31756
+ for(var _iterator = _create_for_of_iterator_helper_loose(chars), _step; !(_step = _iterator()).done;){
31757
+ var str = _step.value;
31179
31758
  var _context_measureText;
31180
- var str = text[i];
31181
31759
  var _context_measureText_width;
31182
31760
  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;
31183
31761
  if (str === "\n") {
@@ -31196,12 +31774,12 @@ var TextComponent = /*#__PURE__*/ function(MaskableGraphic) {
31196
31774
  return lineCount;
31197
31775
  }
31198
31776
  if (this.textLayout.keepWordIntact) {
31199
- // 单词完整换行:优先在空格处断行,避免从单词中间断开
31777
+ // 单词完整换行:优先在换行机会处断行(空格吞断 / CJK 字间可断),避免从西文词中间断开
31200
31778
  var lastBreakX = 0;
31201
31779
  var countAtBreak = 0;
31202
- for(var i1 = 0; i1 < text.length; i1++){
31780
+ for(var _iterator1 = _create_for_of_iterator_helper_loose(chars), _step1; !(_step1 = _iterator1()).done;){
31781
+ var str1 = _step1.value;
31203
31782
  var _context_measureText1;
31204
- var str1 = text[i1];
31205
31783
  var _context_measureText_width1;
31206
31784
  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;
31207
31785
  if (str1 === "\n") {
@@ -31234,22 +31812,23 @@ var TextComponent = /*#__PURE__*/ function(MaskableGraphic) {
31234
31812
  }
31235
31813
  x += textMetrics1;
31236
31814
  charCountInLine++;
31237
- if (IS_BREAK_CHAR(str1)) {
31815
+ // 记换行机会:str 之后可断(空格 swallow / CJK keep)。lastBreakX 含 str 宽度(str 留本行末)
31816
+ if (breakOpportunityAfter(str1) !== false) {
31238
31817
  lastBreakX = x;
31239
31818
  countAtBreak = charCountInLine;
31240
31819
  }
31241
31820
  }
31242
31821
  } else {
31243
31822
  // 逐字符换行:允许在任意字符处断开
31244
- for(var i2 = 0; i2 < text.length; i2++){
31823
+ for(var i = 0; i < chars.length; i++){
31245
31824
  var _context_measureText2;
31246
- var str2 = text[i2];
31825
+ var str2 = chars[i];
31247
31826
  var _context_measureText_width2;
31248
31827
  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;
31249
31828
  if (charCountInLine > 0) {
31250
31829
  x += letterSpace;
31251
31830
  }
31252
- if (x + textMetrics2 > width && i2 > 0 || str2 === "\n") {
31831
+ if (x + textMetrics2 > width && i > 0 || str2 === "\n") {
31253
31832
  lineCount++;
31254
31833
  this.maxLineWidth = Math.max(this.maxLineWidth, x);
31255
31834
  x = 0;
@@ -31342,8 +31921,11 @@ var TextComponent = /*#__PURE__*/ function(MaskableGraphic) {
31342
31921
  var charsArray = [];
31343
31922
  var charOffsetX = [];
31344
31923
  if (layout.keepWordIntact) {
31345
- // 单词完整换行:优先在空格处断行,避免从单词中间断开
31924
+ // 单词完整换行:优先在换行机会处断行(空格吞断 / CJK 字间可断),避免从西文词中间断开。
31925
+ // lastBreakIdx 指向断点字符在 charsArray 中的索引;breakSwallow=true 时该字符被吞(空格),
31926
+ // false 时该字符留本行末(CJK),下行均从 lastBreakIdx+1 起。
31346
31927
  var lastBreakIdx = -1;
31928
+ var breakSwallow = false;
31347
31929
  for(var i = 0; i < char.length; i++){
31348
31930
  var str = char[i];
31349
31931
  var textMetrics = context.measureText(str);
@@ -31359,15 +31941,18 @@ var TextComponent = /*#__PURE__*/ function(MaskableGraphic) {
31359
31941
  charsArray = [];
31360
31942
  charOffsetX = [];
31361
31943
  lastBreakIdx = -1;
31944
+ breakSwallow = false;
31362
31945
  continue;
31363
31946
  }
31364
31947
  var spacing = charsArray.length > 0 ? layout.letterSpace : 0;
31365
31948
  var willWidth = x + spacing + textMetrics.width;
31366
31949
  if (willWidth > baseWidth && charsArray.length > 0) {
31367
31950
  if (lastBreakIdx > 0) {
31368
- // 在空格处换行
31369
- var lineChars = charsArray.slice(0, lastBreakIdx);
31370
- var lineOffsets = charOffsetX.slice(0, lastBreakIdx);
31951
+ // 在换行机会处断行:swallow 取 [0,lastBreakIdx)(吞掉断点字符),
31952
+ // keep [0,lastBreakIdx](断点字符留本行末),下行均从 lastBreakIdx+1 起。
31953
+ var endIdx = breakSwallow ? lastBreakIdx : lastBreakIdx + 1;
31954
+ var lineChars = charsArray.slice(0, endIdx);
31955
+ var lineOffsets = charOffsetX.slice(0, endIdx);
31371
31956
  var lineWidth = lineChars.length > 0 ? lineOffsets[lineOffsets.length - 1] + context.measureText(lineChars[lineChars.length - 1]).width : 0;
31372
31957
  charsInfo.push({
31373
31958
  y: y,
@@ -31388,6 +31973,7 @@ var TextComponent = /*#__PURE__*/ function(MaskableGraphic) {
31388
31973
  x += context.measureText(charsArray[j]).width;
31389
31974
  }
31390
31975
  lastBreakIdx = -1;
31976
+ breakSwallow = false;
31391
31977
  } else {
31392
31978
  charsInfo.push({
31393
31979
  y: y,
@@ -31400,6 +31986,7 @@ var TextComponent = /*#__PURE__*/ function(MaskableGraphic) {
31400
31986
  charsArray = [];
31401
31987
  charOffsetX = [];
31402
31988
  lastBreakIdx = -1;
31989
+ breakSwallow = false;
31403
31990
  }
31404
31991
  }
31405
31992
  if (charsArray.length > 0) {
@@ -31408,8 +31995,12 @@ var TextComponent = /*#__PURE__*/ function(MaskableGraphic) {
31408
31995
  charOffsetX.push(x);
31409
31996
  charsArray.push(str);
31410
31997
  x += textMetrics.width;
31411
- if (IS_BREAK_CHAR(str)) {
31998
+ // 记换行机会:str 之后可断。lastBreakIdx 指向 str(charsArray 末尾),
31999
+ // swallow=吞 str(空格),keep=str 留本行末(CJK)。
32000
+ var opp = breakOpportunityAfter(str);
32001
+ if (opp !== false) {
31412
32002
  lastBreakIdx = charsArray.length - 1;
32003
+ breakSwallow = opp === "swallow";
31413
32004
  }
31414
32005
  }
31415
32006
  } else {
@@ -33359,7 +33950,6 @@ var ShapeComponent = /*#__PURE__*/ function(RendererComponent) {
33359
33950
  var material = Material.create(this.engine, materialProps);
33360
33951
  var renderer = rendererOptions;
33361
33952
  var side = renderer.side, occlusion = renderer.occlusion, blendMode = renderer.blending, texture = renderer.texture;
33362
- var maskMode = this.maskManager.maskMode;
33363
33953
  material.blending = true;
33364
33954
  material.depthTest = true;
33365
33955
  material.depthMask = occlusion;
@@ -33373,7 +33963,6 @@ var ShapeComponent = /*#__PURE__*/ function(RendererComponent) {
33373
33963
  texParams.x = renderer.occlusion ? +renderer.transparentOcclusion : 1;
33374
33964
  texParams.y = preMultiAlpha;
33375
33965
  texParams.z = renderer.renderMode;
33376
- texParams.w = maskMode;
33377
33966
  material.setVector4("_TexParams", texParams);
33378
33967
  if (texParams.x === 0 || this.maskManager.alphaMaskEnabled) {
33379
33968
  material.enableMacro("ALPHA_CLIP");
@@ -33396,9 +33985,9 @@ var ShapeComponent = /*#__PURE__*/ function(RendererComponent) {
33396
33985
  blending: (_renderer_blending = renderer.blending) != null ? _renderer_blending : BlendingMode.ALPHA,
33397
33986
  texture: renderer.texture ? this.engine.findObject(renderer.texture) : this.engine.whiteTexture,
33398
33987
  occlusion: !!renderer.occlusion,
33399
- transparentOcclusion: !!renderer.transparentOcclusion || this.maskManager.maskMode === MaskMode.MASK,
33988
+ transparentOcclusion: !!renderer.transparentOcclusion || this.maskManager.isMask,
33400
33989
  side: (_renderer_side = renderer.side) != null ? _renderer_side : SideMode.DOUBLE,
33401
- mask: this.maskManager.getRefValue()
33990
+ mask: 1
33402
33991
  };
33403
33992
  var _data_strokeCap;
33404
33993
  this.strokeCap = (_data_strokeCap = data.strokeCap) != null ? _data_strokeCap : LineCap.Butt;
@@ -34380,7 +34969,7 @@ function getStandardInteractContent(ui) {
34380
34969
  return ret;
34381
34970
  }
34382
34971
 
34383
- var currentMaskComponent;
34972
+ var currentMaskComponentId;
34384
34973
  var componentMap = new Map();
34385
34974
  var itemMap = new Map();
34386
34975
  /**
@@ -35042,12 +35631,21 @@ function version36Migration(json) {
35042
35631
  for(var _iterator3 = _create_for_of_iterator_helper_loose(json.compositions), _step3; !(_step3 = _iterator3()).done;){
35043
35632
  var composition = _step3.value;
35044
35633
  composition.children = [];
35634
+ currentMaskComponentId = undefined;
35635
+ //@ts-expect-error
35636
+ var legacyCompositionItems = composition.items;
35637
+ if (Array.isArray(legacyCompositionItems)) {
35638
+ processMaskReferenceItems(legacyCompositionItems, itemMap, componentMap);
35639
+ }
35045
35640
  for(var _iterator4 = _create_for_of_iterator_helper_loose(composition.components), _step4; !(_step4 = _iterator4()).done;){
35046
35641
  var componentDataPath = _step4.value;
35047
35642
  var componentData = componentMap.get(componentDataPath.id);
35048
35643
  if (componentData.dataType === DataType.CompositionComponent) {
35049
35644
  var compositionComponent = componentData;
35050
- for(var _iterator5 = _create_for_of_iterator_helper_loose(compositionComponent.items), _step5; !(_step5 = _iterator5()).done;){
35645
+ var _compositionComponent_items;
35646
+ var compositionItems = (_compositionComponent_items = compositionComponent.items) != null ? _compositionComponent_items : [];
35647
+ processMaskReferenceItems(compositionItems, itemMap, componentMap);
35648
+ for(var _iterator5 = _create_for_of_iterator_helper_loose(compositionItems), _step5; !(_step5 = _iterator5()).done;){
35051
35649
  var itemPath = _step5.value;
35052
35650
  var item1 = itemMap.get(itemPath.id);
35053
35651
  if (item1.parentId === undefined) {
@@ -35077,6 +35675,72 @@ function version36Migration(json) {
35077
35675
  json.version = JSONSceneVersion["3_7"];
35078
35676
  return json;
35079
35677
  }
35678
+ /**
35679
+ * 3.8 数据适配:SpriteComponent 的 renderer.texture + splits 迁移为独立 Sprite 资产。
35680
+ *
35681
+ * - 遍历所有未引用 sprite 的 SpriteComponentData,按 splits[0](无则整图 [0,0,1,1])生成
35682
+ * Sprite 资产对象放入 miscs,并把组件的 sprite 指向它。
35683
+ * - 删除组件的 splits 与 renderer.texture(纹理归属 sprite,renderer 仅保留渲染状态)。
35684
+ * - 卫语句 `if (sc.sprite) continue` 处理混合数据(部分组件已用 sprite)。
35685
+ * - 多 split(splits.length>1,2x2 纹理打包)保留原 splits 不迁移,仍走 updateGeometryFromMultiSplit 旧路径。
35686
+ *
35687
+ * 由 getStandardJSON 以 `minorVersion < 8` 守卫调用,数据生命周期内只跑一次。
35688
+ * version 字段设为字符串 '3.8'(JSONSceneVersion 枚举无此值,运行时不依赖枚举)。
35689
+ */ function version37Migration(json) {
35690
+ var _json;
35691
+ var _miscs;
35692
+ (_miscs = (_json = json).miscs) != null ? _miscs : _json.miscs = [];
35693
+ for(var _iterator = _create_for_of_iterator_helper_loose(json.components), _step; !(_step = _iterator()).done;){
35694
+ var component = _step.value;
35695
+ var _sc_renderer;
35696
+ if (component.dataType !== DataType.SpriteComponent) {
35697
+ continue;
35698
+ }
35699
+ // 本地扩展 sprite 字段(spec 包不可改)。ComponentData 是 SpriteComponentData 的超集,
35700
+ // 故直接当 SpriteComponentData 用;sprite 需要写到对象上,用宽松类型承载。
35701
+ var sc = component;
35702
+ if (sc.sprite) {
35703
+ continue; // 已迁移/新数据
35704
+ }
35705
+ var splits = sc.splits;
35706
+ if (splits && splits.length > 1) {
35707
+ continue;
35708
+ }
35709
+ var first = splits == null ? void 0 : splits[0];
35710
+ var rect = first ? [
35711
+ first[0],
35712
+ first[1],
35713
+ first[2],
35714
+ first[3]
35715
+ ] : [
35716
+ 0,
35717
+ 0,
35718
+ 1,
35719
+ 1
35720
+ ];
35721
+ var _first_;
35722
+ // rotation: 0=None 不旋转, 1=Rotate90(值与 Sprite.SpriteRotation 枚举一致,序列化兼容)
35723
+ var rotation = (_first_ = first == null ? void 0 : first[4]) != null ? _first_ : 0;
35724
+ var spriteData = {
35725
+ id: generateGUID(),
35726
+ dataType: "Sprite",
35727
+ // 可能为 undefined(纯色元素)→ Sprite.fromData 兜底 whiteTexture
35728
+ texture: (_sc_renderer = sc.renderer) == null ? void 0 : _sc_renderer.texture,
35729
+ rect: rect,
35730
+ rotation: rotation
35731
+ };
35732
+ json.miscs.push(spriteData);
35733
+ sc.sprite = {
35734
+ id: spriteData.id
35735
+ };
35736
+ delete sc.splits;
35737
+ if (sc.renderer) {
35738
+ delete sc.renderer.texture; // 纹理归属 sprite,renderer 仅保留渲染状态
35739
+ }
35740
+ }
35741
+ json.version = "3.8";
35742
+ return json;
35743
+ }
35080
35744
  /**
35081
35745
  * 确保文本组件有版本标识字段
35082
35746
  */ function ensureTextVerticalAlign(options) {
@@ -35187,6 +35851,21 @@ function processContent(composition) {
35187
35851
  }
35188
35852
  }
35189
35853
  }
35854
+ function processMaskReferenceItems(items, itemMap, componentMap) {
35855
+ for(var _iterator = _create_for_of_iterator_helper_loose(items), _step; !(_step = _iterator()).done;){
35856
+ var item = _step.value;
35857
+ var itemProps = itemMap.get(item.id);
35858
+ if (!itemProps) {
35859
+ continue;
35860
+ }
35861
+ 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) {
35862
+ var component = componentMap.get(itemProps.components[0].id);
35863
+ if (component) {
35864
+ processMaskReference(component);
35865
+ }
35866
+ }
35867
+ }
35868
+ }
35190
35869
  function processMask(renderContent) {
35191
35870
  var renderer = renderContent.renderer;
35192
35871
  var maskMode = renderer == null ? void 0 : renderer.maskMode;
@@ -35197,16 +35876,34 @@ function processMask(renderContent) {
35197
35876
  renderContent.mask = {
35198
35877
  isMask: true
35199
35878
  };
35200
- currentMaskComponent = renderContent.id;
35879
+ currentMaskComponentId = renderContent.id;
35201
35880
  } else if (maskMode === ObscuredMode.OBSCURED || maskMode === ObscuredMode.REVERSE_OBSCURED) {
35202
35881
  renderContent.mask = {
35203
35882
  inverted: maskMode === ObscuredMode.REVERSE_OBSCURED ? true : false,
35204
35883
  reference: {
35205
- "id": currentMaskComponent
35884
+ "id": currentMaskComponentId
35206
35885
  }
35207
35886
  };
35208
35887
  }
35209
35888
  }
35889
+ function processMaskReference(renderContent) {
35890
+ var mask = renderContent.mask;
35891
+ if (mask && !mask.references && mask.reference) {
35892
+ var _mask_isMask, _mask_alphaMaskEnabled, _mask_inverted;
35893
+ // 处理旧版 mask 格式(mask.reference 和 mask.inverted 字段)
35894
+ // 将旧版单蒙版格式转换为 references 数组
35895
+ renderContent.mask = {
35896
+ isMask: (_mask_isMask = mask.isMask) != null ? _mask_isMask : false,
35897
+ alphaMaskEnabled: (_mask_alphaMaskEnabled = mask.alphaMaskEnabled) != null ? _mask_alphaMaskEnabled : false,
35898
+ references: [
35899
+ {
35900
+ mask: mask.reference,
35901
+ inverted: (_mask_inverted = mask.inverted) != null ? _mask_inverted : false
35902
+ }
35903
+ ]
35904
+ };
35905
+ }
35906
+ }
35210
35907
  function convertParam(content) {
35211
35908
  if (!content) {
35212
35909
  return;
@@ -35881,7 +36578,7 @@ function getStandardSpriteContent(sprite, transform) {
35881
36578
  return ret;
35882
36579
  }
35883
36580
 
35884
- var version$1 = "2.10.0-alpha.0";
36581
+ var version$1 = "2.10.0-alpha.1";
35885
36582
  var v0 = /^(\d+)\.(\d+)\.(\d+)(-(\w+)\.\d+)?$/;
35886
36583
  var standardVersion = /^(\d+)\.(\d+)$/;
35887
36584
  var reverseParticle = false;
@@ -35899,7 +36596,7 @@ function getStandardJSON(json) {
35899
36596
  if (v0.test(json.version)) {
35900
36597
  var _exec;
35901
36598
  reverseParticle = ((_exec = /^(\d+)/.exec(json.version)) == null ? void 0 : _exec[0]) === "0";
35902
- return version36Migration(version35Migration(version34Migration(version33Migration(version32Migration(version31Migration(version30Migration(version21Migration(getStandardJSONFromV0(json)))))))));
36599
+ return version37Migration(version36Migration(version35Migration(version34Migration(version33Migration(version32Migration(version31Migration(version30Migration(version21Migration(getStandardJSONFromV0(json))))))))));
35903
36600
  }
35904
36601
  reverseParticle = false;
35905
36602
  var vs = standardVersion.exec(json.version) || [];
@@ -35936,6 +36633,9 @@ function getStandardJSON(json) {
35936
36633
  if (minorVersion < 7) {
35937
36634
  json = version36Migration(json);
35938
36635
  }
36636
+ if (minorVersion < 8) {
36637
+ json = version37Migration(json);
36638
+ }
35939
36639
  }
35940
36640
  return json;
35941
36641
  }
@@ -36394,11 +37094,15 @@ var seed = 1;
36394
37094
  var _proto = AssetManager.prototype;
36395
37095
  _proto.updateOptions = function updateOptions(options) {
36396
37096
  if (options === void 0) options = {};
36397
- this.options = options;
36398
- if (!options.pluginData) {
36399
- options.pluginData = {};
37097
+ var _options_useCompressedTexture, _options_useHevcVideo;
37098
+ this.options = _extends({}, options, {
37099
+ useCompressedTexture: (_options_useCompressedTexture = options.useCompressedTexture) != null ? _options_useCompressedTexture : true,
37100
+ useHevcVideo: (_options_useHevcVideo = options.useHevcVideo) != null ? _options_useHevcVideo : true
37101
+ });
37102
+ if (!this.options.pluginData) {
37103
+ this.options.pluginData = {};
36400
37104
  }
36401
- var _options_timeout = options.timeout, timeout = _options_timeout === void 0 ? 10 : _options_timeout;
37105
+ var _this_options = this.options, _this_options_timeout = _this_options.timeout, timeout = _this_options_timeout === void 0 ? 10 : _this_options_timeout;
36402
37106
  this.timeout = timeout;
36403
37107
  };
36404
37108
  /**
@@ -36656,12 +37360,19 @@ var seed = 1;
36656
37360
  if (canUseKTX2 === void 0) canUseKTX2 = false;
36657
37361
  var _this = this;
36658
37362
  return _async_to_generator(function() {
36659
- var _this_options, useCompressedTexture, variables, disableWebP, disableAVIF, baseUrl, jobs, loadedImages;
37363
+ var _this_options, useCompressedTexture, variables, disableWebP, disableAVIF, isKTX2PluginRegistered, canUseCompressedTexture, baseUrl, jobs, loadedImages;
36660
37364
  return __generator(this, function(_state) {
36661
37365
  switch(_state.label){
36662
37366
  case 0:
36663
37367
  _this_options = _this.options, useCompressedTexture = _this_options.useCompressedTexture, variables = _this_options.variables, disableWebP = _this_options.disableWebP, disableAVIF = _this_options.disableAVIF;
37368
+ isKTX2PluginRegistered = !!pluginLoaderMap.ktx2;
37369
+ canUseCompressedTexture = useCompressedTexture && canUseKTX2 && isKTX2PluginRegistered;
36664
37370
  baseUrl = _this.baseUrl;
37371
+ if (useCompressedTexture && canUseKTX2 && !isKTX2PluginRegistered && images.some(function(img) {
37372
+ return "ktx2" in img && img.ktx2;
37373
+ })) {
37374
+ logger.warn("The plugin 'ktx2' is not found, unable to use compressed textures." + getPluginUsageInfo("ktx2"));
37375
+ }
36665
37376
  jobs = images.map(/*#__PURE__*/ _async_to_generator(function(img, idx) {
36666
37377
  var png, webp, avif, ktx2, imageURL, webpURL, avifURL, ktx2URL, id, template, background, url, isVideo, loadFn, resultImage, e, _ref, url1, image, _tmp;
36667
37378
  return __generator(this, function(_state) {
@@ -36676,7 +37387,7 @@ var seed = 1;
36676
37387
  // eslint-disable-next-line compat/compat
36677
37388
  avifURL = !disableAVIF && avif ? new URL(avif, baseUrl).href : undefined;
36678
37389
  // eslint-disable-next-line compat/compat
36679
- ktx2URL = ktx2 && useCompressedTexture && canUseKTX2 ? new URL(ktx2, baseUrl).href : undefined;
37390
+ ktx2URL = ktx2 && canUseCompressedTexture ? new URL(ktx2, baseUrl).href : undefined;
36680
37391
  id = img.id;
36681
37392
  if (!("template" in img)) return [
36682
37393
  3,
@@ -36828,7 +37539,7 @@ var seed = 1;
36828
37539
  case 0:
36829
37540
  return [
36830
37541
  4,
36831
- PluginSystem.onAssetsLoadStart(scene, _this.options)
37542
+ PluginSystem.notifyAssetsLoadStart(scene, _this.options)
36832
37543
  ];
36833
37544
  case 1:
36834
37545
  _state.sent();
@@ -37910,7 +38621,7 @@ var PreRenderTickData = /*#__PURE__*/ function(TickData) {
37910
38621
  _this.onItemMessage = onItemMessage;
37911
38622
  }
37912
38623
  _this.createRenderFrame();
37913
- PluginSystem.initializeComposition(_assert_this_initialized(_this), scene);
38624
+ PluginSystem.notifyCompositionCreated(_assert_this_initialized(_this), scene);
37914
38625
  return _this;
37915
38626
  }
37916
38627
  var _proto = Composition.prototype;
@@ -38274,18 +38985,13 @@ var PreRenderTickData = /*#__PURE__*/ function(TickData) {
38274
38985
  // }
38275
38986
  };
38276
38987
  _proto.lost = function lost(e) {
38277
- this.videoState = this.textures.map(function(tex) {
38278
- if ("video" in tex.source) {
38279
- tex.source.video.pause();
38280
- return tex.source.video.currentTime;
38281
- }
38282
- });
38283
- this.textures.map(function(tex) {
38284
- return tex.dispose();
38285
- });
38286
- this.dispose();
38988
+ // GPU 资源由引擎统一 rebuild,合成仅保留纯 JS 运行时状态,此处无需处理。
38287
38989
  };
38288
38990
  /**
38991
+ * 上下文恢复后的空操作。
38992
+ * GPU 资源已由引擎统一重建,视频纹理会在下次渲染时自然更新,不自动重新播放。
38993
+ */ _proto.restore = function restore() {};
38994
+ /**
38289
38995
  * 合成对象销毁
38290
38996
  */ _proto.dispose = function dispose() {
38291
38997
  var _this = this;
@@ -38310,7 +39016,7 @@ var PreRenderTickData = /*#__PURE__*/ function(TickData) {
38310
39016
  this.root.dispose();
38311
39017
  // FIXME: 注意这里增加了renderFrame销毁
38312
39018
  this.renderFrame.dispose();
38313
- PluginSystem.destroyComposition(this);
39019
+ PluginSystem.notifyCompositionDestroy(this);
38314
39020
  this.update = function() {
38315
39021
  {
38316
39022
  logger.error("Update disposed composition: " + _this.name + ".");
@@ -40224,12 +40930,20 @@ var DEFAULT_FPS = 60;
40224
40930
  * 计时器
40225
40931
  * 手动渲染 `manualRender=true` 时不创建计时器
40226
40932
  */ _this.ticker = null;
40933
+ /**
40934
+ * 是否不处理上下文丢失恢复(构造期配置,默认 true)
40935
+ */ _this.doNotHandleContextLost = true;
40936
+ /**
40937
+ * WebGL 上下文是否处于丢失状态
40938
+ */ _this.contextWasLost = false;
40227
40939
  _this._disposed = false;
40228
40940
  _this.textures = [];
40229
40941
  _this.materials = [];
40230
40942
  _this.geometries = [];
40231
40943
  _this.meshes = [];
40232
40944
  _this.renderPasses = [];
40945
+ _this.framebuffers = [];
40946
+ _this.renderbuffers = [];
40233
40947
  _this.clearAction = {
40234
40948
  stencilAction: TextureLoadAction.clear,
40235
40949
  clearStencil: 0,
@@ -40246,6 +40960,8 @@ var DEFAULT_FPS = 60;
40246
40960
  _this.canvas = canvas;
40247
40961
  var _options_env;
40248
40962
  _this.env = (_options_env = options == null ? void 0 : options.env) != null ? _options_env : "";
40963
+ var _options_doNotHandleContextLost;
40964
+ _this.doNotHandleContextLost = (_options_doNotHandleContextLost = options == null ? void 0 : options.doNotHandleContextLost) != null ? _options_doNotHandleContextLost : true;
40249
40965
  var _options_name;
40250
40966
  _this.name = (_options_name = options == null ? void 0 : options.name) != null ? _options_name : _this.name;
40251
40967
  var _options_pixelRatio;
@@ -40271,6 +40987,7 @@ var DEFAULT_FPS = 60;
40271
40987
  // @ts-expect-error
40272
40988
  currentFrame: {}
40273
40989
  };
40990
+ PluginSystem.notifyEngineCreated(_assert_this_initialized(_this));
40274
40991
  return _this;
40275
40992
  }
40276
40993
  var _proto = Engine.prototype;
@@ -40370,6 +41087,10 @@ var DEFAULT_FPS = 60;
40370
41087
  (_this_ticker = this.ticker) == null ? void 0 : _this_ticker.add(renderFunction);
40371
41088
  };
40372
41089
  _proto.mainLoop = function mainLoop(dt) {
41090
+ // 上下文丢失/恢复期间跳过渲染,避免打到失效的 GL 上下文。
41091
+ if (this.contextWasLost) {
41092
+ return;
41093
+ }
40373
41094
  var renderErrors = this.renderErrors;
40374
41095
  if (renderErrors.size > 0) {
40375
41096
  var // 有渲染错误时暂停播放
@@ -40582,6 +41303,30 @@ var DEFAULT_FPS = 60;
40582
41303
  }
40583
41304
  removeItem(this.renderPasses, pass);
40584
41305
  };
41306
+ _proto.addFramebuffer = function addFramebuffer(framebuffer) {
41307
+ if (this.disposed) {
41308
+ return;
41309
+ }
41310
+ addItem(this.framebuffers, framebuffer);
41311
+ };
41312
+ _proto.removeFramebuffer = function removeFramebuffer(framebuffer) {
41313
+ if (this.disposed) {
41314
+ return;
41315
+ }
41316
+ removeItem(this.framebuffers, framebuffer);
41317
+ };
41318
+ _proto.addRenderbuffer = function addRenderbuffer(renderbuffer) {
41319
+ if (this.disposed) {
41320
+ return;
41321
+ }
41322
+ addItem(this.renderbuffers, renderbuffer);
41323
+ };
41324
+ _proto.removeRenderbuffer = function removeRenderbuffer(renderbuffer) {
41325
+ if (this.disposed) {
41326
+ return;
41327
+ }
41328
+ removeItem(this.renderbuffers, renderbuffer);
41329
+ };
40585
41330
  _proto.addComposition = function addComposition(composition) {
40586
41331
  if (this.disposed) {
40587
41332
  return;
@@ -40691,6 +41436,7 @@ var DEFAULT_FPS = 60;
40691
41436
  return;
40692
41437
  }
40693
41438
  this._disposed = true;
41439
+ PluginSystem.notifyEngineDestroy(this);
40694
41440
  var info = [];
40695
41441
  if (this.renderPasses.length > 0) {
40696
41442
  info.push("Pass " + this.renderPasses.length);
@@ -40866,8 +41612,8 @@ var PassTextureCache = /*#__PURE__*/ function() {
40866
41612
  case 1:
40867
41613
  loadedScene = _state.sent();
40868
41614
  engine.clearResources();
40869
- // 触发插件系统 pluginSystem 的回调 onAssetsLoadFinish
40870
- PluginSystem.onAssetsLoadFinish(loadedScene, assetManager.options, engine);
41615
+ // 通过 PluginSystem.notifyAssetsLoadFinish 通知所有插件的 onAssetsLoadFinish 回调
41616
+ PluginSystem.notifyAssetsLoadFinish(loadedScene, assetManager.options, engine);
40871
41617
  engine.assetService.prepareAssets(loadedScene, loadedScene.assets);
40872
41618
  engine.assetService.updateTextVariables(loadedScene, options.variables);
40873
41619
  composition = _this.createComposition(loadedScene, engine, options);
@@ -40928,8 +41674,8 @@ var PrecompositionManager = /*#__PURE__*/ function() {
40928
41674
  var options = precomposition.options;
40929
41675
  var engine = composition.engine;
40930
41676
  engine.clearResources();
40931
- // 触发插件系统 pluginSystem 的回调 onAssetsLoadFinish
40932
- PluginSystem.onAssetsLoadFinish(scene, options, engine);
41677
+ // 通过 PluginSystem.notifyAssetsLoadFinish 通知所有插件的 onAssetsLoadFinish 回调
41678
+ PluginSystem.notifyAssetsLoadFinish(scene, options, engine);
40933
41679
  engine.assetService.prepareAssets(scene, scene.assets);
40934
41680
  engine.assetService.updateTextVariables(scene, options.variables);
40935
41681
  composition.createTexturesFromData(scene.textureOptions);
@@ -40969,8 +41715,8 @@ registerPlugin("text", TextLoader);
40969
41715
  registerPlugin("sprite", SpriteLoader);
40970
41716
  registerPlugin("particle", ParticleLoader);
40971
41717
  registerPlugin("interact", InteractLoader);
40972
- var version = "2.10.0-alpha.0";
41718
+ var version = "2.10.0-alpha.1";
40973
41719
  logger.info("Core version: " + version + ".");
40974
41720
 
40975
- 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, 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, TangentMode, TextCache, TextComponent, TextComponentBase, TextLayout, TextLoader, TextStyle, Texture, TextureFactory, TextureLoadAction, TexturePaintScaleMode, TextureSourceType, TextureStoreAction, 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, sortByOrder, index$1 as spec, textureLoaderRegistry, thresholdFrag, throwDestroyedError, trailVert, translatePoint, trianglesFromRect, unregisterPlugin, valIfUndefined, value, valueDefine, vecFill, vecMulCombine, version, vertexFormatType2GLType };
41721
+ 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, 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, TangentMode, TextCache, TextComponent, TextComponentBase, TextLayout, TextLoader, TextStyle, Texture, TextureFactory, TextureLoadAction, TexturePaintScaleMode, TextureSourceType, TextureStoreAction, 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, sortByOrder, index$1 as spec, textureLoaderRegistry, thresholdFrag, throwDestroyedError, trailVert, translatePoint, trianglesFromRect, unregisterPlugin, valIfUndefined, value, valueDefine, vecFill, vecMulCombine, version, vertexFormatType2GLType };
40976
41722
  //# sourceMappingURL=index.mjs.map