@galacean/effects 1.6.0 → 1.6.2-beta.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/alipay.js CHANGED
@@ -20278,13 +20278,21 @@ var TextLayout = /** @class */ (function () {
20278
20278
  this.textAlign = textAlign;
20279
20279
  this.lineHeight = lineHeight;
20280
20280
  }
20281
- TextLayout.prototype.getOffsetY = function (style, lineCount, lineHeight) {
20281
+ /**
20282
+ * 获取初始的行高偏移值
20283
+ * @param style - 字体基础数据
20284
+ * @param lineCount - 渲染行数
20285
+ * @param lineHeight - 渲染时的字体行高
20286
+ * @param fontSize - 渲染时的字体大小
20287
+ * @returns - 行高偏移值
20288
+ */
20289
+ TextLayout.prototype.getOffsetY = function (style, lineCount, lineHeight, fontSize) {
20282
20290
  var offsetResult = 0;
20283
- var fontSize = style.fontSize, outlineWidth = style.outlineWidth, fontScale = style.fontScale;
20284
- // 计算基础偏移量
20285
- var baseOffset = (fontSize + outlineWidth) * fontScale;
20291
+ var outlineWidth = style.outlineWidth, fontScale = style.fontScale;
20286
20292
  // /3 计算Y轴偏移量,以匹配编辑器行为
20287
20293
  var offsetY = (lineHeight - fontSize) / 3;
20294
+ // 计算基础偏移量
20295
+ var baseOffset = fontSize + outlineWidth * fontScale;
20288
20296
  var commonCalculation = lineHeight * (lineCount - 1);
20289
20297
  switch (this.textBaseline) {
20290
20298
  case TextBaseline$1.top:
@@ -20342,7 +20350,7 @@ var TextItem = /** @class */ (function (_super) {
20342
20350
  _this.engine = vfxItem.composition.getEngine();
20343
20351
  _this.textStyle = new TextStyle(options);
20344
20352
  _this.textLayout = new TextLayout(options);
20345
- _this.text = options.text;
20353
+ _this.text = options.text.toString();
20346
20354
  _this.lineCount = _this.getLineCount(options.text, true);
20347
20355
  // Text
20348
20356
  _this.mesh = new TextMesh(_this.engine, _this.renderInfo, vfxItem.composition);
@@ -20419,7 +20427,7 @@ var TextItem = /** @class */ (function (_super) {
20419
20427
  if (this.text === value) {
20420
20428
  return;
20421
20429
  }
20422
- this.text = value;
20430
+ this.text = value.toString();
20423
20431
  this.lineCount = this.getLineCount(value, false);
20424
20432
  this.isDirty = true;
20425
20433
  };
@@ -20571,7 +20579,7 @@ var TextItem = /** @class */ (function (_super) {
20571
20579
  var fontScale = style.fontScale;
20572
20580
  var width = (layout.width + style.fontOffset) * fontScale;
20573
20581
  var height = layout.height * fontScale;
20574
- style.fontSize * fontScale;
20582
+ var fontSize = style.fontSize * fontScale;
20575
20583
  var lineHeight = layout.lineHeight * fontScale;
20576
20584
  this.char = (this.text || '').split('');
20577
20585
  this.canvas.width = width;
@@ -20592,7 +20600,7 @@ var TextItem = /** @class */ (function (_super) {
20592
20600
  context.fillStyle = "rgba(".concat(style.textColor[0], ", ").concat(style.textColor[1], ", ").concat(style.textColor[2], ", ").concat(style.textColor[3], ")");
20593
20601
  var charsInfo = [];
20594
20602
  var x = 0;
20595
- var y = layout.getOffsetY(style, this.lineCount, lineHeight);
20603
+ var y = layout.getOffsetY(style, this.lineCount, lineHeight, fontSize);
20596
20604
  var charsArray = [];
20597
20605
  var charOffsetX = [];
20598
20606
  for (var i = 0; i < this.char.length; i++) {
@@ -21762,11 +21770,13 @@ var Camera = /** @class */ (function () {
21762
21770
  * @param z - 当前的位置 z
21763
21771
  */
21764
21772
  Camera.prototype.getInverseVPRatio = function (z) {
21765
- var pos = new Vector3(0, 0, z);
21773
+ var pos = new Vector3(this.position.x, this.position.y, z);
21766
21774
  var mat = this.getViewProjectionMatrix();
21767
21775
  var inverseVP = this.getInverseViewProjectionMatrix();
21768
21776
  var nz = mat.projectPoint(pos).z;
21769
- return inverseVP.projectPoint(new Vector3(1, 1, nz));
21777
+ var _a = inverseVP.projectPoint(new Vector3(1, 1, nz)), xMax = _a.x, yMax = _a.y;
21778
+ var _b = inverseVP.projectPoint(new Vector3(-1, -1, nz)), xMin = _b.x, yMin = _b.y;
21779
+ return new Vector3((xMax - xMin) / 2, (yMax - yMin) / 2, 0);
21770
21780
  };
21771
21781
  /**
21772
21782
  * 设置相机的旋转四元数
@@ -31024,7 +31034,7 @@ Renderer.create = function (canvas, framework, renderOptions) {
31024
31034
  Engine.create = function (gl) {
31025
31035
  return new GLEngine(gl);
31026
31036
  };
31027
- var version = "1.6.0";
31037
+ var version = "1.6.2-beta.0";
31028
31038
  logger.info('player version: ' + version);
31029
31039
 
31030
31040
  exports.AbstractPlugin = AbstractPlugin;