@galacean/effects-threejs 2.8.7 → 2.8.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@
3
3
  * Description: Galacean Effects runtime threejs plugin for the web
4
4
  * Author: Ant Group CO., Ltd.
5
5
  * Contributors: 燃然,飂兮,十弦,云垣,茂安,意绮
6
- * Version: v2.8.7
6
+ * Version: v2.8.8
7
7
  */
8
8
 
9
9
  'use strict';
@@ -29007,8 +29007,8 @@ var TextComponentBase = /*#__PURE__*/ function() {
29007
29007
  };
29008
29008
  _proto.setupShadow = function setupShadow() {
29009
29009
  var context = this.context;
29010
- var _this_textStyle = this.textStyle, outlineColor = _this_textStyle.outlineColor, shadowBlur = _this_textStyle.shadowBlur, shadowOffsetX = _this_textStyle.shadowOffsetX, shadowOffsetY = _this_textStyle.shadowOffsetY;
29011
- var r = outlineColor[0], g = outlineColor[1], b = outlineColor[2], a = outlineColor[3];
29010
+ var _this_textStyle = this.textStyle, shadowColor = _this_textStyle.shadowColor, shadowBlur = _this_textStyle.shadowBlur, shadowOffsetX = _this_textStyle.shadowOffsetX, shadowOffsetY = _this_textStyle.shadowOffsetY;
29011
+ var r = shadowColor[0], g = shadowColor[1], b = shadowColor[2], a = shadowColor[3];
29012
29012
  if (context) {
29013
29013
  context.shadowColor = "rgba(" + r * 255 + ", " + g * 255 + ", " + b * 255 + ", " + a + ")";
29014
29014
  context.shadowBlur = shadowBlur;
@@ -29233,11 +29233,11 @@ exports.TextComponent = /*#__PURE__*/ function(MaskableGraphic) {
29233
29233
  _proto.getLineCount = function getLineCount(text) {
29234
29234
  var context = this.context;
29235
29235
  var _this_textLayout = this.textLayout, letterSpace = _this_textLayout.letterSpace, overflow = _this_textLayout.overflow;
29236
- // const fontScale = init ? this.textStyle.fontSize / 10 : 1 / this.textStyle.fontScale;
29237
29236
  this.maxLineWidth = 0;
29238
29237
  var width = this.textLayout.width + this.textStyle.fontOffset;
29239
29238
  var lineCount = 1;
29240
29239
  var x = 0;
29240
+ var charCountInLine = 0; // 跟踪当前行的字符数
29241
29241
  // 设置 context.font 的字号,确保 measureText 能正确计算字宽
29242
29242
  if (context) {
29243
29243
  context.font = this.getFontDesc(this.textStyle.fontSize);
@@ -29248,14 +29248,19 @@ exports.TextComponent = /*#__PURE__*/ function(MaskableGraphic) {
29248
29248
  var _context_measureText_width;
29249
29249
  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;
29250
29250
  // 和浏览器行为保持一致
29251
- x += letterSpace;
29251
+ // 字符间距只应用在字符之间,每行第一个字符不加间距
29252
+ if (charCountInLine > 0) {
29253
+ x += letterSpace;
29254
+ }
29252
29255
  // 处理文本结束行为
29253
29256
  if (overflow === TextOverflow.display) {
29254
29257
  if (str === "\n") {
29255
29258
  lineCount++;
29256
29259
  x = 0;
29260
+ charCountInLine = 0; // 重置行字符计数
29257
29261
  } else {
29258
29262
  x += textMetrics;
29263
+ charCountInLine++;
29259
29264
  this.maxLineWidth = Math.max(this.maxLineWidth, x);
29260
29265
  }
29261
29266
  } else {
@@ -29263,9 +29268,11 @@ exports.TextComponent = /*#__PURE__*/ function(MaskableGraphic) {
29263
29268
  lineCount++;
29264
29269
  this.maxLineWidth = Math.max(this.maxLineWidth, x);
29265
29270
  x = 0;
29271
+ charCountInLine = 0; // 重置行字符计数
29266
29272
  }
29267
29273
  if (str !== "\n") {
29268
29274
  x += textMetrics;
29275
+ charCountInLine++;
29269
29276
  }
29270
29277
  }
29271
29278
  }
@@ -29412,7 +29419,10 @@ exports.TextComponent = /*#__PURE__*/ function(MaskableGraphic) {
29412
29419
  var str = char[i];
29413
29420
  var textMetrics = context.measureText(str);
29414
29421
  // 和浏览器行为保持一致
29415
- x += layout.letterSpace * fontScale;
29422
+ // 字符间距只应用在字符之间,每行第一个字符不加间距
29423
+ if (charsArray.length > 0) {
29424
+ x += layout.letterSpace * fontScale;
29425
+ }
29416
29426
  if (x + textMetrics.width > baseWidth && i > 0 || str === "\n") {
29417
29427
  charsInfo.push({
29418
29428
  y: y,
@@ -31642,7 +31652,7 @@ function getStandardSpriteContent(sprite, transform) {
31642
31652
  return ret;
31643
31653
  }
31644
31654
 
31645
- var version$2 = "2.8.7";
31655
+ var version$2 = "2.8.8";
31646
31656
  var v0 = /^(\d+)\.(\d+)\.(\d+)(-(\w+)\.\d+)?$/;
31647
31657
  var standardVersion = /^(\d+)\.(\d+)$/;
31648
31658
  var reverseParticle = false;
@@ -35342,7 +35352,7 @@ registerPlugin("text", TextLoader);
35342
35352
  registerPlugin("sprite", SpriteLoader);
35343
35353
  registerPlugin("particle", ParticleLoader);
35344
35354
  registerPlugin("interact", InteractLoader);
35345
- var version$1 = "2.8.7";
35355
+ var version$1 = "2.8.8";
35346
35356
  logger.info("Core version: " + version$1 + ".");
35347
35357
 
35348
35358
  var _obj;
@@ -36919,7 +36929,7 @@ applyMixins(exports.ThreeTextComponent, [
36919
36929
  */ Mesh.create = function(engine, props) {
36920
36930
  return new ThreeMesh(engine, props);
36921
36931
  };
36922
- var version = "2.8.7";
36932
+ var version = "2.8.8";
36923
36933
  logger.info("THREEJS plugin version: " + version + ".");
36924
36934
 
36925
36935
  exports.ActivationMixerPlayable = ActivationMixerPlayable;