@eva/plugin-renderer-lottie 2.0.1-beta.3 → 2.0.1-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/EVA.plugin.renderer.lottie.js +29 -59
- package/dist/EVA.plugin.renderer.lottie.min.js +1 -1
- package/dist/plugin-renderer-lottie.cjs.js +27 -55
- package/dist/plugin-renderer-lottie.cjs.prod.js +1 -1
- package/dist/plugin-renderer-lottie.d.ts +1 -0
- package/dist/plugin-renderer-lottie.esm.js +32 -60
- package/package.json +3 -3
|
@@ -7092,7 +7092,6 @@ var _EVA_IIFE_lottie = function (exports, eva_js, pluginRenderer, pixi_js) {
|
|
|
7092
7092
|
length: len
|
|
7093
7093
|
});
|
|
7094
7094
|
}
|
|
7095
|
-
window.$commands = [];
|
|
7096
7095
|
class MatrixHelper extends pixi_js.Matrix {
|
|
7097
7096
|
reset() {
|
|
7098
7097
|
this.a = 1;
|
|
@@ -7445,19 +7444,15 @@ var _EVA_IIFE_lottie = function (exports, eva_js, pluginRenderer, pixi_js) {
|
|
|
7445
7444
|
class SpriteElement extends pixi_js.Sprite {
|
|
7446
7445
|
constructor(lottieLayer, imageInfo) {
|
|
7447
7446
|
const {
|
|
7448
|
-
|
|
7449
|
-
texture
|
|
7447
|
+
texture: texturePromise
|
|
7450
7448
|
} = imageInfo;
|
|
7451
|
-
super(
|
|
7449
|
+
super();
|
|
7452
7450
|
this.label = lottieLayer.fullname;
|
|
7453
|
-
|
|
7454
|
-
|
|
7455
|
-
}
|
|
7456
|
-
|
|
7457
|
-
|
|
7458
|
-
texture.baseTexture.texture.orig = new pixi_js.Rectangle(0, 0, asset.w, asset.h);
|
|
7459
|
-
});
|
|
7460
|
-
}
|
|
7451
|
+
texturePromise.then(texture => {
|
|
7452
|
+
this.texture = texture;
|
|
7453
|
+
}).catch(e => {
|
|
7454
|
+
console.error(e);
|
|
7455
|
+
});
|
|
7461
7456
|
this.lottieLayer = lottieLayer;
|
|
7462
7457
|
if (this.lottieLayer.masks) {
|
|
7463
7458
|
this.mask = new LottieGraphicsMask(this.lottieLayer.session.local, this.lottieLayer);
|
|
@@ -7500,29 +7495,6 @@ var _EVA_IIFE_lottie = function (exports, eva_js, pluginRenderer, pixi_js) {
|
|
|
7500
7495
|
this.mask.updateMasks(masks);
|
|
7501
7496
|
}
|
|
7502
7497
|
}
|
|
7503
|
-
class BaseTexture extends pixi_js.EventEmitter {
|
|
7504
|
-
constructor(url) {
|
|
7505
|
-
super();
|
|
7506
|
-
this.texture = pixi_js.Texture.EMPTY;
|
|
7507
|
-
this.img = new Image();
|
|
7508
|
-
this.img.src = url;
|
|
7509
|
-
this.img.onload = () => {
|
|
7510
|
-
this.texture = pixi_js.Texture.from(this.img);
|
|
7511
|
-
this.emit('loaded');
|
|
7512
|
-
};
|
|
7513
|
-
this.img.onerror = () => {
|
|
7514
|
-
this.emit('error');
|
|
7515
|
-
};
|
|
7516
|
-
}
|
|
7517
|
-
}
|
|
7518
|
-
class Texture {
|
|
7519
|
-
constructor(url) {
|
|
7520
|
-
this.baseTexture = new BaseTexture(url);
|
|
7521
|
-
}
|
|
7522
|
-
static from(url) {
|
|
7523
|
-
return new Texture(url);
|
|
7524
|
-
}
|
|
7525
|
-
}
|
|
7526
7498
|
const regHttp = /^(https?:)?\/\//;
|
|
7527
7499
|
function createUrl(asset, prefix) {
|
|
7528
7500
|
if (asset.e === 1) return asset.p;
|
|
@@ -7562,25 +7534,18 @@ var _EVA_IIFE_lottie = function (exports, eva_js, pluginRenderer, pixi_js) {
|
|
|
7562
7534
|
this.assets.forEach(asset => {
|
|
7563
7535
|
const id = asset.id;
|
|
7564
7536
|
const url = createUrl(asset, this.prefix);
|
|
7565
|
-
const
|
|
7566
|
-
this.textures[id] =
|
|
7537
|
+
const texturePromise = pixi_js.Assets.load(url);
|
|
7538
|
+
this.textures[id] = texturePromise;
|
|
7567
7539
|
this._total++;
|
|
7568
|
-
|
|
7540
|
+
texturePromise.then(() => {
|
|
7569
7541
|
this._received++;
|
|
7570
7542
|
this.emit('update');
|
|
7571
7543
|
if (this._received + this._failed >= this._total) this._onComplete();
|
|
7572
|
-
}
|
|
7573
|
-
|
|
7574
|
-
|
|
7575
|
-
|
|
7576
|
-
|
|
7577
|
-
});
|
|
7578
|
-
texture.baseTexture.once('error', () => {
|
|
7579
|
-
this._failed++;
|
|
7580
|
-
this.emit('update');
|
|
7581
|
-
if (this._received + this._failed >= this._total) this._onComplete();
|
|
7582
|
-
});
|
|
7583
|
-
}
|
|
7544
|
+
}).catch(e => {
|
|
7545
|
+
this._failed++;
|
|
7546
|
+
this.emit('update');
|
|
7547
|
+
if (this._received + this._failed >= this._total) this._onComplete();
|
|
7548
|
+
});
|
|
7584
7549
|
});
|
|
7585
7550
|
}
|
|
7586
7551
|
_onComplete() {
|
|
@@ -8400,7 +8365,7 @@ var _EVA_IIFE_lottie = function (exports, eva_js, pluginRenderer, pixi_js) {
|
|
|
8400
8365
|
var iOSVersion = iosVersion;
|
|
8401
8366
|
const {
|
|
8402
8367
|
major
|
|
8403
|
-
} = iOSVersion(
|
|
8368
|
+
} = iOSVersion(globalThis.navigator.userAgent) || {};
|
|
8404
8369
|
function dataURL2blob(dataURL) {
|
|
8405
8370
|
let binaryString = atob(dataURL.split(',')[1]);
|
|
8406
8371
|
let arrayBuffer = new ArrayBuffer(binaryString.length);
|
|
@@ -8466,16 +8431,17 @@ var _EVA_IIFE_lottie = function (exports, eva_js, pluginRenderer, pixi_js) {
|
|
|
8466
8431
|
resource: rn
|
|
8467
8432
|
} = _a,
|
|
8468
8433
|
otherOpts = __rest(_a, ["resource"]);
|
|
8469
|
-
const
|
|
8470
|
-
|
|
8471
|
-
|
|
8434
|
+
const res = yield eva_js.resource.getResource(rn);
|
|
8435
|
+
const data = res.data;
|
|
8436
|
+
const url = res.src.json.url;
|
|
8472
8437
|
const json = _extends({}, data.json || {});
|
|
8473
8438
|
const assets = json.assets || [];
|
|
8474
8439
|
assets.forEach(item => {
|
|
8475
8440
|
if (item.p) item.p = imageHandle(item.p);
|
|
8476
8441
|
});
|
|
8477
8442
|
const anim = this.manager.parseAnimation(_extends({
|
|
8478
|
-
keyframes: json
|
|
8443
|
+
keyframes: json,
|
|
8444
|
+
prefix: this.getDir(url)
|
|
8479
8445
|
}, otherOpts));
|
|
8480
8446
|
component.anim = anim;
|
|
8481
8447
|
container.addChildAt(anim.group, 0);
|
|
@@ -8485,6 +8451,9 @@ var _EVA_IIFE_lottie = function (exports, eva_js, pluginRenderer, pixi_js) {
|
|
|
8485
8451
|
if (anim.isImagesLoaded) component.emit('success', {});
|
|
8486
8452
|
});
|
|
8487
8453
|
}
|
|
8454
|
+
getDir(url) {
|
|
8455
|
+
return new URL('./', url).href;
|
|
8456
|
+
}
|
|
8488
8457
|
remove(changed) {
|
|
8489
8458
|
const component = changed.component;
|
|
8490
8459
|
const container = this.renderSystem.containerManager.getContainer(changed.gameObject.id);
|
|
@@ -8558,7 +8527,10 @@ var _EVA_IIFE_lottie = function (exports, eva_js, pluginRenderer, pixi_js) {
|
|
|
8558
8527
|
if (type === 'IMAGE') {
|
|
8559
8528
|
this.currentSlot[name] = pixi_js.Sprite.from(value);
|
|
8560
8529
|
} else if (type === 'TEXT') {
|
|
8561
|
-
this.currentSlot[name] = new pixi_js.Text(
|
|
8530
|
+
this.currentSlot[name] = new pixi_js.Text({
|
|
8531
|
+
text: value,
|
|
8532
|
+
style: new pixi_js.TextStyle(style)
|
|
8533
|
+
});
|
|
8562
8534
|
}
|
|
8563
8535
|
if (x) this.currentSlot[name].x = x;
|
|
8564
8536
|
if (y) this.currentSlot[name].y = y;
|
|
@@ -8589,9 +8561,7 @@ var _EVA_IIFE_lottie = function (exports, eva_js, pluginRenderer, pixi_js) {
|
|
|
8589
8561
|
this.on('success', () => {
|
|
8590
8562
|
const ele = this.anim.querySelector(name);
|
|
8591
8563
|
const display = ele.display;
|
|
8592
|
-
g.
|
|
8593
|
-
g.drawRect(0, 0, 100, 100);
|
|
8594
|
-
g.endFill();
|
|
8564
|
+
g.rect(0, 0, 100, 100).fill(0xffffff);
|
|
8595
8565
|
g.alpha = 0;
|
|
8596
8566
|
display.addChild(g);
|
|
8597
8567
|
ele.display.interactive = true;
|