@galacean/effects-threejs 2.3.0-beta.2 → 2.3.0-beta.3

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.3.0-beta.2
6
+ * Version: v2.3.0-beta.3
7
7
  */
8
8
 
9
9
  'use strict';
@@ -25543,9 +25543,12 @@ var TextComponentBase = /*#__PURE__*/ function() {
25543
25543
  this.textStyle = new TextStyle(options);
25544
25544
  this.textLayout = new TextLayout(options);
25545
25545
  this.text = options.text.toString();
25546
+ this.lineCount = this.getLineCount(options.text, true);
25546
25547
  };
25547
- _proto.getLineCount = function getLineCount(text, context) {
25548
+ _proto.getLineCount = function getLineCount(text, init) {
25549
+ var context = this.context;
25548
25550
  var _this_textLayout = this.textLayout, letterSpace = _this_textLayout.letterSpace, overflow = _this_textLayout.overflow;
25551
+ var fontScale = init ? this.textStyle.fontSize / 10 : 1 / this.textStyle.fontScale;
25549
25552
  var width = this.textLayout.width + this.textStyle.fontOffset;
25550
25553
  var lineCount = 1;
25551
25554
  var x = 0;
@@ -25553,7 +25556,7 @@ var TextComponentBase = /*#__PURE__*/ function() {
25553
25556
  var _context_measureText;
25554
25557
  var str = text[i];
25555
25558
  var _context_measureText_width;
25556
- 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;
25559
+ 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;
25557
25560
  // 和浏览器行为保持一致
25558
25561
  x += letterSpace;
25559
25562
  // 处理文本结束行为
@@ -25623,6 +25626,7 @@ var TextComponentBase = /*#__PURE__*/ function() {
25623
25626
  return;
25624
25627
  }
25625
25628
  this.text = value.toString();
25629
+ this.lineCount = this.getLineCount(value, false);
25626
25630
  this.isDirty = true;
25627
25631
  };
25628
25632
  /**
@@ -25783,35 +25787,32 @@ var TextComponentBase = /*#__PURE__*/ function() {
25783
25787
  var layout = this.textLayout;
25784
25788
  var fontScale = style.fontScale;
25785
25789
  var width = (layout.width + style.fontOffset) * fontScale;
25790
+ var finalHeight = layout.lineHeight * this.lineCount;
25786
25791
  var fontSize = style.fontSize * fontScale;
25787
25792
  var lineHeight = layout.lineHeight * fontScale;
25788
25793
  style.fontDesc = this.getFontDesc(fontSize);
25789
25794
  this.char = (this.text || "").split("");
25790
25795
  this.canvas.width = width;
25791
- var height = this.canvas.height;
25792
- context.font = style.fontDesc;
25793
- this.lineCount = this.getLineCount(this.text, context);
25794
- var finalHeight = layout.lineHeight * this.lineCount;
25795
25796
  if (layout.autoWidth) {
25796
25797
  this.canvas.height = finalHeight * fontScale;
25797
25798
  this.item.transform.size.set(1, finalHeight / layout.height);
25798
25799
  } else {
25799
25800
  this.canvas.height = layout.height * fontScale;
25800
25801
  }
25802
+ var height = this.canvas.height;
25803
+ // fix bug 1/255
25804
+ context.fillStyle = "rgba(255, 255, 255, 0.0039)";
25805
+ if (!flipY) {
25806
+ context.translate(0, height);
25807
+ context.scale(1, -1);
25808
+ }
25801
25809
  // canvas size 变化后重新刷新 context
25802
25810
  if (this.maxLineWidth > width && layout.overflow === TextOverflow.display) {
25803
25811
  context.font = this.getFontDesc(fontSize * width / this.maxLineWidth);
25804
25812
  } else {
25805
25813
  context.font = style.fontDesc;
25806
25814
  }
25807
- // fix bug 1/255
25808
- context.fillStyle = "rgba(255, 255, 255, 0.0039)";
25809
25815
  context.clearRect(0, 0, width, height);
25810
- if (!flipY) {
25811
- context.translate(0, height);
25812
- context.scale(1, -1);
25813
- }
25814
- context.fillRect(0, 0, width, height);
25815
25816
  if (style.hasShadow) {
25816
25817
  this.setupShadow();
25817
25818
  }
@@ -25883,9 +25884,9 @@ var TextComponentBase = /*#__PURE__*/ function() {
25883
25884
  this.material.setTexture("_MainTex", texture);
25884
25885
  this.isDirty = false;
25885
25886
  };
25886
- _proto.getFontDesc = function getFontDesc(fontSize) {
25887
- var _this_textStyle = this.textStyle, fontFamily = _this_textStyle.fontFamily, textWeight = _this_textStyle.textWeight, fontStyle = _this_textStyle.fontStyle;
25888
- var fontDesc = "" + fontSize.toString() + "px ";
25887
+ _proto.getFontDesc = function getFontDesc(size) {
25888
+ 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;
25889
+ var fontDesc = "" + (size || fontSize * fontScale).toString() + "px ";
25889
25890
  if (!DEFAULT_FONTS.includes(fontFamily)) {
25890
25891
  fontDesc += '"' + fontFamily + '"';
25891
25892
  } else {
@@ -32100,7 +32101,7 @@ registerPlugin("sprite", SpriteLoader, exports.VFXItem);
32100
32101
  registerPlugin("particle", ParticleLoader, exports.VFXItem);
32101
32102
  registerPlugin("cal", CalculateLoader, exports.VFXItem);
32102
32103
  registerPlugin("interact", InteractLoader, exports.VFXItem);
32103
- var version$1 = "2.3.0-beta.2";
32104
+ var version$1 = "2.3.0-beta.3";
32104
32105
  logger.info("Core version: " + version$1 + ".");
32105
32106
 
32106
32107
  var _obj;
@@ -33746,7 +33747,7 @@ setMaxSpriteMeshItemCount(8);
33746
33747
  */ Mesh.create = function(engine, props) {
33747
33748
  return new ThreeMesh(engine, props);
33748
33749
  };
33749
- var version = "2.3.0-beta.2";
33750
+ var version = "2.3.0-beta.3";
33750
33751
  logger.info("THREEJS plugin version: " + version + ".");
33751
33752
 
33752
33753
  exports.AbstractPlugin = AbstractPlugin;