@galacean/effects-core 2.8.7 → 2.8.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@
3
3
  * Description: Galacean Effects runtime core for the web
4
4
  * Author: Ant Group CO., Ltd.
5
5
  * Contributors: 燃然,飂兮,十弦,云垣,茂安,意绮
6
- * Version: v2.8.7
6
+ * Version: v2.8.9
7
7
  */
8
8
 
9
9
  'use strict';
@@ -17845,14 +17845,14 @@ exports.CompositionComponent = /*#__PURE__*/ function(Component) {
17845
17845
  }
17846
17846
  }
17847
17847
  }
17848
- if (exports.VFXItem.isComposition(hitTestItem)) {
17849
- if (hitTestItem.getComponent(CompositionComponent).hitTest(ray, x, y, regions, force, options)) {
17850
- hitTestSuccess = true;
17851
- }
17852
- } else {
17853
- if (_this.hitTestRecursive(hitTestItem, ray, x, y, regions, force, options)) {
17854
- hitTestSuccess = true;
17855
- }
17848
+ }
17849
+ if (exports.VFXItem.isComposition(hitTestItem)) {
17850
+ if (hitTestItem.getComponent(CompositionComponent).hitTest(ray, x, y, regions, force, options)) {
17851
+ hitTestSuccess = true;
17852
+ }
17853
+ } else {
17854
+ if (_this.hitTestRecursive(hitTestItem, ray, x, y, regions, force, options)) {
17855
+ hitTestSuccess = true;
17856
17856
  }
17857
17857
  }
17858
17858
  };
@@ -28985,8 +28985,8 @@ var TextComponentBase = /*#__PURE__*/ function() {
28985
28985
  };
28986
28986
  _proto.setupShadow = function setupShadow() {
28987
28987
  var context = this.context;
28988
- var _this_textStyle = this.textStyle, outlineColor = _this_textStyle.outlineColor, shadowBlur = _this_textStyle.shadowBlur, shadowOffsetX = _this_textStyle.shadowOffsetX, shadowOffsetY = _this_textStyle.shadowOffsetY;
28989
- var r = outlineColor[0], g = outlineColor[1], b = outlineColor[2], a = outlineColor[3];
28988
+ var _this_textStyle = this.textStyle, shadowColor = _this_textStyle.shadowColor, shadowBlur = _this_textStyle.shadowBlur, shadowOffsetX = _this_textStyle.shadowOffsetX, shadowOffsetY = _this_textStyle.shadowOffsetY;
28989
+ var r = shadowColor[0], g = shadowColor[1], b = shadowColor[2], a = shadowColor[3];
28990
28990
  if (context) {
28991
28991
  context.shadowColor = "rgba(" + r * 255 + ", " + g * 255 + ", " + b * 255 + ", " + a + ")";
28992
28992
  context.shadowBlur = shadowBlur;
@@ -29211,11 +29211,11 @@ exports.TextComponent = /*#__PURE__*/ function(MaskableGraphic) {
29211
29211
  _proto.getLineCount = function getLineCount(text) {
29212
29212
  var context = this.context;
29213
29213
  var _this_textLayout = this.textLayout, letterSpace = _this_textLayout.letterSpace, overflow = _this_textLayout.overflow;
29214
- // const fontScale = init ? this.textStyle.fontSize / 10 : 1 / this.textStyle.fontScale;
29215
29214
  this.maxLineWidth = 0;
29216
29215
  var width = this.textLayout.width + this.textStyle.fontOffset;
29217
29216
  var lineCount = 1;
29218
29217
  var x = 0;
29218
+ var charCountInLine = 0; // 跟踪当前行的字符数
29219
29219
  // 设置 context.font 的字号,确保 measureText 能正确计算字宽
29220
29220
  if (context) {
29221
29221
  context.font = this.getFontDesc(this.textStyle.fontSize);
@@ -29226,14 +29226,19 @@ exports.TextComponent = /*#__PURE__*/ function(MaskableGraphic) {
29226
29226
  var _context_measureText_width;
29227
29227
  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;
29228
29228
  // 和浏览器行为保持一致
29229
- x += letterSpace;
29229
+ // 字符间距只应用在字符之间,每行第一个字符不加间距
29230
+ if (charCountInLine > 0) {
29231
+ x += letterSpace;
29232
+ }
29230
29233
  // 处理文本结束行为
29231
29234
  if (overflow === TextOverflow.display) {
29232
29235
  if (str === "\n") {
29233
29236
  lineCount++;
29234
29237
  x = 0;
29238
+ charCountInLine = 0; // 重置行字符计数
29235
29239
  } else {
29236
29240
  x += textMetrics;
29241
+ charCountInLine++;
29237
29242
  this.maxLineWidth = Math.max(this.maxLineWidth, x);
29238
29243
  }
29239
29244
  } else {
@@ -29241,9 +29246,11 @@ exports.TextComponent = /*#__PURE__*/ function(MaskableGraphic) {
29241
29246
  lineCount++;
29242
29247
  this.maxLineWidth = Math.max(this.maxLineWidth, x);
29243
29248
  x = 0;
29249
+ charCountInLine = 0; // 重置行字符计数
29244
29250
  }
29245
29251
  if (str !== "\n") {
29246
29252
  x += textMetrics;
29253
+ charCountInLine++;
29247
29254
  }
29248
29255
  }
29249
29256
  }
@@ -29372,12 +29379,6 @@ exports.TextComponent = /*#__PURE__*/ function(MaskableGraphic) {
29372
29379
  } else {
29373
29380
  context.font = style.fontDesc;
29374
29381
  }
29375
- if (style.hasShadow) {
29376
- _this.setupShadow();
29377
- }
29378
- if (style.isOutlined) {
29379
- _this.setupOutline();
29380
- }
29381
29382
  // textColor 统一是 0-1,写入 canvas 时乘 255
29382
29383
  var _style_textColor = style.textColor, r = _style_textColor[0], g = _style_textColor[1], b = _style_textColor[2], a = _style_textColor[3];
29383
29384
  context.fillStyle = "rgba(" + r * 255 + ", " + g * 255 + ", " + b * 255 + ", " + a + ")";
@@ -29390,7 +29391,10 @@ exports.TextComponent = /*#__PURE__*/ function(MaskableGraphic) {
29390
29391
  var str = char[i];
29391
29392
  var textMetrics = context.measureText(str);
29392
29393
  // 和浏览器行为保持一致
29393
- x += layout.letterSpace * fontScale;
29394
+ // 字符间距只应用在字符之间,每行第一个字符不加间距
29395
+ if (charsArray.length > 0) {
29396
+ x += layout.letterSpace * fontScale;
29397
+ }
29394
29398
  if (x + textMetrics.width > baseWidth && i > 0 || str === "\n") {
29395
29399
  charsInfo.push({
29396
29400
  y: y,
@@ -29415,8 +29419,13 @@ exports.TextComponent = /*#__PURE__*/ function(MaskableGraphic) {
29415
29419
  chars: charsArray,
29416
29420
  charOffsetX: charOffsetX
29417
29421
  });
29418
- // 先描边
29419
- if (style.isOutlined && style.outlineWidth > 0) {
29422
+ var hasOutline = style.isOutlined && style.outlineWidth > 0;
29423
+ if (hasOutline) {
29424
+ // 有描边:在描边时启用阴影
29425
+ if (style.hasShadow) {
29426
+ _this.setupShadow();
29427
+ }
29428
+ _this.setupOutline();
29420
29429
  charsInfo.forEach(function(charInfo) {
29421
29430
  var ox = layout.getOffsetX(style, charInfo.width);
29422
29431
  for(var i = 0; i < charInfo.chars.length; i++){
@@ -29426,8 +29435,15 @@ exports.TextComponent = /*#__PURE__*/ function(MaskableGraphic) {
29426
29435
  context.strokeText(str, drawX, drawY);
29427
29436
  }
29428
29437
  });
29438
+ // 描边完成后立即禁用阴影,避免填充时重复绘制阴影
29439
+ if (style.hasShadow) {
29440
+ context.shadowColor = "transparent";
29441
+ }
29442
+ }
29443
+ // 填充阶段:无描边时才启用阴影
29444
+ if (!hasOutline && style.hasShadow) {
29445
+ _this.setupShadow();
29429
29446
  }
29430
- // 再填充
29431
29447
  charsInfo.forEach(function(charInfo) {
29432
29448
  var ox = layout.getOffsetX(style, charInfo.width);
29433
29449
  for(var i = 0; i < charInfo.chars.length; i++){
@@ -29437,6 +29453,7 @@ exports.TextComponent = /*#__PURE__*/ function(MaskableGraphic) {
29437
29453
  context.fillText(str, drawX, drawY);
29438
29454
  }
29439
29455
  });
29456
+ // 清理阴影状态
29440
29457
  if (style.hasShadow) {
29441
29458
  context.shadowColor = "transparent";
29442
29459
  }
@@ -31620,7 +31637,7 @@ function getStandardSpriteContent(sprite, transform) {
31620
31637
  return ret;
31621
31638
  }
31622
31639
 
31623
- var version$1 = "2.8.7";
31640
+ var version$1 = "2.8.9";
31624
31641
  var v0 = /^(\d+)\.(\d+)\.(\d+)(-(\w+)\.\d+)?$/;
31625
31642
  var standardVersion = /^(\d+)\.(\d+)$/;
31626
31643
  var reverseParticle = false;
@@ -35320,7 +35337,7 @@ registerPlugin("text", TextLoader);
35320
35337
  registerPlugin("sprite", SpriteLoader);
35321
35338
  registerPlugin("particle", ParticleLoader);
35322
35339
  registerPlugin("interact", InteractLoader);
35323
- var version = "2.8.7";
35340
+ var version = "2.8.9";
35324
35341
  logger.info("Core version: " + version + ".");
35325
35342
 
35326
35343
  exports.ActivationMixerPlayable = ActivationMixerPlayable;