@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.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: v1.6.0
|
|
6
|
+
* Version: v1.6.2-beta.0
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
'use strict';
|
|
@@ -20284,13 +20284,21 @@ var TextLayout = /** @class */ (function () {
|
|
|
20284
20284
|
this.textAlign = textAlign;
|
|
20285
20285
|
this.lineHeight = lineHeight;
|
|
20286
20286
|
}
|
|
20287
|
-
|
|
20287
|
+
/**
|
|
20288
|
+
* 获取初始的行高偏移值
|
|
20289
|
+
* @param style - 字体基础数据
|
|
20290
|
+
* @param lineCount - 渲染行数
|
|
20291
|
+
* @param lineHeight - 渲染时的字体行高
|
|
20292
|
+
* @param fontSize - 渲染时的字体大小
|
|
20293
|
+
* @returns - 行高偏移值
|
|
20294
|
+
*/
|
|
20295
|
+
TextLayout.prototype.getOffsetY = function (style, lineCount, lineHeight, fontSize) {
|
|
20288
20296
|
var offsetResult = 0;
|
|
20289
|
-
var
|
|
20290
|
-
// 计算基础偏移量
|
|
20291
|
-
var baseOffset = (fontSize + outlineWidth) * fontScale;
|
|
20297
|
+
var outlineWidth = style.outlineWidth, fontScale = style.fontScale;
|
|
20292
20298
|
// /3 计算Y轴偏移量,以匹配编辑器行为
|
|
20293
20299
|
var offsetY = (lineHeight - fontSize) / 3;
|
|
20300
|
+
// 计算基础偏移量
|
|
20301
|
+
var baseOffset = fontSize + outlineWidth * fontScale;
|
|
20294
20302
|
var commonCalculation = lineHeight * (lineCount - 1);
|
|
20295
20303
|
switch (this.textBaseline) {
|
|
20296
20304
|
case TextBaseline$1.top:
|
|
@@ -20348,7 +20356,7 @@ var TextItem = /** @class */ (function (_super) {
|
|
|
20348
20356
|
_this.engine = vfxItem.composition.getEngine();
|
|
20349
20357
|
_this.textStyle = new TextStyle(options);
|
|
20350
20358
|
_this.textLayout = new TextLayout(options);
|
|
20351
|
-
_this.text = options.text;
|
|
20359
|
+
_this.text = options.text.toString();
|
|
20352
20360
|
_this.lineCount = _this.getLineCount(options.text, true);
|
|
20353
20361
|
// Text
|
|
20354
20362
|
_this.mesh = new TextMesh(_this.engine, _this.renderInfo, vfxItem.composition);
|
|
@@ -20425,7 +20433,7 @@ var TextItem = /** @class */ (function (_super) {
|
|
|
20425
20433
|
if (this.text === value) {
|
|
20426
20434
|
return;
|
|
20427
20435
|
}
|
|
20428
|
-
this.text = value;
|
|
20436
|
+
this.text = value.toString();
|
|
20429
20437
|
this.lineCount = this.getLineCount(value, false);
|
|
20430
20438
|
this.isDirty = true;
|
|
20431
20439
|
};
|
|
@@ -20577,7 +20585,7 @@ var TextItem = /** @class */ (function (_super) {
|
|
|
20577
20585
|
var fontScale = style.fontScale;
|
|
20578
20586
|
var width = (layout.width + style.fontOffset) * fontScale;
|
|
20579
20587
|
var height = layout.height * fontScale;
|
|
20580
|
-
style.fontSize * fontScale;
|
|
20588
|
+
var fontSize = style.fontSize * fontScale;
|
|
20581
20589
|
var lineHeight = layout.lineHeight * fontScale;
|
|
20582
20590
|
this.char = (this.text || '').split('');
|
|
20583
20591
|
this.canvas.width = width;
|
|
@@ -20598,7 +20606,7 @@ var TextItem = /** @class */ (function (_super) {
|
|
|
20598
20606
|
context.fillStyle = "rgba(".concat(style.textColor[0], ", ").concat(style.textColor[1], ", ").concat(style.textColor[2], ", ").concat(style.textColor[3], ")");
|
|
20599
20607
|
var charsInfo = [];
|
|
20600
20608
|
var x = 0;
|
|
20601
|
-
var y = layout.getOffsetY(style, this.lineCount, lineHeight);
|
|
20609
|
+
var y = layout.getOffsetY(style, this.lineCount, lineHeight, fontSize);
|
|
20602
20610
|
var charsArray = [];
|
|
20603
20611
|
var charOffsetX = [];
|
|
20604
20612
|
for (var i = 0; i < this.char.length; i++) {
|
|
@@ -21768,11 +21776,13 @@ var Camera = /** @class */ (function () {
|
|
|
21768
21776
|
* @param z - 当前的位置 z
|
|
21769
21777
|
*/
|
|
21770
21778
|
Camera.prototype.getInverseVPRatio = function (z) {
|
|
21771
|
-
var pos = new Vector3(
|
|
21779
|
+
var pos = new Vector3(this.position.x, this.position.y, z);
|
|
21772
21780
|
var mat = this.getViewProjectionMatrix();
|
|
21773
21781
|
var inverseVP = this.getInverseViewProjectionMatrix();
|
|
21774
21782
|
var nz = mat.projectPoint(pos).z;
|
|
21775
|
-
|
|
21783
|
+
var _a = inverseVP.projectPoint(new Vector3(1, 1, nz)), xMax = _a.x, yMax = _a.y;
|
|
21784
|
+
var _b = inverseVP.projectPoint(new Vector3(-1, -1, nz)), xMin = _b.x, yMin = _b.y;
|
|
21785
|
+
return new Vector3((xMax - xMin) / 2, (yMax - yMin) / 2, 0);
|
|
21776
21786
|
};
|
|
21777
21787
|
/**
|
|
21778
21788
|
* 设置相机的旋转四元数
|