@galacean/effects-threejs 2.8.7 → 2.8.9
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 +43 -26
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +2 -2
- package/dist/index.min.js.map +1 -1
- package/dist/index.mjs +43 -26
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
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: v2.8.
|
|
6
|
+
* Version: v2.8.9
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
'use strict';
|
|
@@ -17867,14 +17867,14 @@ exports.CompositionComponent = /*#__PURE__*/ function(Component) {
|
|
|
17867
17867
|
}
|
|
17868
17868
|
}
|
|
17869
17869
|
}
|
|
17870
|
-
|
|
17871
|
-
|
|
17872
|
-
|
|
17873
|
-
|
|
17874
|
-
}
|
|
17875
|
-
|
|
17876
|
-
|
|
17877
|
-
|
|
17870
|
+
}
|
|
17871
|
+
if (exports.VFXItem.isComposition(hitTestItem)) {
|
|
17872
|
+
if (hitTestItem.getComponent(CompositionComponent).hitTest(ray, x, y, regions, force, options)) {
|
|
17873
|
+
hitTestSuccess = true;
|
|
17874
|
+
}
|
|
17875
|
+
} else {
|
|
17876
|
+
if (_this.hitTestRecursive(hitTestItem, ray, x, y, regions, force, options)) {
|
|
17877
|
+
hitTestSuccess = true;
|
|
17878
17878
|
}
|
|
17879
17879
|
}
|
|
17880
17880
|
};
|
|
@@ -29007,8 +29007,8 @@ var TextComponentBase = /*#__PURE__*/ function() {
|
|
|
29007
29007
|
};
|
|
29008
29008
|
_proto.setupShadow = function setupShadow() {
|
|
29009
29009
|
var context = this.context;
|
|
29010
|
-
var _this_textStyle = this.textStyle,
|
|
29011
|
-
var r =
|
|
29010
|
+
var _this_textStyle = this.textStyle, shadowColor = _this_textStyle.shadowColor, shadowBlur = _this_textStyle.shadowBlur, shadowOffsetX = _this_textStyle.shadowOffsetX, shadowOffsetY = _this_textStyle.shadowOffsetY;
|
|
29011
|
+
var r = shadowColor[0], g = shadowColor[1], b = shadowColor[2], a = shadowColor[3];
|
|
29012
29012
|
if (context) {
|
|
29013
29013
|
context.shadowColor = "rgba(" + r * 255 + ", " + g * 255 + ", " + b * 255 + ", " + a + ")";
|
|
29014
29014
|
context.shadowBlur = shadowBlur;
|
|
@@ -29233,11 +29233,11 @@ exports.TextComponent = /*#__PURE__*/ function(MaskableGraphic) {
|
|
|
29233
29233
|
_proto.getLineCount = function getLineCount(text) {
|
|
29234
29234
|
var context = this.context;
|
|
29235
29235
|
var _this_textLayout = this.textLayout, letterSpace = _this_textLayout.letterSpace, overflow = _this_textLayout.overflow;
|
|
29236
|
-
// const fontScale = init ? this.textStyle.fontSize / 10 : 1 / this.textStyle.fontScale;
|
|
29237
29236
|
this.maxLineWidth = 0;
|
|
29238
29237
|
var width = this.textLayout.width + this.textStyle.fontOffset;
|
|
29239
29238
|
var lineCount = 1;
|
|
29240
29239
|
var x = 0;
|
|
29240
|
+
var charCountInLine = 0; // 跟踪当前行的字符数
|
|
29241
29241
|
// 设置 context.font 的字号,确保 measureText 能正确计算字宽
|
|
29242
29242
|
if (context) {
|
|
29243
29243
|
context.font = this.getFontDesc(this.textStyle.fontSize);
|
|
@@ -29248,14 +29248,19 @@ exports.TextComponent = /*#__PURE__*/ function(MaskableGraphic) {
|
|
|
29248
29248
|
var _context_measureText_width;
|
|
29249
29249
|
var textMetrics = (_context_measureText_width = context == null ? void 0 : (_context_measureText = context.measureText(str)) == null ? void 0 : _context_measureText.width) != null ? _context_measureText_width : 0;
|
|
29250
29250
|
// 和浏览器行为保持一致
|
|
29251
|
-
|
|
29251
|
+
// 字符间距只应用在字符之间,每行第一个字符不加间距
|
|
29252
|
+
if (charCountInLine > 0) {
|
|
29253
|
+
x += letterSpace;
|
|
29254
|
+
}
|
|
29252
29255
|
// 处理文本结束行为
|
|
29253
29256
|
if (overflow === TextOverflow.display) {
|
|
29254
29257
|
if (str === "\n") {
|
|
29255
29258
|
lineCount++;
|
|
29256
29259
|
x = 0;
|
|
29260
|
+
charCountInLine = 0; // 重置行字符计数
|
|
29257
29261
|
} else {
|
|
29258
29262
|
x += textMetrics;
|
|
29263
|
+
charCountInLine++;
|
|
29259
29264
|
this.maxLineWidth = Math.max(this.maxLineWidth, x);
|
|
29260
29265
|
}
|
|
29261
29266
|
} else {
|
|
@@ -29263,9 +29268,11 @@ exports.TextComponent = /*#__PURE__*/ function(MaskableGraphic) {
|
|
|
29263
29268
|
lineCount++;
|
|
29264
29269
|
this.maxLineWidth = Math.max(this.maxLineWidth, x);
|
|
29265
29270
|
x = 0;
|
|
29271
|
+
charCountInLine = 0; // 重置行字符计数
|
|
29266
29272
|
}
|
|
29267
29273
|
if (str !== "\n") {
|
|
29268
29274
|
x += textMetrics;
|
|
29275
|
+
charCountInLine++;
|
|
29269
29276
|
}
|
|
29270
29277
|
}
|
|
29271
29278
|
}
|
|
@@ -29394,12 +29401,6 @@ exports.TextComponent = /*#__PURE__*/ function(MaskableGraphic) {
|
|
|
29394
29401
|
} else {
|
|
29395
29402
|
context.font = style.fontDesc;
|
|
29396
29403
|
}
|
|
29397
|
-
if (style.hasShadow) {
|
|
29398
|
-
_this.setupShadow();
|
|
29399
|
-
}
|
|
29400
|
-
if (style.isOutlined) {
|
|
29401
|
-
_this.setupOutline();
|
|
29402
|
-
}
|
|
29403
29404
|
// textColor 统一是 0-1,写入 canvas 时乘 255
|
|
29404
29405
|
var _style_textColor = style.textColor, r = _style_textColor[0], g = _style_textColor[1], b = _style_textColor[2], a = _style_textColor[3];
|
|
29405
29406
|
context.fillStyle = "rgba(" + r * 255 + ", " + g * 255 + ", " + b * 255 + ", " + a + ")";
|
|
@@ -29412,7 +29413,10 @@ exports.TextComponent = /*#__PURE__*/ function(MaskableGraphic) {
|
|
|
29412
29413
|
var str = char[i];
|
|
29413
29414
|
var textMetrics = context.measureText(str);
|
|
29414
29415
|
// 和浏览器行为保持一致
|
|
29415
|
-
|
|
29416
|
+
// 字符间距只应用在字符之间,每行第一个字符不加间距
|
|
29417
|
+
if (charsArray.length > 0) {
|
|
29418
|
+
x += layout.letterSpace * fontScale;
|
|
29419
|
+
}
|
|
29416
29420
|
if (x + textMetrics.width > baseWidth && i > 0 || str === "\n") {
|
|
29417
29421
|
charsInfo.push({
|
|
29418
29422
|
y: y,
|
|
@@ -29437,8 +29441,13 @@ exports.TextComponent = /*#__PURE__*/ function(MaskableGraphic) {
|
|
|
29437
29441
|
chars: charsArray,
|
|
29438
29442
|
charOffsetX: charOffsetX
|
|
29439
29443
|
});
|
|
29440
|
-
|
|
29441
|
-
if (
|
|
29444
|
+
var hasOutline = style.isOutlined && style.outlineWidth > 0;
|
|
29445
|
+
if (hasOutline) {
|
|
29446
|
+
// 有描边:在描边时启用阴影
|
|
29447
|
+
if (style.hasShadow) {
|
|
29448
|
+
_this.setupShadow();
|
|
29449
|
+
}
|
|
29450
|
+
_this.setupOutline();
|
|
29442
29451
|
charsInfo.forEach(function(charInfo) {
|
|
29443
29452
|
var ox = layout.getOffsetX(style, charInfo.width);
|
|
29444
29453
|
for(var i = 0; i < charInfo.chars.length; i++){
|
|
@@ -29448,8 +29457,15 @@ exports.TextComponent = /*#__PURE__*/ function(MaskableGraphic) {
|
|
|
29448
29457
|
context.strokeText(str, drawX, drawY);
|
|
29449
29458
|
}
|
|
29450
29459
|
});
|
|
29460
|
+
// 描边完成后立即禁用阴影,避免填充时重复绘制阴影
|
|
29461
|
+
if (style.hasShadow) {
|
|
29462
|
+
context.shadowColor = "transparent";
|
|
29463
|
+
}
|
|
29464
|
+
}
|
|
29465
|
+
// 填充阶段:无描边时才启用阴影
|
|
29466
|
+
if (!hasOutline && style.hasShadow) {
|
|
29467
|
+
_this.setupShadow();
|
|
29451
29468
|
}
|
|
29452
|
-
// 再填充
|
|
29453
29469
|
charsInfo.forEach(function(charInfo) {
|
|
29454
29470
|
var ox = layout.getOffsetX(style, charInfo.width);
|
|
29455
29471
|
for(var i = 0; i < charInfo.chars.length; i++){
|
|
@@ -29459,6 +29475,7 @@ exports.TextComponent = /*#__PURE__*/ function(MaskableGraphic) {
|
|
|
29459
29475
|
context.fillText(str, drawX, drawY);
|
|
29460
29476
|
}
|
|
29461
29477
|
});
|
|
29478
|
+
// 清理阴影状态
|
|
29462
29479
|
if (style.hasShadow) {
|
|
29463
29480
|
context.shadowColor = "transparent";
|
|
29464
29481
|
}
|
|
@@ -31642,7 +31659,7 @@ function getStandardSpriteContent(sprite, transform) {
|
|
|
31642
31659
|
return ret;
|
|
31643
31660
|
}
|
|
31644
31661
|
|
|
31645
|
-
var version$2 = "2.8.
|
|
31662
|
+
var version$2 = "2.8.9";
|
|
31646
31663
|
var v0 = /^(\d+)\.(\d+)\.(\d+)(-(\w+)\.\d+)?$/;
|
|
31647
31664
|
var standardVersion = /^(\d+)\.(\d+)$/;
|
|
31648
31665
|
var reverseParticle = false;
|
|
@@ -35342,7 +35359,7 @@ registerPlugin("text", TextLoader);
|
|
|
35342
35359
|
registerPlugin("sprite", SpriteLoader);
|
|
35343
35360
|
registerPlugin("particle", ParticleLoader);
|
|
35344
35361
|
registerPlugin("interact", InteractLoader);
|
|
35345
|
-
var version$1 = "2.8.
|
|
35362
|
+
var version$1 = "2.8.9";
|
|
35346
35363
|
logger.info("Core version: " + version$1 + ".");
|
|
35347
35364
|
|
|
35348
35365
|
var _obj;
|
|
@@ -36919,7 +36936,7 @@ applyMixins(exports.ThreeTextComponent, [
|
|
|
36919
36936
|
*/ Mesh.create = function(engine, props) {
|
|
36920
36937
|
return new ThreeMesh(engine, props);
|
|
36921
36938
|
};
|
|
36922
|
-
var version = "2.8.
|
|
36939
|
+
var version = "2.8.9";
|
|
36923
36940
|
logger.info("THREEJS plugin version: " + version + ".");
|
|
36924
36941
|
|
|
36925
36942
|
exports.ActivationMixerPlayable = ActivationMixerPlayable;
|