@galacean/effects-core 2.3.0-beta.2 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@
3
3
  * Description: Galacean Effects runtime core for the web
4
4
  * Author: Ant Group CO., Ltd.
5
5
  * Contributors: 燃然,飂兮,十弦,云垣,茂安,意绮
6
- * Version: v2.3.0-beta.2
6
+ * Version: v2.3.0
7
7
  */
8
8
 
9
9
  'use strict';
@@ -25521,9 +25521,12 @@ var TextComponentBase = /*#__PURE__*/ function() {
25521
25521
  this.textStyle = new TextStyle(options);
25522
25522
  this.textLayout = new TextLayout(options);
25523
25523
  this.text = options.text.toString();
25524
+ this.lineCount = this.getLineCount(options.text, true);
25524
25525
  };
25525
- _proto.getLineCount = function getLineCount(text, context) {
25526
+ _proto.getLineCount = function getLineCount(text, init) {
25527
+ var context = this.context;
25526
25528
  var _this_textLayout = this.textLayout, letterSpace = _this_textLayout.letterSpace, overflow = _this_textLayout.overflow;
25529
+ var fontScale = init ? this.textStyle.fontSize / 10 : 1 / this.textStyle.fontScale;
25527
25530
  var width = this.textLayout.width + this.textStyle.fontOffset;
25528
25531
  var lineCount = 1;
25529
25532
  var x = 0;
@@ -25531,7 +25534,7 @@ var TextComponentBase = /*#__PURE__*/ function() {
25531
25534
  var _context_measureText;
25532
25535
  var str = text[i];
25533
25536
  var _context_measureText_width;
25534
- 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;
25537
+ 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) * fontScale;
25535
25538
  // 和浏览器行为保持一致
25536
25539
  x += letterSpace;
25537
25540
  // 处理文本结束行为
@@ -25601,6 +25604,7 @@ var TextComponentBase = /*#__PURE__*/ function() {
25601
25604
  return;
25602
25605
  }
25603
25606
  this.text = value.toString();
25607
+ this.lineCount = this.getLineCount(value, false);
25604
25608
  this.isDirty = true;
25605
25609
  };
25606
25610
  /**
@@ -25761,35 +25765,32 @@ var TextComponentBase = /*#__PURE__*/ function() {
25761
25765
  var layout = this.textLayout;
25762
25766
  var fontScale = style.fontScale;
25763
25767
  var width = (layout.width + style.fontOffset) * fontScale;
25768
+ var finalHeight = layout.lineHeight * this.lineCount;
25764
25769
  var fontSize = style.fontSize * fontScale;
25765
25770
  var lineHeight = layout.lineHeight * fontScale;
25766
25771
  style.fontDesc = this.getFontDesc(fontSize);
25767
25772
  this.char = (this.text || "").split("");
25768
25773
  this.canvas.width = width;
25769
- var height = this.canvas.height;
25770
- context.font = style.fontDesc;
25771
- this.lineCount = this.getLineCount(this.text, context);
25772
- var finalHeight = layout.lineHeight * this.lineCount;
25773
25774
  if (layout.autoWidth) {
25774
25775
  this.canvas.height = finalHeight * fontScale;
25775
25776
  this.item.transform.size.set(1, finalHeight / layout.height);
25776
25777
  } else {
25777
25778
  this.canvas.height = layout.height * fontScale;
25778
25779
  }
25780
+ var height = this.canvas.height;
25781
+ // fix bug 1/255
25782
+ context.fillStyle = "rgba(255, 255, 255, 0.0039)";
25783
+ if (!flipY) {
25784
+ context.translate(0, height);
25785
+ context.scale(1, -1);
25786
+ }
25779
25787
  // canvas size 变化后重新刷新 context
25780
25788
  if (this.maxLineWidth > width && layout.overflow === TextOverflow.display) {
25781
25789
  context.font = this.getFontDesc(fontSize * width / this.maxLineWidth);
25782
25790
  } else {
25783
25791
  context.font = style.fontDesc;
25784
25792
  }
25785
- // fix bug 1/255
25786
- context.fillStyle = "rgba(255, 255, 255, 0.0039)";
25787
25793
  context.clearRect(0, 0, width, height);
25788
- if (!flipY) {
25789
- context.translate(0, height);
25790
- context.scale(1, -1);
25791
- }
25792
- context.fillRect(0, 0, width, height);
25793
25794
  if (style.hasShadow) {
25794
25795
  this.setupShadow();
25795
25796
  }
@@ -25861,9 +25862,9 @@ var TextComponentBase = /*#__PURE__*/ function() {
25861
25862
  this.material.setTexture("_MainTex", texture);
25862
25863
  this.isDirty = false;
25863
25864
  };
25864
- _proto.getFontDesc = function getFontDesc(fontSize) {
25865
- var _this_textStyle = this.textStyle, fontFamily = _this_textStyle.fontFamily, textWeight = _this_textStyle.textWeight, fontStyle = _this_textStyle.fontStyle;
25866
- var fontDesc = "" + fontSize.toString() + "px ";
25865
+ _proto.getFontDesc = function getFontDesc(size) {
25866
+ var _this_textStyle = this.textStyle, fontSize = _this_textStyle.fontSize, fontScale = _this_textStyle.fontScale, fontFamily = _this_textStyle.fontFamily, textWeight = _this_textStyle.textWeight, fontStyle = _this_textStyle.fontStyle;
25867
+ var fontDesc = "" + (size || fontSize * fontScale).toString() + "px ";
25867
25868
  if (!DEFAULT_FONTS.includes(fontFamily)) {
25868
25869
  fontDesc += '"' + fontFamily + '"';
25869
25870
  } else {
@@ -32078,7 +32079,7 @@ registerPlugin("sprite", SpriteLoader, exports.VFXItem);
32078
32079
  registerPlugin("particle", ParticleLoader, exports.VFXItem);
32079
32080
  registerPlugin("cal", CalculateLoader, exports.VFXItem);
32080
32081
  registerPlugin("interact", InteractLoader, exports.VFXItem);
32081
- var version = "2.3.0-beta.2";
32082
+ var version = "2.3.0";
32082
32083
  logger.info("Core version: " + version + ".");
32083
32084
 
32084
32085
  exports.AbstractPlugin = AbstractPlugin;