@galacean/effects-threejs 1.6.0-beta.1 → 1.6.0-beta.2

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: v1.6.0-beta.1
6
+ * Version: v1.6.0-beta.2
7
7
  */
8
8
 
9
9
  'use strict';
@@ -20306,32 +20306,37 @@ var TextLayout = /** @class */ (function () {
20306
20306
  this.textAlign = textAlign;
20307
20307
  this.lineHeight = lineHeight;
20308
20308
  }
20309
- TextLayout.prototype.getOffsetY = function (style) {
20310
- var offsetY = 0;
20311
- var offset = (style.fontSize + style.outlineWidth) * style.fontScale;
20309
+ TextLayout.prototype.getOffsetY = function (style, lineCount, lineHeight) {
20310
+ var offsetResult = 0;
20311
+ var fontSize = style.fontSize, outlineWidth = style.outlineWidth, fontScale = style.fontScale;
20312
+ // 计算基础偏移量
20313
+ var baseOffset = (fontSize + outlineWidth) * fontScale;
20314
+ // /3 计算Y轴偏移量,以匹配编辑器行为
20315
+ var offsetY = (lineHeight - fontSize) / 3;
20316
+ var commonCalculation = lineHeight * (lineCount - 1);
20312
20317
  switch (this.textBaseline) {
20313
- case 0:
20314
- offsetY = offset;
20318
+ case TextBaseline$1.top:
20319
+ offsetResult = baseOffset + offsetY;
20315
20320
  break;
20316
- case 1:
20317
- offsetY = (this.height + offset) / 2; // fonSize;
20321
+ case TextBaseline$1.middle:
20322
+ offsetResult = (this.height * fontScale - commonCalculation + baseOffset) / 2;
20318
20323
  break;
20319
- case 2:
20320
- offsetY = this.height - offset / 2;
20324
+ case TextBaseline$1.bottom:
20325
+ offsetResult = (this.height * fontScale - commonCalculation) - offsetY;
20321
20326
  break;
20322
20327
  }
20323
- return offsetY;
20328
+ return offsetResult;
20324
20329
  };
20325
20330
  TextLayout.prototype.getOffsetX = function (style, maxWidth) {
20326
20331
  var offsetX = 0;
20327
20332
  switch (this.textAlign) {
20328
- case 0:
20333
+ case TextAlignment$1.left:
20329
20334
  offsetX = style.outlineWidth * style.fontScale;
20330
20335
  break;
20331
- case 1:
20336
+ case TextAlignment$1.middle:
20332
20337
  offsetX = (this.width * style.fontScale - maxWidth) / 2;
20333
20338
  break;
20334
- case 2:
20339
+ case TextAlignment$1.right:
20335
20340
  offsetX = (this.width * style.fontScale - maxWidth);
20336
20341
  break;
20337
20342
  }
@@ -20565,7 +20570,7 @@ var TextItem = /** @class */ (function (_super) {
20565
20570
  var fontScale = style.fontScale;
20566
20571
  var width = (layout.width + style.fontOffset) * fontScale;
20567
20572
  var height = layout.height * fontScale;
20568
- var fontSize = style.fontSize * fontScale;
20573
+ style.fontSize * fontScale;
20569
20574
  var lineHeight = layout.lineHeight * fontScale;
20570
20575
  this.char = (this.text || '').split('');
20571
20576
  this.canvas.width = width;
@@ -20585,10 +20590,9 @@ var TextItem = /** @class */ (function (_super) {
20585
20590
  // 文本颜色
20586
20591
  context.fillStyle = "rgba(".concat(style.textColor[0], ", ").concat(style.textColor[1], ", ").concat(style.textColor[2], ", ").concat(style.textColor[3], ")");
20587
20592
  var charsInfo = [];
20588
- // /3 为了和编辑器行为保持一致
20589
- var offsetY = (lineHeight - fontSize) / 3;
20590
20593
  var x = 0;
20591
- var y = layout.getOffsetY(style) + offsetY;
20594
+ var lineCount = this.text.split('\n').length;
20595
+ var y = layout.getOffsetY(style, lineCount, lineHeight);
20592
20596
  var charsArray = [];
20593
20597
  var charOffsetX = [];
20594
20598
  for (var i = 0; i < this.char.length; i++) {
@@ -27478,7 +27482,7 @@ Geometry.create = function (engine, options) {
27478
27482
  Mesh.create = function (engine, props) {
27479
27483
  return new ThreeMesh(engine, props);
27480
27484
  };
27481
- var version = "1.6.0-beta.1";
27485
+ var version = "1.6.0-beta.2";
27482
27486
  logger.info('THREEJS plugin version: ' + version);
27483
27487
 
27484
27488
  exports.AbstractPlugin = AbstractPlugin;