@galacean/effects-threejs 2.8.2 → 2.8.3
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 +105 -32
- 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 +105 -32
- 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.3
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
'use strict';
|
|
@@ -18392,6 +18392,15 @@ exports.PostProcessVolume = __decorate([
|
|
|
18392
18392
|
});
|
|
18393
18393
|
})();
|
|
18394
18394
|
};
|
|
18395
|
+
_proto.onUpdate = function onUpdate(dt) {
|
|
18396
|
+
for(var i = 0; i < this.materials.length; i++){
|
|
18397
|
+
var material = this.materials[i];
|
|
18398
|
+
material.setVector2("_Size", this.transform.size);
|
|
18399
|
+
if (this.renderer.renderMode === RenderMode.BILLBOARD || this.renderer.renderMode === RenderMode.VERTICAL_BILLBOARD || this.renderer.renderMode === RenderMode.HORIZONTAL_BILLBOARD) {
|
|
18400
|
+
material.setVector3("_Scale", this.transform.scale);
|
|
18401
|
+
}
|
|
18402
|
+
}
|
|
18403
|
+
};
|
|
18395
18404
|
_proto.render = function render(renderer) {
|
|
18396
18405
|
if (!this.getVisible()) {
|
|
18397
18406
|
return;
|
|
@@ -18453,12 +18462,7 @@ exports.PostProcessVolume = __decorate([
|
|
|
18453
18462
|
};
|
|
18454
18463
|
_proto.draw = function draw(renderer) {
|
|
18455
18464
|
for(var i = 0; i < this.materials.length; i++){
|
|
18456
|
-
|
|
18457
|
-
material.setVector2("_Size", this.transform.size);
|
|
18458
|
-
if (this.renderer.renderMode === RenderMode.BILLBOARD || this.renderer.renderMode === RenderMode.VERTICAL_BILLBOARD || this.renderer.renderMode === RenderMode.HORIZONTAL_BILLBOARD) {
|
|
18459
|
-
material.setVector3("_Scale", this.transform.scale);
|
|
18460
|
-
}
|
|
18461
|
-
renderer.drawGeometry(this.geometry, this.transform.getWorldMatrix(), material, i);
|
|
18465
|
+
renderer.drawGeometry(this.geometry, this.transform.getWorldMatrix(), this.materials[i], i);
|
|
18462
18466
|
}
|
|
18463
18467
|
};
|
|
18464
18468
|
_proto.fromData = function fromData(data) {
|
|
@@ -25716,6 +25720,7 @@ exports.SpriteComponent = /*#__PURE__*/ function(MaskableGraphic) {
|
|
|
25716
25720
|
var _proto = SpriteComponent.prototype;
|
|
25717
25721
|
_proto.onUpdate = function onUpdate(dt) {
|
|
25718
25722
|
var _this = this;
|
|
25723
|
+
MaskableGraphic.prototype.onUpdate.call(this, dt);
|
|
25719
25724
|
var time = this.time;
|
|
25720
25725
|
var duration = this.duration;
|
|
25721
25726
|
var textureAnimation = this.textureSheetAnimation;
|
|
@@ -28709,11 +28714,11 @@ var TextLayout = /*#__PURE__*/ function() {
|
|
|
28709
28714
|
* @param totalLineHeight - 可选的实际总行高,用于替代默认计算
|
|
28710
28715
|
* @returns - 行高偏移值
|
|
28711
28716
|
*/ _proto.getOffsetY = function getOffsetY(style, lineCount, lineHeight, fontSize, totalLineHeight) {
|
|
28712
|
-
var
|
|
28717
|
+
var fontScale = style.fontScale;
|
|
28713
28718
|
// /3 计算Y轴偏移量,以匹配编辑器行为
|
|
28714
28719
|
var offsetY = (lineHeight - fontSize) / 3;
|
|
28715
28720
|
// 计算基础偏移量
|
|
28716
|
-
var baseOffset = fontSize
|
|
28721
|
+
var baseOffset = fontSize;
|
|
28717
28722
|
var commonCalculation = totalLineHeight !== undefined ? totalLineHeight : lineHeight * (lineCount - 1);
|
|
28718
28723
|
var offsetResult = 0;
|
|
28719
28724
|
switch(this.textVerticalAlign){
|
|
@@ -28729,11 +28734,16 @@ var TextLayout = /*#__PURE__*/ function() {
|
|
|
28729
28734
|
}
|
|
28730
28735
|
return offsetResult;
|
|
28731
28736
|
};
|
|
28732
|
-
|
|
28737
|
+
/**
|
|
28738
|
+
* 获取初始的水平偏移值
|
|
28739
|
+
* @param style - 字体基础数据
|
|
28740
|
+
* @param maxWidth - 最大行宽
|
|
28741
|
+
* @returns - 水平偏移值
|
|
28742
|
+
*/ _proto.getOffsetX = function getOffsetX(style, maxWidth) {
|
|
28733
28743
|
var offsetX = 0;
|
|
28734
28744
|
switch(this.textAlign){
|
|
28735
28745
|
case TextAlignment.left:
|
|
28736
|
-
offsetX =
|
|
28746
|
+
offsetX = 0;
|
|
28737
28747
|
break;
|
|
28738
28748
|
case TextAlignment.middle:
|
|
28739
28749
|
offsetX = (this.width * style.fontScale - maxWidth) / 2;
|
|
@@ -28809,7 +28819,8 @@ var TextStyle = /*#__PURE__*/ function() {
|
|
|
28809
28819
|
1
|
|
28810
28820
|
];
|
|
28811
28821
|
this.outlineWidth = 0;
|
|
28812
|
-
|
|
28822
|
+
var _outline_outlineWidth;
|
|
28823
|
+
if (outline && ((_outline_outlineWidth = outline.outlineWidth) != null ? _outline_outlineWidth : 0) > 0) {
|
|
28813
28824
|
this.isOutlined = true;
|
|
28814
28825
|
var _outline_outlineColor;
|
|
28815
28826
|
this.outlineColor = [].concat((_outline_outlineColor = outline.outlineColor) != null ? _outline_outlineColor : [
|
|
@@ -28818,8 +28829,8 @@ var TextStyle = /*#__PURE__*/ function() {
|
|
|
28818
28829
|
1,
|
|
28819
28830
|
1
|
|
28820
28831
|
]);
|
|
28821
|
-
var
|
|
28822
|
-
this.outlineWidth = (
|
|
28832
|
+
var _outline_outlineWidth1;
|
|
28833
|
+
this.outlineWidth = (_outline_outlineWidth1 = outline.outlineWidth) != null ? _outline_outlineWidth1 : 0;
|
|
28823
28834
|
}
|
|
28824
28835
|
// 重置阴影状态
|
|
28825
28836
|
this.hasShadow = false;
|
|
@@ -29080,6 +29091,10 @@ exports.TextComponent = /*#__PURE__*/ function(MaskableGraphic) {
|
|
|
29080
29091
|
* 文本行数
|
|
29081
29092
|
*/ _this.lineCount = 0;
|
|
29082
29093
|
/**
|
|
29094
|
+
* 描边/阴影等特效导致的纹理扩容比例 X/Y
|
|
29095
|
+
*/ _this.effectScaleX = 1;
|
|
29096
|
+
_this.effectScaleY = 1;
|
|
29097
|
+
/**
|
|
29083
29098
|
* 每一行文本的最大宽度
|
|
29084
29099
|
*/ _this.maxLineWidth = 0;
|
|
29085
29100
|
/**
|
|
@@ -29141,6 +29156,16 @@ exports.TextComponent = /*#__PURE__*/ function(MaskableGraphic) {
|
|
|
29141
29156
|
_proto.onUpdate = function onUpdate(dt) {
|
|
29142
29157
|
MaskableGraphic.prototype.onUpdate.call(this, dt);
|
|
29143
29158
|
this.updateTexture();
|
|
29159
|
+
// 覆盖基类每帧更新 size 行为,应用扩容比例
|
|
29160
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(this.materials), _step; !(_step = _iterator()).done;){
|
|
29161
|
+
var material = _step.value;
|
|
29162
|
+
var sizeX = this.transform.size.x;
|
|
29163
|
+
var sizeY = this.transform.size.y;
|
|
29164
|
+
var _this_getTextureExpandScale = this.getTextureExpandScale(), scalex = _this_getTextureExpandScale[0], scaley = _this_getTextureExpandScale[1];
|
|
29165
|
+
sizeX *= scalex;
|
|
29166
|
+
sizeY *= scaley;
|
|
29167
|
+
material.setVector2("_Size", new Vector2(sizeX, sizeY));
|
|
29168
|
+
}
|
|
29144
29169
|
};
|
|
29145
29170
|
_proto.onDestroy = function onDestroy() {
|
|
29146
29171
|
MaskableGraphic.prototype.onDestroy.call(this);
|
|
@@ -29330,23 +29355,32 @@ exports.TextComponent = /*#__PURE__*/ function(MaskableGraphic) {
|
|
|
29330
29355
|
var style = this.textStyle;
|
|
29331
29356
|
var layout = this.textLayout;
|
|
29332
29357
|
var fontScale = style.fontScale;
|
|
29333
|
-
var
|
|
29358
|
+
var baseWidth = (layout.width + style.fontOffset) * fontScale;
|
|
29334
29359
|
var finalHeight = layout.lineHeight * this.lineCount;
|
|
29335
29360
|
var fontSize = style.fontSize * fontScale;
|
|
29336
29361
|
var lineHeight = layout.lineHeight * fontScale;
|
|
29337
29362
|
style.fontDesc = this.getFontDesc(fontSize);
|
|
29338
29363
|
var char = (this.text || "").split("");
|
|
29364
|
+
var baseHeight = 0;
|
|
29339
29365
|
if (layout.autoWidth) {
|
|
29340
|
-
|
|
29366
|
+
baseHeight = finalHeight * fontScale;
|
|
29341
29367
|
this.item.transform.size.set(1, finalHeight / layout.height);
|
|
29342
29368
|
} else {
|
|
29343
|
-
|
|
29344
|
-
}
|
|
29345
|
-
var
|
|
29346
|
-
|
|
29369
|
+
baseHeight = layout.height * fontScale;
|
|
29370
|
+
}
|
|
29371
|
+
var _this_getEffectPadding = this.getEffectPadding(), padL = _this_getEffectPadding.padL, padR = _this_getEffectPadding.padR, padT = _this_getEffectPadding.padT, padB = _this_getEffectPadding.padB;
|
|
29372
|
+
var hasEffect = (padL | padR | padT | padB) !== 0;
|
|
29373
|
+
var texWidth = hasEffect ? Math.ceil(baseWidth + padL + padR) : baseWidth;
|
|
29374
|
+
var texHeight = hasEffect ? Math.ceil(baseHeight + padT + padB) : baseHeight;
|
|
29375
|
+
var shiftX = hasEffect ? padL : 0;
|
|
29376
|
+
var shiftY = hasEffect ? flipY ? padT : padB : 0;
|
|
29377
|
+
// 给渲染层用:扩容比例
|
|
29378
|
+
this.effectScaleX = baseWidth > 0 ? texWidth / baseWidth : 1;
|
|
29379
|
+
this.effectScaleY = baseHeight > 0 ? texHeight / baseHeight : 1;
|
|
29380
|
+
this.renderToTexture(texWidth, texHeight, flipY, function(context) {
|
|
29347
29381
|
// canvas size 变化后重新刷新 context
|
|
29348
|
-
if (_this.maxLineWidth >
|
|
29349
|
-
context.font = _this.getFontDesc(fontSize *
|
|
29382
|
+
if (_this.maxLineWidth > baseWidth && layout.overflow === TextOverflow.display) {
|
|
29383
|
+
context.font = _this.getFontDesc(fontSize * baseWidth / _this.maxLineWidth);
|
|
29350
29384
|
} else {
|
|
29351
29385
|
context.font = style.fontDesc;
|
|
29352
29386
|
}
|
|
@@ -29369,7 +29403,7 @@ exports.TextComponent = /*#__PURE__*/ function(MaskableGraphic) {
|
|
|
29369
29403
|
var textMetrics = context.measureText(str);
|
|
29370
29404
|
// 和浏览器行为保持一致
|
|
29371
29405
|
x += layout.letterSpace * fontScale;
|
|
29372
|
-
if (x + textMetrics.width >
|
|
29406
|
+
if (x + textMetrics.width > baseWidth && i > 0 || str === "\n") {
|
|
29373
29407
|
charsInfo.push({
|
|
29374
29408
|
y: y,
|
|
29375
29409
|
width: x,
|
|
@@ -29393,14 +29427,27 @@ exports.TextComponent = /*#__PURE__*/ function(MaskableGraphic) {
|
|
|
29393
29427
|
chars: charsArray,
|
|
29394
29428
|
charOffsetX: charOffsetX
|
|
29395
29429
|
});
|
|
29396
|
-
|
|
29397
|
-
|
|
29398
|
-
|
|
29399
|
-
|
|
29400
|
-
|
|
29430
|
+
// 先描边
|
|
29431
|
+
if (style.isOutlined) {
|
|
29432
|
+
charsInfo.forEach(function(charInfo) {
|
|
29433
|
+
var ox = layout.getOffsetX(style, charInfo.width);
|
|
29434
|
+
for(var i = 0; i < charInfo.chars.length; i++){
|
|
29435
|
+
var str = charInfo.chars[i];
|
|
29436
|
+
var drawX = shiftX + ox + charInfo.charOffsetX[i];
|
|
29437
|
+
var drawY = shiftY + charInfo.y;
|
|
29438
|
+
context.strokeText(str, drawX, drawY);
|
|
29401
29439
|
}
|
|
29402
|
-
context.fillText(str, x + charInfo.charOffsetX[i], charInfo.y);
|
|
29403
29440
|
});
|
|
29441
|
+
}
|
|
29442
|
+
// 再填充
|
|
29443
|
+
charsInfo.forEach(function(charInfo) {
|
|
29444
|
+
var ox = layout.getOffsetX(style, charInfo.width);
|
|
29445
|
+
for(var i = 0; i < charInfo.chars.length; i++){
|
|
29446
|
+
var str = charInfo.chars[i];
|
|
29447
|
+
var drawX = shiftX + ox + charInfo.charOffsetX[i];
|
|
29448
|
+
var drawY = shiftY + charInfo.y;
|
|
29449
|
+
context.fillText(str, drawX, drawY);
|
|
29450
|
+
}
|
|
29404
29451
|
});
|
|
29405
29452
|
if (style.hasShadow) {
|
|
29406
29453
|
context.shadowColor = "transparent";
|
|
@@ -29411,6 +29458,32 @@ exports.TextComponent = /*#__PURE__*/ function(MaskableGraphic) {
|
|
|
29411
29458
|
_proto.renderText = function renderText(options) {
|
|
29412
29459
|
this.updateTexture();
|
|
29413
29460
|
};
|
|
29461
|
+
/**
|
|
29462
|
+
* 给渲染层用:获取特效扩容比例(描边/阴影导致的纹理扩容)
|
|
29463
|
+
* @returns
|
|
29464
|
+
*/ _proto.getTextureExpandScale = function getTextureExpandScale() {
|
|
29465
|
+
return [
|
|
29466
|
+
this.effectScaleX,
|
|
29467
|
+
this.effectScaleY
|
|
29468
|
+
];
|
|
29469
|
+
};
|
|
29470
|
+
/**
|
|
29471
|
+
* 获取描边和阴影的 padding 值(单位:px)
|
|
29472
|
+
* @returns
|
|
29473
|
+
*/ _proto.getEffectPadding = function getEffectPadding() {
|
|
29474
|
+
var style = this.textStyle;
|
|
29475
|
+
var hasDrawOutline = style.isOutlined && style.outlineWidth > 0;
|
|
29476
|
+
var outlinePad = hasDrawOutline ? Math.ceil(style.outlineWidth * 2 * style.fontScale) : 0;
|
|
29477
|
+
var hasShadow = style.hasShadow && (style.shadowBlur > 0 || style.shadowOffsetX !== 0 || style.shadowOffsetY !== 0);
|
|
29478
|
+
var shadowPad = hasShadow ? Math.ceil((Math.abs(style.shadowOffsetX) + Math.abs(style.shadowOffsetY) + style.shadowBlur) * style.fontScale) : 0;
|
|
29479
|
+
var pad = outlinePad + shadowPad;
|
|
29480
|
+
return {
|
|
29481
|
+
padL: pad,
|
|
29482
|
+
padR: pad,
|
|
29483
|
+
padT: pad,
|
|
29484
|
+
padB: pad
|
|
29485
|
+
};
|
|
29486
|
+
};
|
|
29414
29487
|
_proto.setAutoWidth = function setAutoWidth(value) {
|
|
29415
29488
|
var layout = this.textLayout;
|
|
29416
29489
|
var normalizedValue = !!value;
|
|
@@ -31559,7 +31632,7 @@ function getStandardSpriteContent(sprite, transform) {
|
|
|
31559
31632
|
return ret;
|
|
31560
31633
|
}
|
|
31561
31634
|
|
|
31562
|
-
var version$2 = "2.8.
|
|
31635
|
+
var version$2 = "2.8.3";
|
|
31563
31636
|
var v0 = /^(\d+)\.(\d+)\.(\d+)(-(\w+)\.\d+)?$/;
|
|
31564
31637
|
var standardVersion = /^(\d+)\.(\d+)$/;
|
|
31565
31638
|
var reverseParticle = false;
|
|
@@ -35259,7 +35332,7 @@ registerPlugin("text", TextLoader);
|
|
|
35259
35332
|
registerPlugin("sprite", SpriteLoader);
|
|
35260
35333
|
registerPlugin("particle", ParticleLoader);
|
|
35261
35334
|
registerPlugin("interact", InteractLoader);
|
|
35262
|
-
var version$1 = "2.8.
|
|
35335
|
+
var version$1 = "2.8.3";
|
|
35263
35336
|
logger.info("Core version: " + version$1 + ".");
|
|
35264
35337
|
|
|
35265
35338
|
var _obj;
|
|
@@ -36836,7 +36909,7 @@ applyMixins(exports.ThreeTextComponent, [
|
|
|
36836
36909
|
*/ Mesh.create = function(engine, props) {
|
|
36837
36910
|
return new ThreeMesh(engine, props);
|
|
36838
36911
|
};
|
|
36839
|
-
var version = "2.8.
|
|
36912
|
+
var version = "2.8.3";
|
|
36840
36913
|
logger.info("THREEJS plugin version: " + version + ".");
|
|
36841
36914
|
|
|
36842
36915
|
exports.ActivationMixerPlayable = ActivationMixerPlayable;
|