@eva/plugin-renderer-lottie 2.0.1-beta.7 → 2.0.1-beta.8
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/EVA.plugin.renderer.lottie.js +29 -10
- package/dist/EVA.plugin.renderer.lottie.min.js +1 -1
- package/dist/plugin-renderer-lottie.cjs.js +35 -11
- package/dist/plugin-renderer-lottie.cjs.prod.js +1 -1
- package/dist/plugin-renderer-lottie.d.ts +2 -0
- package/dist/plugin-renderer-lottie.esm.js +35 -11
- package/package.json +3 -3
|
@@ -10675,7 +10675,7 @@ class TextElement extends pixi_js.Text {
|
|
|
10675
10675
|
this.style.lineHeight = this._values.lineHeight;
|
|
10676
10676
|
|
|
10677
10677
|
this.anchor.x = 0.5;
|
|
10678
|
-
this.anchor.y =
|
|
10678
|
+
this.anchor.y = 0.8;
|
|
10679
10679
|
}
|
|
10680
10680
|
|
|
10681
10681
|
/**
|
|
@@ -12504,10 +12504,11 @@ class AnimationGroup extends Eventer {
|
|
|
12504
12504
|
*/
|
|
12505
12505
|
update(snippetCache, firstFrame = false) {
|
|
12506
12506
|
if (!this.living || !this.isDisplayLoaded || (this.isPaused && !firstFrame)) return;
|
|
12507
|
-
|
|
12508
|
-
const
|
|
12509
|
-
|
|
12510
|
-
|
|
12507
|
+
let isEnd = this._updateTime(snippetCache);
|
|
12508
|
+
const correctedFrameNum = this.direction === 1 ? this.beginFrame + this.frameNum : this.frameNum;
|
|
12509
|
+
if (this.direction === -1 && correctedFrameNum <= this.beginFrame) {
|
|
12510
|
+
isEnd = true;
|
|
12511
|
+
}
|
|
12511
12512
|
this.root.updateFrame(correctedFrameNum);
|
|
12512
12513
|
|
|
12513
12514
|
const np = correctedFrameNum >> 0;
|
|
@@ -12609,6 +12610,7 @@ class AnimationGroup extends Eventer {
|
|
|
12609
12610
|
* @param {boolean} [options.alternate=false] alternate direction every round
|
|
12610
12611
|
* @param {number} [options.wait=0] need wait how much millisecond to start
|
|
12611
12612
|
* @param {number} [options.delay=0] need delay how much millisecond to begin, effect every loop round
|
|
12613
|
+
* @param {number} [options.direction=1] need direction
|
|
12612
12614
|
* @return {this}
|
|
12613
12615
|
*/
|
|
12614
12616
|
playSegment(name, options = {}) {
|
|
@@ -12632,6 +12634,11 @@ class AnimationGroup extends Eventer {
|
|
|
12632
12634
|
if (Tools.isBoolean(options.alternate)) this.alternate = options.alternate;
|
|
12633
12635
|
if (Tools.isNumber(options.wait)) this.wait = options.wait;
|
|
12634
12636
|
if (Tools.isNumber(options.delay)) this.delay = options.delay;
|
|
12637
|
+
if (Tools.isNumber(options.direction)) {
|
|
12638
|
+
this.direction = options.direction;
|
|
12639
|
+
} else {
|
|
12640
|
+
this.direction = 1;
|
|
12641
|
+
}
|
|
12635
12642
|
|
|
12636
12643
|
this.replay();
|
|
12637
12644
|
return this;
|
|
@@ -12737,9 +12744,15 @@ class AnimationGroup extends Eventer {
|
|
|
12737
12744
|
this._repeatsCut = this.repeats;
|
|
12738
12745
|
this._delayCut = this.delay;
|
|
12739
12746
|
this.living = true;
|
|
12740
|
-
|
|
12747
|
+
// 根据播放方向设置初始帧位置
|
|
12748
|
+
if (this.direction === -1) {
|
|
12749
|
+
// 倒着播放从duration开始
|
|
12750
|
+
this.frameNum = this.duration;
|
|
12751
|
+
} else {
|
|
12752
|
+
// 正常播放从0开始
|
|
12753
|
+
this.frameNum = 0;
|
|
12754
|
+
}
|
|
12741
12755
|
this.duration = Math.floor(this.endFrame - this.beginFrame);
|
|
12742
|
-
this.direction = 1;
|
|
12743
12756
|
return this;
|
|
12744
12757
|
}
|
|
12745
12758
|
|
|
@@ -13125,16 +13138,17 @@ let LottieSystem = class LottieSystem extends pluginRenderer.Renderer {
|
|
|
13125
13138
|
});
|
|
13126
13139
|
}
|
|
13127
13140
|
add(changed) {
|
|
13141
|
+
var _a, _b;
|
|
13128
13142
|
return __awaiter(this, void 0, void 0, function* () {
|
|
13129
13143
|
this.manager = new AnimationManager(this.app);
|
|
13130
13144
|
const component = changed.component;
|
|
13131
13145
|
const container = this.renderSystem.containerManager.getContainer(changed.gameObject.id);
|
|
13132
13146
|
if (!container)
|
|
13133
13147
|
return;
|
|
13134
|
-
const
|
|
13148
|
+
const _c = component.options, { resource: rn } = _c, otherOpts = __rest(_c, ["resource"]);
|
|
13135
13149
|
const res = yield eva_js.resource.getResource(rn);
|
|
13136
13150
|
const data = res.data;
|
|
13137
|
-
const url = res.src.json.url;
|
|
13151
|
+
const url = ((_b = (_a = res.src) === null || _a === void 0 ? void 0 : _a.json) === null || _b === void 0 ? void 0 : _b.url) || '';
|
|
13138
13152
|
const json = Object.assign({}, (data.json || {}));
|
|
13139
13153
|
const assets = json.assets || [];
|
|
13140
13154
|
assets.forEach(item => {
|
|
@@ -13143,6 +13157,9 @@ let LottieSystem = class LottieSystem extends pluginRenderer.Renderer {
|
|
|
13143
13157
|
});
|
|
13144
13158
|
const anim = this.manager.parseAnimation(Object.assign({ keyframes: json, prefix: this.getDir(url) }, otherOpts));
|
|
13145
13159
|
component.anim = anim;
|
|
13160
|
+
if (component._replaceData) {
|
|
13161
|
+
anim.replaceData(component._replaceData);
|
|
13162
|
+
}
|
|
13146
13163
|
container.addChildAt(anim.group, 0);
|
|
13147
13164
|
this.managerLife.forEach(eventName => {
|
|
13148
13165
|
anim.on(eventName, e => component.emit(eventName, e));
|
|
@@ -13152,6 +13169,8 @@ let LottieSystem = class LottieSystem extends pluginRenderer.Renderer {
|
|
|
13152
13169
|
});
|
|
13153
13170
|
}
|
|
13154
13171
|
getDir(url) {
|
|
13172
|
+
if (!url)
|
|
13173
|
+
return url;
|
|
13155
13174
|
return new URL('./', url).href;
|
|
13156
13175
|
}
|
|
13157
13176
|
remove(changed) {
|
|
@@ -13175,6 +13194,7 @@ var LottieSystem$1 = LottieSystem;
|
|
|
13175
13194
|
class Lottie extends eva_js.Component {
|
|
13176
13195
|
constructor(options) {
|
|
13177
13196
|
super();
|
|
13197
|
+
this._replaceData = null;
|
|
13178
13198
|
this.loadStatus = false;
|
|
13179
13199
|
this.firstPlay = null;
|
|
13180
13200
|
this.prevSlot = {};
|
|
@@ -13229,8 +13249,12 @@ class Lottie extends eva_js.Component {
|
|
|
13229
13249
|
this.anim.playSegment(this.playParamsHandle(params), expandOpts);
|
|
13230
13250
|
}
|
|
13231
13251
|
replaceData(data) {
|
|
13232
|
-
if (data)
|
|
13233
|
-
this.anim
|
|
13252
|
+
if (data) {
|
|
13253
|
+
if (this.anim)
|
|
13254
|
+
this.anim.replaceData(data);
|
|
13255
|
+
else
|
|
13256
|
+
this._replaceData = data;
|
|
13257
|
+
}
|
|
13234
13258
|
}
|
|
13235
13259
|
playParamsHandle(params) {
|
|
13236
13260
|
let p = [].concat(params);
|