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