@galacean/effects 1.6.0-beta.2 → 1.6.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 +31 -3
- package/dist/alipay.js.map +1 -1
- package/dist/alipay.mjs +31 -3
- package/dist/alipay.mjs.map +1 -1
- package/dist/index.js +32 -4
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +4 -4
- package/dist/index.min.js.map +1 -1
- package/dist/index.mjs +32 -4
- package/dist/index.mjs.map +1 -1
- package/dist/weapp.js +31 -3
- package/dist/weapp.js.map +1 -1
- package/dist/weapp.mjs +31 -3
- package/dist/weapp.mjs.map +1 -1
- package/package.json +3 -3
package/dist/alipay.js
CHANGED
|
@@ -20331,6 +20331,10 @@ var TextItem = /** @class */ (function (_super) {
|
|
|
20331
20331
|
function TextItem(props, opts, vfxItem) {
|
|
20332
20332
|
var _this = _super.call(this, props, opts, vfxItem) || this;
|
|
20333
20333
|
_this.isDirty = true;
|
|
20334
|
+
/**
|
|
20335
|
+
* 文本行数
|
|
20336
|
+
*/
|
|
20337
|
+
_this.lineCount = 0;
|
|
20334
20338
|
var options = props.options;
|
|
20335
20339
|
_this.canvas = canvasPool.getCanvas();
|
|
20336
20340
|
canvasPool.saveCanvas(_this.canvas);
|
|
@@ -20339,10 +20343,34 @@ var TextItem = /** @class */ (function (_super) {
|
|
|
20339
20343
|
_this.textStyle = new TextStyle(options);
|
|
20340
20344
|
_this.textLayout = new TextLayout(options);
|
|
20341
20345
|
_this.text = options.text;
|
|
20346
|
+
_this.lineCount = _this.getLineCount(options.text, true);
|
|
20342
20347
|
// Text
|
|
20343
20348
|
_this.mesh = new TextMesh(_this.engine, _this.renderInfo, vfxItem.composition);
|
|
20344
20349
|
return _this;
|
|
20345
20350
|
}
|
|
20351
|
+
TextItem.prototype.getLineCount = function (text, init) {
|
|
20352
|
+
var _a, _b;
|
|
20353
|
+
var context = this.context;
|
|
20354
|
+
var letterSpace = this.textLayout.letterSpace;
|
|
20355
|
+
var fontScale = init ? this.textStyle.fontSize / 10 : 1 / this.textStyle.fontScale;
|
|
20356
|
+
var width = (this.textLayout.width + this.textStyle.fontOffset);
|
|
20357
|
+
var lineCount = 1;
|
|
20358
|
+
var x = 0;
|
|
20359
|
+
for (var i = 0; i < text.length; i++) {
|
|
20360
|
+
var str = text[i];
|
|
20361
|
+
var textMetrics = ((_b = (_a = context === null || context === void 0 ? void 0 : context.measureText(str)) === null || _a === void 0 ? void 0 : _a.width) !== null && _b !== void 0 ? _b : 0) * fontScale;
|
|
20362
|
+
// 和浏览器行为保持一致
|
|
20363
|
+
x += letterSpace;
|
|
20364
|
+
if (((x + textMetrics) > width && i > 0) || str === '\n') {
|
|
20365
|
+
lineCount++;
|
|
20366
|
+
x = 0;
|
|
20367
|
+
}
|
|
20368
|
+
if (str !== '\n') {
|
|
20369
|
+
x += textMetrics;
|
|
20370
|
+
}
|
|
20371
|
+
}
|
|
20372
|
+
return lineCount;
|
|
20373
|
+
};
|
|
20346
20374
|
/**
|
|
20347
20375
|
* 设置字号大小
|
|
20348
20376
|
* @param value - 字号
|
|
@@ -20392,6 +20420,7 @@ var TextItem = /** @class */ (function (_super) {
|
|
|
20392
20420
|
return;
|
|
20393
20421
|
}
|
|
20394
20422
|
this.text = value;
|
|
20423
|
+
this.lineCount = this.getLineCount(value, false);
|
|
20395
20424
|
this.isDirty = true;
|
|
20396
20425
|
};
|
|
20397
20426
|
/**
|
|
@@ -20563,8 +20592,7 @@ var TextItem = /** @class */ (function (_super) {
|
|
|
20563
20592
|
context.fillStyle = "rgba(".concat(style.textColor[0], ", ").concat(style.textColor[1], ", ").concat(style.textColor[2], ", ").concat(style.textColor[3], ")");
|
|
20564
20593
|
var charsInfo = [];
|
|
20565
20594
|
var x = 0;
|
|
20566
|
-
var
|
|
20567
|
-
var y = layout.getOffsetY(style, lineCount, lineHeight);
|
|
20595
|
+
var y = layout.getOffsetY(style, this.lineCount, lineHeight);
|
|
20568
20596
|
var charsArray = [];
|
|
20569
20597
|
var charOffsetX = [];
|
|
20570
20598
|
for (var i = 0; i < this.char.length; i++) {
|
|
@@ -30996,7 +31024,7 @@ Renderer.create = function (canvas, framework, renderOptions) {
|
|
|
30996
31024
|
Engine.create = function (gl) {
|
|
30997
31025
|
return new GLEngine(gl);
|
|
30998
31026
|
};
|
|
30999
|
-
var version = "1.6.0
|
|
31027
|
+
var version = "1.6.0";
|
|
31000
31028
|
logger.info('player version: ' + version);
|
|
31001
31029
|
|
|
31002
31030
|
exports.AbstractPlugin = AbstractPlugin;
|