@eva/plugin-renderer-dragonbone 2.0.0-beta.1 → 2.0.0-beta.2
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.dragonbone.js +1 -1
- package/dist/EVA.plugin.renderer.dragonbone.min.js +1 -1
- package/dist/plugin-renderer-dragonbone.cjs.js +124 -197
- package/dist/plugin-renderer-dragonbone.cjs.prod.js +16 -1
- package/dist/plugin-renderer-dragonbone.esm.js +125 -198
- package/package.json +3 -3
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type } from '@eva/inspector-decorator';
|
|
2
2
|
import { Component, resource, RESOURCE_TYPE, OBSERVER_TYPE, decorators } from '@eva/eva.js';
|
|
3
3
|
import { Texture, Rectangle, Sprite, Graphics, BLEND_MODES, mesh, ticker } from 'pixi.js';
|
|
4
|
-
import {
|
|
4
|
+
import { Renderer, RendererSystem } from '@eva/plugin-renderer';
|
|
5
5
|
|
|
6
6
|
/*! *****************************************************************************
|
|
7
7
|
Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -17,20 +17,6 @@ MERCHANTABLITY OR NON-INFRINGEMENT.
|
|
|
17
17
|
See the Apache Version 2.0 License for specific language governing permissions
|
|
18
18
|
and limitations under the License.
|
|
19
19
|
***************************************************************************** */
|
|
20
|
-
/* global Reflect, Promise */
|
|
21
|
-
|
|
22
|
-
var extendStatics = function(d, b) {
|
|
23
|
-
extendStatics = Object.setPrototypeOf ||
|
|
24
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
25
|
-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
26
|
-
return extendStatics(d, b);
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
function __extends$1(d, b) {
|
|
30
|
-
extendStatics(d, b);
|
|
31
|
-
function __() { this.constructor = d; }
|
|
32
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
33
|
-
}
|
|
34
20
|
|
|
35
21
|
function __decorate(decorators, target, key, desc) {
|
|
36
22
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -46,74 +32,44 @@ function __awaiter(thisArg, _arguments, P, generator) {
|
|
|
46
32
|
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
|
47
33
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
48
34
|
});
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
function __generator(thisArg, body) {
|
|
52
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
53
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
54
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
55
|
-
function step(op) {
|
|
56
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
57
|
-
while (_) try {
|
|
58
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
59
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
60
|
-
switch (op[0]) {
|
|
61
|
-
case 0: case 1: t = op; break;
|
|
62
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
63
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
64
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
65
|
-
default:
|
|
66
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
67
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
68
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
69
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
70
|
-
if (t[2]) _.ops.pop();
|
|
71
|
-
_.trys.pop(); continue;
|
|
72
|
-
}
|
|
73
|
-
op = body.call(thisArg, _);
|
|
74
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
75
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
76
|
-
}
|
|
77
35
|
}
|
|
78
36
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
_this.waitPlayInfo = {
|
|
37
|
+
class DragonBone$3 extends Component {
|
|
38
|
+
constructor() {
|
|
39
|
+
super(...arguments);
|
|
40
|
+
this.waitPlay = false;
|
|
41
|
+
this.waitStop = false;
|
|
42
|
+
this.waitPlayInfo = {
|
|
86
43
|
animationName: null,
|
|
87
44
|
};
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
return _this;
|
|
45
|
+
this.resource = '';
|
|
46
|
+
this.armatureName = '';
|
|
47
|
+
this.animationName = '';
|
|
48
|
+
this.autoPlay = true;
|
|
93
49
|
}
|
|
94
|
-
|
|
50
|
+
init(obj) {
|
|
95
51
|
if (!obj)
|
|
96
52
|
return;
|
|
97
53
|
if (!obj.armatureName) {
|
|
98
|
-
throw new Error(
|
|
54
|
+
throw new Error(`The dragonBone component on ${this.gameObject.name}, armatureName is required!`);
|
|
99
55
|
}
|
|
100
56
|
Object.assign(this, obj);
|
|
101
57
|
if (this.autoPlay) {
|
|
102
58
|
this.play(this.animationName);
|
|
103
59
|
}
|
|
104
|
-
}
|
|
105
|
-
|
|
60
|
+
}
|
|
61
|
+
play(name, times) {
|
|
106
62
|
if (name)
|
|
107
63
|
this.animationName = name;
|
|
108
64
|
if (!this.armature) {
|
|
109
|
-
this.waitPlayInfo = { animationName: name, times
|
|
65
|
+
this.waitPlayInfo = { animationName: name, times };
|
|
110
66
|
this.waitPlay = true;
|
|
111
67
|
}
|
|
112
68
|
else {
|
|
113
69
|
this.armature.play(this.animationName, times);
|
|
114
70
|
}
|
|
115
|
-
}
|
|
116
|
-
|
|
71
|
+
}
|
|
72
|
+
stop(name) {
|
|
117
73
|
if (!this.armature) {
|
|
118
74
|
this.waitPlayInfo = { animationName: name };
|
|
119
75
|
this.waitStop = true;
|
|
@@ -122,43 +78,37 @@ var DragonBone$3 = (function (_super) {
|
|
|
122
78
|
this.armature.stop(name);
|
|
123
79
|
}
|
|
124
80
|
this.animationName = null;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
enumerable: false,
|
|
141
|
-
configurable: true
|
|
142
|
-
});
|
|
143
|
-
DragonBone.prototype.onDestroy = function () {
|
|
81
|
+
}
|
|
82
|
+
set armature(val) {
|
|
83
|
+
this._armature = val;
|
|
84
|
+
if (!val)
|
|
85
|
+
return;
|
|
86
|
+
const { animationName, times } = this.waitPlayInfo;
|
|
87
|
+
this.waitPlay && this.play(animationName, times);
|
|
88
|
+
this.waitStop && this.stop(animationName);
|
|
89
|
+
this.waitPlay = false;
|
|
90
|
+
this.waitStop = false;
|
|
91
|
+
}
|
|
92
|
+
get armature() {
|
|
93
|
+
return this._armature;
|
|
94
|
+
}
|
|
95
|
+
onDestroy() {
|
|
144
96
|
this.removeAllListeners();
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
}(Component));
|
|
161
|
-
var DragonBone$4 = DragonBone$3;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
DragonBone$3.componentName = 'DragonBone';
|
|
100
|
+
__decorate([
|
|
101
|
+
type('string')
|
|
102
|
+
], DragonBone$3.prototype, "resource", void 0);
|
|
103
|
+
__decorate([
|
|
104
|
+
type('string')
|
|
105
|
+
], DragonBone$3.prototype, "armatureName", void 0);
|
|
106
|
+
__decorate([
|
|
107
|
+
type('string')
|
|
108
|
+
], DragonBone$3.prototype, "animationName", void 0);
|
|
109
|
+
__decorate([
|
|
110
|
+
type('boolean')
|
|
111
|
+
], DragonBone$3.prototype, "autoPlay", void 0);
|
|
162
112
|
|
|
163
113
|
const PIXI = {
|
|
164
114
|
Texture,
|
|
@@ -16951,23 +16901,20 @@ if (!Date.now) {
|
|
|
16951
16901
|
|
|
16952
16902
|
var dragonBones$1 = dragonBones;
|
|
16953
16903
|
|
|
16954
|
-
|
|
16955
|
-
|
|
16956
|
-
var armatureName = _a.armatureName;
|
|
16904
|
+
class DragonBone$2 {
|
|
16905
|
+
constructor({ armatureName }) {
|
|
16957
16906
|
this.factory = dragonBones$1.PixiFactory.factory;
|
|
16958
16907
|
this.armature = this.factory.buildArmatureDisplay(armatureName);
|
|
16959
16908
|
}
|
|
16960
|
-
|
|
16909
|
+
play(name, time) {
|
|
16961
16910
|
return this.armature.animation.play(name, time);
|
|
16962
|
-
}
|
|
16963
|
-
|
|
16911
|
+
}
|
|
16912
|
+
stop(name) {
|
|
16964
16913
|
return this.armature.animation.stop(name);
|
|
16965
|
-
}
|
|
16966
|
-
|
|
16967
|
-
}());
|
|
16968
|
-
var DragonBoneEngine = DragonBone$2;
|
|
16914
|
+
}
|
|
16915
|
+
}
|
|
16969
16916
|
|
|
16970
|
-
|
|
16917
|
+
const events = {
|
|
16971
16918
|
START: 'start',
|
|
16972
16919
|
LOOP_COMPLETE: 'loopComplete',
|
|
16973
16920
|
COMPLETE: 'complete',
|
|
@@ -16978,106 +16925,87 @@ var events = {
|
|
|
16978
16925
|
FRAME_EVENT: 'frameEvent',
|
|
16979
16926
|
SOUND_EVENT: 'soundEvent',
|
|
16980
16927
|
};
|
|
16981
|
-
|
|
16928
|
+
const factory = dragonBones$1.PixiFactory.factory;
|
|
16982
16929
|
resource.registerResourceType('DRAGONBONE');
|
|
16983
|
-
resource.registerInstance(RESOURCE_TYPE.DRAGONBONE,
|
|
16984
|
-
var data = _a.data, name = _a.name;
|
|
16930
|
+
resource.registerInstance(RESOURCE_TYPE.DRAGONBONE, ({ data, name }) => {
|
|
16985
16931
|
factory.parseDragonBonesData(data.ske, name);
|
|
16986
16932
|
factory.parseTextureAtlasData(data.tex, Texture.from(data.image), name);
|
|
16987
16933
|
});
|
|
16988
|
-
resource.registerDestroy(RESOURCE_TYPE.DRAGONBONE,
|
|
16989
|
-
var name = _a.name;
|
|
16934
|
+
resource.registerDestroy(RESOURCE_TYPE.DRAGONBONE, ({ name }) => {
|
|
16990
16935
|
factory.removeDragonBonesData(name);
|
|
16991
16936
|
factory.removeTextureAtlasData(name);
|
|
16992
16937
|
});
|
|
16993
|
-
|
|
16994
|
-
|
|
16995
|
-
|
|
16996
|
-
|
|
16997
|
-
|
|
16998
|
-
|
|
16999
|
-
|
|
17000
|
-
_this.isRemovedMap = new Map();
|
|
17001
|
-
return _this;
|
|
16938
|
+
let DragonBone = class DragonBone extends Renderer {
|
|
16939
|
+
constructor() {
|
|
16940
|
+
super(...arguments);
|
|
16941
|
+
this.name = 'DragonBone';
|
|
16942
|
+
this.armatures = {};
|
|
16943
|
+
this.autoPlay = {};
|
|
16944
|
+
this.isRemovedMap = new Map();
|
|
17002
16945
|
}
|
|
17003
|
-
|
|
16946
|
+
init() {
|
|
17004
16947
|
this.renderSystem = this.game.getSystem(RendererSystem);
|
|
17005
16948
|
this.renderSystem.rendererManager.register(this);
|
|
17006
16949
|
this.renderSystem.application.ticker.add(dragonBones$1.PixiFactory._clockHandler, dragonBones$1.PixiFactory);
|
|
17007
|
-
}
|
|
17008
|
-
|
|
16950
|
+
}
|
|
16951
|
+
onDestroy() {
|
|
17009
16952
|
this.renderSystem.application.ticker.remove(dragonBones$1.PixiFactory._clockHandler, dragonBones$1.PixiFactory);
|
|
17010
|
-
}
|
|
17011
|
-
|
|
17012
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
17013
|
-
|
|
17014
|
-
|
|
17015
|
-
if (changed.
|
|
17016
|
-
|
|
17017
|
-
|
|
17018
|
-
|
|
17019
|
-
|
|
17020
|
-
|
|
17021
|
-
|
|
17022
|
-
|
|
17023
|
-
break;
|
|
17024
|
-
}
|
|
17025
|
-
}
|
|
17026
|
-
else if (changed.type === OBSERVER_TYPE.REMOVE) {
|
|
17027
|
-
this.remove(changed);
|
|
16953
|
+
}
|
|
16954
|
+
componentChanged(changed) {
|
|
16955
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
16956
|
+
this.autoPlay[changed.gameObject.id] = changed.component.autoPlay;
|
|
16957
|
+
if (changed.componentName === 'DragonBone') {
|
|
16958
|
+
if (changed.type === OBSERVER_TYPE.ADD) {
|
|
16959
|
+
this.add(changed);
|
|
16960
|
+
}
|
|
16961
|
+
else if (changed.type === OBSERVER_TYPE.CHANGE) {
|
|
16962
|
+
switch (changed.prop.prop[0]) {
|
|
16963
|
+
case 'armature':
|
|
16964
|
+
this.change(changed);
|
|
16965
|
+
break;
|
|
17028
16966
|
}
|
|
17029
16967
|
}
|
|
17030
|
-
|
|
17031
|
-
|
|
17032
|
-
});
|
|
17033
|
-
};
|
|
17034
|
-
DragonBone.prototype.add = function (changed) {
|
|
17035
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
17036
|
-
var component, asyncId, armature, _loop_1, key;
|
|
17037
|
-
return __generator(this, function (_a) {
|
|
17038
|
-
switch (_a.label) {
|
|
17039
|
-
case 0:
|
|
17040
|
-
component = changed.component;
|
|
17041
|
-
this.isRemovedMap.delete(component);
|
|
17042
|
-
asyncId = this.increaseAsyncId(changed.gameObject.id);
|
|
17043
|
-
return [4, resource.getResource(component.resource)];
|
|
17044
|
-
case 1:
|
|
17045
|
-
_a.sent();
|
|
17046
|
-
if (!this.validateAsyncId(changed.gameObject.id, asyncId))
|
|
17047
|
-
return [2];
|
|
17048
|
-
if (this.isRemovedMap.get(component)) {
|
|
17049
|
-
this.isRemovedMap.delete(component);
|
|
17050
|
-
return [2];
|
|
17051
|
-
}
|
|
17052
|
-
armature = new DragonBoneEngine({
|
|
17053
|
-
armatureName: component.armatureName,
|
|
17054
|
-
});
|
|
17055
|
-
this.armatures[changed.gameObject.id] = armature;
|
|
17056
|
-
this.renderSystem.containerManager.getContainer(changed.gameObject.id).addChildAt(armature.armature, 0);
|
|
17057
|
-
component.armature = armature;
|
|
17058
|
-
_loop_1 = function (key) {
|
|
17059
|
-
armature.armature.on(events[key], function (e) {
|
|
17060
|
-
component.emit(events[key], e);
|
|
17061
|
-
});
|
|
17062
|
-
};
|
|
17063
|
-
for (key in events) {
|
|
17064
|
-
_loop_1(key);
|
|
17065
|
-
}
|
|
17066
|
-
return [2];
|
|
16968
|
+
else if (changed.type === OBSERVER_TYPE.REMOVE) {
|
|
16969
|
+
this.remove(changed);
|
|
17067
16970
|
}
|
|
16971
|
+
}
|
|
16972
|
+
});
|
|
16973
|
+
}
|
|
16974
|
+
add(changed) {
|
|
16975
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
16976
|
+
const component = changed.component;
|
|
16977
|
+
this.isRemovedMap.delete(component);
|
|
16978
|
+
const asyncId = this.increaseAsyncId(changed.gameObject.id);
|
|
16979
|
+
yield resource.getResource(component.resource);
|
|
16980
|
+
if (!this.validateAsyncId(changed.gameObject.id, asyncId))
|
|
16981
|
+
return;
|
|
16982
|
+
if (this.isRemovedMap.get(component)) {
|
|
16983
|
+
this.isRemovedMap.delete(component);
|
|
16984
|
+
return;
|
|
16985
|
+
}
|
|
16986
|
+
const armature = new DragonBone$2({
|
|
16987
|
+
armatureName: component.armatureName,
|
|
17068
16988
|
});
|
|
16989
|
+
this.armatures[changed.gameObject.id] = armature;
|
|
16990
|
+
this.renderSystem.containerManager.getContainer(changed.gameObject.id).addChildAt(armature.armature, 0);
|
|
16991
|
+
component.armature = armature;
|
|
16992
|
+
for (const key in events) {
|
|
16993
|
+
armature.armature.on(events[key], e => {
|
|
16994
|
+
component.emit(events[key], e);
|
|
16995
|
+
});
|
|
16996
|
+
}
|
|
17069
16997
|
});
|
|
17070
|
-
}
|
|
17071
|
-
|
|
16998
|
+
}
|
|
16999
|
+
change(changed) {
|
|
17072
17000
|
this.remove(changed);
|
|
17073
17001
|
this.add(changed);
|
|
17074
17002
|
if (this.autoPlay[changed.gameObject.id]) {
|
|
17075
|
-
|
|
17003
|
+
const component = changed.component;
|
|
17076
17004
|
component.play(component.animationName);
|
|
17077
17005
|
}
|
|
17078
|
-
}
|
|
17079
|
-
|
|
17080
|
-
|
|
17006
|
+
}
|
|
17007
|
+
remove(changed) {
|
|
17008
|
+
const armature = this.armatures[changed.gameObject.id];
|
|
17081
17009
|
if (!armature) {
|
|
17082
17010
|
this.isRemovedMap.set(changed.component, true);
|
|
17083
17011
|
return;
|
|
@@ -17086,22 +17014,21 @@ var DragonBone = (function (_super) {
|
|
|
17086
17014
|
this.renderSystem.containerManager.getContainer(changed.gameObject.id).removeChild(armature.armature);
|
|
17087
17015
|
armature.armature.removeAllListeners();
|
|
17088
17016
|
armature.armature.destroy({ children: true });
|
|
17089
|
-
|
|
17017
|
+
const component = changed.component;
|
|
17090
17018
|
component.armature = null;
|
|
17091
17019
|
delete this.armatures[changed.gameObject.id];
|
|
17092
17020
|
if (changed.type === OBSERVER_TYPE.CHANGE) {
|
|
17093
17021
|
delete this.autoPlay[changed.gameObject.id];
|
|
17094
17022
|
component.removeAllListeners();
|
|
17095
17023
|
}
|
|
17096
|
-
}
|
|
17097
|
-
|
|
17098
|
-
|
|
17099
|
-
|
|
17100
|
-
|
|
17101
|
-
|
|
17102
|
-
|
|
17103
|
-
|
|
17104
|
-
}(Renderer));
|
|
17024
|
+
}
|
|
17025
|
+
};
|
|
17026
|
+
DragonBone.systemName = 'DragonBone';
|
|
17027
|
+
DragonBone = __decorate([
|
|
17028
|
+
decorators.componentObserver({
|
|
17029
|
+
DragonBone: ['armatureName'],
|
|
17030
|
+
})
|
|
17031
|
+
], DragonBone);
|
|
17105
17032
|
var DragonBone$1 = DragonBone;
|
|
17106
17033
|
|
|
17107
|
-
export { DragonBone$
|
|
17034
|
+
export { DragonBone$3 as DragonBone, DragonBone$1 as DragonBoneSystem };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eva/plugin-renderer-dragonbone",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.2",
|
|
4
4
|
"description": "@eva/plugin-renderer-dragonbone",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "dist/plugin-renderer-dragonbone.esm.js",
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
"homepage": "https://eva.js.org",
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"@eva/inspector-decorator": "^0.0.5",
|
|
22
|
-
"@eva/plugin-renderer": "2.0.0-beta.
|
|
23
|
-
"@eva/eva.js": "2.0.0-beta.
|
|
22
|
+
"@eva/plugin-renderer": "2.0.0-beta.2",
|
|
23
|
+
"@eva/eva.js": "2.0.0-beta.2",
|
|
24
24
|
"pixi.js": "^8.6.3"
|
|
25
25
|
}
|
|
26
26
|
}
|