@eva/plugin-renderer-lottie 2.0.1-beta.3 → 2.0.1-beta.30
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 +311 -177
- package/dist/EVA.plugin.renderer.lottie.min.js +1 -1
- package/dist/plugin-renderer-lottie.cjs.js +464 -196
- package/dist/plugin-renderer-lottie.cjs.prod.js +1 -1
- package/dist/plugin-renderer-lottie.d.ts +80 -0
- package/dist/plugin-renderer-lottie.esm.js +469 -201
- package/package.json +3 -3
|
@@ -279,7 +279,7 @@ if (typeof Uint8ClampedArray === 'function' && typeof Float32Array === 'function
|
|
|
279
279
|
* @param {*} len a
|
|
280
280
|
* @return {*}
|
|
281
281
|
*/
|
|
282
|
-
function createSizedArray$
|
|
282
|
+
function createSizedArray$2(len) {
|
|
283
283
|
return new Array(len);
|
|
284
284
|
}
|
|
285
285
|
|
|
@@ -509,7 +509,7 @@ var BezierFactory = {
|
|
|
509
509
|
* @return {*}
|
|
510
510
|
*/
|
|
511
511
|
function _double(arr) {
|
|
512
|
-
return arr.concat(createSizedArray$
|
|
512
|
+
return arr.concat(createSizedArray$2(arr.length));
|
|
513
513
|
}
|
|
514
514
|
var pooling = {
|
|
515
515
|
double: _double,
|
|
@@ -518,7 +518,7 @@ var pooling = {
|
|
|
518
518
|
var PoolFactory = function PoolFactory(initialLength, _create, _release) {
|
|
519
519
|
var _length = 0;
|
|
520
520
|
var _maxLength = initialLength;
|
|
521
|
-
var pool = createSizedArray$
|
|
521
|
+
var pool = createSizedArray$2(_maxLength);
|
|
522
522
|
var ob = {
|
|
523
523
|
newElement: newElement,
|
|
524
524
|
release: release,
|
|
@@ -798,7 +798,7 @@ function buildBezierData(pt1, pt2, pt3, pt4) {
|
|
|
798
798
|
var bezierData = new BezierData(curveSegments);
|
|
799
799
|
var len = pt3.length;
|
|
800
800
|
for (var k = 0; k < curveSegments; k += 1) {
|
|
801
|
-
point = createSizedArray$
|
|
801
|
+
point = createSizedArray$2(len);
|
|
802
802
|
var perc = k / (curveSegments - 1);
|
|
803
803
|
ptDistance = 0;
|
|
804
804
|
for (var i = 0; i < len; i += 1) {
|
|
@@ -2186,9 +2186,9 @@ var ShapePath = /*#__PURE__*/ (function () {
|
|
|
2186
2186
|
this.c = false;
|
|
2187
2187
|
this._length = 0;
|
|
2188
2188
|
this._maxLength = 8;
|
|
2189
|
-
this.v = createSizedArray$
|
|
2190
|
-
this.o = createSizedArray$
|
|
2191
|
-
this.i = createSizedArray$
|
|
2189
|
+
this.v = createSizedArray$2(this._maxLength);
|
|
2190
|
+
this.o = createSizedArray$2(this._maxLength);
|
|
2191
|
+
this.i = createSizedArray$2(this._maxLength);
|
|
2192
2192
|
}
|
|
2193
2193
|
|
|
2194
2194
|
/**
|
|
@@ -2232,9 +2232,9 @@ var ShapePath = /*#__PURE__*/ (function () {
|
|
|
2232
2232
|
{
|
|
2233
2233
|
key: 'doubleArrayLength',
|
|
2234
2234
|
value: function doubleArrayLength() {
|
|
2235
|
-
this.v = this.v.concat(createSizedArray$
|
|
2236
|
-
this.i = this.i.concat(createSizedArray$
|
|
2237
|
-
this.o = this.o.concat(createSizedArray$
|
|
2235
|
+
this.v = this.v.concat(createSizedArray$2(this._maxLength));
|
|
2236
|
+
this.i = this.i.concat(createSizedArray$2(this._maxLength));
|
|
2237
|
+
this.o = this.o.concat(createSizedArray$2(this._maxLength));
|
|
2238
2238
|
this._maxLength *= 2;
|
|
2239
2239
|
},
|
|
2240
2240
|
|
|
@@ -2403,7 +2403,7 @@ var ShapeCollection = /*#__PURE__*/ (function () {
|
|
|
2403
2403
|
_classCallCheck(this, ShapeCollection);
|
|
2404
2404
|
this._length = 0;
|
|
2405
2405
|
this._maxLength = 4;
|
|
2406
|
-
this.shapes = createSizedArray$
|
|
2406
|
+
this.shapes = createSizedArray$2(this._maxLength);
|
|
2407
2407
|
}
|
|
2408
2408
|
|
|
2409
2409
|
/**
|
|
@@ -2415,7 +2415,7 @@ var ShapeCollection = /*#__PURE__*/ (function () {
|
|
|
2415
2415
|
key: 'addShape',
|
|
2416
2416
|
value: function addShape(shapeData) {
|
|
2417
2417
|
if (this._length === this._maxLength) {
|
|
2418
|
-
this.shapes = this.shapes.concat(createSizedArray$
|
|
2418
|
+
this.shapes = this.shapes.concat(createSizedArray$2(this._maxLength));
|
|
2419
2419
|
this._maxLength *= 2;
|
|
2420
2420
|
}
|
|
2421
2421
|
this.shapes[this._length] = shapeData;
|
|
@@ -2440,7 +2440,7 @@ var ShapeCollection = /*#__PURE__*/ (function () {
|
|
|
2440
2440
|
|
|
2441
2441
|
var _length = 0;
|
|
2442
2442
|
var _maxLength = 4;
|
|
2443
|
-
var pool = createSizedArray$
|
|
2443
|
+
var pool = createSizedArray$2(_maxLength);
|
|
2444
2444
|
|
|
2445
2445
|
/**
|
|
2446
2446
|
* a
|
|
@@ -3265,7 +3265,7 @@ var MaskFrames = /*#__PURE__*/ (function (_DynamicPropertyConta) {
|
|
|
3265
3265
|
_this.propType = 'mask';
|
|
3266
3266
|
_this.masksProperties = masksProperties || [];
|
|
3267
3267
|
_this.initDynamicPropertyContainer(elem);
|
|
3268
|
-
_this.viewData = createSizedArray$
|
|
3268
|
+
_this.viewData = createSizedArray$2(_this.masksProperties.length);
|
|
3269
3269
|
var len = _this.masksProperties.length;
|
|
3270
3270
|
var hasMasks = false;
|
|
3271
3271
|
for (var i = 0; i < len; i++) {
|
|
@@ -5696,7 +5696,7 @@ var DashProperty = /*#__PURE__*/ (function (_DynamicPropertyConta) {
|
|
|
5696
5696
|
_this = _callSuper(this, DashProperty);
|
|
5697
5697
|
_this.elem = elem;
|
|
5698
5698
|
_this.frameId = -1;
|
|
5699
|
-
_this.dataProps = createSizedArray$
|
|
5699
|
+
_this.dataProps = createSizedArray$2(data.length);
|
|
5700
5700
|
// this.renderer = renderer;
|
|
5701
5701
|
_this.k = false;
|
|
5702
5702
|
// this.dashStr = '';
|
|
@@ -7421,7 +7421,7 @@ var TextAnimatorProperty = /*#__PURE__*/ (function (_DynamicPropertyConta) {
|
|
|
7421
7421
|
_this._textData = textData;
|
|
7422
7422
|
_this._renderType = renderType;
|
|
7423
7423
|
_this.elem = elem;
|
|
7424
|
-
_this._animatorsData = createSizedArray$
|
|
7424
|
+
_this._animatorsData = createSizedArray$2(_this._textData.a.length);
|
|
7425
7425
|
_this._pathData = {};
|
|
7426
7426
|
_this._moreOptions = {
|
|
7427
7427
|
alignment: {},
|
|
@@ -10216,7 +10216,6 @@ const Tween = {
|
|
|
10216
10216
|
};
|
|
10217
10217
|
|
|
10218
10218
|
({
|
|
10219
|
-
UPDATE_PRIORITY: pixi_js.UPDATE_PRIORITY,
|
|
10220
10219
|
animationTicker: pixi_js.Ticker.shared,
|
|
10221
10220
|
});
|
|
10222
10221
|
|
|
@@ -10276,6 +10275,61 @@ class LottieGraphicsMask extends pixi_js.Graphics {
|
|
|
10276
10275
|
}
|
|
10277
10276
|
}
|
|
10278
10277
|
|
|
10278
|
+
const updateTransformByHierarchy = (container, transform, parent) => {
|
|
10279
|
+
// const localMatrixA = new Matrix();
|
|
10280
|
+
|
|
10281
|
+
if (transform.p) {
|
|
10282
|
+
container.x = transform.p.v[0];
|
|
10283
|
+
container.y = transform.p.v[1];
|
|
10284
|
+
} else {
|
|
10285
|
+
container.x = transform.px.v;
|
|
10286
|
+
container.y = transform.py.v;
|
|
10287
|
+
}
|
|
10288
|
+
|
|
10289
|
+
container.pivot.x = transform.a.v[0];
|
|
10290
|
+
container.pivot.y = transform.a.v[1];
|
|
10291
|
+
|
|
10292
|
+
container.scale.x = transform.s.v[0];
|
|
10293
|
+
container.scale.y = transform.s.v[1];
|
|
10294
|
+
|
|
10295
|
+
if (transform.r) {
|
|
10296
|
+
container.rotation = transform.r.v + transform.orientation;
|
|
10297
|
+
} else if (transform.rz) {
|
|
10298
|
+
container.rotation = transform.rz.v + transform.or.v[2];
|
|
10299
|
+
}
|
|
10300
|
+
|
|
10301
|
+
// let x = transform.p ? transform.p.v[0] : transform.px.v;
|
|
10302
|
+
// let y = transform.p ? transform.p.v[1] : transform.py.v;
|
|
10303
|
+
|
|
10304
|
+
// const rotation = transform.r
|
|
10305
|
+
// ? transform.r.v + transform.orientation
|
|
10306
|
+
// : transform.rz
|
|
10307
|
+
// ? transform.rz.v + transform.or.v[2]
|
|
10308
|
+
// : 0;
|
|
10309
|
+
|
|
10310
|
+
// localMatrixA.setTransform(
|
|
10311
|
+
// x,
|
|
10312
|
+
// y,
|
|
10313
|
+
// transform.a.v[0],
|
|
10314
|
+
// transform.a.v[1],
|
|
10315
|
+
// transform.s.v[0],
|
|
10316
|
+
// transform.s.v[1],
|
|
10317
|
+
// rotation,
|
|
10318
|
+
// 0,
|
|
10319
|
+
// 0
|
|
10320
|
+
// );
|
|
10321
|
+
|
|
10322
|
+
// if (parent) {
|
|
10323
|
+
// const parentWorldTransform = parent.worldTransform.clone();
|
|
10324
|
+
// container.setFromMatrix(localMatrixA.append(parentWorldTransform));
|
|
10325
|
+
// } else {
|
|
10326
|
+
// container.setFromMatrix(localMatrixA);
|
|
10327
|
+
// }
|
|
10328
|
+
|
|
10329
|
+
const parentAlpha = parent ? parent.alpha : 1;
|
|
10330
|
+
container.alpha = parentAlpha * transform.o.v;
|
|
10331
|
+
};
|
|
10332
|
+
|
|
10279
10333
|
/**
|
|
10280
10334
|
* NullElement class
|
|
10281
10335
|
* @class
|
|
@@ -10324,27 +10378,7 @@ class CompElement extends pixi_js.Container {
|
|
|
10324
10378
|
}
|
|
10325
10379
|
|
|
10326
10380
|
updateLottieTransform(transform) {
|
|
10327
|
-
|
|
10328
|
-
this.x = transform.p.v[0];
|
|
10329
|
-
this.y = transform.p.v[1];
|
|
10330
|
-
} else {
|
|
10331
|
-
this.x = transform.px.v;
|
|
10332
|
-
this.y = transform.py.v;
|
|
10333
|
-
}
|
|
10334
|
-
|
|
10335
|
-
this.pivot.x = transform.a.v[0];
|
|
10336
|
-
this.pivot.y = transform.a.v[1];
|
|
10337
|
-
|
|
10338
|
-
this.scale.x = transform.s.v[0];
|
|
10339
|
-
this.scale.y = transform.s.v[1];
|
|
10340
|
-
|
|
10341
|
-
if (transform.r) {
|
|
10342
|
-
this.rotation = transform.r.v + transform.orientation;
|
|
10343
|
-
} else if (transform.rz) {
|
|
10344
|
-
this.rotation = transform.rz.v + transform.or.v[2];
|
|
10345
|
-
}
|
|
10346
|
-
|
|
10347
|
-
this.alpha = transform.o.v;
|
|
10381
|
+
updateTransformByHierarchy(this, transform, this.hierarchy);
|
|
10348
10382
|
}
|
|
10349
10383
|
|
|
10350
10384
|
/**
|
|
@@ -10519,27 +10553,7 @@ class ShapeElement extends pixi_js.Graphics {
|
|
|
10519
10553
|
* @param {*} transform
|
|
10520
10554
|
*/
|
|
10521
10555
|
updateLottieTransform(transform) {
|
|
10522
|
-
|
|
10523
|
-
this.x = transform.p.v[0];
|
|
10524
|
-
this.y = transform.p.v[1];
|
|
10525
|
-
} else {
|
|
10526
|
-
this.x = transform.px.v;
|
|
10527
|
-
this.y = transform.py.v;
|
|
10528
|
-
}
|
|
10529
|
-
|
|
10530
|
-
this.pivot.x = transform.a.v[0];
|
|
10531
|
-
this.pivot.y = transform.a.v[1];
|
|
10532
|
-
|
|
10533
|
-
this.scale.x = transform.s.v[0];
|
|
10534
|
-
this.scale.y = transform.s.v[1];
|
|
10535
|
-
|
|
10536
|
-
if (transform.r) {
|
|
10537
|
-
this.rotation = transform.r.v + transform.orientation;
|
|
10538
|
-
} else if (transform.rz) {
|
|
10539
|
-
this.rotation = transform.rz.v + transform.or.v[2];
|
|
10540
|
-
}
|
|
10541
|
-
|
|
10542
|
-
this.alpha = transform.o.v;
|
|
10556
|
+
updateTransformByHierarchy(this, transform, this.hierarchy);
|
|
10543
10557
|
}
|
|
10544
10558
|
|
|
10545
10559
|
/**
|
|
@@ -10565,7 +10579,153 @@ function createSizedArray(len) {
|
|
|
10565
10579
|
return Array.apply(null, { length: len });
|
|
10566
10580
|
}
|
|
10567
10581
|
|
|
10568
|
-
|
|
10582
|
+
/**
|
|
10583
|
+
* NullElement class
|
|
10584
|
+
* @class
|
|
10585
|
+
* @private
|
|
10586
|
+
*/
|
|
10587
|
+
class TextElement extends pixi_js.Text {
|
|
10588
|
+
/**
|
|
10589
|
+
* ShapeElement constructor
|
|
10590
|
+
*/
|
|
10591
|
+
constructor(lottieLayer) {
|
|
10592
|
+
super();
|
|
10593
|
+
this.label = lottieLayer.fullname;
|
|
10594
|
+
this.lottieLayer = lottieLayer;
|
|
10595
|
+
this.lottieLayer.lettersChangedFlag = true;
|
|
10596
|
+
if (this.lottieLayer.masks) {
|
|
10597
|
+
this.mask = new LottieGraphicsMask(this.lottieLayer.session.local, this.lottieLayer);
|
|
10598
|
+
this.addChild(this.mask);
|
|
10599
|
+
}
|
|
10600
|
+
|
|
10601
|
+
this.init();
|
|
10602
|
+
this.buildNewText();
|
|
10603
|
+
this.updateLottie = this.updateLottie.bind(this);
|
|
10604
|
+
this.updateLottie(this.lottieLayer, true);
|
|
10605
|
+
this.lottieLayer.on('updatelayer', this.updateLottie);
|
|
10606
|
+
this.onRender = () => {
|
|
10607
|
+
this.updateLottie(this.lottieLayer, true);
|
|
10608
|
+
};
|
|
10609
|
+
}
|
|
10610
|
+
|
|
10611
|
+
init() {
|
|
10612
|
+
this._textSpans = [];
|
|
10613
|
+
this._yOffset = 0;
|
|
10614
|
+
this._fillColorAnim = false;
|
|
10615
|
+
this._strokeColorAnim = false;
|
|
10616
|
+
this._strokeWidthAnim = false;
|
|
10617
|
+
this._stroke = false;
|
|
10618
|
+
this._fill = false;
|
|
10619
|
+
this._justifyOffset = 0;
|
|
10620
|
+
this._currentRender = null;
|
|
10621
|
+
this._renderType = 'canvas';
|
|
10622
|
+
this._fillStyle = {};
|
|
10623
|
+
this._values = {
|
|
10624
|
+
fill: '#000000',
|
|
10625
|
+
stroke: '#000000',
|
|
10626
|
+
sWidth: 0,
|
|
10627
|
+
fValue: '',
|
|
10628
|
+
};
|
|
10629
|
+
}
|
|
10630
|
+
|
|
10631
|
+
buildNewText() {
|
|
10632
|
+
const documentData = this.lottieLayer.textProperty.currentData;
|
|
10633
|
+
this.renderedLetters = createSizedArray(documentData.l ? documentData.l.length : 0);
|
|
10634
|
+
let hasFill = false;
|
|
10635
|
+
if (documentData.fc) {
|
|
10636
|
+
hasFill = true;
|
|
10637
|
+
this._values.fill = Tools.rgb2hex(
|
|
10638
|
+
documentData.fc.map(item => {
|
|
10639
|
+
return item > 1 ? item : item * 255;
|
|
10640
|
+
}),
|
|
10641
|
+
documentData.fc,
|
|
10642
|
+
);
|
|
10643
|
+
} else {
|
|
10644
|
+
this._values.fill = '#000000';
|
|
10645
|
+
}
|
|
10646
|
+
this._fill = hasFill;
|
|
10647
|
+
let hasStroke = false;
|
|
10648
|
+
if (documentData.sc) {
|
|
10649
|
+
hasStroke = true;
|
|
10650
|
+
this._values.stroke = this.buildColor(documentData.sc);
|
|
10651
|
+
this._values.sWidth = documentData.sw;
|
|
10652
|
+
}
|
|
10653
|
+
const fontManager = this.lottieLayer.global.fontManager;
|
|
10654
|
+
this._stroke = hasStroke;
|
|
10655
|
+
this._values.fontSize = documentData.finalSize;
|
|
10656
|
+
this._values.fontFamily = fontManager.getFontByName(documentData.f).fFamily;
|
|
10657
|
+
this._values.fontWeight = documentData.fWeight;
|
|
10658
|
+
this._values.fontStyle = documentData.fStyle;
|
|
10659
|
+
this._values.lineHeight = documentData.finalLineHeight;
|
|
10660
|
+
this._text = documentData.t;
|
|
10661
|
+
|
|
10662
|
+
this.renderText();
|
|
10663
|
+
}
|
|
10664
|
+
|
|
10665
|
+
async renderText() {
|
|
10666
|
+
this.text = this._text;
|
|
10667
|
+
if (this.style.fontFamily) {
|
|
10668
|
+
await pixi_js.Assets.get(this.style.fontFamily);
|
|
10669
|
+
}
|
|
10670
|
+
this.style.fontFamily = this._values.fontFamily;
|
|
10671
|
+
this.style.fontSize = this._values.fontSize;
|
|
10672
|
+
this.style.fill = this._values.fill;
|
|
10673
|
+
this.style.fontWeight = this._values.fontWeight;
|
|
10674
|
+
this.style.fontStyle = this._values.fontStyle;
|
|
10675
|
+
this.style.lineHeight = this._values.lineHeight;
|
|
10676
|
+
|
|
10677
|
+
this.anchor.x = 0.5;
|
|
10678
|
+
this.anchor.y = 0.8;
|
|
10679
|
+
}
|
|
10680
|
+
|
|
10681
|
+
/**
|
|
10682
|
+
* update lottie information
|
|
10683
|
+
* @param {*} lottieLayer lottie element object
|
|
10684
|
+
* @param {boolean} forceUpdate forceUpdate
|
|
10685
|
+
*/
|
|
10686
|
+
updateLottie(lottieLayer, _forceUpdate = false) {
|
|
10687
|
+
let forceUpdate = true;
|
|
10688
|
+
if (lottieLayer.transform && forceUpdate) {
|
|
10689
|
+
this.updateLottieTransform(lottieLayer.transform);
|
|
10690
|
+
}
|
|
10691
|
+
if (lottieLayer.masks && forceUpdate) {
|
|
10692
|
+
this.updateLottieMasks(lottieLayer.masks);
|
|
10693
|
+
}
|
|
10694
|
+
if (lottieLayer._mdf) {
|
|
10695
|
+
this.renderText();
|
|
10696
|
+
}
|
|
10697
|
+
this.visible = lottieLayer.isInRange;
|
|
10698
|
+
this._onUpdate();
|
|
10699
|
+
}
|
|
10700
|
+
|
|
10701
|
+
/**
|
|
10702
|
+
* a
|
|
10703
|
+
* @param {*} parent a
|
|
10704
|
+
*/
|
|
10705
|
+
setTransformHierarchy(parent) {
|
|
10706
|
+
this.hierarchy = parent;
|
|
10707
|
+
}
|
|
10708
|
+
|
|
10709
|
+
/**
|
|
10710
|
+
* a
|
|
10711
|
+
* @param {*} transform
|
|
10712
|
+
*/
|
|
10713
|
+
updateLottieTransform(transform) {
|
|
10714
|
+
updateTransformByHierarchy(this, transform, this.hierarchy);
|
|
10715
|
+
}
|
|
10716
|
+
|
|
10717
|
+
/**
|
|
10718
|
+
* a
|
|
10719
|
+
* @param {*} masks a
|
|
10720
|
+
*/
|
|
10721
|
+
updateLottieMasks(masks) {
|
|
10722
|
+
this.mask.updateMasks(masks);
|
|
10723
|
+
}
|
|
10724
|
+
}
|
|
10725
|
+
|
|
10726
|
+
function createSizedArray$1(len) {
|
|
10727
|
+
return Array.apply(null, { length: len });
|
|
10728
|
+
}
|
|
10569
10729
|
|
|
10570
10730
|
class MatrixHelper extends pixi_js.Matrix {
|
|
10571
10731
|
reset() {
|
|
@@ -10640,7 +10800,7 @@ class MatrixHelper extends pixi_js.Matrix {
|
|
|
10640
10800
|
* @class
|
|
10641
10801
|
* @private
|
|
10642
10802
|
*/
|
|
10643
|
-
class
|
|
10803
|
+
class TextGlyphsElement extends pixi_js.Graphics {
|
|
10644
10804
|
/**
|
|
10645
10805
|
* ShapeElement constructor
|
|
10646
10806
|
*/
|
|
@@ -10686,15 +10846,14 @@ class TextElement extends pixi_js.Graphics {
|
|
|
10686
10846
|
|
|
10687
10847
|
buildNewText() {
|
|
10688
10848
|
const documentData = this.lottieLayer.textProperty.currentData;
|
|
10689
|
-
this.renderedLetters = createSizedArray(documentData.l ? documentData.l.length : 0);
|
|
10849
|
+
this.renderedLetters = createSizedArray$1(documentData.l ? documentData.l.length : 0);
|
|
10690
10850
|
let hasFill = false;
|
|
10691
10851
|
if (documentData.fc) {
|
|
10692
10852
|
hasFill = true;
|
|
10693
10853
|
this._values.fill = Tools.rgb2hex(
|
|
10694
|
-
|
|
10695
|
-
|
|
10696
|
-
|
|
10697
|
-
// }),
|
|
10854
|
+
documentData.fc.map(item => {
|
|
10855
|
+
return item > 1 ? item : item * 255;
|
|
10856
|
+
}),
|
|
10698
10857
|
documentData.fc,
|
|
10699
10858
|
);
|
|
10700
10859
|
} else {
|
|
@@ -10751,8 +10910,7 @@ class TextElement extends pixi_js.Graphics {
|
|
|
10751
10910
|
shapes = shapeData.shapes ? shapeData.shapes[0].it : [];
|
|
10752
10911
|
jLen = shapes.length;
|
|
10753
10912
|
matrixHelper.scale(documentData.finalSize / 100, documentData.finalSize / 100);
|
|
10754
|
-
commands = createSizedArray(jLen - 1);
|
|
10755
|
-
window.$commands.push(commands);
|
|
10913
|
+
commands = createSizedArray$1(jLen - 1);
|
|
10756
10914
|
let commandsCounter = 0;
|
|
10757
10915
|
for (j = 0; j < jLen; j += 1) {
|
|
10758
10916
|
if (shapes[j].ty === 'sh') {
|
|
@@ -10967,27 +11125,7 @@ class TextElement extends pixi_js.Graphics {
|
|
|
10967
11125
|
* @param {*} transform
|
|
10968
11126
|
*/
|
|
10969
11127
|
updateLottieTransform(transform) {
|
|
10970
|
-
|
|
10971
|
-
this.x = transform.p.v[0];
|
|
10972
|
-
this.y = transform.p.v[1];
|
|
10973
|
-
} else {
|
|
10974
|
-
this.x = transform.px.v;
|
|
10975
|
-
this.y = transform.py.v;
|
|
10976
|
-
}
|
|
10977
|
-
|
|
10978
|
-
this.pivot.x = transform.a.v[0];
|
|
10979
|
-
this.pivot.y = transform.a.v[1];
|
|
10980
|
-
|
|
10981
|
-
this.scale.x = transform.s.v[0];
|
|
10982
|
-
this.scale.y = transform.s.v[1];
|
|
10983
|
-
|
|
10984
|
-
if (transform.r) {
|
|
10985
|
-
this.rotation = transform.r.v + transform.orientation;
|
|
10986
|
-
} else if (transform.rz) {
|
|
10987
|
-
this.rotation = transform.rz.v + transform.or.v[2];
|
|
10988
|
-
}
|
|
10989
|
-
|
|
10990
|
-
this.alpha = transform.o.v;
|
|
11128
|
+
updateTransformByHierarchy(this, transform, this.hierarchy);
|
|
10991
11129
|
}
|
|
10992
11130
|
|
|
10993
11131
|
/**
|
|
@@ -11053,27 +11191,7 @@ class SolidElement extends pixi_js.Graphics {
|
|
|
11053
11191
|
* @param {*} transform
|
|
11054
11192
|
*/
|
|
11055
11193
|
updateLottieTransform(transform) {
|
|
11056
|
-
|
|
11057
|
-
this.x = transform.p.v[0];
|
|
11058
|
-
this.y = transform.p.v[1];
|
|
11059
|
-
} else {
|
|
11060
|
-
this.x = transform.px.v;
|
|
11061
|
-
this.y = transform.py.v;
|
|
11062
|
-
}
|
|
11063
|
-
|
|
11064
|
-
this.pivot.x = transform.a.v[0];
|
|
11065
|
-
this.pivot.y = transform.a.v[1];
|
|
11066
|
-
|
|
11067
|
-
this.scale.x = transform.s.v[0];
|
|
11068
|
-
this.scale.y = transform.s.v[1];
|
|
11069
|
-
|
|
11070
|
-
if (transform.r) {
|
|
11071
|
-
this.rotation = transform.r.v + transform.orientation;
|
|
11072
|
-
} else if (transform.rz) {
|
|
11073
|
-
this.rotation = transform.rz.v + transform.or.v[2];
|
|
11074
|
-
}
|
|
11075
|
-
|
|
11076
|
-
this.alpha = transform.o.v;
|
|
11194
|
+
updateTransformByHierarchy(this, transform, this.hierarchy);
|
|
11077
11195
|
}
|
|
11078
11196
|
|
|
11079
11197
|
/**
|
|
@@ -11097,18 +11215,17 @@ class SpriteElement extends pixi_js.Sprite {
|
|
|
11097
11215
|
* @param {object} config layer data information
|
|
11098
11216
|
*/
|
|
11099
11217
|
constructor(lottieLayer, imageInfo) {
|
|
11100
|
-
const {
|
|
11101
|
-
super(
|
|
11218
|
+
const { texture: texturePromise } = imageInfo;
|
|
11219
|
+
super();
|
|
11102
11220
|
this.label = lottieLayer.fullname;
|
|
11103
11221
|
|
|
11104
|
-
|
|
11105
|
-
|
|
11106
|
-
|
|
11107
|
-
|
|
11108
|
-
|
|
11109
|
-
|
|
11222
|
+
texturePromise
|
|
11223
|
+
.then(texture => {
|
|
11224
|
+
this.texture = texture;
|
|
11225
|
+
})
|
|
11226
|
+
.catch(e => {
|
|
11227
|
+
console.error(e);
|
|
11110
11228
|
});
|
|
11111
|
-
}
|
|
11112
11229
|
|
|
11113
11230
|
this.lottieLayer = lottieLayer;
|
|
11114
11231
|
|
|
@@ -11149,27 +11266,7 @@ class SpriteElement extends pixi_js.Sprite {
|
|
|
11149
11266
|
* @param {*} transform
|
|
11150
11267
|
*/
|
|
11151
11268
|
updateLottieTransform(transform) {
|
|
11152
|
-
|
|
11153
|
-
this.x = transform.p.v[0];
|
|
11154
|
-
this.y = transform.p.v[1];
|
|
11155
|
-
} else {
|
|
11156
|
-
this.x = transform.px.v;
|
|
11157
|
-
this.y = transform.py.v;
|
|
11158
|
-
}
|
|
11159
|
-
|
|
11160
|
-
this.pivot.x = transform.a.v[0];
|
|
11161
|
-
this.pivot.y = transform.a.v[1];
|
|
11162
|
-
|
|
11163
|
-
this.scale.x = transform.s.v[0];
|
|
11164
|
-
this.scale.y = transform.s.v[1];
|
|
11165
|
-
|
|
11166
|
-
if (transform.r) {
|
|
11167
|
-
this.rotation = transform.r.v + transform.orientation;
|
|
11168
|
-
} else if (transform.rz) {
|
|
11169
|
-
this.rotation = transform.rz.v + transform.or.v[2];
|
|
11170
|
-
}
|
|
11171
|
-
|
|
11172
|
-
this.alpha = transform.o.v;
|
|
11269
|
+
updateTransformByHierarchy(this, transform, this.hierarchy);
|
|
11173
11270
|
}
|
|
11174
11271
|
|
|
11175
11272
|
/**
|
|
@@ -11181,32 +11278,6 @@ class SpriteElement extends pixi_js.Sprite {
|
|
|
11181
11278
|
}
|
|
11182
11279
|
}
|
|
11183
11280
|
|
|
11184
|
-
class BaseTexture extends pixi_js.EventEmitter {
|
|
11185
|
-
constructor(url) {
|
|
11186
|
-
super();
|
|
11187
|
-
this.texture = pixi_js.Texture.EMPTY;
|
|
11188
|
-
this.img = new Image();
|
|
11189
|
-
this.img.src = url;
|
|
11190
|
-
this.img.onload = () => {
|
|
11191
|
-
this.texture = pixi_js.Texture.from(this.img);
|
|
11192
|
-
this.emit('loaded');
|
|
11193
|
-
};
|
|
11194
|
-
this.img.onerror = () => {
|
|
11195
|
-
this.emit('error');
|
|
11196
|
-
};
|
|
11197
|
-
}
|
|
11198
|
-
}
|
|
11199
|
-
|
|
11200
|
-
class Texture {
|
|
11201
|
-
constructor(url) {
|
|
11202
|
-
this.baseTexture = new BaseTexture(url);
|
|
11203
|
-
}
|
|
11204
|
-
|
|
11205
|
-
static from(url) {
|
|
11206
|
-
return new Texture(url);
|
|
11207
|
-
}
|
|
11208
|
-
}
|
|
11209
|
-
|
|
11210
11281
|
const regHttp = /^(https?:)?\/\//;
|
|
11211
11282
|
|
|
11212
11283
|
/**
|
|
@@ -11262,25 +11333,20 @@ class LoadTexture extends Eventer {
|
|
|
11262
11333
|
this.assets.forEach(asset => {
|
|
11263
11334
|
const id = asset.id;
|
|
11264
11335
|
const url = createUrl(asset, this.prefix);
|
|
11265
|
-
const
|
|
11266
|
-
this.textures[id] =
|
|
11336
|
+
const texturePromise = pixi_js.Assets.load(url);
|
|
11337
|
+
this.textures[id] = texturePromise;
|
|
11267
11338
|
this._total++;
|
|
11268
|
-
|
|
11269
|
-
|
|
11270
|
-
this.emit('update');
|
|
11271
|
-
if (this._received + this._failed >= this._total) this._onComplete();
|
|
11272
|
-
} else {
|
|
11273
|
-
texture.baseTexture.once('loaded', () => {
|
|
11339
|
+
texturePromise
|
|
11340
|
+
.then(() => {
|
|
11274
11341
|
this._received++;
|
|
11275
11342
|
this.emit('update');
|
|
11276
11343
|
if (this._received + this._failed >= this._total) this._onComplete();
|
|
11277
|
-
})
|
|
11278
|
-
|
|
11344
|
+
})
|
|
11345
|
+
.catch(e => {
|
|
11279
11346
|
this._failed++;
|
|
11280
11347
|
this.emit('update');
|
|
11281
11348
|
if (this._received + this._failed >= this._total) this._onComplete();
|
|
11282
11349
|
});
|
|
11283
|
-
}
|
|
11284
11350
|
});
|
|
11285
11351
|
}
|
|
11286
11352
|
|
|
@@ -11419,6 +11485,29 @@ function loadJson(path) {
|
|
|
11419
11485
|
return new LoadJson(path);
|
|
11420
11486
|
}
|
|
11421
11487
|
|
|
11488
|
+
const getLayerBySubstituteId = (lottieFile, substituteId) => {
|
|
11489
|
+
const { substituteIds } = lottieFile || {};
|
|
11490
|
+
if (!substituteIds || Object.keys(substituteIds).length === 0) return null;
|
|
11491
|
+
let layer;
|
|
11492
|
+
// 在复合图层内部
|
|
11493
|
+
if (substituteId && substituteId.indexOf('_') === -1) {
|
|
11494
|
+
const outerIndex = Number(substituteId);
|
|
11495
|
+
if (!Number.isNaN(outerIndex)) {
|
|
11496
|
+
layer = lottieFile?.layers?.[outerIndex];
|
|
11497
|
+
}
|
|
11498
|
+
} else if (substituteId) {
|
|
11499
|
+
// 在顶层图层
|
|
11500
|
+
const substituteIdArr = substituteId.split('_');
|
|
11501
|
+
const outerIndex = Number(substituteIdArr[0]);
|
|
11502
|
+
const innerIndex = Number(substituteIdArr[1]);
|
|
11503
|
+
if (!Number.isNaN(outerIndex) && !Number.isNaN(innerIndex)) {
|
|
11504
|
+
const asset = lottieFile.assets[outerIndex];
|
|
11505
|
+
layer = asset?.layers?.[innerIndex];
|
|
11506
|
+
}
|
|
11507
|
+
}
|
|
11508
|
+
return layer;
|
|
11509
|
+
};
|
|
11510
|
+
|
|
11422
11511
|
/**
|
|
11423
11512
|
* an animation group, store and compute frame information, one lottie animate one AnimationGroup
|
|
11424
11513
|
* @class
|
|
@@ -11447,6 +11536,7 @@ class AnimationGroup extends Eventer {
|
|
|
11447
11536
|
* @param {boolean} [options.depthTest=true] enable depth test for 3d layer
|
|
11448
11537
|
* @param {boolean} [options.maskComp=false] add mask for each comp
|
|
11449
11538
|
* @param {string} [options.prefix=''] assets url prefix, look like link path
|
|
11539
|
+
* @param {boolean} [options.replaceData=''] assets url prefix, look like link path
|
|
11450
11540
|
*/
|
|
11451
11541
|
constructor(options) {
|
|
11452
11542
|
super();
|
|
@@ -11677,7 +11767,14 @@ class AnimationGroup extends Eventer {
|
|
|
11677
11767
|
|
|
11678
11768
|
if (options.keyframes) {
|
|
11679
11769
|
if (!this._prefix && options.keyframes.prefix) this._prefix = options.keyframes.prefix;
|
|
11680
|
-
|
|
11770
|
+
if (!options.replaceData) {
|
|
11771
|
+
this._setupDate(options.keyframes);
|
|
11772
|
+
} else {
|
|
11773
|
+
this._response = options.keyframes;
|
|
11774
|
+
if (this._replaceData) {
|
|
11775
|
+
this._setupReplaceData();
|
|
11776
|
+
}
|
|
11777
|
+
}
|
|
11681
11778
|
} else if (options.path) {
|
|
11682
11779
|
let prefix = '';
|
|
11683
11780
|
if (options.path.lastIndexOf('\\') !== -1) {
|
|
@@ -11689,7 +11786,14 @@ class AnimationGroup extends Eventer {
|
|
|
11689
11786
|
|
|
11690
11787
|
this.jsonLoader = loadJson(options.path);
|
|
11691
11788
|
this.jsonLoader.once('success', response => {
|
|
11692
|
-
|
|
11789
|
+
if (!options.replaceData) {
|
|
11790
|
+
this._setupDate(response);
|
|
11791
|
+
} else {
|
|
11792
|
+
this._response = response;
|
|
11793
|
+
if (this._replaceData) {
|
|
11794
|
+
this._setupReplaceData();
|
|
11795
|
+
}
|
|
11796
|
+
}
|
|
11693
11797
|
});
|
|
11694
11798
|
this.jsonLoader.once('error', error => {
|
|
11695
11799
|
this.emit('error', error);
|
|
@@ -11697,6 +11801,43 @@ class AnimationGroup extends Eventer {
|
|
|
11697
11801
|
}
|
|
11698
11802
|
}
|
|
11699
11803
|
|
|
11804
|
+
replaceData(data) {
|
|
11805
|
+
this._replaceData = data;
|
|
11806
|
+
this._setupReplaceData();
|
|
11807
|
+
}
|
|
11808
|
+
|
|
11809
|
+
_setupReplaceData() {
|
|
11810
|
+
if (this._response && this._replaceData) {
|
|
11811
|
+
if (this._response.substituteIds) {
|
|
11812
|
+
const revertSubstituteIds = {};
|
|
11813
|
+
for (const key in this._response.substituteIds) {
|
|
11814
|
+
const value = this._response.substituteIds[key];
|
|
11815
|
+
revertSubstituteIds[value] = key;
|
|
11816
|
+
}
|
|
11817
|
+
|
|
11818
|
+
for (const name in this._replaceData) {
|
|
11819
|
+
const data = this._replaceData[name];
|
|
11820
|
+
|
|
11821
|
+
const layer = getLayerBySubstituteId(this._response, revertSubstituteIds[name]);
|
|
11822
|
+
if (!layer) continue;
|
|
11823
|
+
// 更新图片图层或文本图层的内容
|
|
11824
|
+
const { ty } = layer;
|
|
11825
|
+
if (ty === 2) {
|
|
11826
|
+
const asset = lottieFile.assets.find(item => item.id === layer.refId);
|
|
11827
|
+
if (asset) {
|
|
11828
|
+
asset.p = data;
|
|
11829
|
+
}
|
|
11830
|
+
} else if (ty === 5) {
|
|
11831
|
+
if (layer?.t?.d?.k?.[0]?.s?.t) {
|
|
11832
|
+
layer.t.d.k[0].s.t = data;
|
|
11833
|
+
}
|
|
11834
|
+
}
|
|
11835
|
+
}
|
|
11836
|
+
}
|
|
11837
|
+
this._setupDate(this._response);
|
|
11838
|
+
}
|
|
11839
|
+
}
|
|
11840
|
+
|
|
11700
11841
|
/**
|
|
11701
11842
|
* 安装动画数据
|
|
11702
11843
|
* @private
|
|
@@ -11827,8 +11968,20 @@ class AnimationGroup extends Eventer {
|
|
|
11827
11968
|
st,
|
|
11828
11969
|
},
|
|
11829
11970
|
};
|
|
11830
|
-
session.fontManager.addChars(data.chars);
|
|
11971
|
+
session.fontManager.addChars(data.chars || []);
|
|
11831
11972
|
session.fontManager.addFonts(data.fonts, document.body);
|
|
11973
|
+
if (data.fonts?.list?.length) {
|
|
11974
|
+
const fonts = data.fonts.list
|
|
11975
|
+
.map(item => ({
|
|
11976
|
+
alias: item.fFamily,
|
|
11977
|
+
src: item.fPath,
|
|
11978
|
+
data: { family: item.fFamily },
|
|
11979
|
+
}))
|
|
11980
|
+
.filter(item => item.src);
|
|
11981
|
+
pixi_js.Assets.load(fonts).catch(e => {
|
|
11982
|
+
console.error(e);
|
|
11983
|
+
});
|
|
11984
|
+
}
|
|
11832
11985
|
|
|
11833
11986
|
this._buildElements(session);
|
|
11834
11987
|
|
|
@@ -12064,7 +12217,10 @@ class AnimationGroup extends Eventer {
|
|
|
12064
12217
|
// texture,
|
|
12065
12218
|
// });
|
|
12066
12219
|
} else {
|
|
12067
|
-
lottieLayer.display = new SpriteElement(lottieLayer, {
|
|
12220
|
+
lottieLayer.display = new SpriteElement(lottieLayer, {
|
|
12221
|
+
asset,
|
|
12222
|
+
texture,
|
|
12223
|
+
});
|
|
12068
12224
|
}
|
|
12069
12225
|
return lottieLayer;
|
|
12070
12226
|
}
|
|
@@ -12107,7 +12263,13 @@ class AnimationGroup extends Eventer {
|
|
|
12107
12263
|
_extraText(layer, session) {
|
|
12108
12264
|
layer.global = session;
|
|
12109
12265
|
const lottieLayer = new TextLottieLayer(layer, session);
|
|
12110
|
-
|
|
12266
|
+
const usesGlyphs = !!session.fontManager.chars?.length;
|
|
12267
|
+
if (usesGlyphs) {
|
|
12268
|
+
lottieLayer.display = new TextGlyphsElement(lottieLayer);
|
|
12269
|
+
} else {
|
|
12270
|
+
lottieLayer.display = new TextElement(lottieLayer);
|
|
12271
|
+
}
|
|
12272
|
+
|
|
12111
12273
|
return lottieLayer;
|
|
12112
12274
|
}
|
|
12113
12275
|
|
|
@@ -12342,10 +12504,11 @@ class AnimationGroup extends Eventer {
|
|
|
12342
12504
|
*/
|
|
12343
12505
|
update(snippetCache, firstFrame = false) {
|
|
12344
12506
|
if (!this.living || !this.isDisplayLoaded || (this.isPaused && !firstFrame)) return;
|
|
12345
|
-
|
|
12346
|
-
const
|
|
12347
|
-
|
|
12348
|
-
|
|
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
|
+
}
|
|
12349
12512
|
this.root.updateFrame(correctedFrameNum);
|
|
12350
12513
|
|
|
12351
12514
|
const np = correctedFrameNum >> 0;
|
|
@@ -12447,6 +12610,7 @@ class AnimationGroup extends Eventer {
|
|
|
12447
12610
|
* @param {boolean} [options.alternate=false] alternate direction every round
|
|
12448
12611
|
* @param {number} [options.wait=0] need wait how much millisecond to start
|
|
12449
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
|
|
12450
12614
|
* @return {this}
|
|
12451
12615
|
*/
|
|
12452
12616
|
playSegment(name, options = {}) {
|
|
@@ -12470,6 +12634,11 @@ class AnimationGroup extends Eventer {
|
|
|
12470
12634
|
if (Tools.isBoolean(options.alternate)) this.alternate = options.alternate;
|
|
12471
12635
|
if (Tools.isNumber(options.wait)) this.wait = options.wait;
|
|
12472
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
|
+
}
|
|
12473
12642
|
|
|
12474
12643
|
this.replay();
|
|
12475
12644
|
return this;
|
|
@@ -12575,9 +12744,15 @@ class AnimationGroup extends Eventer {
|
|
|
12575
12744
|
this._repeatsCut = this.repeats;
|
|
12576
12745
|
this._delayCut = this.delay;
|
|
12577
12746
|
this.living = true;
|
|
12578
|
-
|
|
12747
|
+
// 根据播放方向设置初始帧位置
|
|
12748
|
+
if (this.direction === -1) {
|
|
12749
|
+
// 倒着播放从duration开始
|
|
12750
|
+
this.frameNum = this.duration;
|
|
12751
|
+
} else {
|
|
12752
|
+
// 正常播放从0开始
|
|
12753
|
+
this.frameNum = 0;
|
|
12754
|
+
}
|
|
12579
12755
|
this.duration = Math.floor(this.endFrame - this.beginFrame);
|
|
12580
|
-
this.direction = 1;
|
|
12581
12756
|
return this;
|
|
12582
12757
|
}
|
|
12583
12758
|
|
|
@@ -12884,7 +13059,7 @@ class AnimationManager extends Eventer {
|
|
|
12884
13059
|
}
|
|
12885
13060
|
}
|
|
12886
13061
|
|
|
12887
|
-
const { major } = iOSVersion__default(
|
|
13062
|
+
const { major } = iOSVersion__default(globalThis.navigator.userAgent) || {};
|
|
12888
13063
|
|
|
12889
13064
|
/**
|
|
12890
13065
|
* dataURL 转成 blob
|
|
@@ -12946,6 +13121,12 @@ let LottieSystem = class LottieSystem extends pluginRenderer.Renderer {
|
|
|
12946
13121
|
'update',
|
|
12947
13122
|
];
|
|
12948
13123
|
}
|
|
13124
|
+
/**
|
|
13125
|
+
* System 初始化用,可以配置参数,游戏未开始
|
|
13126
|
+
*
|
|
13127
|
+
* System init, set params, game is not begain
|
|
13128
|
+
* @param param init params
|
|
13129
|
+
*/
|
|
12949
13130
|
init() {
|
|
12950
13131
|
this.renderSystem = this.game.getSystem('Renderer');
|
|
12951
13132
|
this.app = this.renderSystem.application;
|
|
@@ -12963,22 +13144,28 @@ let LottieSystem = class LottieSystem extends pluginRenderer.Renderer {
|
|
|
12963
13144
|
});
|
|
12964
13145
|
}
|
|
12965
13146
|
add(changed) {
|
|
13147
|
+
var _a, _b;
|
|
12966
13148
|
return __awaiter(this, void 0, void 0, function* () {
|
|
12967
13149
|
this.manager = new AnimationManager(this.app);
|
|
12968
13150
|
const component = changed.component;
|
|
12969
13151
|
const container = this.renderSystem.containerManager.getContainer(changed.gameObject.id);
|
|
12970
13152
|
if (!container)
|
|
12971
13153
|
return;
|
|
12972
|
-
const
|
|
12973
|
-
const
|
|
13154
|
+
const _c = component.options, { resource: rn } = _c, otherOpts = __rest(_c, ["resource"]);
|
|
13155
|
+
const res = yield eva_js.resource.getResource(rn);
|
|
13156
|
+
const data = res.data;
|
|
13157
|
+
const url = ((_b = (_a = res.src) === null || _a === void 0 ? void 0 : _a.json) === null || _b === void 0 ? void 0 : _b.url) || '';
|
|
12974
13158
|
const json = Object.assign({}, (data.json || {}));
|
|
12975
13159
|
const assets = json.assets || [];
|
|
12976
13160
|
assets.forEach(item => {
|
|
12977
13161
|
if (item.p)
|
|
12978
13162
|
item.p = imageHandle(item.p);
|
|
12979
13163
|
});
|
|
12980
|
-
const anim = this.manager.parseAnimation(Object.assign({ keyframes: json }, otherOpts));
|
|
13164
|
+
const anim = this.manager.parseAnimation(Object.assign({ keyframes: json, prefix: this.getDir(url) }, otherOpts));
|
|
12981
13165
|
component.anim = anim;
|
|
13166
|
+
if (component._replaceData) {
|
|
13167
|
+
anim.replaceData(component._replaceData);
|
|
13168
|
+
}
|
|
12982
13169
|
container.addChildAt(anim.group, 0);
|
|
12983
13170
|
this.managerLife.forEach(eventName => {
|
|
12984
13171
|
anim.on(eventName, e => component.emit(eventName, e));
|
|
@@ -12987,6 +13174,11 @@ let LottieSystem = class LottieSystem extends pluginRenderer.Renderer {
|
|
|
12987
13174
|
component.emit('success', {});
|
|
12988
13175
|
});
|
|
12989
13176
|
}
|
|
13177
|
+
getDir(url) {
|
|
13178
|
+
if (!url)
|
|
13179
|
+
return url;
|
|
13180
|
+
return new URL('./', url).href;
|
|
13181
|
+
}
|
|
12990
13182
|
remove(changed) {
|
|
12991
13183
|
const component = changed.component;
|
|
12992
13184
|
const container = this.renderSystem.containerManager.getContainer(changed.gameObject.id);
|
|
@@ -13005,12 +13197,78 @@ LottieSystem = __decorate([
|
|
|
13005
13197
|
], LottieSystem);
|
|
13006
13198
|
var LottieSystem$1 = LottieSystem;
|
|
13007
13199
|
|
|
13200
|
+
/**
|
|
13201
|
+
* Lottie 动画组件
|
|
13202
|
+
*
|
|
13203
|
+
* Lottie 组件用于播放 Adobe After Effects 导出的 Lottie 动画文件。
|
|
13204
|
+
* Lottie 是一种基于 JSON 的动画格式,可以实现复杂的矢量动画效果,
|
|
13205
|
+
* 文件体积小、性能高,适用于图标动画、loading 动画、复杂 UI 动效等场景。
|
|
13206
|
+
*
|
|
13207
|
+
* 主要功能:
|
|
13208
|
+
* - 播放 Lottie JSON 动画
|
|
13209
|
+
* - 支持动画片段播放和循环
|
|
13210
|
+
* - 支持插槽(slot)动态替换内容
|
|
13211
|
+
* - 支持帧事件监听
|
|
13212
|
+
* - 支持交互热区绑定
|
|
13213
|
+
* - 支持动态替换动画数据
|
|
13214
|
+
*
|
|
13215
|
+
* @example
|
|
13216
|
+
* ```typescript
|
|
13217
|
+
* // 基础用法
|
|
13218
|
+
* const animation = new GameObject('animation');
|
|
13219
|
+
* animation.addComponent(new Lottie({
|
|
13220
|
+
* resource: 'loadingAnimation', // Lottie JSON 资源
|
|
13221
|
+
* autoStart: true
|
|
13222
|
+
* }));
|
|
13223
|
+
*
|
|
13224
|
+
* // 播放指定片段
|
|
13225
|
+
* const lottie = animation.getComponent('Lottie');
|
|
13226
|
+
* lottie.play([0, 60], { repeats: -1 }); // 播放 0-60 帧,无限循环
|
|
13227
|
+
*
|
|
13228
|
+
* // 动态替换插槽内容
|
|
13229
|
+
* lottie.play([0, 120], {
|
|
13230
|
+
* slot: [{
|
|
13231
|
+
* name: 'avatar',
|
|
13232
|
+
* type: 'IMAGE',
|
|
13233
|
+
* value: 'user-avatar.png',
|
|
13234
|
+
* style: { width: 100, height: 100 }
|
|
13235
|
+
* }, {
|
|
13236
|
+
* name: 'username',
|
|
13237
|
+
* type: 'TEXT',
|
|
13238
|
+
* value: '玩家名称',
|
|
13239
|
+
* style: { fontSize: 24 }
|
|
13240
|
+
* }]
|
|
13241
|
+
* });
|
|
13242
|
+
*
|
|
13243
|
+
* // 监听特定帧事件
|
|
13244
|
+
* lottie.on('@30', () => {
|
|
13245
|
+
* console.log('到达第 30 帧');
|
|
13246
|
+
* });
|
|
13247
|
+
*
|
|
13248
|
+
* // 绑定点击热区
|
|
13249
|
+
* lottie.onTap('buttonLayer', () => {
|
|
13250
|
+
* console.log('按钮被点击');
|
|
13251
|
+
* });
|
|
13252
|
+
* ```
|
|
13253
|
+
*/
|
|
13008
13254
|
class Lottie extends eva_js.Component {
|
|
13255
|
+
/**
|
|
13256
|
+
* 构造 Lottie 组件
|
|
13257
|
+
* @param options - Lottie 配置选项
|
|
13258
|
+
* @param options.resource - Lottie JSON 资源名称
|
|
13259
|
+
* @param options.autoStart - 是否自动开始播放
|
|
13260
|
+
*/
|
|
13009
13261
|
constructor(options) {
|
|
13010
13262
|
super();
|
|
13263
|
+
/** 待替换的数据 */
|
|
13264
|
+
this._replaceData = null;
|
|
13265
|
+
/** 资源加载状态 */
|
|
13011
13266
|
this.loadStatus = false;
|
|
13267
|
+
/** 首次播放回调 */
|
|
13012
13268
|
this.firstPlay = null;
|
|
13269
|
+
/** 前一次的插槽内容 */
|
|
13013
13270
|
this.prevSlot = {};
|
|
13271
|
+
/** 当前的插槽内容 */
|
|
13014
13272
|
this.currentSlot = {};
|
|
13015
13273
|
this.options = Object.assign({ autoStart: false }, options);
|
|
13016
13274
|
this.on('success', () => {
|
|
@@ -13039,7 +13297,10 @@ class Lottie extends eva_js.Component {
|
|
|
13039
13297
|
this.currentSlot[name] = pixi_js.Sprite.from(value);
|
|
13040
13298
|
}
|
|
13041
13299
|
else if (type === 'TEXT') {
|
|
13042
|
-
this.currentSlot[name] = new pixi_js.Text(
|
|
13300
|
+
this.currentSlot[name] = new pixi_js.Text({
|
|
13301
|
+
text: value,
|
|
13302
|
+
style: new pixi_js.TextStyle(style),
|
|
13303
|
+
});
|
|
13043
13304
|
}
|
|
13044
13305
|
if (x)
|
|
13045
13306
|
this.currentSlot[name].x = x;
|
|
@@ -13058,6 +13319,14 @@ class Lottie extends eva_js.Component {
|
|
|
13058
13319
|
});
|
|
13059
13320
|
this.anim.playSegment(this.playParamsHandle(params), expandOpts);
|
|
13060
13321
|
}
|
|
13322
|
+
replaceData(data) {
|
|
13323
|
+
if (data) {
|
|
13324
|
+
if (this.anim)
|
|
13325
|
+
this.anim.replaceData(data);
|
|
13326
|
+
else
|
|
13327
|
+
this._replaceData = data;
|
|
13328
|
+
}
|
|
13329
|
+
}
|
|
13061
13330
|
playParamsHandle(params) {
|
|
13062
13331
|
let p = [].concat(params);
|
|
13063
13332
|
const { keyframes } = this.anim;
|
|
@@ -13074,9 +13343,7 @@ class Lottie extends eva_js.Component {
|
|
|
13074
13343
|
this.on('success', () => {
|
|
13075
13344
|
const ele = this.anim.querySelector(name);
|
|
13076
13345
|
const display = ele.display;
|
|
13077
|
-
g.
|
|
13078
|
-
g.drawRect(0, 0, 100, 100);
|
|
13079
|
-
g.endFill();
|
|
13346
|
+
g.rect(0, 0, 100, 100).fill(0xffffff);
|
|
13080
13347
|
g.alpha = 0;
|
|
13081
13348
|
display.addChild(g);
|
|
13082
13349
|
ele.display.interactive = true;
|
|
@@ -13086,6 +13353,7 @@ class Lottie extends eva_js.Component {
|
|
|
13086
13353
|
});
|
|
13087
13354
|
}
|
|
13088
13355
|
}
|
|
13356
|
+
/** 组件名称 */
|
|
13089
13357
|
Lottie.componentName = 'Lottie';
|
|
13090
13358
|
|
|
13091
13359
|
eva_js.resource.registerResourceType('LOTTIE');
|