@galacean/effects-core 2.8.1 → 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/components/base-render-component.d.ts +1 -0
- package/dist/components/composition-component.d.ts +3 -2
- package/dist/index.js +181 -67
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +181 -67
- package/dist/index.mjs.map +1 -1
- package/dist/plugins/text/text-item.d.ts +20 -0
- package/dist/plugins/text/text-layout.d.ts +6 -0
- package/package.json +1 -1
|
@@ -85,6 +85,7 @@ export declare class MaskableGraphic extends RendererComponent implements Maskab
|
|
|
85
85
|
* @since 2.3.0
|
|
86
86
|
*/
|
|
87
87
|
setTexture(input: string): Promise<void>;
|
|
88
|
+
onUpdate(dt: number): void;
|
|
88
89
|
render(renderer: Renderer): void;
|
|
89
90
|
onStart(): void;
|
|
90
91
|
getHitTestParams: (force?: boolean) => HitTestTriangleParams | undefined;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Ray } from '@galacean/effects-math/es/core/ray';
|
|
2
|
-
import
|
|
2
|
+
import * as spec from '@galacean/effects-specification';
|
|
3
3
|
import type { CompositionHitTestOptions } from '../composition';
|
|
4
4
|
import type { Region, TrackAsset } from '../plugins';
|
|
5
5
|
import { VFXItem } from '../vfx-item';
|
|
@@ -30,6 +30,7 @@ export declare class CompositionComponent extends Component {
|
|
|
30
30
|
onEnable(): void;
|
|
31
31
|
onDisable(): void;
|
|
32
32
|
onDestroy(): void;
|
|
33
|
-
hitTest(ray: Ray, x: number, y: number, regions: Region[], force?: boolean, options?: CompositionHitTestOptions):
|
|
33
|
+
hitTest(ray: Ray, x: number, y: number, regions: Region[], force?: boolean, options?: CompositionHitTestOptions): boolean;
|
|
34
|
+
private hitTestRecursive;
|
|
34
35
|
fromData(data: any): void;
|
|
35
36
|
}
|
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: v2.8.
|
|
6
|
+
* Version: v2.8.3
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
'use strict';
|
|
@@ -13350,22 +13350,34 @@ function _loadVideo() {
|
|
|
13350
13350
|
return [
|
|
13351
13351
|
2,
|
|
13352
13352
|
new Promise(function(resolve, reject) {
|
|
13353
|
-
var
|
|
13353
|
+
var settled = false;
|
|
13354
|
+
var handleSuccess = function() {
|
|
13355
|
+
if (settled) {
|
|
13356
|
+
return;
|
|
13357
|
+
}
|
|
13358
|
+
settled = true;
|
|
13359
|
+
cleanup();
|
|
13354
13360
|
resolve(video);
|
|
13355
|
-
video.removeEventListener("error", handleError);
|
|
13356
13361
|
};
|
|
13357
|
-
var handleError = function(
|
|
13358
|
-
|
|
13362
|
+
var handleError = function() {
|
|
13363
|
+
if (settled) {
|
|
13364
|
+
return;
|
|
13365
|
+
}
|
|
13366
|
+
settled = true;
|
|
13367
|
+
cleanup();
|
|
13359
13368
|
reject("Load video fail.");
|
|
13360
13369
|
};
|
|
13361
|
-
|
|
13362
|
-
|
|
13363
|
-
|
|
13364
|
-
|
|
13365
|
-
|
|
13370
|
+
var cleanup = function() {
|
|
13371
|
+
video.removeEventListener("loadeddata", handleSuccess);
|
|
13372
|
+
video.removeEventListener("canplay", handleSuccess);
|
|
13373
|
+
video.removeEventListener("error", handleError);
|
|
13374
|
+
};
|
|
13375
|
+
video.addEventListener("loadeddata", handleSuccess);
|
|
13376
|
+
video.addEventListener("canplay", handleSuccess);
|
|
13377
|
+
video.addEventListener("error", handleError);
|
|
13378
|
+
video.play().catch(function(err) {
|
|
13379
|
+
console.warn("Autoplay blocked:", err);
|
|
13366
13380
|
});
|
|
13367
|
-
// 显式触发视频加载
|
|
13368
|
-
video.load();
|
|
13369
13381
|
})
|
|
13370
13382
|
];
|
|
13371
13383
|
});
|
|
@@ -16667,10 +16679,7 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
|
|
|
16667
16679
|
}
|
|
16668
16680
|
var regions = [];
|
|
16669
16681
|
var ray = this.getHitTestRay(x, y);
|
|
16670
|
-
this.
|
|
16671
|
-
var _ref_getComponent;
|
|
16672
|
-
(_ref_getComponent = ref.getComponent(exports.CompositionComponent)) == null ? void 0 : _ref_getComponent.hitTest(ray, x, y, regions, force, options);
|
|
16673
|
-
});
|
|
16682
|
+
this.rootComposition.hitTest(ray, x, y, regions, force, options);
|
|
16674
16683
|
return regions;
|
|
16675
16684
|
};
|
|
16676
16685
|
/**
|
|
@@ -17747,10 +17756,32 @@ exports.CompositionComponent = /*#__PURE__*/ function(Component) {
|
|
|
17747
17756
|
});
|
|
17748
17757
|
};
|
|
17749
17758
|
_proto.hitTest = function hitTest(ray, x, y, regions, force, options) {
|
|
17750
|
-
var
|
|
17751
|
-
|
|
17752
|
-
|
|
17753
|
-
|
|
17759
|
+
var _this_item_composition;
|
|
17760
|
+
var isHitTestSuccess = this.hitTestRecursive(this.item, ray, x, y, regions, force, options);
|
|
17761
|
+
// 子元素碰撞测试成功加入当前预合成元素,判断是否是合成根元素,根元素不加入
|
|
17762
|
+
if (isHitTestSuccess && this.item !== ((_this_item_composition = this.item.composition) == null ? void 0 : _this_item_composition.rootItem)) {
|
|
17763
|
+
var item = this.item;
|
|
17764
|
+
var lastRegion = regions[regions.length - 1];
|
|
17765
|
+
var hitPositions = lastRegion.hitPositions;
|
|
17766
|
+
var region = {
|
|
17767
|
+
id: item.getInstanceId(),
|
|
17768
|
+
name: item.name,
|
|
17769
|
+
position: hitPositions[hitPositions.length - 1],
|
|
17770
|
+
parentId: item.parentId,
|
|
17771
|
+
hitPositions: hitPositions,
|
|
17772
|
+
behavior: InteractBehavior.NONE,
|
|
17773
|
+
item: item,
|
|
17774
|
+
composition: item.composition
|
|
17775
|
+
};
|
|
17776
|
+
regions.push(region);
|
|
17777
|
+
}
|
|
17778
|
+
return isHitTestSuccess;
|
|
17779
|
+
};
|
|
17780
|
+
_proto.hitTestRecursive = function hitTestRecursive(item, ray, x, y, regions, force, options) {
|
|
17781
|
+
var _this, _loop = function() {
|
|
17782
|
+
var hitTestItem = _step.value;
|
|
17783
|
+
if (hitTestItem.isActive && hitTestItem.transform.getValid() && !skip(hitTestItem)) {
|
|
17784
|
+
var hitParams = hitTestItem.getHitTestParams(force);
|
|
17754
17785
|
if (hitParams) {
|
|
17755
17786
|
var success = false;
|
|
17756
17787
|
var intersectPoint = new Vector3();
|
|
@@ -17795,35 +17826,48 @@ exports.CompositionComponent = /*#__PURE__*/ function(Component) {
|
|
|
17795
17826
|
}
|
|
17796
17827
|
if (success) {
|
|
17797
17828
|
var region = {
|
|
17798
|
-
|
|
17799
|
-
|
|
17800
|
-
name: item.name,
|
|
17829
|
+
id: hitTestItem.getInstanceId(),
|
|
17830
|
+
name: hitTestItem.name,
|
|
17801
17831
|
position: hitPositions[hitPositions.length - 1],
|
|
17802
|
-
parentId:
|
|
17832
|
+
parentId: hitTestItem.parentId,
|
|
17803
17833
|
hitPositions: hitPositions,
|
|
17804
17834
|
behavior: hitParams.behavior,
|
|
17805
|
-
item:
|
|
17835
|
+
item: hitTestItem,
|
|
17806
17836
|
composition: _this.item.composition
|
|
17807
17837
|
};
|
|
17808
17838
|
regions.push(region);
|
|
17839
|
+
hitTestSuccess = true;
|
|
17809
17840
|
if (stop(region)) {
|
|
17810
17841
|
return {
|
|
17811
|
-
v:
|
|
17842
|
+
v: true
|
|
17812
17843
|
};
|
|
17813
17844
|
}
|
|
17814
17845
|
}
|
|
17815
17846
|
}
|
|
17847
|
+
if (exports.VFXItem.isComposition(hitTestItem)) {
|
|
17848
|
+
if (hitTestItem.getComponent(CompositionComponent).hitTest(ray, x, y, regions, force, options)) {
|
|
17849
|
+
hitTestSuccess = true;
|
|
17850
|
+
}
|
|
17851
|
+
} else {
|
|
17852
|
+
if (_this.hitTestRecursive(hitTestItem, ray, x, y, regions, force, options)) {
|
|
17853
|
+
hitTestSuccess = true;
|
|
17854
|
+
}
|
|
17855
|
+
}
|
|
17816
17856
|
}
|
|
17817
17857
|
};
|
|
17818
17858
|
var hitPositions = [];
|
|
17819
17859
|
var stop = (options == null ? void 0 : options.stop) || noop;
|
|
17820
17860
|
var skip = (options == null ? void 0 : options.skip) || noop;
|
|
17821
|
-
var maxCount =
|
|
17822
|
-
|
|
17823
|
-
|
|
17861
|
+
var maxCount = options == null ? void 0 : options.maxCount;
|
|
17862
|
+
if (maxCount !== undefined && regions.length >= maxCount) {
|
|
17863
|
+
return false;
|
|
17864
|
+
}
|
|
17865
|
+
var hitTestSuccess = false;
|
|
17866
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(item.children), _step; !(_step = _iterator()).done;){
|
|
17867
|
+
var _ret = (_this = this, _loop());
|
|
17824
17868
|
if (_type_of(_ret) === "object") return _ret.v;
|
|
17825
17869
|
}
|
|
17826
|
-
return
|
|
17870
|
+
return hitTestSuccess;
|
|
17827
17871
|
};
|
|
17828
17872
|
/**
|
|
17829
17873
|
* 设置当前合成子元素的渲染顺序
|
|
@@ -18326,6 +18370,15 @@ exports.PostProcessVolume = __decorate([
|
|
|
18326
18370
|
});
|
|
18327
18371
|
})();
|
|
18328
18372
|
};
|
|
18373
|
+
_proto.onUpdate = function onUpdate(dt) {
|
|
18374
|
+
for(var i = 0; i < this.materials.length; i++){
|
|
18375
|
+
var material = this.materials[i];
|
|
18376
|
+
material.setVector2("_Size", this.transform.size);
|
|
18377
|
+
if (this.renderer.renderMode === RenderMode.BILLBOARD || this.renderer.renderMode === RenderMode.VERTICAL_BILLBOARD || this.renderer.renderMode === RenderMode.HORIZONTAL_BILLBOARD) {
|
|
18378
|
+
material.setVector3("_Scale", this.transform.scale);
|
|
18379
|
+
}
|
|
18380
|
+
}
|
|
18381
|
+
};
|
|
18329
18382
|
_proto.render = function render(renderer) {
|
|
18330
18383
|
if (!this.getVisible()) {
|
|
18331
18384
|
return;
|
|
@@ -18387,12 +18440,7 @@ exports.PostProcessVolume = __decorate([
|
|
|
18387
18440
|
};
|
|
18388
18441
|
_proto.draw = function draw(renderer) {
|
|
18389
18442
|
for(var i = 0; i < this.materials.length; i++){
|
|
18390
|
-
|
|
18391
|
-
material.setVector2("_Size", this.transform.size);
|
|
18392
|
-
if (this.renderer.renderMode === RenderMode.BILLBOARD || this.renderer.renderMode === RenderMode.VERTICAL_BILLBOARD || this.renderer.renderMode === RenderMode.HORIZONTAL_BILLBOARD) {
|
|
18393
|
-
material.setVector3("_Scale", this.transform.scale);
|
|
18394
|
-
}
|
|
18395
|
-
renderer.drawGeometry(this.geometry, this.transform.getWorldMatrix(), material, i);
|
|
18443
|
+
renderer.drawGeometry(this.geometry, this.transform.getWorldMatrix(), this.materials[i], i);
|
|
18396
18444
|
}
|
|
18397
18445
|
};
|
|
18398
18446
|
_proto.fromData = function fromData(data) {
|
|
@@ -25650,6 +25698,7 @@ exports.SpriteComponent = /*#__PURE__*/ function(MaskableGraphic) {
|
|
|
25650
25698
|
var _proto = SpriteComponent.prototype;
|
|
25651
25699
|
_proto.onUpdate = function onUpdate(dt) {
|
|
25652
25700
|
var _this = this;
|
|
25701
|
+
MaskableGraphic.prototype.onUpdate.call(this, dt);
|
|
25653
25702
|
var time = this.time;
|
|
25654
25703
|
var duration = this.duration;
|
|
25655
25704
|
var textureAnimation = this.textureSheetAnimation;
|
|
@@ -28643,11 +28692,11 @@ var TextLayout = /*#__PURE__*/ function() {
|
|
|
28643
28692
|
* @param totalLineHeight - 可选的实际总行高,用于替代默认计算
|
|
28644
28693
|
* @returns - 行高偏移值
|
|
28645
28694
|
*/ _proto.getOffsetY = function getOffsetY(style, lineCount, lineHeight, fontSize, totalLineHeight) {
|
|
28646
|
-
var
|
|
28695
|
+
var fontScale = style.fontScale;
|
|
28647
28696
|
// /3 计算Y轴偏移量,以匹配编辑器行为
|
|
28648
28697
|
var offsetY = (lineHeight - fontSize) / 3;
|
|
28649
28698
|
// 计算基础偏移量
|
|
28650
|
-
var baseOffset = fontSize
|
|
28699
|
+
var baseOffset = fontSize;
|
|
28651
28700
|
var commonCalculation = totalLineHeight !== undefined ? totalLineHeight : lineHeight * (lineCount - 1);
|
|
28652
28701
|
var offsetResult = 0;
|
|
28653
28702
|
switch(this.textVerticalAlign){
|
|
@@ -28663,11 +28712,16 @@ var TextLayout = /*#__PURE__*/ function() {
|
|
|
28663
28712
|
}
|
|
28664
28713
|
return offsetResult;
|
|
28665
28714
|
};
|
|
28666
|
-
|
|
28715
|
+
/**
|
|
28716
|
+
* 获取初始的水平偏移值
|
|
28717
|
+
* @param style - 字体基础数据
|
|
28718
|
+
* @param maxWidth - 最大行宽
|
|
28719
|
+
* @returns - 水平偏移值
|
|
28720
|
+
*/ _proto.getOffsetX = function getOffsetX(style, maxWidth) {
|
|
28667
28721
|
var offsetX = 0;
|
|
28668
28722
|
switch(this.textAlign){
|
|
28669
28723
|
case TextAlignment.left:
|
|
28670
|
-
offsetX =
|
|
28724
|
+
offsetX = 0;
|
|
28671
28725
|
break;
|
|
28672
28726
|
case TextAlignment.middle:
|
|
28673
28727
|
offsetX = (this.width * style.fontScale - maxWidth) / 2;
|
|
@@ -28743,7 +28797,8 @@ var TextStyle = /*#__PURE__*/ function() {
|
|
|
28743
28797
|
1
|
|
28744
28798
|
];
|
|
28745
28799
|
this.outlineWidth = 0;
|
|
28746
|
-
|
|
28800
|
+
var _outline_outlineWidth;
|
|
28801
|
+
if (outline && ((_outline_outlineWidth = outline.outlineWidth) != null ? _outline_outlineWidth : 0) > 0) {
|
|
28747
28802
|
this.isOutlined = true;
|
|
28748
28803
|
var _outline_outlineColor;
|
|
28749
28804
|
this.outlineColor = [].concat((_outline_outlineColor = outline.outlineColor) != null ? _outline_outlineColor : [
|
|
@@ -28752,8 +28807,8 @@ var TextStyle = /*#__PURE__*/ function() {
|
|
|
28752
28807
|
1,
|
|
28753
28808
|
1
|
|
28754
28809
|
]);
|
|
28755
|
-
var
|
|
28756
|
-
this.outlineWidth = (
|
|
28810
|
+
var _outline_outlineWidth1;
|
|
28811
|
+
this.outlineWidth = (_outline_outlineWidth1 = outline.outlineWidth) != null ? _outline_outlineWidth1 : 0;
|
|
28757
28812
|
}
|
|
28758
28813
|
// 重置阴影状态
|
|
28759
28814
|
this.hasShadow = false;
|
|
@@ -29014,6 +29069,10 @@ exports.TextComponent = /*#__PURE__*/ function(MaskableGraphic) {
|
|
|
29014
29069
|
* 文本行数
|
|
29015
29070
|
*/ _this.lineCount = 0;
|
|
29016
29071
|
/**
|
|
29072
|
+
* 描边/阴影等特效导致的纹理扩容比例 X/Y
|
|
29073
|
+
*/ _this.effectScaleX = 1;
|
|
29074
|
+
_this.effectScaleY = 1;
|
|
29075
|
+
/**
|
|
29017
29076
|
* 每一行文本的最大宽度
|
|
29018
29077
|
*/ _this.maxLineWidth = 0;
|
|
29019
29078
|
/**
|
|
@@ -29075,6 +29134,16 @@ exports.TextComponent = /*#__PURE__*/ function(MaskableGraphic) {
|
|
|
29075
29134
|
_proto.onUpdate = function onUpdate(dt) {
|
|
29076
29135
|
MaskableGraphic.prototype.onUpdate.call(this, dt);
|
|
29077
29136
|
this.updateTexture();
|
|
29137
|
+
// 覆盖基类每帧更新 size 行为,应用扩容比例
|
|
29138
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(this.materials), _step; !(_step = _iterator()).done;){
|
|
29139
|
+
var material = _step.value;
|
|
29140
|
+
var sizeX = this.transform.size.x;
|
|
29141
|
+
var sizeY = this.transform.size.y;
|
|
29142
|
+
var _this_getTextureExpandScale = this.getTextureExpandScale(), scalex = _this_getTextureExpandScale[0], scaley = _this_getTextureExpandScale[1];
|
|
29143
|
+
sizeX *= scalex;
|
|
29144
|
+
sizeY *= scaley;
|
|
29145
|
+
material.setVector2("_Size", new Vector2(sizeX, sizeY));
|
|
29146
|
+
}
|
|
29078
29147
|
};
|
|
29079
29148
|
_proto.onDestroy = function onDestroy() {
|
|
29080
29149
|
MaskableGraphic.prototype.onDestroy.call(this);
|
|
@@ -29264,23 +29333,32 @@ exports.TextComponent = /*#__PURE__*/ function(MaskableGraphic) {
|
|
|
29264
29333
|
var style = this.textStyle;
|
|
29265
29334
|
var layout = this.textLayout;
|
|
29266
29335
|
var fontScale = style.fontScale;
|
|
29267
|
-
var
|
|
29336
|
+
var baseWidth = (layout.width + style.fontOffset) * fontScale;
|
|
29268
29337
|
var finalHeight = layout.lineHeight * this.lineCount;
|
|
29269
29338
|
var fontSize = style.fontSize * fontScale;
|
|
29270
29339
|
var lineHeight = layout.lineHeight * fontScale;
|
|
29271
29340
|
style.fontDesc = this.getFontDesc(fontSize);
|
|
29272
29341
|
var char = (this.text || "").split("");
|
|
29342
|
+
var baseHeight = 0;
|
|
29273
29343
|
if (layout.autoWidth) {
|
|
29274
|
-
|
|
29344
|
+
baseHeight = finalHeight * fontScale;
|
|
29275
29345
|
this.item.transform.size.set(1, finalHeight / layout.height);
|
|
29276
29346
|
} else {
|
|
29277
|
-
|
|
29278
|
-
}
|
|
29279
|
-
var
|
|
29280
|
-
|
|
29347
|
+
baseHeight = layout.height * fontScale;
|
|
29348
|
+
}
|
|
29349
|
+
var _this_getEffectPadding = this.getEffectPadding(), padL = _this_getEffectPadding.padL, padR = _this_getEffectPadding.padR, padT = _this_getEffectPadding.padT, padB = _this_getEffectPadding.padB;
|
|
29350
|
+
var hasEffect = (padL | padR | padT | padB) !== 0;
|
|
29351
|
+
var texWidth = hasEffect ? Math.ceil(baseWidth + padL + padR) : baseWidth;
|
|
29352
|
+
var texHeight = hasEffect ? Math.ceil(baseHeight + padT + padB) : baseHeight;
|
|
29353
|
+
var shiftX = hasEffect ? padL : 0;
|
|
29354
|
+
var shiftY = hasEffect ? flipY ? padT : padB : 0;
|
|
29355
|
+
// 给渲染层用:扩容比例
|
|
29356
|
+
this.effectScaleX = baseWidth > 0 ? texWidth / baseWidth : 1;
|
|
29357
|
+
this.effectScaleY = baseHeight > 0 ? texHeight / baseHeight : 1;
|
|
29358
|
+
this.renderToTexture(texWidth, texHeight, flipY, function(context) {
|
|
29281
29359
|
// canvas size 变化后重新刷新 context
|
|
29282
|
-
if (_this.maxLineWidth >
|
|
29283
|
-
context.font = _this.getFontDesc(fontSize *
|
|
29360
|
+
if (_this.maxLineWidth > baseWidth && layout.overflow === TextOverflow.display) {
|
|
29361
|
+
context.font = _this.getFontDesc(fontSize * baseWidth / _this.maxLineWidth);
|
|
29284
29362
|
} else {
|
|
29285
29363
|
context.font = style.fontDesc;
|
|
29286
29364
|
}
|
|
@@ -29303,7 +29381,7 @@ exports.TextComponent = /*#__PURE__*/ function(MaskableGraphic) {
|
|
|
29303
29381
|
var textMetrics = context.measureText(str);
|
|
29304
29382
|
// 和浏览器行为保持一致
|
|
29305
29383
|
x += layout.letterSpace * fontScale;
|
|
29306
|
-
if (x + textMetrics.width >
|
|
29384
|
+
if (x + textMetrics.width > baseWidth && i > 0 || str === "\n") {
|
|
29307
29385
|
charsInfo.push({
|
|
29308
29386
|
y: y,
|
|
29309
29387
|
width: x,
|
|
@@ -29327,14 +29405,27 @@ exports.TextComponent = /*#__PURE__*/ function(MaskableGraphic) {
|
|
|
29327
29405
|
chars: charsArray,
|
|
29328
29406
|
charOffsetX: charOffsetX
|
|
29329
29407
|
});
|
|
29330
|
-
|
|
29331
|
-
|
|
29332
|
-
|
|
29333
|
-
|
|
29334
|
-
|
|
29408
|
+
// 先描边
|
|
29409
|
+
if (style.isOutlined) {
|
|
29410
|
+
charsInfo.forEach(function(charInfo) {
|
|
29411
|
+
var ox = layout.getOffsetX(style, charInfo.width);
|
|
29412
|
+
for(var i = 0; i < charInfo.chars.length; i++){
|
|
29413
|
+
var str = charInfo.chars[i];
|
|
29414
|
+
var drawX = shiftX + ox + charInfo.charOffsetX[i];
|
|
29415
|
+
var drawY = shiftY + charInfo.y;
|
|
29416
|
+
context.strokeText(str, drawX, drawY);
|
|
29335
29417
|
}
|
|
29336
|
-
context.fillText(str, x + charInfo.charOffsetX[i], charInfo.y);
|
|
29337
29418
|
});
|
|
29419
|
+
}
|
|
29420
|
+
// 再填充
|
|
29421
|
+
charsInfo.forEach(function(charInfo) {
|
|
29422
|
+
var ox = layout.getOffsetX(style, charInfo.width);
|
|
29423
|
+
for(var i = 0; i < charInfo.chars.length; i++){
|
|
29424
|
+
var str = charInfo.chars[i];
|
|
29425
|
+
var drawX = shiftX + ox + charInfo.charOffsetX[i];
|
|
29426
|
+
var drawY = shiftY + charInfo.y;
|
|
29427
|
+
context.fillText(str, drawX, drawY);
|
|
29428
|
+
}
|
|
29338
29429
|
});
|
|
29339
29430
|
if (style.hasShadow) {
|
|
29340
29431
|
context.shadowColor = "transparent";
|
|
@@ -29345,6 +29436,32 @@ exports.TextComponent = /*#__PURE__*/ function(MaskableGraphic) {
|
|
|
29345
29436
|
_proto.renderText = function renderText(options) {
|
|
29346
29437
|
this.updateTexture();
|
|
29347
29438
|
};
|
|
29439
|
+
/**
|
|
29440
|
+
* 给渲染层用:获取特效扩容比例(描边/阴影导致的纹理扩容)
|
|
29441
|
+
* @returns
|
|
29442
|
+
*/ _proto.getTextureExpandScale = function getTextureExpandScale() {
|
|
29443
|
+
return [
|
|
29444
|
+
this.effectScaleX,
|
|
29445
|
+
this.effectScaleY
|
|
29446
|
+
];
|
|
29447
|
+
};
|
|
29448
|
+
/**
|
|
29449
|
+
* 获取描边和阴影的 padding 值(单位:px)
|
|
29450
|
+
* @returns
|
|
29451
|
+
*/ _proto.getEffectPadding = function getEffectPadding() {
|
|
29452
|
+
var style = this.textStyle;
|
|
29453
|
+
var hasDrawOutline = style.isOutlined && style.outlineWidth > 0;
|
|
29454
|
+
var outlinePad = hasDrawOutline ? Math.ceil(style.outlineWidth * 2 * style.fontScale) : 0;
|
|
29455
|
+
var hasShadow = style.hasShadow && (style.shadowBlur > 0 || style.shadowOffsetX !== 0 || style.shadowOffsetY !== 0);
|
|
29456
|
+
var shadowPad = hasShadow ? Math.ceil((Math.abs(style.shadowOffsetX) + Math.abs(style.shadowOffsetY) + style.shadowBlur) * style.fontScale) : 0;
|
|
29457
|
+
var pad = outlinePad + shadowPad;
|
|
29458
|
+
return {
|
|
29459
|
+
padL: pad,
|
|
29460
|
+
padR: pad,
|
|
29461
|
+
padT: pad,
|
|
29462
|
+
padB: pad
|
|
29463
|
+
};
|
|
29464
|
+
};
|
|
29348
29465
|
_proto.setAutoWidth = function setAutoWidth(value) {
|
|
29349
29466
|
var layout = this.textLayout;
|
|
29350
29467
|
var normalizedValue = !!value;
|
|
@@ -29395,14 +29512,11 @@ exports.TextComponent = /*#__PURE__*/ function(MaskableGraphic) {
|
|
|
29395
29512
|
this.isDirty = true;
|
|
29396
29513
|
};
|
|
29397
29514
|
_proto.setFontSize = function setFontSize(value) {
|
|
29398
|
-
|
|
29515
|
+
var size = Math.max(1, Number(value) || 1);
|
|
29516
|
+
if (this.textStyle.fontSize === size) {
|
|
29399
29517
|
return;
|
|
29400
29518
|
}
|
|
29401
|
-
|
|
29402
|
-
var diff = this.textStyle.fontSize - value;
|
|
29403
|
-
var layout = this.textLayout;
|
|
29404
|
-
layout.lineHeight += diff;
|
|
29405
|
-
this.textStyle.fontSize = value;
|
|
29519
|
+
this.textStyle.fontSize = size;
|
|
29406
29520
|
this.isDirty = true;
|
|
29407
29521
|
};
|
|
29408
29522
|
_proto.setOutlineWidth = function setOutlineWidth(value) {
|
|
@@ -31496,7 +31610,7 @@ function getStandardSpriteContent(sprite, transform) {
|
|
|
31496
31610
|
return ret;
|
|
31497
31611
|
}
|
|
31498
31612
|
|
|
31499
|
-
var version$1 = "2.8.
|
|
31613
|
+
var version$1 = "2.8.3";
|
|
31500
31614
|
var v0 = /^(\d+)\.(\d+)\.(\d+)(-(\w+)\.\d+)?$/;
|
|
31501
31615
|
var standardVersion = /^(\d+)\.(\d+)$/;
|
|
31502
31616
|
var reverseParticle = false;
|
|
@@ -32841,7 +32955,7 @@ function _createTextureOptionsBySource() {
|
|
|
32841
32955
|
scene.jsonScene.items.forEach(function(item) {
|
|
32842
32956
|
if (item.type === ItemType.text || item.type === ItemType.richtext) {
|
|
32843
32957
|
var textVariable = variables[item.name];
|
|
32844
|
-
if (
|
|
32958
|
+
if (textVariable === undefined || textVariable === null) {
|
|
32845
32959
|
return;
|
|
32846
32960
|
}
|
|
32847
32961
|
item.components.forEach(function(param) {
|
|
@@ -35196,7 +35310,7 @@ registerPlugin("text", TextLoader);
|
|
|
35196
35310
|
registerPlugin("sprite", SpriteLoader);
|
|
35197
35311
|
registerPlugin("particle", ParticleLoader);
|
|
35198
35312
|
registerPlugin("interact", InteractLoader);
|
|
35199
|
-
var version = "2.8.
|
|
35313
|
+
var version = "2.8.3";
|
|
35200
35314
|
logger.info("Core version: " + version + ".");
|
|
35201
35315
|
|
|
35202
35316
|
exports.ActivationMixerPlayable = ActivationMixerPlayable;
|