@eva/plugin-renderer-lottie 2.0.1-beta.6 → 2.0.1-beta.7
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 +257 -111
- package/dist/EVA.plugin.renderer.lottie.min.js +1 -1
- package/dist/plugin-renderer-lottie.cjs.js +336 -137
- 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 +337 -138
- package/package.json +3 -3
|
@@ -28,6 +28,7 @@ declare interface IOptions {
|
|
|
28
28
|
resource: string;
|
|
29
29
|
width?: number;
|
|
30
30
|
height?: number;
|
|
31
|
+
replaceData?: boolean;
|
|
31
32
|
}
|
|
32
33
|
|
|
33
34
|
export declare class Lottie extends Component {
|
|
@@ -47,6 +48,7 @@ export declare class Lottie extends Component {
|
|
|
47
48
|
};
|
|
48
49
|
constructor(options: IOptions);
|
|
49
50
|
play(params?: number[], expandOpts?: IExpandOpts): void;
|
|
51
|
+
replaceData(data: Record<string, string>): void;
|
|
50
52
|
playParamsHandle(params: any): any[];
|
|
51
53
|
onTap(name: any, callback: any): void;
|
|
52
54
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { decorators, OBSERVER_TYPE, resource, Component } from '@eva/eva.js';
|
|
2
2
|
import { Renderer } from '@eva/plugin-renderer';
|
|
3
|
-
import {
|
|
3
|
+
import { Ticker, Container, Assets, Texture, Graphics, Text, Matrix as Matrix$1, Sprite, TextStyle } from 'pixi.js';
|
|
4
4
|
import iOSVersion from 'ios-version';
|
|
5
5
|
|
|
6
6
|
/*! *****************************************************************************
|
|
@@ -271,7 +271,7 @@ if (typeof Uint8ClampedArray === 'function' && typeof Float32Array === 'function
|
|
|
271
271
|
* @param {*} len a
|
|
272
272
|
* @return {*}
|
|
273
273
|
*/
|
|
274
|
-
function createSizedArray$
|
|
274
|
+
function createSizedArray$2(len) {
|
|
275
275
|
return new Array(len);
|
|
276
276
|
}
|
|
277
277
|
|
|
@@ -501,7 +501,7 @@ var BezierFactory = {
|
|
|
501
501
|
* @return {*}
|
|
502
502
|
*/
|
|
503
503
|
function _double(arr) {
|
|
504
|
-
return arr.concat(createSizedArray$
|
|
504
|
+
return arr.concat(createSizedArray$2(arr.length));
|
|
505
505
|
}
|
|
506
506
|
var pooling = {
|
|
507
507
|
double: _double,
|
|
@@ -510,7 +510,7 @@ var pooling = {
|
|
|
510
510
|
var PoolFactory = function PoolFactory(initialLength, _create, _release) {
|
|
511
511
|
var _length = 0;
|
|
512
512
|
var _maxLength = initialLength;
|
|
513
|
-
var pool = createSizedArray$
|
|
513
|
+
var pool = createSizedArray$2(_maxLength);
|
|
514
514
|
var ob = {
|
|
515
515
|
newElement: newElement,
|
|
516
516
|
release: release,
|
|
@@ -790,7 +790,7 @@ function buildBezierData(pt1, pt2, pt3, pt4) {
|
|
|
790
790
|
var bezierData = new BezierData(curveSegments);
|
|
791
791
|
var len = pt3.length;
|
|
792
792
|
for (var k = 0; k < curveSegments; k += 1) {
|
|
793
|
-
point = createSizedArray$
|
|
793
|
+
point = createSizedArray$2(len);
|
|
794
794
|
var perc = k / (curveSegments - 1);
|
|
795
795
|
ptDistance = 0;
|
|
796
796
|
for (var i = 0; i < len; i += 1) {
|
|
@@ -2178,9 +2178,9 @@ var ShapePath = /*#__PURE__*/ (function () {
|
|
|
2178
2178
|
this.c = false;
|
|
2179
2179
|
this._length = 0;
|
|
2180
2180
|
this._maxLength = 8;
|
|
2181
|
-
this.v = createSizedArray$
|
|
2182
|
-
this.o = createSizedArray$
|
|
2183
|
-
this.i = createSizedArray$
|
|
2181
|
+
this.v = createSizedArray$2(this._maxLength);
|
|
2182
|
+
this.o = createSizedArray$2(this._maxLength);
|
|
2183
|
+
this.i = createSizedArray$2(this._maxLength);
|
|
2184
2184
|
}
|
|
2185
2185
|
|
|
2186
2186
|
/**
|
|
@@ -2224,9 +2224,9 @@ var ShapePath = /*#__PURE__*/ (function () {
|
|
|
2224
2224
|
{
|
|
2225
2225
|
key: 'doubleArrayLength',
|
|
2226
2226
|
value: function doubleArrayLength() {
|
|
2227
|
-
this.v = this.v.concat(createSizedArray$
|
|
2228
|
-
this.i = this.i.concat(createSizedArray$
|
|
2229
|
-
this.o = this.o.concat(createSizedArray$
|
|
2227
|
+
this.v = this.v.concat(createSizedArray$2(this._maxLength));
|
|
2228
|
+
this.i = this.i.concat(createSizedArray$2(this._maxLength));
|
|
2229
|
+
this.o = this.o.concat(createSizedArray$2(this._maxLength));
|
|
2230
2230
|
this._maxLength *= 2;
|
|
2231
2231
|
},
|
|
2232
2232
|
|
|
@@ -2395,7 +2395,7 @@ var ShapeCollection = /*#__PURE__*/ (function () {
|
|
|
2395
2395
|
_classCallCheck(this, ShapeCollection);
|
|
2396
2396
|
this._length = 0;
|
|
2397
2397
|
this._maxLength = 4;
|
|
2398
|
-
this.shapes = createSizedArray$
|
|
2398
|
+
this.shapes = createSizedArray$2(this._maxLength);
|
|
2399
2399
|
}
|
|
2400
2400
|
|
|
2401
2401
|
/**
|
|
@@ -2407,7 +2407,7 @@ var ShapeCollection = /*#__PURE__*/ (function () {
|
|
|
2407
2407
|
key: 'addShape',
|
|
2408
2408
|
value: function addShape(shapeData) {
|
|
2409
2409
|
if (this._length === this._maxLength) {
|
|
2410
|
-
this.shapes = this.shapes.concat(createSizedArray$
|
|
2410
|
+
this.shapes = this.shapes.concat(createSizedArray$2(this._maxLength));
|
|
2411
2411
|
this._maxLength *= 2;
|
|
2412
2412
|
}
|
|
2413
2413
|
this.shapes[this._length] = shapeData;
|
|
@@ -2432,7 +2432,7 @@ var ShapeCollection = /*#__PURE__*/ (function () {
|
|
|
2432
2432
|
|
|
2433
2433
|
var _length = 0;
|
|
2434
2434
|
var _maxLength = 4;
|
|
2435
|
-
var pool = createSizedArray$
|
|
2435
|
+
var pool = createSizedArray$2(_maxLength);
|
|
2436
2436
|
|
|
2437
2437
|
/**
|
|
2438
2438
|
* a
|
|
@@ -3257,7 +3257,7 @@ var MaskFrames = /*#__PURE__*/ (function (_DynamicPropertyConta) {
|
|
|
3257
3257
|
_this.propType = 'mask';
|
|
3258
3258
|
_this.masksProperties = masksProperties || [];
|
|
3259
3259
|
_this.initDynamicPropertyContainer(elem);
|
|
3260
|
-
_this.viewData = createSizedArray$
|
|
3260
|
+
_this.viewData = createSizedArray$2(_this.masksProperties.length);
|
|
3261
3261
|
var len = _this.masksProperties.length;
|
|
3262
3262
|
var hasMasks = false;
|
|
3263
3263
|
for (var i = 0; i < len; i++) {
|
|
@@ -5688,7 +5688,7 @@ var DashProperty = /*#__PURE__*/ (function (_DynamicPropertyConta) {
|
|
|
5688
5688
|
_this = _callSuper(this, DashProperty);
|
|
5689
5689
|
_this.elem = elem;
|
|
5690
5690
|
_this.frameId = -1;
|
|
5691
|
-
_this.dataProps = createSizedArray$
|
|
5691
|
+
_this.dataProps = createSizedArray$2(data.length);
|
|
5692
5692
|
// this.renderer = renderer;
|
|
5693
5693
|
_this.k = false;
|
|
5694
5694
|
// this.dashStr = '';
|
|
@@ -7413,7 +7413,7 @@ var TextAnimatorProperty = /*#__PURE__*/ (function (_DynamicPropertyConta) {
|
|
|
7413
7413
|
_this._textData = textData;
|
|
7414
7414
|
_this._renderType = renderType;
|
|
7415
7415
|
_this.elem = elem;
|
|
7416
|
-
_this._animatorsData = createSizedArray$
|
|
7416
|
+
_this._animatorsData = createSizedArray$2(_this._textData.a.length);
|
|
7417
7417
|
_this._pathData = {};
|
|
7418
7418
|
_this._moreOptions = {
|
|
7419
7419
|
alignment: {},
|
|
@@ -10208,7 +10208,6 @@ const Tween = {
|
|
|
10208
10208
|
};
|
|
10209
10209
|
|
|
10210
10210
|
({
|
|
10211
|
-
UPDATE_PRIORITY,
|
|
10212
10211
|
animationTicker: Ticker.shared,
|
|
10213
10212
|
});
|
|
10214
10213
|
|
|
@@ -10268,6 +10267,61 @@ class LottieGraphicsMask extends Graphics {
|
|
|
10268
10267
|
}
|
|
10269
10268
|
}
|
|
10270
10269
|
|
|
10270
|
+
const updateTransformByHierarchy = (container, transform, parent) => {
|
|
10271
|
+
// const localMatrixA = new Matrix();
|
|
10272
|
+
|
|
10273
|
+
if (transform.p) {
|
|
10274
|
+
container.x = transform.p.v[0];
|
|
10275
|
+
container.y = transform.p.v[1];
|
|
10276
|
+
} else {
|
|
10277
|
+
container.x = transform.px.v;
|
|
10278
|
+
container.y = transform.py.v;
|
|
10279
|
+
}
|
|
10280
|
+
|
|
10281
|
+
container.pivot.x = transform.a.v[0];
|
|
10282
|
+
container.pivot.y = transform.a.v[1];
|
|
10283
|
+
|
|
10284
|
+
container.scale.x = transform.s.v[0];
|
|
10285
|
+
container.scale.y = transform.s.v[1];
|
|
10286
|
+
|
|
10287
|
+
if (transform.r) {
|
|
10288
|
+
container.rotation = transform.r.v + transform.orientation;
|
|
10289
|
+
} else if (transform.rz) {
|
|
10290
|
+
container.rotation = transform.rz.v + transform.or.v[2];
|
|
10291
|
+
}
|
|
10292
|
+
|
|
10293
|
+
// let x = transform.p ? transform.p.v[0] : transform.px.v;
|
|
10294
|
+
// let y = transform.p ? transform.p.v[1] : transform.py.v;
|
|
10295
|
+
|
|
10296
|
+
// const rotation = transform.r
|
|
10297
|
+
// ? transform.r.v + transform.orientation
|
|
10298
|
+
// : transform.rz
|
|
10299
|
+
// ? transform.rz.v + transform.or.v[2]
|
|
10300
|
+
// : 0;
|
|
10301
|
+
|
|
10302
|
+
// localMatrixA.setTransform(
|
|
10303
|
+
// x,
|
|
10304
|
+
// y,
|
|
10305
|
+
// transform.a.v[0],
|
|
10306
|
+
// transform.a.v[1],
|
|
10307
|
+
// transform.s.v[0],
|
|
10308
|
+
// transform.s.v[1],
|
|
10309
|
+
// rotation,
|
|
10310
|
+
// 0,
|
|
10311
|
+
// 0
|
|
10312
|
+
// );
|
|
10313
|
+
|
|
10314
|
+
// if (parent) {
|
|
10315
|
+
// const parentWorldTransform = parent.worldTransform.clone();
|
|
10316
|
+
// container.setFromMatrix(localMatrixA.append(parentWorldTransform));
|
|
10317
|
+
// } else {
|
|
10318
|
+
// container.setFromMatrix(localMatrixA);
|
|
10319
|
+
// }
|
|
10320
|
+
|
|
10321
|
+
const parentAlpha = parent ? parent.alpha : 1;
|
|
10322
|
+
container.alpha = parentAlpha * transform.o.v;
|
|
10323
|
+
};
|
|
10324
|
+
|
|
10271
10325
|
/**
|
|
10272
10326
|
* NullElement class
|
|
10273
10327
|
* @class
|
|
@@ -10316,27 +10370,7 @@ class CompElement extends Container {
|
|
|
10316
10370
|
}
|
|
10317
10371
|
|
|
10318
10372
|
updateLottieTransform(transform) {
|
|
10319
|
-
|
|
10320
|
-
this.x = transform.p.v[0];
|
|
10321
|
-
this.y = transform.p.v[1];
|
|
10322
|
-
} else {
|
|
10323
|
-
this.x = transform.px.v;
|
|
10324
|
-
this.y = transform.py.v;
|
|
10325
|
-
}
|
|
10326
|
-
|
|
10327
|
-
this.pivot.x = transform.a.v[0];
|
|
10328
|
-
this.pivot.y = transform.a.v[1];
|
|
10329
|
-
|
|
10330
|
-
this.scale.x = transform.s.v[0];
|
|
10331
|
-
this.scale.y = transform.s.v[1];
|
|
10332
|
-
|
|
10333
|
-
if (transform.r) {
|
|
10334
|
-
this.rotation = transform.r.v + transform.orientation;
|
|
10335
|
-
} else if (transform.rz) {
|
|
10336
|
-
this.rotation = transform.rz.v + transform.or.v[2];
|
|
10337
|
-
}
|
|
10338
|
-
|
|
10339
|
-
this.alpha = transform.o.v;
|
|
10373
|
+
updateTransformByHierarchy(this, transform, this.hierarchy);
|
|
10340
10374
|
}
|
|
10341
10375
|
|
|
10342
10376
|
/**
|
|
@@ -10511,27 +10545,7 @@ class ShapeElement extends Graphics {
|
|
|
10511
10545
|
* @param {*} transform
|
|
10512
10546
|
*/
|
|
10513
10547
|
updateLottieTransform(transform) {
|
|
10514
|
-
|
|
10515
|
-
this.x = transform.p.v[0];
|
|
10516
|
-
this.y = transform.p.v[1];
|
|
10517
|
-
} else {
|
|
10518
|
-
this.x = transform.px.v;
|
|
10519
|
-
this.y = transform.py.v;
|
|
10520
|
-
}
|
|
10521
|
-
|
|
10522
|
-
this.pivot.x = transform.a.v[0];
|
|
10523
|
-
this.pivot.y = transform.a.v[1];
|
|
10524
|
-
|
|
10525
|
-
this.scale.x = transform.s.v[0];
|
|
10526
|
-
this.scale.y = transform.s.v[1];
|
|
10527
|
-
|
|
10528
|
-
if (transform.r) {
|
|
10529
|
-
this.rotation = transform.r.v + transform.orientation;
|
|
10530
|
-
} else if (transform.rz) {
|
|
10531
|
-
this.rotation = transform.rz.v + transform.or.v[2];
|
|
10532
|
-
}
|
|
10533
|
-
|
|
10534
|
-
this.alpha = transform.o.v;
|
|
10548
|
+
updateTransformByHierarchy(this, transform, this.hierarchy);
|
|
10535
10549
|
}
|
|
10536
10550
|
|
|
10537
10551
|
/**
|
|
@@ -10557,6 +10571,154 @@ function createSizedArray(len) {
|
|
|
10557
10571
|
return Array.apply(null, { length: len });
|
|
10558
10572
|
}
|
|
10559
10573
|
|
|
10574
|
+
/**
|
|
10575
|
+
* NullElement class
|
|
10576
|
+
* @class
|
|
10577
|
+
* @private
|
|
10578
|
+
*/
|
|
10579
|
+
class TextElement extends Text {
|
|
10580
|
+
/**
|
|
10581
|
+
* ShapeElement constructor
|
|
10582
|
+
*/
|
|
10583
|
+
constructor(lottieLayer) {
|
|
10584
|
+
super();
|
|
10585
|
+
this.label = lottieLayer.fullname;
|
|
10586
|
+
this.lottieLayer = lottieLayer;
|
|
10587
|
+
this.lottieLayer.lettersChangedFlag = true;
|
|
10588
|
+
if (this.lottieLayer.masks) {
|
|
10589
|
+
this.mask = new LottieGraphicsMask(this.lottieLayer.session.local, this.lottieLayer);
|
|
10590
|
+
this.addChild(this.mask);
|
|
10591
|
+
}
|
|
10592
|
+
|
|
10593
|
+
this.init();
|
|
10594
|
+
this.buildNewText();
|
|
10595
|
+
this.updateLottie = this.updateLottie.bind(this);
|
|
10596
|
+
this.updateLottie(this.lottieLayer, true);
|
|
10597
|
+
this.lottieLayer.on('updatelayer', this.updateLottie);
|
|
10598
|
+
this.onRender = () => {
|
|
10599
|
+
this.updateLottie(this.lottieLayer, true);
|
|
10600
|
+
};
|
|
10601
|
+
}
|
|
10602
|
+
|
|
10603
|
+
init() {
|
|
10604
|
+
this._textSpans = [];
|
|
10605
|
+
this._yOffset = 0;
|
|
10606
|
+
this._fillColorAnim = false;
|
|
10607
|
+
this._strokeColorAnim = false;
|
|
10608
|
+
this._strokeWidthAnim = false;
|
|
10609
|
+
this._stroke = false;
|
|
10610
|
+
this._fill = false;
|
|
10611
|
+
this._justifyOffset = 0;
|
|
10612
|
+
this._currentRender = null;
|
|
10613
|
+
this._renderType = 'canvas';
|
|
10614
|
+
this._fillStyle = {};
|
|
10615
|
+
this._values = {
|
|
10616
|
+
fill: '#000000',
|
|
10617
|
+
stroke: '#000000',
|
|
10618
|
+
sWidth: 0,
|
|
10619
|
+
fValue: '',
|
|
10620
|
+
};
|
|
10621
|
+
}
|
|
10622
|
+
|
|
10623
|
+
buildNewText() {
|
|
10624
|
+
const documentData = this.lottieLayer.textProperty.currentData;
|
|
10625
|
+
this.renderedLetters = createSizedArray(documentData.l ? documentData.l.length : 0);
|
|
10626
|
+
let hasFill = false;
|
|
10627
|
+
if (documentData.fc) {
|
|
10628
|
+
hasFill = true;
|
|
10629
|
+
this._values.fill = Tools.rgb2hex(
|
|
10630
|
+
documentData.fc.map(item => {
|
|
10631
|
+
return item > 1 ? item : item * 255;
|
|
10632
|
+
}),
|
|
10633
|
+
documentData.fc,
|
|
10634
|
+
);
|
|
10635
|
+
} else {
|
|
10636
|
+
this._values.fill = '#000000';
|
|
10637
|
+
}
|
|
10638
|
+
this._fill = hasFill;
|
|
10639
|
+
let hasStroke = false;
|
|
10640
|
+
if (documentData.sc) {
|
|
10641
|
+
hasStroke = true;
|
|
10642
|
+
this._values.stroke = this.buildColor(documentData.sc);
|
|
10643
|
+
this._values.sWidth = documentData.sw;
|
|
10644
|
+
}
|
|
10645
|
+
const fontManager = this.lottieLayer.global.fontManager;
|
|
10646
|
+
this._stroke = hasStroke;
|
|
10647
|
+
this._values.fontSize = documentData.finalSize;
|
|
10648
|
+
this._values.fontFamily = fontManager.getFontByName(documentData.f).fFamily;
|
|
10649
|
+
this._values.fontWeight = documentData.fWeight;
|
|
10650
|
+
this._values.fontStyle = documentData.fStyle;
|
|
10651
|
+
this._values.lineHeight = documentData.finalLineHeight;
|
|
10652
|
+
this._text = documentData.t;
|
|
10653
|
+
|
|
10654
|
+
this.renderText();
|
|
10655
|
+
}
|
|
10656
|
+
|
|
10657
|
+
async renderText() {
|
|
10658
|
+
this.text = this._text;
|
|
10659
|
+
if (this.style.fontFamily) {
|
|
10660
|
+
await Assets.get(this.style.fontFamily);
|
|
10661
|
+
}
|
|
10662
|
+
this.style.fontFamily = this._values.fontFamily;
|
|
10663
|
+
this.style.fontSize = this._values.fontSize;
|
|
10664
|
+
this.style.fill = this._values.fill;
|
|
10665
|
+
this.style.fontWeight = this._values.fontWeight;
|
|
10666
|
+
this.style.fontStyle = this._values.fontStyle;
|
|
10667
|
+
this.style.lineHeight = this._values.lineHeight;
|
|
10668
|
+
|
|
10669
|
+
this.anchor.x = 0.5;
|
|
10670
|
+
this.anchor.y = 1;
|
|
10671
|
+
}
|
|
10672
|
+
|
|
10673
|
+
/**
|
|
10674
|
+
* update lottie information
|
|
10675
|
+
* @param {*} lottieLayer lottie element object
|
|
10676
|
+
* @param {boolean} forceUpdate forceUpdate
|
|
10677
|
+
*/
|
|
10678
|
+
updateLottie(lottieLayer, _forceUpdate = false) {
|
|
10679
|
+
let forceUpdate = true;
|
|
10680
|
+
if (lottieLayer.transform && forceUpdate) {
|
|
10681
|
+
this.updateLottieTransform(lottieLayer.transform);
|
|
10682
|
+
}
|
|
10683
|
+
if (lottieLayer.masks && forceUpdate) {
|
|
10684
|
+
this.updateLottieMasks(lottieLayer.masks);
|
|
10685
|
+
}
|
|
10686
|
+
if (lottieLayer._mdf) {
|
|
10687
|
+
this.renderText();
|
|
10688
|
+
}
|
|
10689
|
+
this.visible = lottieLayer.isInRange;
|
|
10690
|
+
this._onUpdate();
|
|
10691
|
+
}
|
|
10692
|
+
|
|
10693
|
+
/**
|
|
10694
|
+
* a
|
|
10695
|
+
* @param {*} parent a
|
|
10696
|
+
*/
|
|
10697
|
+
setTransformHierarchy(parent) {
|
|
10698
|
+
this.hierarchy = parent;
|
|
10699
|
+
}
|
|
10700
|
+
|
|
10701
|
+
/**
|
|
10702
|
+
* a
|
|
10703
|
+
* @param {*} transform
|
|
10704
|
+
*/
|
|
10705
|
+
updateLottieTransform(transform) {
|
|
10706
|
+
updateTransformByHierarchy(this, transform, this.hierarchy);
|
|
10707
|
+
}
|
|
10708
|
+
|
|
10709
|
+
/**
|
|
10710
|
+
* a
|
|
10711
|
+
* @param {*} masks a
|
|
10712
|
+
*/
|
|
10713
|
+
updateLottieMasks(masks) {
|
|
10714
|
+
this.mask.updateMasks(masks);
|
|
10715
|
+
}
|
|
10716
|
+
}
|
|
10717
|
+
|
|
10718
|
+
function createSizedArray$1(len) {
|
|
10719
|
+
return Array.apply(null, { length: len });
|
|
10720
|
+
}
|
|
10721
|
+
|
|
10560
10722
|
class MatrixHelper extends Matrix$1 {
|
|
10561
10723
|
reset() {
|
|
10562
10724
|
// 重置为单位矩阵
|
|
@@ -10630,7 +10792,7 @@ class MatrixHelper extends Matrix$1 {
|
|
|
10630
10792
|
* @class
|
|
10631
10793
|
* @private
|
|
10632
10794
|
*/
|
|
10633
|
-
class
|
|
10795
|
+
class TextGlyphsElement extends Graphics {
|
|
10634
10796
|
/**
|
|
10635
10797
|
* ShapeElement constructor
|
|
10636
10798
|
*/
|
|
@@ -10676,15 +10838,14 @@ class TextElement extends Graphics {
|
|
|
10676
10838
|
|
|
10677
10839
|
buildNewText() {
|
|
10678
10840
|
const documentData = this.lottieLayer.textProperty.currentData;
|
|
10679
|
-
this.renderedLetters = createSizedArray(documentData.l ? documentData.l.length : 0);
|
|
10841
|
+
this.renderedLetters = createSizedArray$1(documentData.l ? documentData.l.length : 0);
|
|
10680
10842
|
let hasFill = false;
|
|
10681
10843
|
if (documentData.fc) {
|
|
10682
10844
|
hasFill = true;
|
|
10683
10845
|
this._values.fill = Tools.rgb2hex(
|
|
10684
|
-
|
|
10685
|
-
|
|
10686
|
-
|
|
10687
|
-
// }),
|
|
10846
|
+
documentData.fc.map(item => {
|
|
10847
|
+
return item > 1 ? item : item * 255;
|
|
10848
|
+
}),
|
|
10688
10849
|
documentData.fc,
|
|
10689
10850
|
);
|
|
10690
10851
|
} else {
|
|
@@ -10741,8 +10902,7 @@ class TextElement extends Graphics {
|
|
|
10741
10902
|
shapes = shapeData.shapes ? shapeData.shapes[0].it : [];
|
|
10742
10903
|
jLen = shapes.length;
|
|
10743
10904
|
matrixHelper.scale(documentData.finalSize / 100, documentData.finalSize / 100);
|
|
10744
|
-
commands = createSizedArray(jLen - 1);
|
|
10745
|
-
window.$commands.push(commands);
|
|
10905
|
+
commands = createSizedArray$1(jLen - 1);
|
|
10746
10906
|
let commandsCounter = 0;
|
|
10747
10907
|
for (j = 0; j < jLen; j += 1) {
|
|
10748
10908
|
if (shapes[j].ty === 'sh') {
|
|
@@ -10957,27 +11117,7 @@ class TextElement extends Graphics {
|
|
|
10957
11117
|
* @param {*} transform
|
|
10958
11118
|
*/
|
|
10959
11119
|
updateLottieTransform(transform) {
|
|
10960
|
-
|
|
10961
|
-
this.x = transform.p.v[0];
|
|
10962
|
-
this.y = transform.p.v[1];
|
|
10963
|
-
} else {
|
|
10964
|
-
this.x = transform.px.v;
|
|
10965
|
-
this.y = transform.py.v;
|
|
10966
|
-
}
|
|
10967
|
-
|
|
10968
|
-
this.pivot.x = transform.a.v[0];
|
|
10969
|
-
this.pivot.y = transform.a.v[1];
|
|
10970
|
-
|
|
10971
|
-
this.scale.x = transform.s.v[0];
|
|
10972
|
-
this.scale.y = transform.s.v[1];
|
|
10973
|
-
|
|
10974
|
-
if (transform.r) {
|
|
10975
|
-
this.rotation = transform.r.v + transform.orientation;
|
|
10976
|
-
} else if (transform.rz) {
|
|
10977
|
-
this.rotation = transform.rz.v + transform.or.v[2];
|
|
10978
|
-
}
|
|
10979
|
-
|
|
10980
|
-
this.alpha = transform.o.v;
|
|
11120
|
+
updateTransformByHierarchy(this, transform, this.hierarchy);
|
|
10981
11121
|
}
|
|
10982
11122
|
|
|
10983
11123
|
/**
|
|
@@ -11043,27 +11183,7 @@ class SolidElement extends Graphics {
|
|
|
11043
11183
|
* @param {*} transform
|
|
11044
11184
|
*/
|
|
11045
11185
|
updateLottieTransform(transform) {
|
|
11046
|
-
|
|
11047
|
-
this.x = transform.p.v[0];
|
|
11048
|
-
this.y = transform.p.v[1];
|
|
11049
|
-
} else {
|
|
11050
|
-
this.x = transform.px.v;
|
|
11051
|
-
this.y = transform.py.v;
|
|
11052
|
-
}
|
|
11053
|
-
|
|
11054
|
-
this.pivot.x = transform.a.v[0];
|
|
11055
|
-
this.pivot.y = transform.a.v[1];
|
|
11056
|
-
|
|
11057
|
-
this.scale.x = transform.s.v[0];
|
|
11058
|
-
this.scale.y = transform.s.v[1];
|
|
11059
|
-
|
|
11060
|
-
if (transform.r) {
|
|
11061
|
-
this.rotation = transform.r.v + transform.orientation;
|
|
11062
|
-
} else if (transform.rz) {
|
|
11063
|
-
this.rotation = transform.rz.v + transform.or.v[2];
|
|
11064
|
-
}
|
|
11065
|
-
|
|
11066
|
-
this.alpha = transform.o.v;
|
|
11186
|
+
updateTransformByHierarchy(this, transform, this.hierarchy);
|
|
11067
11187
|
}
|
|
11068
11188
|
|
|
11069
11189
|
/**
|
|
@@ -11138,27 +11258,7 @@ class SpriteElement extends Sprite {
|
|
|
11138
11258
|
* @param {*} transform
|
|
11139
11259
|
*/
|
|
11140
11260
|
updateLottieTransform(transform) {
|
|
11141
|
-
|
|
11142
|
-
this.x = transform.p.v[0];
|
|
11143
|
-
this.y = transform.p.v[1];
|
|
11144
|
-
} else {
|
|
11145
|
-
this.x = transform.px.v;
|
|
11146
|
-
this.y = transform.py.v;
|
|
11147
|
-
}
|
|
11148
|
-
|
|
11149
|
-
this.pivot.x = transform.a.v[0];
|
|
11150
|
-
this.pivot.y = transform.a.v[1];
|
|
11151
|
-
|
|
11152
|
-
this.scale.x = transform.s.v[0];
|
|
11153
|
-
this.scale.y = transform.s.v[1];
|
|
11154
|
-
|
|
11155
|
-
if (transform.r) {
|
|
11156
|
-
this.rotation = transform.r.v + transform.orientation;
|
|
11157
|
-
} else if (transform.rz) {
|
|
11158
|
-
this.rotation = transform.rz.v + transform.or.v[2];
|
|
11159
|
-
}
|
|
11160
|
-
|
|
11161
|
-
this.alpha = transform.o.v;
|
|
11261
|
+
updateTransformByHierarchy(this, transform, this.hierarchy);
|
|
11162
11262
|
}
|
|
11163
11263
|
|
|
11164
11264
|
/**
|
|
@@ -11377,6 +11477,29 @@ function loadJson(path) {
|
|
|
11377
11477
|
return new LoadJson(path);
|
|
11378
11478
|
}
|
|
11379
11479
|
|
|
11480
|
+
const getLayerBySubstituteId = (lottieFile, substituteId) => {
|
|
11481
|
+
const { substituteIds } = lottieFile || {};
|
|
11482
|
+
if (!substituteIds || Object.keys(substituteIds).length === 0) return null;
|
|
11483
|
+
let layer;
|
|
11484
|
+
// 在复合图层内部
|
|
11485
|
+
if (substituteId && substituteId.indexOf('_') === -1) {
|
|
11486
|
+
const outerIndex = Number(substituteId);
|
|
11487
|
+
if (!Number.isNaN(outerIndex)) {
|
|
11488
|
+
layer = lottieFile?.layers?.[outerIndex];
|
|
11489
|
+
}
|
|
11490
|
+
} else if (substituteId) {
|
|
11491
|
+
// 在顶层图层
|
|
11492
|
+
const substituteIdArr = substituteId.split('_');
|
|
11493
|
+
const outerIndex = Number(substituteIdArr[0]);
|
|
11494
|
+
const innerIndex = Number(substituteIdArr[1]);
|
|
11495
|
+
if (!Number.isNaN(outerIndex) && !Number.isNaN(innerIndex)) {
|
|
11496
|
+
const asset = lottieFile.assets[outerIndex];
|
|
11497
|
+
layer = asset?.layers?.[innerIndex];
|
|
11498
|
+
}
|
|
11499
|
+
}
|
|
11500
|
+
return layer;
|
|
11501
|
+
};
|
|
11502
|
+
|
|
11380
11503
|
/**
|
|
11381
11504
|
* an animation group, store and compute frame information, one lottie animate one AnimationGroup
|
|
11382
11505
|
* @class
|
|
@@ -11405,6 +11528,7 @@ class AnimationGroup extends Eventer {
|
|
|
11405
11528
|
* @param {boolean} [options.depthTest=true] enable depth test for 3d layer
|
|
11406
11529
|
* @param {boolean} [options.maskComp=false] add mask for each comp
|
|
11407
11530
|
* @param {string} [options.prefix=''] assets url prefix, look like link path
|
|
11531
|
+
* @param {boolean} [options.replaceData=''] assets url prefix, look like link path
|
|
11408
11532
|
*/
|
|
11409
11533
|
constructor(options) {
|
|
11410
11534
|
super();
|
|
@@ -11635,7 +11759,14 @@ class AnimationGroup extends Eventer {
|
|
|
11635
11759
|
|
|
11636
11760
|
if (options.keyframes) {
|
|
11637
11761
|
if (!this._prefix && options.keyframes.prefix) this._prefix = options.keyframes.prefix;
|
|
11638
|
-
|
|
11762
|
+
if (!options.replaceData) {
|
|
11763
|
+
this._setupDate(options.keyframes);
|
|
11764
|
+
} else {
|
|
11765
|
+
this._response = options.keyframes;
|
|
11766
|
+
if (this._replaceData) {
|
|
11767
|
+
this._setupReplaceData();
|
|
11768
|
+
}
|
|
11769
|
+
}
|
|
11639
11770
|
} else if (options.path) {
|
|
11640
11771
|
let prefix = '';
|
|
11641
11772
|
if (options.path.lastIndexOf('\\') !== -1) {
|
|
@@ -11647,7 +11778,14 @@ class AnimationGroup extends Eventer {
|
|
|
11647
11778
|
|
|
11648
11779
|
this.jsonLoader = loadJson(options.path);
|
|
11649
11780
|
this.jsonLoader.once('success', response => {
|
|
11650
|
-
|
|
11781
|
+
if (!options.replaceData) {
|
|
11782
|
+
this._setupDate(response);
|
|
11783
|
+
} else {
|
|
11784
|
+
this._response = response;
|
|
11785
|
+
if (this._replaceData) {
|
|
11786
|
+
this._setupReplaceData();
|
|
11787
|
+
}
|
|
11788
|
+
}
|
|
11651
11789
|
});
|
|
11652
11790
|
this.jsonLoader.once('error', error => {
|
|
11653
11791
|
this.emit('error', error);
|
|
@@ -11655,6 +11793,43 @@ class AnimationGroup extends Eventer {
|
|
|
11655
11793
|
}
|
|
11656
11794
|
}
|
|
11657
11795
|
|
|
11796
|
+
replaceData(data) {
|
|
11797
|
+
this._replaceData = data;
|
|
11798
|
+
this._setupReplaceData();
|
|
11799
|
+
}
|
|
11800
|
+
|
|
11801
|
+
_setupReplaceData() {
|
|
11802
|
+
if (this._response && this._replaceData) {
|
|
11803
|
+
if (this._response.substituteIds) {
|
|
11804
|
+
const revertSubstituteIds = {};
|
|
11805
|
+
for (const key in this._response.substituteIds) {
|
|
11806
|
+
const value = this._response.substituteIds[key];
|
|
11807
|
+
revertSubstituteIds[value] = key;
|
|
11808
|
+
}
|
|
11809
|
+
|
|
11810
|
+
for (const name in this._replaceData) {
|
|
11811
|
+
const data = this._replaceData[name];
|
|
11812
|
+
|
|
11813
|
+
const layer = getLayerBySubstituteId(this._response, revertSubstituteIds[name]);
|
|
11814
|
+
if (!layer) continue;
|
|
11815
|
+
// 更新图片图层或文本图层的内容
|
|
11816
|
+
const { ty } = layer;
|
|
11817
|
+
if (ty === 2) {
|
|
11818
|
+
const asset = lottieFile.assets.find(item => item.id === layer.refId);
|
|
11819
|
+
if (asset) {
|
|
11820
|
+
asset.p = data;
|
|
11821
|
+
}
|
|
11822
|
+
} else if (ty === 5) {
|
|
11823
|
+
if (layer?.t?.d?.k?.[0]?.s?.t) {
|
|
11824
|
+
layer.t.d.k[0].s.t = data;
|
|
11825
|
+
}
|
|
11826
|
+
}
|
|
11827
|
+
}
|
|
11828
|
+
}
|
|
11829
|
+
this._setupDate(this._response);
|
|
11830
|
+
}
|
|
11831
|
+
}
|
|
11832
|
+
|
|
11658
11833
|
/**
|
|
11659
11834
|
* 安装动画数据
|
|
11660
11835
|
* @private
|
|
@@ -11785,9 +11960,20 @@ class AnimationGroup extends Eventer {
|
|
|
11785
11960
|
st,
|
|
11786
11961
|
},
|
|
11787
11962
|
};
|
|
11788
|
-
session.fontManager.addChars(data.chars);
|
|
11789
|
-
|
|
11790
|
-
|
|
11963
|
+
session.fontManager.addChars(data.chars || []);
|
|
11964
|
+
session.fontManager.addFonts(data.fonts, document.body);
|
|
11965
|
+
if (data.fonts?.list?.length) {
|
|
11966
|
+
const fonts = data.fonts.list
|
|
11967
|
+
.map(item => ({
|
|
11968
|
+
alias: item.fFamily,
|
|
11969
|
+
src: item.fPath,
|
|
11970
|
+
data: { family: item.fFamily },
|
|
11971
|
+
}))
|
|
11972
|
+
.filter(item => item.src);
|
|
11973
|
+
Assets.load(fonts).catch(e => {
|
|
11974
|
+
console.error(e);
|
|
11975
|
+
});
|
|
11976
|
+
}
|
|
11791
11977
|
|
|
11792
11978
|
this._buildElements(session);
|
|
11793
11979
|
|
|
@@ -12023,7 +12209,10 @@ class AnimationGroup extends Eventer {
|
|
|
12023
12209
|
// texture,
|
|
12024
12210
|
// });
|
|
12025
12211
|
} else {
|
|
12026
|
-
lottieLayer.display = new SpriteElement(lottieLayer, {
|
|
12212
|
+
lottieLayer.display = new SpriteElement(lottieLayer, {
|
|
12213
|
+
asset,
|
|
12214
|
+
texture,
|
|
12215
|
+
});
|
|
12027
12216
|
}
|
|
12028
12217
|
return lottieLayer;
|
|
12029
12218
|
}
|
|
@@ -12066,7 +12255,13 @@ class AnimationGroup extends Eventer {
|
|
|
12066
12255
|
_extraText(layer, session) {
|
|
12067
12256
|
layer.global = session;
|
|
12068
12257
|
const lottieLayer = new TextLottieLayer(layer, session);
|
|
12069
|
-
|
|
12258
|
+
const usesGlyphs = !!session.fontManager.chars?.length;
|
|
12259
|
+
if (usesGlyphs) {
|
|
12260
|
+
lottieLayer.display = new TextGlyphsElement(lottieLayer);
|
|
12261
|
+
} else {
|
|
12262
|
+
lottieLayer.display = new TextElement(lottieLayer);
|
|
12263
|
+
}
|
|
12264
|
+
|
|
12070
12265
|
return lottieLayer;
|
|
12071
12266
|
}
|
|
12072
12267
|
|
|
@@ -13025,6 +13220,10 @@ class Lottie extends Component {
|
|
|
13025
13220
|
});
|
|
13026
13221
|
this.anim.playSegment(this.playParamsHandle(params), expandOpts);
|
|
13027
13222
|
}
|
|
13223
|
+
replaceData(data) {
|
|
13224
|
+
if (data)
|
|
13225
|
+
this.anim.replaceData(data);
|
|
13226
|
+
}
|
|
13028
13227
|
playParamsHandle(params) {
|
|
13029
13228
|
let p = [].concat(params);
|
|
13030
13229
|
const { keyframes } = this.anim;
|