@eva/plugin-renderer-lottie 2.0.1-beta.5 → 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.
@@ -279,7 +279,7 @@ if (typeof Uint8ClampedArray === 'function' && typeof Float32Array === 'function
279
279
  * @param {*} len a
280
280
  * @return {*}
281
281
  */
282
- function createSizedArray$1(len) {
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$1(arr.length));
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$1(_maxLength);
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$1(len);
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$1(this._maxLength);
2190
- this.o = createSizedArray$1(this._maxLength);
2191
- this.i = createSizedArray$1(this._maxLength);
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$1(this._maxLength));
2236
- this.i = this.i.concat(createSizedArray$1(this._maxLength));
2237
- this.o = this.o.concat(createSizedArray$1(this._maxLength));
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$1(this._maxLength);
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$1(this._maxLength));
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$1(_maxLength);
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$1(_this.masksProperties.length);
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$1(data.length);
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$1(_this._textData.a.length);
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
- if (transform.p) {
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
- if (transform.p) {
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,6 +10579,154 @@ function createSizedArray(len) {
10565
10579
  return Array.apply(null, { length: len });
10566
10580
  }
10567
10581
 
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 = 1;
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
+ }
10729
+
10568
10730
  class MatrixHelper extends pixi_js.Matrix {
10569
10731
  reset() {
10570
10732
  // 重置为单位矩阵
@@ -10638,7 +10800,7 @@ class MatrixHelper extends pixi_js.Matrix {
10638
10800
  * @class
10639
10801
  * @private
10640
10802
  */
10641
- class TextElement extends pixi_js.Graphics {
10803
+ class TextGlyphsElement extends pixi_js.Graphics {
10642
10804
  /**
10643
10805
  * ShapeElement constructor
10644
10806
  */
@@ -10684,15 +10846,14 @@ class TextElement extends pixi_js.Graphics {
10684
10846
 
10685
10847
  buildNewText() {
10686
10848
  const documentData = this.lottieLayer.textProperty.currentData;
10687
- this.renderedLetters = createSizedArray(documentData.l ? documentData.l.length : 0);
10849
+ this.renderedLetters = createSizedArray$1(documentData.l ? documentData.l.length : 0);
10688
10850
  let hasFill = false;
10689
10851
  if (documentData.fc) {
10690
10852
  hasFill = true;
10691
10853
  this._values.fill = Tools.rgb2hex(
10692
- // documentData.fc.map((item) => {
10693
- // console.log(item)
10694
- // return item > 1 ? item : item * 255
10695
- // }),
10854
+ documentData.fc.map(item => {
10855
+ return item > 1 ? item : item * 255;
10856
+ }),
10696
10857
  documentData.fc,
10697
10858
  );
10698
10859
  } else {
@@ -10749,8 +10910,7 @@ class TextElement extends pixi_js.Graphics {
10749
10910
  shapes = shapeData.shapes ? shapeData.shapes[0].it : [];
10750
10911
  jLen = shapes.length;
10751
10912
  matrixHelper.scale(documentData.finalSize / 100, documentData.finalSize / 100);
10752
- commands = createSizedArray(jLen - 1);
10753
- window.$commands.push(commands);
10913
+ commands = createSizedArray$1(jLen - 1);
10754
10914
  let commandsCounter = 0;
10755
10915
  for (j = 0; j < jLen; j += 1) {
10756
10916
  if (shapes[j].ty === 'sh') {
@@ -10965,27 +11125,7 @@ class TextElement extends pixi_js.Graphics {
10965
11125
  * @param {*} transform
10966
11126
  */
10967
11127
  updateLottieTransform(transform) {
10968
- if (transform.p) {
10969
- this.x = transform.p.v[0];
10970
- this.y = transform.p.v[1];
10971
- } else {
10972
- this.x = transform.px.v;
10973
- this.y = transform.py.v;
10974
- }
10975
-
10976
- this.pivot.x = transform.a.v[0];
10977
- this.pivot.y = transform.a.v[1];
10978
-
10979
- this.scale.x = transform.s.v[0];
10980
- this.scale.y = transform.s.v[1];
10981
-
10982
- if (transform.r) {
10983
- this.rotation = transform.r.v + transform.orientation;
10984
- } else if (transform.rz) {
10985
- this.rotation = transform.rz.v + transform.or.v[2];
10986
- }
10987
-
10988
- this.alpha = transform.o.v;
11128
+ updateTransformByHierarchy(this, transform, this.hierarchy);
10989
11129
  }
10990
11130
 
10991
11131
  /**
@@ -11051,27 +11191,7 @@ class SolidElement extends pixi_js.Graphics {
11051
11191
  * @param {*} transform
11052
11192
  */
11053
11193
  updateLottieTransform(transform) {
11054
- if (transform.p) {
11055
- this.x = transform.p.v[0];
11056
- this.y = transform.p.v[1];
11057
- } else {
11058
- this.x = transform.px.v;
11059
- this.y = transform.py.v;
11060
- }
11061
-
11062
- this.pivot.x = transform.a.v[0];
11063
- this.pivot.y = transform.a.v[1];
11064
-
11065
- this.scale.x = transform.s.v[0];
11066
- this.scale.y = transform.s.v[1];
11067
-
11068
- if (transform.r) {
11069
- this.rotation = transform.r.v + transform.orientation;
11070
- } else if (transform.rz) {
11071
- this.rotation = transform.rz.v + transform.or.v[2];
11072
- }
11073
-
11074
- this.alpha = transform.o.v;
11194
+ updateTransformByHierarchy(this, transform, this.hierarchy);
11075
11195
  }
11076
11196
 
11077
11197
  /**
@@ -11146,27 +11266,7 @@ class SpriteElement extends pixi_js.Sprite {
11146
11266
  * @param {*} transform
11147
11267
  */
11148
11268
  updateLottieTransform(transform) {
11149
- if (transform.p) {
11150
- this.x = transform.p.v[0];
11151
- this.y = transform.p.v[1];
11152
- } else {
11153
- this.x = transform.px.v;
11154
- this.y = transform.py.v;
11155
- }
11156
-
11157
- this.pivot.x = transform.a.v[0];
11158
- this.pivot.y = transform.a.v[1];
11159
-
11160
- this.scale.x = transform.s.v[0];
11161
- this.scale.y = transform.s.v[1];
11162
-
11163
- if (transform.r) {
11164
- this.rotation = transform.r.v + transform.orientation;
11165
- } else if (transform.rz) {
11166
- this.rotation = transform.rz.v + transform.or.v[2];
11167
- }
11168
-
11169
- this.alpha = transform.o.v;
11269
+ updateTransformByHierarchy(this, transform, this.hierarchy);
11170
11270
  }
11171
11271
 
11172
11272
  /**
@@ -11385,6 +11485,29 @@ function loadJson(path) {
11385
11485
  return new LoadJson(path);
11386
11486
  }
11387
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
+
11388
11511
  /**
11389
11512
  * an animation group, store and compute frame information, one lottie animate one AnimationGroup
11390
11513
  * @class
@@ -11413,6 +11536,7 @@ class AnimationGroup extends Eventer {
11413
11536
  * @param {boolean} [options.depthTest=true] enable depth test for 3d layer
11414
11537
  * @param {boolean} [options.maskComp=false] add mask for each comp
11415
11538
  * @param {string} [options.prefix=''] assets url prefix, look like link path
11539
+ * @param {boolean} [options.replaceData=''] assets url prefix, look like link path
11416
11540
  */
11417
11541
  constructor(options) {
11418
11542
  super();
@@ -11643,7 +11767,14 @@ class AnimationGroup extends Eventer {
11643
11767
 
11644
11768
  if (options.keyframes) {
11645
11769
  if (!this._prefix && options.keyframes.prefix) this._prefix = options.keyframes.prefix;
11646
- this._setupDate(options.keyframes);
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
+ }
11647
11778
  } else if (options.path) {
11648
11779
  let prefix = '';
11649
11780
  if (options.path.lastIndexOf('\\') !== -1) {
@@ -11655,7 +11786,14 @@ class AnimationGroup extends Eventer {
11655
11786
 
11656
11787
  this.jsonLoader = loadJson(options.path);
11657
11788
  this.jsonLoader.once('success', response => {
11658
- this._setupDate(response);
11789
+ if (!options.replaceData) {
11790
+ this._setupDate(response);
11791
+ } else {
11792
+ this._response = response;
11793
+ if (this._replaceData) {
11794
+ this._setupReplaceData();
11795
+ }
11796
+ }
11659
11797
  });
11660
11798
  this.jsonLoader.once('error', error => {
11661
11799
  this.emit('error', error);
@@ -11663,6 +11801,43 @@ class AnimationGroup extends Eventer {
11663
11801
  }
11664
11802
  }
11665
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
+
11666
11841
  /**
11667
11842
  * 安装动画数据
11668
11843
  * @private
@@ -11793,9 +11968,20 @@ class AnimationGroup extends Eventer {
11793
11968
  st,
11794
11969
  },
11795
11970
  };
11796
- session.fontManager.addChars(data.chars);
11797
- // @TODO
11798
- // session.fontManager.addFonts(data.fonts, document.body);
11971
+ session.fontManager.addChars(data.chars || []);
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
+ }
11799
11985
 
11800
11986
  this._buildElements(session);
11801
11987
 
@@ -12031,7 +12217,10 @@ class AnimationGroup extends Eventer {
12031
12217
  // texture,
12032
12218
  // });
12033
12219
  } else {
12034
- lottieLayer.display = new SpriteElement(lottieLayer, { asset, texture });
12220
+ lottieLayer.display = new SpriteElement(lottieLayer, {
12221
+ asset,
12222
+ texture,
12223
+ });
12035
12224
  }
12036
12225
  return lottieLayer;
12037
12226
  }
@@ -12074,7 +12263,13 @@ class AnimationGroup extends Eventer {
12074
12263
  _extraText(layer, session) {
12075
12264
  layer.global = session;
12076
12265
  const lottieLayer = new TextLottieLayer(layer, session);
12077
- lottieLayer.display = new TextElement(lottieLayer);
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
+
12078
12273
  return lottieLayer;
12079
12274
  }
12080
12275
 
@@ -13033,6 +13228,10 @@ class Lottie extends eva_js.Component {
13033
13228
  });
13034
13229
  this.anim.playSegment(this.playParamsHandle(params), expandOpts);
13035
13230
  }
13231
+ replaceData(data) {
13232
+ if (data)
13233
+ this.anim.replaceData(data);
13234
+ }
13036
13235
  playParamsHandle(params) {
13037
13236
  let p = [].concat(params);
13038
13237
  const { keyframes } = this.anim;