@eva/plugin-renderer-event 1.3.0-alpha.1 → 2.0.0-beta.1
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.event.js +42 -99
- package/dist/EVA.plugin.renderer.event.min.js +1 -1
- package/dist/plugin-renderer-event.cjs.js +7 -8
- package/dist/plugin-renderer-event.cjs.prod.js +1 -1
- package/dist/plugin-renderer-event.d.ts +5 -1
- package/dist/plugin-renderer-event.esm.js +7 -8
- package/package.json +4 -4
|
@@ -1,53 +1,40 @@
|
|
|
1
|
-
function _extends() { _extends = Object.assign
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
this.EVA.plugin.renderer.event = function (exports, pluginRenderer, eva_js, pixi_js) {
|
|
1
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
2
|
+
window.EVA = window.EVA || {};
|
|
3
|
+
window.EVA.plugin = window.EVA.plugin || {};
|
|
4
|
+
window.EVA.plugin.renderer = window.EVA.plugin.renderer || {};
|
|
5
|
+
var _EVA_IIFE_event = function (exports, pluginRenderer, eva_js, pixi_js) {
|
|
8
6
|
'use strict';
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
_extendStatics = Object.setPrototypeOf || {
|
|
7
|
+
var extendStatics = function (d, b) {
|
|
8
|
+
extendStatics = Object.setPrototypeOf || {
|
|
12
9
|
__proto__: []
|
|
13
10
|
} instanceof Array && function (d, b) {
|
|
14
11
|
d.__proto__ = b;
|
|
15
12
|
} || function (d, b) {
|
|
16
|
-
for (var p in b)
|
|
17
|
-
if (b.hasOwnProperty(p)) d[p] = b[p];
|
|
18
|
-
}
|
|
13
|
+
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
|
19
14
|
};
|
|
20
|
-
|
|
21
|
-
return _extendStatics(d, b);
|
|
15
|
+
return extendStatics(d, b);
|
|
22
16
|
};
|
|
23
|
-
|
|
24
17
|
function __extends(d, b) {
|
|
25
|
-
|
|
26
|
-
|
|
18
|
+
extendStatics(d, b);
|
|
27
19
|
function __() {
|
|
28
20
|
this.constructor = d;
|
|
29
21
|
}
|
|
30
|
-
|
|
31
22
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
32
23
|
}
|
|
33
|
-
|
|
34
24
|
function __decorate(decorators, target, key, desc) {
|
|
35
25
|
var c = arguments.length,
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--)
|
|
39
|
-
if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
40
|
-
}
|
|
26
|
+
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
27
|
+
d;
|
|
28
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
41
29
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
42
30
|
}
|
|
43
|
-
|
|
44
31
|
function __values(o) {
|
|
45
32
|
var s = typeof Symbol === "function" && Symbol.iterator,
|
|
46
|
-
|
|
47
|
-
|
|
33
|
+
m = s && o[s],
|
|
34
|
+
i = 0;
|
|
48
35
|
if (m) return m.call(o);
|
|
49
36
|
if (o && typeof o.length === "number") return {
|
|
50
|
-
next: function
|
|
37
|
+
next: function () {
|
|
51
38
|
if (o && i >= o.length) o = void 0;
|
|
52
39
|
return {
|
|
53
40
|
value: o && o[i++],
|
|
@@ -57,19 +44,15 @@ this.EVA.plugin.renderer.event = function (exports, pluginRenderer, eva_js, pixi
|
|
|
57
44
|
};
|
|
58
45
|
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
59
46
|
}
|
|
60
|
-
|
|
61
47
|
function __read(o, n) {
|
|
62
48
|
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
63
49
|
if (!m) return o;
|
|
64
50
|
var i = m.call(o),
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
51
|
+
r,
|
|
52
|
+
ar = [],
|
|
53
|
+
e;
|
|
69
54
|
try {
|
|
70
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
|
|
71
|
-
ar.push(r.value);
|
|
72
|
-
}
|
|
55
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
73
56
|
} catch (error) {
|
|
74
57
|
e = {
|
|
75
58
|
error: error
|
|
@@ -81,18 +64,12 @@ this.EVA.plugin.renderer.event = function (exports, pluginRenderer, eva_js, pixi
|
|
|
81
64
|
if (e) throw e.error;
|
|
82
65
|
}
|
|
83
66
|
}
|
|
84
|
-
|
|
85
67
|
return ar;
|
|
86
68
|
}
|
|
87
|
-
|
|
88
69
|
function __spread() {
|
|
89
|
-
for (var ar = [], i = 0; i < arguments.length; i++)
|
|
90
|
-
ar = ar.concat(__read(arguments[i]));
|
|
91
|
-
}
|
|
92
|
-
|
|
70
|
+
for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
|
|
93
71
|
return ar;
|
|
94
72
|
}
|
|
95
|
-
|
|
96
73
|
var hitAreaFunc = {
|
|
97
74
|
Circle: pixi_js.Circle,
|
|
98
75
|
Ellipse: pixi_js.Ellipse,
|
|
@@ -107,59 +84,41 @@ this.EVA.plugin.renderer.event = function (exports, pluginRenderer, eva_js, pixi
|
|
|
107
84
|
RoundedRect: ['x', 'y', 'width', 'height', 'radius'],
|
|
108
85
|
Polygon: ['paths']
|
|
109
86
|
};
|
|
110
|
-
|
|
111
87
|
var Event$2 = function (_super) {
|
|
112
88
|
__extends(Event, _super);
|
|
113
|
-
|
|
114
89
|
function Event() {
|
|
115
90
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
116
|
-
|
|
117
91
|
_this.name = 'Event';
|
|
118
92
|
return _this;
|
|
119
93
|
}
|
|
120
|
-
|
|
121
|
-
Event.prototype.init = function (_a) {
|
|
122
|
-
var _b = (_a === void 0 ? {} : _a).moveWhenInside,
|
|
123
|
-
moveWhenInside = _b === void 0 ? false : _b;
|
|
94
|
+
Event.prototype.init = function () {
|
|
124
95
|
this.renderSystem = this.game.getSystem(pluginRenderer.RendererSystem);
|
|
125
96
|
this.renderSystem.rendererManager.register(this);
|
|
126
|
-
|
|
127
|
-
try {
|
|
128
|
-
this.renderSystem.application.renderer.plugins.interaction.moveWhenInside = moveWhenInside;
|
|
129
|
-
} catch (e) {
|
|
130
|
-
console.error('Setting moveWhenInside error.', e);
|
|
131
|
-
}
|
|
132
97
|
};
|
|
133
|
-
|
|
134
98
|
Event.prototype.componentChanged = function (changed) {
|
|
135
99
|
switch (changed.type) {
|
|
136
100
|
case eva_js.OBSERVER_TYPE.ADD:
|
|
137
101
|
this.add(changed);
|
|
138
102
|
break;
|
|
139
|
-
|
|
140
103
|
case eva_js.OBSERVER_TYPE.REMOVE:
|
|
141
104
|
this.remove(changed);
|
|
142
105
|
break;
|
|
143
|
-
|
|
144
106
|
case eva_js.OBSERVER_TYPE.CHANGE:
|
|
145
107
|
this.change(changed);
|
|
146
108
|
break;
|
|
147
109
|
}
|
|
148
110
|
};
|
|
149
|
-
|
|
150
111
|
Event.prototype.add = function (changed) {
|
|
151
112
|
var container = this.containerManager.getContainer(changed.gameObject.id);
|
|
152
113
|
container.interactive = true;
|
|
153
114
|
container.interactiveChildren = true;
|
|
154
115
|
var component = changed.component;
|
|
155
|
-
|
|
156
116
|
if (component.hitArea) {
|
|
157
117
|
this.addHitArea(changed, container, component.hitArea);
|
|
158
118
|
}
|
|
159
|
-
|
|
160
119
|
container.on('pointertap', function (e) {
|
|
161
120
|
component.emit('tap', {
|
|
162
|
-
stopPropagation: function
|
|
121
|
+
stopPropagation: function () {
|
|
163
122
|
return e.stopPropagation();
|
|
164
123
|
},
|
|
165
124
|
data: {
|
|
@@ -167,14 +126,15 @@ this.EVA.plugin.renderer.event = function (exports, pluginRenderer, eva_js, pixi
|
|
|
167
126
|
position: {
|
|
168
127
|
x: e.data.global.x,
|
|
169
128
|
y: e.data.global.y
|
|
170
|
-
}
|
|
129
|
+
},
|
|
130
|
+
localPosition: container.worldTransform.applyInverse(e.data.global)
|
|
171
131
|
},
|
|
172
132
|
gameObject: component.gameObject
|
|
173
133
|
});
|
|
174
134
|
});
|
|
175
135
|
container.on('pointerdown', function (e) {
|
|
176
136
|
component.emit('touchstart', {
|
|
177
|
-
stopPropagation: function
|
|
137
|
+
stopPropagation: function () {
|
|
178
138
|
return e.stopPropagation();
|
|
179
139
|
},
|
|
180
140
|
data: {
|
|
@@ -182,14 +142,15 @@ this.EVA.plugin.renderer.event = function (exports, pluginRenderer, eva_js, pixi
|
|
|
182
142
|
position: {
|
|
183
143
|
x: e.data.global.x,
|
|
184
144
|
y: e.data.global.y
|
|
185
|
-
}
|
|
145
|
+
},
|
|
146
|
+
localPosition: container.worldTransform.applyInverse(e.data.global)
|
|
186
147
|
},
|
|
187
148
|
gameObject: component.gameObject
|
|
188
149
|
});
|
|
189
150
|
});
|
|
190
151
|
container.on('pointermove', function (e) {
|
|
191
152
|
component.emit('touchmove', {
|
|
192
|
-
stopPropagation: function
|
|
153
|
+
stopPropagation: function () {
|
|
193
154
|
return e.stopPropagation();
|
|
194
155
|
},
|
|
195
156
|
data: {
|
|
@@ -197,14 +158,15 @@ this.EVA.plugin.renderer.event = function (exports, pluginRenderer, eva_js, pixi
|
|
|
197
158
|
position: {
|
|
198
159
|
x: e.data.global.x,
|
|
199
160
|
y: e.data.global.y
|
|
200
|
-
}
|
|
161
|
+
},
|
|
162
|
+
localPosition: container.worldTransform.applyInverse(e.data.global)
|
|
201
163
|
},
|
|
202
164
|
gameObject: component.gameObject
|
|
203
165
|
});
|
|
204
166
|
});
|
|
205
167
|
container.on('pointerup', function (e) {
|
|
206
168
|
component.emit('touchend', {
|
|
207
|
-
stopPropagation: function
|
|
169
|
+
stopPropagation: function () {
|
|
208
170
|
return e.stopPropagation();
|
|
209
171
|
},
|
|
210
172
|
data: {
|
|
@@ -212,14 +174,15 @@ this.EVA.plugin.renderer.event = function (exports, pluginRenderer, eva_js, pixi
|
|
|
212
174
|
position: {
|
|
213
175
|
x: e.data.global.x,
|
|
214
176
|
y: e.data.global.y
|
|
215
|
-
}
|
|
177
|
+
},
|
|
178
|
+
localPosition: container.worldTransform.applyInverse(e.data.global)
|
|
216
179
|
},
|
|
217
180
|
gameObject: component.gameObject
|
|
218
181
|
});
|
|
219
182
|
});
|
|
220
183
|
container.on('pointerupoutside', function (e) {
|
|
221
184
|
component.emit('touchendoutside', {
|
|
222
|
-
stopPropagation: function
|
|
185
|
+
stopPropagation: function () {
|
|
223
186
|
return e.stopPropagation();
|
|
224
187
|
},
|
|
225
188
|
data: {
|
|
@@ -227,14 +190,15 @@ this.EVA.plugin.renderer.event = function (exports, pluginRenderer, eva_js, pixi
|
|
|
227
190
|
position: {
|
|
228
191
|
x: e.data.global.x,
|
|
229
192
|
y: e.data.global.y
|
|
230
|
-
}
|
|
193
|
+
},
|
|
194
|
+
localPosition: container.worldTransform.applyInverse(e.data.global)
|
|
231
195
|
},
|
|
232
196
|
gameObject: component.gameObject
|
|
233
197
|
});
|
|
234
198
|
});
|
|
235
199
|
container.on('pointercancel', function (e) {
|
|
236
200
|
component.emit('touchcancel', {
|
|
237
|
-
stopPropagation: function
|
|
201
|
+
stopPropagation: function () {
|
|
238
202
|
return e.stopPropagation();
|
|
239
203
|
},
|
|
240
204
|
data: {
|
|
@@ -242,13 +206,13 @@ this.EVA.plugin.renderer.event = function (exports, pluginRenderer, eva_js, pixi
|
|
|
242
206
|
position: {
|
|
243
207
|
x: e.data.global.x,
|
|
244
208
|
y: e.data.global.y
|
|
245
|
-
}
|
|
209
|
+
},
|
|
210
|
+
localPosition: container.worldTransform.applyInverse(e.data.global)
|
|
246
211
|
},
|
|
247
212
|
gameObject: component.gameObject
|
|
248
213
|
});
|
|
249
214
|
});
|
|
250
215
|
};
|
|
251
|
-
|
|
252
216
|
Event.prototype.remove = function (changed) {
|
|
253
217
|
var container = this.containerManager.getContainer(changed.gameObject.id);
|
|
254
218
|
container.interactive = false;
|
|
@@ -260,32 +224,25 @@ this.EVA.plugin.renderer.event = function (exports, pluginRenderer, eva_js, pixi
|
|
|
260
224
|
container.off('pointercancel');
|
|
261
225
|
changed.component.removeAllListeners();
|
|
262
226
|
};
|
|
263
|
-
|
|
264
227
|
Event.prototype.change = function (changed) {
|
|
265
228
|
var container = this.containerManager.getContainer(changed.gameObject.id);
|
|
266
229
|
container.interactive = true;
|
|
267
230
|
var component = changed.component;
|
|
268
|
-
|
|
269
231
|
if (component.hitArea) {
|
|
270
232
|
this.addHitArea(changed, container, component.hitArea);
|
|
271
233
|
} else {
|
|
272
234
|
component.hitArea = null;
|
|
273
235
|
}
|
|
274
236
|
};
|
|
275
|
-
|
|
276
237
|
Event.prototype.addHitArea = function (changed, container, hitArea) {
|
|
277
238
|
var e_1, _a, _b;
|
|
278
|
-
|
|
279
239
|
var type = hitArea.type,
|
|
280
|
-
|
|
281
|
-
|
|
240
|
+
style = hitArea.style;
|
|
282
241
|
if (!hitAreaFunc[type]) {
|
|
283
242
|
console.error(changed.gameObject.name + "'s hitArea type is not defined");
|
|
284
243
|
return;
|
|
285
244
|
}
|
|
286
|
-
|
|
287
245
|
var params = [];
|
|
288
|
-
|
|
289
246
|
try {
|
|
290
247
|
for (var _c = __values(propertyForHitArea[type]), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
291
248
|
var key = _d.value;
|
|
@@ -302,11 +259,9 @@ this.EVA.plugin.renderer.event = function (exports, pluginRenderer, eva_js, pixi
|
|
|
302
259
|
if (e_1) throw e_1.error;
|
|
303
260
|
}
|
|
304
261
|
}
|
|
305
|
-
|
|
306
262
|
var hitAreaShape = new ((_b = hitAreaFunc[type]).bind.apply(_b, __spread([void 0], params)))();
|
|
307
263
|
container.hitArea = hitAreaShape;
|
|
308
264
|
};
|
|
309
|
-
|
|
310
265
|
Event.systemName = 'Event';
|
|
311
266
|
Event = __decorate([eva_js.decorators.componentObserver({
|
|
312
267
|
Event: [{
|
|
@@ -316,10 +271,8 @@ this.EVA.plugin.renderer.event = function (exports, pluginRenderer, eva_js, pixi
|
|
|
316
271
|
})], Event);
|
|
317
272
|
return Event;
|
|
318
273
|
}(pluginRenderer.Renderer);
|
|
319
|
-
|
|
320
274
|
var Event$3 = Event$2;
|
|
321
275
|
exports.HIT_AREA_TYPE = void 0;
|
|
322
|
-
|
|
323
276
|
(function (HIT_AREA_TYPE) {
|
|
324
277
|
HIT_AREA_TYPE["Circle"] = "Circle";
|
|
325
278
|
HIT_AREA_TYPE["Ellipse"] = "Ellipse";
|
|
@@ -327,43 +280,32 @@ this.EVA.plugin.renderer.event = function (exports, pluginRenderer, eva_js, pixi
|
|
|
327
280
|
HIT_AREA_TYPE["Rect"] = "Rect";
|
|
328
281
|
HIT_AREA_TYPE["RoundedRect"] = "RoundedRect";
|
|
329
282
|
})(exports.HIT_AREA_TYPE || (exports.HIT_AREA_TYPE = {}));
|
|
330
|
-
|
|
331
283
|
var Event = function (_super) {
|
|
332
284
|
__extends(Event, _super);
|
|
333
|
-
|
|
334
285
|
function Event() {
|
|
335
286
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
336
|
-
|
|
337
287
|
_this.hitArea = undefined;
|
|
338
288
|
return _this;
|
|
339
289
|
}
|
|
340
|
-
|
|
341
290
|
Event.prototype.init = function (params) {
|
|
342
291
|
params && _extends(this, params);
|
|
343
292
|
};
|
|
344
|
-
|
|
345
293
|
Event.prototype.emit = function (en) {
|
|
346
294
|
var args = [];
|
|
347
|
-
|
|
348
295
|
for (var _i = 1; _i < arguments.length; _i++) {
|
|
349
296
|
args[_i - 1] = arguments[_i];
|
|
350
297
|
}
|
|
351
|
-
|
|
352
298
|
return _super.prototype.emit.apply(this, __spread([en], args));
|
|
353
299
|
};
|
|
354
|
-
|
|
355
300
|
Event.prototype.once = function (en, fn, context) {
|
|
356
301
|
return _super.prototype.once.call(this, en, fn, context);
|
|
357
302
|
};
|
|
358
|
-
|
|
359
303
|
Event.prototype.on = function (en, fn, context) {
|
|
360
304
|
return _super.prototype.on.call(this, en, fn, context);
|
|
361
305
|
};
|
|
362
|
-
|
|
363
306
|
Event.componentName = 'Event';
|
|
364
307
|
return Event;
|
|
365
308
|
}(eva_js.Component);
|
|
366
|
-
|
|
367
309
|
var Event$1 = Event;
|
|
368
310
|
exports.Event = Event$1;
|
|
369
311
|
exports.EventSystem = Event$3;
|
|
@@ -372,3 +314,4 @@ this.EVA.plugin.renderer.event = function (exports, pluginRenderer, eva_js, pixi
|
|
|
372
314
|
});
|
|
373
315
|
return exports;
|
|
374
316
|
}({}, EVA.plugin.renderer, EVA, PIXI);
|
|
317
|
+
window.EVA.plugin.renderer.event = window.EVA.plugin.renderer.event || _EVA_IIFE_event;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function _extends(){return
|
|
1
|
+
function _extends(){return _extends=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var o=arguments[e];for(var n in o)({}).hasOwnProperty.call(o,n)&&(t[n]=o[n])}return t},_extends.apply(null,arguments)}window.EVA=window.EVA||{},window.EVA.plugin=window.EVA.plugin||{},window.EVA.plugin.renderer=window.EVA.plugin.renderer||{};var _EVA_IIFE_event=function(t,e,o,n){"use strict";var r=function(t,e){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var o in e)e.hasOwnProperty(o)&&(t[o]=e[o])},r(t,e)};function a(t,e){function o(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(o.prototype=e.prototype,new o)}function i(t,e){var o="function"==typeof Symbol&&t[Symbol.iterator];if(!o)return t;var n,r,a=o.call(t),i=[];try{for(;(void 0===e||e-- >0)&&!(n=a.next()).done;)i.push(n.value)}catch(t){r={error:t}}finally{try{n&&!n.done&&(o=a.return)&&o.call(a)}finally{if(r)throw r.error}}return i}function l(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(i(arguments[e]));return t}var p,c={Circle:n.Circle,Ellipse:n.Ellipse,Polygon:n.Polygon,Rect:n.Rectangle,RoundedRect:n.RoundedRectangle},d={Circle:["x","y","radius"],Ellipse:["x","y","width","height"],Rect:["x","y","width","height"],RoundedRect:["x","y","width","height","radius"],Polygon:["paths"]},s=function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="Event",e}return a(n,t),n.prototype.init=function(){this.renderSystem=this.game.getSystem(e.RendererSystem),this.renderSystem.rendererManager.register(this)},n.prototype.componentChanged=function(t){switch(t.type){case o.OBSERVER_TYPE.ADD:this.add(t);break;case o.OBSERVER_TYPE.REMOVE:this.remove(t);break;case o.OBSERVER_TYPE.CHANGE:this.change(t)}},n.prototype.add=function(t){var e=this.containerManager.getContainer(t.gameObject.id);e.interactive=!0,e.interactiveChildren=!0;var o=t.component;o.hitArea&&this.addHitArea(t,e,o.hitArea),e.on("pointertap",(function(t){o.emit("tap",{stopPropagation:function(){return t.stopPropagation()},data:{pointerId:t.data.pointerId,position:{x:t.data.global.x,y:t.data.global.y},localPosition:e.worldTransform.applyInverse(t.data.global)},gameObject:o.gameObject})})),e.on("pointerdown",(function(t){o.emit("touchstart",{stopPropagation:function(){return t.stopPropagation()},data:{pointerId:t.data.pointerId,position:{x:t.data.global.x,y:t.data.global.y},localPosition:e.worldTransform.applyInverse(t.data.global)},gameObject:o.gameObject})})),e.on("pointermove",(function(t){o.emit("touchmove",{stopPropagation:function(){return t.stopPropagation()},data:{pointerId:t.data.pointerId,position:{x:t.data.global.x,y:t.data.global.y},localPosition:e.worldTransform.applyInverse(t.data.global)},gameObject:o.gameObject})})),e.on("pointerup",(function(t){o.emit("touchend",{stopPropagation:function(){return t.stopPropagation()},data:{pointerId:t.data.pointerId,position:{x:t.data.global.x,y:t.data.global.y},localPosition:e.worldTransform.applyInverse(t.data.global)},gameObject:o.gameObject})})),e.on("pointerupoutside",(function(t){o.emit("touchendoutside",{stopPropagation:function(){return t.stopPropagation()},data:{pointerId:t.data.pointerId,position:{x:t.data.global.x,y:t.data.global.y},localPosition:e.worldTransform.applyInverse(t.data.global)},gameObject:o.gameObject})})),e.on("pointercancel",(function(t){o.emit("touchcancel",{stopPropagation:function(){return t.stopPropagation()},data:{pointerId:t.data.pointerId,position:{x:t.data.global.x,y:t.data.global.y},localPosition:e.worldTransform.applyInverse(t.data.global)},gameObject:o.gameObject})}))},n.prototype.remove=function(t){var e=this.containerManager.getContainer(t.gameObject.id);e.interactive=!1,e.off("tap"),e.off("pointerdown"),e.off("pointermove"),e.off("pointerup"),e.off("pointerupoutside"),e.off("pointercancel"),t.component.removeAllListeners()},n.prototype.change=function(t){var e=this.containerManager.getContainer(t.gameObject.id);e.interactive=!0;var o=t.component;o.hitArea?this.addHitArea(t,e,o.hitArea):o.hitArea=null},n.prototype.addHitArea=function(t,e,o){var n,r,a,i=o.type,p=o.style;if(c[i]){var s=[];try{for(var u=function(t){var e="function"==typeof Symbol&&Symbol.iterator,o=e&&t[e],n=0;if(o)return o.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}(d[i]),f=u.next();!f.done;f=u.next()){var g=f.value;s.push(p[g])}}catch(t){n={error:t}}finally{try{f&&!f.done&&(r=u.return)&&r.call(u)}finally{if(n)throw n.error}}var y=new((a=c[i]).bind.apply(a,l([void 0],s)));e.hitArea=y}else console.error(t.gameObject.name+"'s hitArea type is not defined")},n.systemName="Event",n=function(t,e,o,n){var r,a=arguments.length,i=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,o):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(t,e,o,n);else for(var l=t.length-1;l>=0;l--)(r=t[l])&&(i=(a<3?r(i):a>3?r(e,o,i):r(e,o))||i);return a>3&&i&&Object.defineProperty(e,o,i),i}([o.decorators.componentObserver({Event:[{prop:["hitArea"],deep:!0}]})],n),n}(e.Renderer),u=s;t.HIT_AREA_TYPE=void 0,(p=t.HIT_AREA_TYPE||(t.HIT_AREA_TYPE={})).Circle="Circle",p.Ellipse="Ellipse",p.Polygon="Polygon",p.Rect="Rect",p.RoundedRect="RoundedRect";var f=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.hitArea=void 0,e}return a(e,t),e.prototype.init=function(t){t&&_extends(this,t)},e.prototype.emit=function(e){for(var o=[],n=1;n<arguments.length;n++)o[n-1]=arguments[n];return t.prototype.emit.apply(this,l([e],o))},e.prototype.once=function(e,o,n){return t.prototype.once.call(this,e,o,n)},e.prototype.on=function(e,o,n){return t.prototype.on.call(this,e,o,n)},e.componentName="Event",e}(o.Component),g=f;return t.Event=g,t.EventSystem=u,Object.defineProperty(t,"__esModule",{value:!0}),t}({},EVA.plugin.renderer,EVA,PIXI);window.EVA.plugin.renderer.event=window.EVA.plugin.renderer.event||_EVA_IIFE_event;
|
|
@@ -97,16 +97,9 @@ var Event$2 = (function (_super) {
|
|
|
97
97
|
_this.name = 'Event';
|
|
98
98
|
return _this;
|
|
99
99
|
}
|
|
100
|
-
Event.prototype.init = function (
|
|
101
|
-
var _b = (_a === void 0 ? {} : _a).moveWhenInside, moveWhenInside = _b === void 0 ? false : _b;
|
|
100
|
+
Event.prototype.init = function () {
|
|
102
101
|
this.renderSystem = this.game.getSystem(pluginRenderer.RendererSystem);
|
|
103
102
|
this.renderSystem.rendererManager.register(this);
|
|
104
|
-
try {
|
|
105
|
-
this.renderSystem.application.renderer.plugins.interaction.moveWhenInside = moveWhenInside;
|
|
106
|
-
}
|
|
107
|
-
catch (e) {
|
|
108
|
-
console.error('Setting moveWhenInside error.', e);
|
|
109
|
-
}
|
|
110
103
|
};
|
|
111
104
|
Event.prototype.componentChanged = function (changed) {
|
|
112
105
|
switch (changed.type) {
|
|
@@ -138,6 +131,7 @@ var Event$2 = (function (_super) {
|
|
|
138
131
|
x: e.data.global.x,
|
|
139
132
|
y: e.data.global.y,
|
|
140
133
|
},
|
|
134
|
+
localPosition: container.worldTransform.applyInverse(e.data.global),
|
|
141
135
|
},
|
|
142
136
|
gameObject: component.gameObject,
|
|
143
137
|
});
|
|
@@ -151,6 +145,7 @@ var Event$2 = (function (_super) {
|
|
|
151
145
|
x: e.data.global.x,
|
|
152
146
|
y: e.data.global.y,
|
|
153
147
|
},
|
|
148
|
+
localPosition: container.worldTransform.applyInverse(e.data.global),
|
|
154
149
|
},
|
|
155
150
|
gameObject: component.gameObject,
|
|
156
151
|
});
|
|
@@ -164,6 +159,7 @@ var Event$2 = (function (_super) {
|
|
|
164
159
|
x: e.data.global.x,
|
|
165
160
|
y: e.data.global.y,
|
|
166
161
|
},
|
|
162
|
+
localPosition: container.worldTransform.applyInverse(e.data.global),
|
|
167
163
|
},
|
|
168
164
|
gameObject: component.gameObject,
|
|
169
165
|
});
|
|
@@ -177,6 +173,7 @@ var Event$2 = (function (_super) {
|
|
|
177
173
|
x: e.data.global.x,
|
|
178
174
|
y: e.data.global.y,
|
|
179
175
|
},
|
|
176
|
+
localPosition: container.worldTransform.applyInverse(e.data.global),
|
|
180
177
|
},
|
|
181
178
|
gameObject: component.gameObject,
|
|
182
179
|
});
|
|
@@ -190,6 +187,7 @@ var Event$2 = (function (_super) {
|
|
|
190
187
|
x: e.data.global.x,
|
|
191
188
|
y: e.data.global.y,
|
|
192
189
|
},
|
|
190
|
+
localPosition: container.worldTransform.applyInverse(e.data.global),
|
|
193
191
|
},
|
|
194
192
|
gameObject: component.gameObject,
|
|
195
193
|
});
|
|
@@ -203,6 +201,7 @@ var Event$2 = (function (_super) {
|
|
|
203
201
|
x: e.data.global.x,
|
|
204
202
|
y: e.data.global.y,
|
|
205
203
|
},
|
|
204
|
+
localPosition: container.worldTransform.applyInverse(e.data.global),
|
|
206
205
|
},
|
|
207
206
|
gameObject: component.gameObject,
|
|
208
207
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("@eva/plugin-renderer"),e=require("@eva/eva.js"),o=require("pixi.js"),n=function(t,e){return
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("@eva/plugin-renderer"),e=require("@eva/eva.js"),o=require("pixi.js"),n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var o in e)e.hasOwnProperty(o)&&(t[o]=e[o])},n(t,e)};function r(t,e){function o(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(o.prototype=e.prototype,new o)}function a(t,e){var o="function"==typeof Symbol&&t[Symbol.iterator];if(!o)return t;var n,r,a=o.call(t),i=[];try{for(;(void 0===e||e-- >0)&&!(n=a.next()).done;)i.push(n.value)}catch(t){r={error:t}}finally{try{n&&!n.done&&(o=a.return)&&o.call(a)}finally{if(r)throw r.error}}return i}function i(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(a(arguments[e]));return t}var p,l={Circle:o.Circle,Ellipse:o.Ellipse,Polygon:o.Polygon,Rect:o.Rectangle,RoundedRect:o.RoundedRectangle},c={Circle:["x","y","radius"],Ellipse:["x","y","width","height"],Rect:["x","y","width","height"],RoundedRect:["x","y","width","height","radius"],Polygon:["paths"]},d=function(o){function n(){var t=null!==o&&o.apply(this,arguments)||this;return t.name="Event",t}return r(n,o),n.prototype.init=function(){this.renderSystem=this.game.getSystem(t.RendererSystem),this.renderSystem.rendererManager.register(this)},n.prototype.componentChanged=function(t){switch(t.type){case e.OBSERVER_TYPE.ADD:this.add(t);break;case e.OBSERVER_TYPE.REMOVE:this.remove(t);break;case e.OBSERVER_TYPE.CHANGE:this.change(t)}},n.prototype.add=function(t){var e=this.containerManager.getContainer(t.gameObject.id);e.interactive=!0,e.interactiveChildren=!0;var o=t.component;o.hitArea&&this.addHitArea(t,e,o.hitArea),e.on("pointertap",(function(t){o.emit("tap",{stopPropagation:function(){return t.stopPropagation()},data:{pointerId:t.data.pointerId,position:{x:t.data.global.x,y:t.data.global.y},localPosition:e.worldTransform.applyInverse(t.data.global)},gameObject:o.gameObject})})),e.on("pointerdown",(function(t){o.emit("touchstart",{stopPropagation:function(){return t.stopPropagation()},data:{pointerId:t.data.pointerId,position:{x:t.data.global.x,y:t.data.global.y},localPosition:e.worldTransform.applyInverse(t.data.global)},gameObject:o.gameObject})})),e.on("pointermove",(function(t){o.emit("touchmove",{stopPropagation:function(){return t.stopPropagation()},data:{pointerId:t.data.pointerId,position:{x:t.data.global.x,y:t.data.global.y},localPosition:e.worldTransform.applyInverse(t.data.global)},gameObject:o.gameObject})})),e.on("pointerup",(function(t){o.emit("touchend",{stopPropagation:function(){return t.stopPropagation()},data:{pointerId:t.data.pointerId,position:{x:t.data.global.x,y:t.data.global.y},localPosition:e.worldTransform.applyInverse(t.data.global)},gameObject:o.gameObject})})),e.on("pointerupoutside",(function(t){o.emit("touchendoutside",{stopPropagation:function(){return t.stopPropagation()},data:{pointerId:t.data.pointerId,position:{x:t.data.global.x,y:t.data.global.y},localPosition:e.worldTransform.applyInverse(t.data.global)},gameObject:o.gameObject})})),e.on("pointercancel",(function(t){o.emit("touchcancel",{stopPropagation:function(){return t.stopPropagation()},data:{pointerId:t.data.pointerId,position:{x:t.data.global.x,y:t.data.global.y},localPosition:e.worldTransform.applyInverse(t.data.global)},gameObject:o.gameObject})}))},n.prototype.remove=function(t){var e=this.containerManager.getContainer(t.gameObject.id);e.interactive=!1,e.off("tap"),e.off("pointerdown"),e.off("pointermove"),e.off("pointerup"),e.off("pointerupoutside"),e.off("pointercancel"),t.component.removeAllListeners()},n.prototype.change=function(t){var e=this.containerManager.getContainer(t.gameObject.id);e.interactive=!0;var o=t.component;o.hitArea?this.addHitArea(t,e,o.hitArea):o.hitArea=null},n.prototype.addHitArea=function(t,e,o){var n,r,a,p=o.type,d=o.style;if(l[p]){var s=[];try{for(var u=function(t){var e="function"==typeof Symbol&&t[Symbol.iterator],o=0;return e?e.call(t):{next:function(){return t&&o>=t.length&&(t=void 0),{value:t&&t[o++],done:!t}}}}(c[p]),f=u.next();!f.done;f=u.next()){var y=f.value;s.push(d[y])}}catch(t){n={error:t}}finally{try{f&&!f.done&&(r=u.return)&&r.call(u)}finally{if(n)throw n.error}}var g=new((a=l[p]).bind.apply(a,i([void 0],s)));e.hitArea=g}else console.error(t.gameObject.name+"'s hitArea type is not defined")},n.systemName="Event",n=function(t,e,o,n){var r,a=arguments.length,i=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,o):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(t,e,o,n);else for(var p=t.length-1;p>=0;p--)(r=t[p])&&(i=(a<3?r(i):a>3?r(e,o,i):r(e,o))||i);return a>3&&i&&Object.defineProperty(e,o,i),i}([e.decorators.componentObserver({Event:[{prop:["hitArea"],deep:!0}]})],n),n}(t.Renderer),s=d;exports.HIT_AREA_TYPE=void 0,(p=exports.HIT_AREA_TYPE||(exports.HIT_AREA_TYPE={})).Circle="Circle",p.Ellipse="Ellipse",p.Polygon="Polygon",p.Rect="Rect",p.RoundedRect="RoundedRect";var u=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.hitArea=void 0,e}return r(e,t),e.prototype.init=function(t){t&&Object.assign(this,t)},e.prototype.emit=function(e){for(var o=[],n=1;n<arguments.length;n++)o[n-1]=arguments[n];return t.prototype.emit.apply(this,i([e],o))},e.prototype.once=function(e,o,n){return t.prototype.once.call(this,e,o,n)},e.prototype.on=function(e,o,n){return t.prototype.on.call(this,e,o,n)},e.componentName="Event",e}(e.Component);exports.Event=u,exports.EventSystem=s;
|
|
@@ -27,6 +27,10 @@ declare type EventParam = {
|
|
|
27
27
|
x: number;
|
|
28
28
|
y: number;
|
|
29
29
|
};
|
|
30
|
+
localPosition: {
|
|
31
|
+
x: number;
|
|
32
|
+
y: number;
|
|
33
|
+
};
|
|
30
34
|
};
|
|
31
35
|
gameObject: GameObject;
|
|
32
36
|
};
|
|
@@ -41,7 +45,7 @@ export declare class EventSystem extends Renderer<EventSystemParams> {
|
|
|
41
45
|
renderSystem: RendererSystem;
|
|
42
46
|
rendererManager: RendererManager;
|
|
43
47
|
containerManager: ContainerManager;
|
|
44
|
-
init(
|
|
48
|
+
init(): void;
|
|
45
49
|
componentChanged(changed: ComponentChanged): void;
|
|
46
50
|
add(changed: ComponentChanged): void;
|
|
47
51
|
remove(changed: ComponentChanged): void;
|
|
@@ -93,16 +93,9 @@ var Event$2 = (function (_super) {
|
|
|
93
93
|
_this.name = 'Event';
|
|
94
94
|
return _this;
|
|
95
95
|
}
|
|
96
|
-
Event.prototype.init = function (
|
|
97
|
-
var _b = (_a === void 0 ? {} : _a).moveWhenInside, moveWhenInside = _b === void 0 ? false : _b;
|
|
96
|
+
Event.prototype.init = function () {
|
|
98
97
|
this.renderSystem = this.game.getSystem(RendererSystem);
|
|
99
98
|
this.renderSystem.rendererManager.register(this);
|
|
100
|
-
try {
|
|
101
|
-
this.renderSystem.application.renderer.plugins.interaction.moveWhenInside = moveWhenInside;
|
|
102
|
-
}
|
|
103
|
-
catch (e) {
|
|
104
|
-
console.error('Setting moveWhenInside error.', e);
|
|
105
|
-
}
|
|
106
99
|
};
|
|
107
100
|
Event.prototype.componentChanged = function (changed) {
|
|
108
101
|
switch (changed.type) {
|
|
@@ -134,6 +127,7 @@ var Event$2 = (function (_super) {
|
|
|
134
127
|
x: e.data.global.x,
|
|
135
128
|
y: e.data.global.y,
|
|
136
129
|
},
|
|
130
|
+
localPosition: container.worldTransform.applyInverse(e.data.global),
|
|
137
131
|
},
|
|
138
132
|
gameObject: component.gameObject,
|
|
139
133
|
});
|
|
@@ -147,6 +141,7 @@ var Event$2 = (function (_super) {
|
|
|
147
141
|
x: e.data.global.x,
|
|
148
142
|
y: e.data.global.y,
|
|
149
143
|
},
|
|
144
|
+
localPosition: container.worldTransform.applyInverse(e.data.global),
|
|
150
145
|
},
|
|
151
146
|
gameObject: component.gameObject,
|
|
152
147
|
});
|
|
@@ -160,6 +155,7 @@ var Event$2 = (function (_super) {
|
|
|
160
155
|
x: e.data.global.x,
|
|
161
156
|
y: e.data.global.y,
|
|
162
157
|
},
|
|
158
|
+
localPosition: container.worldTransform.applyInverse(e.data.global),
|
|
163
159
|
},
|
|
164
160
|
gameObject: component.gameObject,
|
|
165
161
|
});
|
|
@@ -173,6 +169,7 @@ var Event$2 = (function (_super) {
|
|
|
173
169
|
x: e.data.global.x,
|
|
174
170
|
y: e.data.global.y,
|
|
175
171
|
},
|
|
172
|
+
localPosition: container.worldTransform.applyInverse(e.data.global),
|
|
176
173
|
},
|
|
177
174
|
gameObject: component.gameObject,
|
|
178
175
|
});
|
|
@@ -186,6 +183,7 @@ var Event$2 = (function (_super) {
|
|
|
186
183
|
x: e.data.global.x,
|
|
187
184
|
y: e.data.global.y,
|
|
188
185
|
},
|
|
186
|
+
localPosition: container.worldTransform.applyInverse(e.data.global),
|
|
189
187
|
},
|
|
190
188
|
gameObject: component.gameObject,
|
|
191
189
|
});
|
|
@@ -199,6 +197,7 @@ var Event$2 = (function (_super) {
|
|
|
199
197
|
x: e.data.global.x,
|
|
200
198
|
y: e.data.global.y,
|
|
201
199
|
},
|
|
200
|
+
localPosition: container.worldTransform.applyInverse(e.data.global),
|
|
202
201
|
},
|
|
203
202
|
gameObject: component.gameObject,
|
|
204
203
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eva/plugin-renderer-event",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-beta.1",
|
|
4
4
|
"description": "@eva/plugin-renderer-event",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "dist/plugin-renderer-event.esm.js",
|
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
"license": "MIT",
|
|
19
19
|
"homepage": "https://eva.js.org",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@eva/plugin-renderer": "
|
|
22
|
-
"@eva/eva.js": "
|
|
23
|
-
"pixi.js": "^
|
|
21
|
+
"@eva/plugin-renderer": "2.0.0-beta.1",
|
|
22
|
+
"@eva/eva.js": "2.0.0-beta.1",
|
|
23
|
+
"pixi.js": "^8.6.3"
|
|
24
24
|
}
|
|
25
25
|
}
|