@galacean/effects-core 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/index.js +21 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +21 -11
- package/dist/index.mjs.map +1 -1
- package/dist/plugins/text/text-layout.d.ts +9 -1
- package/package.json +1 -1
package/dist/index.mjs
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: v1.6.0
|
|
6
|
+
* Version: v1.6.2-beta.0
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
/******************************************************************************
|
|
@@ -20280,13 +20280,21 @@ var TextLayout = /** @class */ (function () {
|
|
|
20280
20280
|
this.textAlign = textAlign;
|
|
20281
20281
|
this.lineHeight = lineHeight;
|
|
20282
20282
|
}
|
|
20283
|
-
|
|
20283
|
+
/**
|
|
20284
|
+
* 获取初始的行高偏移值
|
|
20285
|
+
* @param style - 字体基础数据
|
|
20286
|
+
* @param lineCount - 渲染行数
|
|
20287
|
+
* @param lineHeight - 渲染时的字体行高
|
|
20288
|
+
* @param fontSize - 渲染时的字体大小
|
|
20289
|
+
* @returns - 行高偏移值
|
|
20290
|
+
*/
|
|
20291
|
+
TextLayout.prototype.getOffsetY = function (style, lineCount, lineHeight, fontSize) {
|
|
20284
20292
|
var offsetResult = 0;
|
|
20285
|
-
var
|
|
20286
|
-
// 计算基础偏移量
|
|
20287
|
-
var baseOffset = (fontSize + outlineWidth) * fontScale;
|
|
20293
|
+
var outlineWidth = style.outlineWidth, fontScale = style.fontScale;
|
|
20288
20294
|
// /3 计算Y轴偏移量,以匹配编辑器行为
|
|
20289
20295
|
var offsetY = (lineHeight - fontSize) / 3;
|
|
20296
|
+
// 计算基础偏移量
|
|
20297
|
+
var baseOffset = fontSize + outlineWidth * fontScale;
|
|
20290
20298
|
var commonCalculation = lineHeight * (lineCount - 1);
|
|
20291
20299
|
switch (this.textBaseline) {
|
|
20292
20300
|
case TextBaseline$1.top:
|
|
@@ -20344,7 +20352,7 @@ var TextItem = /** @class */ (function (_super) {
|
|
|
20344
20352
|
_this.engine = vfxItem.composition.getEngine();
|
|
20345
20353
|
_this.textStyle = new TextStyle(options);
|
|
20346
20354
|
_this.textLayout = new TextLayout(options);
|
|
20347
|
-
_this.text = options.text;
|
|
20355
|
+
_this.text = options.text.toString();
|
|
20348
20356
|
_this.lineCount = _this.getLineCount(options.text, true);
|
|
20349
20357
|
// Text
|
|
20350
20358
|
_this.mesh = new TextMesh(_this.engine, _this.renderInfo, vfxItem.composition);
|
|
@@ -20421,7 +20429,7 @@ var TextItem = /** @class */ (function (_super) {
|
|
|
20421
20429
|
if (this.text === value) {
|
|
20422
20430
|
return;
|
|
20423
20431
|
}
|
|
20424
|
-
this.text = value;
|
|
20432
|
+
this.text = value.toString();
|
|
20425
20433
|
this.lineCount = this.getLineCount(value, false);
|
|
20426
20434
|
this.isDirty = true;
|
|
20427
20435
|
};
|
|
@@ -20573,7 +20581,7 @@ var TextItem = /** @class */ (function (_super) {
|
|
|
20573
20581
|
var fontScale = style.fontScale;
|
|
20574
20582
|
var width = (layout.width + style.fontOffset) * fontScale;
|
|
20575
20583
|
var height = layout.height * fontScale;
|
|
20576
|
-
style.fontSize * fontScale;
|
|
20584
|
+
var fontSize = style.fontSize * fontScale;
|
|
20577
20585
|
var lineHeight = layout.lineHeight * fontScale;
|
|
20578
20586
|
this.char = (this.text || '').split('');
|
|
20579
20587
|
this.canvas.width = width;
|
|
@@ -20594,7 +20602,7 @@ var TextItem = /** @class */ (function (_super) {
|
|
|
20594
20602
|
context.fillStyle = "rgba(".concat(style.textColor[0], ", ").concat(style.textColor[1], ", ").concat(style.textColor[2], ", ").concat(style.textColor[3], ")");
|
|
20595
20603
|
var charsInfo = [];
|
|
20596
20604
|
var x = 0;
|
|
20597
|
-
var y = layout.getOffsetY(style, this.lineCount, lineHeight);
|
|
20605
|
+
var y = layout.getOffsetY(style, this.lineCount, lineHeight, fontSize);
|
|
20598
20606
|
var charsArray = [];
|
|
20599
20607
|
var charOffsetX = [];
|
|
20600
20608
|
for (var i = 0; i < this.char.length; i++) {
|
|
@@ -21764,11 +21772,13 @@ var Camera = /** @class */ (function () {
|
|
|
21764
21772
|
* @param z - 当前的位置 z
|
|
21765
21773
|
*/
|
|
21766
21774
|
Camera.prototype.getInverseVPRatio = function (z) {
|
|
21767
|
-
var pos = new Vector3(
|
|
21775
|
+
var pos = new Vector3(this.position.x, this.position.y, z);
|
|
21768
21776
|
var mat = this.getViewProjectionMatrix();
|
|
21769
21777
|
var inverseVP = this.getInverseViewProjectionMatrix();
|
|
21770
21778
|
var nz = mat.projectPoint(pos).z;
|
|
21771
|
-
|
|
21779
|
+
var _a = inverseVP.projectPoint(new Vector3(1, 1, nz)), xMax = _a.x, yMax = _a.y;
|
|
21780
|
+
var _b = inverseVP.projectPoint(new Vector3(-1, -1, nz)), xMin = _b.x, yMin = _b.y;
|
|
21781
|
+
return new Vector3((xMax - xMin) / 2, (yMax - yMin) / 2, 0);
|
|
21772
21782
|
};
|
|
21773
21783
|
/**
|
|
21774
21784
|
* 设置相机的旋转四元数
|