@awayjs/scene 0.13.266 → 0.13.268
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/bundle/awayjs-scene.umd.js +1 -1
- package/bundle/awayjs-scene.umd.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/lib/events/TouchEvent.d.ts +4 -0
- package/dist/lib/events/TouchEvent.d.ts.map +1 -1
- package/dist/lib/events/TouchEvent.js +7 -1
- package/dist/lib/managers/MouseManager.d.ts.map +1 -1
- package/dist/lib/managers/MouseManager.js +45 -43
- package/index.ts +1 -1
- package/lib/events/TouchEvent.ts +6 -0
- package/lib/managers/MouseManager.ts +48 -45
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
console.debug('AwayJS - Scene - 0.13.
|
|
1
|
+
console.debug('AwayJS - Scene - 0.13.268');
|
|
2
2
|
export { Timeline } from './lib/base/Timeline';
|
|
3
3
|
export { ControllerBase } from './lib/controllers/ControllerBase';
|
|
4
4
|
export { FirstPersonController } from './lib/controllers/FirstPersonController';
|
|
@@ -37,6 +37,10 @@ export declare class TouchEvent extends PointerEvent {
|
|
|
37
37
|
* Defines the value of the type property of a click3d event object.
|
|
38
38
|
*/
|
|
39
39
|
static TOUCH_TAP: string;
|
|
40
|
+
/**
|
|
41
|
+
* Unique identifier of associated touchPoint
|
|
42
|
+
*/
|
|
43
|
+
touchPointID: number;
|
|
40
44
|
/**
|
|
41
45
|
* Create a new touchEvent object.
|
|
42
46
|
* @param type The type of the touchEvent.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TouchEvent.d.ts","sourceRoot":"","sources":["../../../lib/events/TouchEvent.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAA6B,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAI7F,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C;;;GAGG;AACH,qBAAa,U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AIxB;;OAEG;IACI,KAAK,IAAI,UAAU;IA+BnB,cAAc,CAAC,UAAU,EAAE,aAAa,EAAE,MAAM,EAAE,mBAAmB;CAM5E"}
|
|
@@ -12,7 +12,12 @@ var TouchEvent = /** @class */ (function (_super) {
|
|
|
12
12
|
* @param type The type of the touchEvent.
|
|
13
13
|
*/
|
|
14
14
|
function TouchEvent(type) {
|
|
15
|
-
|
|
15
|
+
var _this = _super.call(this, type) || this;
|
|
16
|
+
/**
|
|
17
|
+
* Unique identifier of associated touchPoint
|
|
18
|
+
*/
|
|
19
|
+
_this.touchPointID = 0;
|
|
20
|
+
return _this;
|
|
16
21
|
}
|
|
17
22
|
/**
|
|
18
23
|
* Creates a copy of the touchEvent object and sets the value of each property to match that of the original.
|
|
@@ -34,6 +39,7 @@ var TouchEvent = /** @class */ (function (_super) {
|
|
|
34
39
|
result.position = this.position;
|
|
35
40
|
result.normal = this.normal;
|
|
36
41
|
result.elementIndex = this.elementIndex;
|
|
42
|
+
result.touchPointID = this.touchPointID;
|
|
37
43
|
result.ctrlKey = this.ctrlKey;
|
|
38
44
|
result.shiftKey = this.shiftKey;
|
|
39
45
|
result._iParentEvent = this;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MouseManager.d.ts","sourceRoot":"","sources":["../../../lib/managers/MouseManager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEtC,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAM9E,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAEtD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAGlD;;;GAGG;AACH,qBAAa,YAAY;IACxB,OAAO,CAAC,MAAM,CAAC,SAAS,CAAe;IACvC,OAAc,aAAa,EAAE,cAAc,CAAC;IAE5C,OAAO,CAAC,MAAM,CAAQ;IACtB,OAAO,CAAC,MAAM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E,4BAA4B,CAAC,YAAY,EAAE,MAAM,EAAE,SAAS,GAAE,MAAU,GAAG,IAAI;IA4DtF,OAAO,CAAC,UAAU;IA2ClB,OAAO,CAAC,aAAa;IAmBd,SAAS,CAAC,KAAK,KAAA,GAAG,IAAI;IAgCtB,OAAO,CAAC,KAAK,KAAA,GAAG,IAAI;IAiCpB,WAAW,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU,GAAG,IAAI;IAKjD,UAAU,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI;IAKnC,WAAW,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI;IAKpC,aAAa,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI;IAUtC,WAAW,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU,GAAG,IAAI;IAkBjD,SAAS,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU,GAAG,IAAI;IAkB/C,YAAY,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI;IAK5C,OAAO,CAAC,eAAe;CAyBvB"}
|
|
@@ -191,18 +191,19 @@ var MouseManager = /** @class */ (function () {
|
|
|
191
191
|
}
|
|
192
192
|
}
|
|
193
193
|
};
|
|
194
|
-
MouseManager.prototype.setupAndDispatchEvent = function (event,
|
|
194
|
+
MouseManager.prototype.setupAndDispatchEvent = function (event, pointerData, collision, commonAncestor) {
|
|
195
195
|
if (commonAncestor === void 0) { commonAncestor = null; }
|
|
196
|
+
var sourceEvent = pointerData.sourceEvent;
|
|
196
197
|
if (sourceEvent) {
|
|
197
198
|
if (event instanceof AwayMouseEvent) {
|
|
198
|
-
event.delta = sourceEvent.
|
|
199
|
+
event.delta = sourceEvent.deltaY;
|
|
199
200
|
event.buttons = sourceEvent.buttons;
|
|
200
201
|
}
|
|
201
202
|
event.ctrlKey = sourceEvent.ctrlKey;
|
|
202
203
|
event.altKey = sourceEvent.altKey;
|
|
203
204
|
event.shiftKey = sourceEvent.shiftKey;
|
|
204
205
|
}
|
|
205
|
-
event = this.setUpEvent(event, collision, commonAncestor);
|
|
206
|
+
event = this.setUpEvent(event, pointerData, collision, commonAncestor);
|
|
206
207
|
this.dispatchEvent(event, event.rootNode);
|
|
207
208
|
};
|
|
208
209
|
MouseManager.prototype.fireMouseEvents = function (forcePicker) {
|
|
@@ -232,7 +233,7 @@ var MouseManager = /** @class */ (function () {
|
|
|
232
233
|
for (var i = 0; i < len; ++i) {
|
|
233
234
|
event = pointerData.queuedEvents[i];
|
|
234
235
|
dispatcher = collision === null || collision === void 0 ? void 0 : collision.rootNode;
|
|
235
|
-
this.setUpEvent(event, collision);
|
|
236
|
+
this.setUpEvent(event, pointerData, collision);
|
|
236
237
|
if (event.type == pointerData.down.type) {
|
|
237
238
|
this._mouseDragging = true;
|
|
238
239
|
// no event-bubbling. dispatch on stage first
|
|
@@ -242,8 +243,9 @@ var MouseManager = /** @class */ (function () {
|
|
|
242
243
|
// so we need to recheck the collision ?
|
|
243
244
|
// on Touch dispatch mouseOver Command
|
|
244
245
|
if (!pointerData.isMouse)
|
|
245
|
-
this.setupAndDispatchEvent(pointerData.over, pointerData
|
|
246
|
-
|
|
246
|
+
this.setupAndDispatchEvent(pointerData.over, pointerData, collision);
|
|
247
|
+
if (pointerData.id == 0)
|
|
248
|
+
this._mouseDragCollision = collision;
|
|
247
249
|
if (dispatcher) {
|
|
248
250
|
//console.log("onPress", dispatcher)
|
|
249
251
|
this.dispatchEvent(event, dispatcher);
|
|
@@ -252,7 +254,7 @@ var MouseManager = /** @class */ (function () {
|
|
|
252
254
|
this._stage.dispatchEvent(event);
|
|
253
255
|
if (this._mouseDragCollision) {
|
|
254
256
|
this.setFocus((_a = this._mouseDragCollision) === null || _a === void 0 ? void 0 : _a.rootNode);
|
|
255
|
-
this.setupAndDispatchEvent(this._dragStart,
|
|
257
|
+
this.setupAndDispatchEvent(this._dragStart, pointerData, this._mouseDragCollision);
|
|
256
258
|
}
|
|
257
259
|
}
|
|
258
260
|
else if (event.type == pointerData.up.type) {
|
|
@@ -293,32 +295,33 @@ var MouseManager = /** @class */ (function () {
|
|
|
293
295
|
this._stage.dispatchEvent(event);
|
|
294
296
|
if (upContainerNode) {
|
|
295
297
|
if (!this._isAVM1Dragging)
|
|
296
|
-
this.setupAndDispatchEvent(pointerData.click, pointerData
|
|
297
|
-
this.setupAndDispatchEvent(this._dragStop,
|
|
298
|
+
this.setupAndDispatchEvent(pointerData.click, pointerData, this._mouseDragCollision);
|
|
299
|
+
this.setupAndDispatchEvent(this._dragStop, pointerData, this._mouseDragCollision);
|
|
298
300
|
}
|
|
299
301
|
else if (this._mouseDragging && this._mouseDragCollision) {
|
|
300
|
-
this.setupAndDispatchEvent(pointerData.upOutside,
|
|
302
|
+
this.setupAndDispatchEvent(pointerData.upOutside, pointerData, this._mouseDragCollision);
|
|
301
303
|
}
|
|
302
304
|
this._mouseDragCollision = null;
|
|
303
305
|
this._mouseDragging = false;
|
|
304
306
|
this._isAVM1Dragging = false;
|
|
307
|
+
//make sure to clear old touch references when no longer needed
|
|
308
|
+
if (pointerData.id != 0)
|
|
309
|
+
delete this._pointerDataArray[pointerData.id];
|
|
305
310
|
}
|
|
306
311
|
else if (event.type == pointerData.move.type) {
|
|
307
312
|
// no event-bubbling. dispatch on stage first
|
|
308
|
-
if (!this._eventBubbling)
|
|
313
|
+
if (!this._eventBubbling)
|
|
309
314
|
this._stage.dispatchEvent(event);
|
|
310
|
-
}
|
|
311
315
|
// fire to picker
|
|
312
|
-
if (
|
|
313
|
-
this.dispatchEvent(event,
|
|
314
|
-
}
|
|
315
|
-
if (this._mouseDragCollision) {
|
|
316
|
-
this.setupAndDispatchEvent(this._dragMove, event, this._mouseDragCollision);
|
|
316
|
+
if (dispatcher) {
|
|
317
|
+
this.dispatchEvent(event, dispatcher);
|
|
317
318
|
}
|
|
318
|
-
|
|
319
|
-
if (this._eventBubbling) {
|
|
319
|
+
else if (this._eventBubbling) {
|
|
320
320
|
this._stage.dispatchEvent(event);
|
|
321
321
|
}
|
|
322
|
+
if (this._mouseDragCollision) {
|
|
323
|
+
this.setupAndDispatchEvent(this._dragMove, pointerData, this._mouseDragCollision);
|
|
324
|
+
}
|
|
322
325
|
}
|
|
323
326
|
else {
|
|
324
327
|
// MouseEvent.MOUSE_OVER / MouseEvent.MOUSE_OUT / MouseEvent.DRAG_OVER / MouseEvent.DRAG_OUT
|
|
@@ -337,20 +340,20 @@ var MouseManager = /** @class */ (function () {
|
|
|
337
340
|
// (_mouseDragEntity)
|
|
338
341
|
// Store the info if the collision is a enabled Button (_collisionIsEnabledButton)
|
|
339
342
|
if (prevCollisionNode) {
|
|
340
|
-
this.setupAndDispatchEvent(pointerData.out, pointerData
|
|
343
|
+
this.setupAndDispatchEvent(pointerData.out, pointerData, pointerData.prevCollision);
|
|
341
344
|
if (this._mouseDragging && this._mouseDragCollision
|
|
342
345
|
&& this._mouseDragCollision.rootNode == prevCollisionNode)
|
|
343
|
-
this.setupAndDispatchEvent(this._dragOut, pointerData
|
|
346
|
+
this.setupAndDispatchEvent(this._dragOut, pointerData, pointerData.prevCollision);
|
|
344
347
|
}
|
|
345
348
|
if (!prevCollisionNode && collisionNode) {
|
|
346
349
|
// rollout / rollover easy case, can just bubble up
|
|
347
|
-
this.setupAndDispatchEvent(pointerData.rollOut, pointerData
|
|
348
|
-
this.setupAndDispatchEvent(pointerData.rollOver, pointerData
|
|
350
|
+
this.setupAndDispatchEvent(pointerData.rollOut, pointerData, pointerData.prevCollision);
|
|
351
|
+
this.setupAndDispatchEvent(pointerData.rollOver, pointerData, collision);
|
|
349
352
|
}
|
|
350
353
|
if (prevCollisionNode && !collisionNode) {
|
|
351
354
|
// rollout / rollover easy case, can just bubble up
|
|
352
|
-
this.setupAndDispatchEvent(pointerData.rollOut, pointerData
|
|
353
|
-
this.setupAndDispatchEvent(pointerData.rollOver, pointerData
|
|
355
|
+
this.setupAndDispatchEvent(pointerData.rollOut, pointerData, pointerData.prevCollision);
|
|
356
|
+
this.setupAndDispatchEvent(pointerData.rollOver, pointerData, collision);
|
|
354
357
|
}
|
|
355
358
|
if (prevCollisionNode && collisionNode) {
|
|
356
359
|
// rollout / rollover find common ancester and only bubble up to that point
|
|
@@ -373,15 +376,15 @@ var MouseManager = /** @class */ (function () {
|
|
|
373
376
|
}
|
|
374
377
|
}
|
|
375
378
|
if (commonAncestor != prevCollisionNode)
|
|
376
|
-
this.setupAndDispatchEvent(pointerData.rollOut, pointerData
|
|
379
|
+
this.setupAndDispatchEvent(pointerData.rollOut, pointerData, pointerData.prevCollision, commonAncestor);
|
|
377
380
|
if (commonAncestor != collisionNode)
|
|
378
|
-
this.setupAndDispatchEvent(pointerData.rollOver, pointerData
|
|
381
|
+
this.setupAndDispatchEvent(pointerData.rollOver, pointerData, collision, commonAncestor);
|
|
379
382
|
}
|
|
380
383
|
pointerData.collisionIsEnabledButton = collisionNode ? collisionNode.buttonEnabled : false;
|
|
381
384
|
if (collisionNode) {
|
|
382
|
-
this.setupAndDispatchEvent(pointerData.over, pointerData
|
|
385
|
+
this.setupAndDispatchEvent(pointerData.over, pointerData, collision);
|
|
383
386
|
if (this._mouseDragging)
|
|
384
|
-
this.setupAndDispatchEvent(this._dragOver, pointerData
|
|
387
|
+
this.setupAndDispatchEvent(this._dragOver, pointerData, collision);
|
|
385
388
|
}
|
|
386
389
|
pointerData.prevCollision = collision;
|
|
387
390
|
}
|
|
@@ -392,9 +395,9 @@ var MouseManager = /** @class */ (function () {
|
|
|
392
395
|
var isActiveButton = collisionNode ? collisionNode.buttonEnabled : false;
|
|
393
396
|
if (pointerData.collisionIsEnabledButton != isActiveButton && isActiveButton) {
|
|
394
397
|
if (pointerData.isMouse)
|
|
395
|
-
this.setupAndDispatchEvent(pointerData.over, pointerData
|
|
398
|
+
this.setupAndDispatchEvent(pointerData.over, pointerData, collision);
|
|
396
399
|
else if (this._mouseDragCollision && this._mouseDragCollision.rootNode == collisionNode)
|
|
397
|
-
this.setupAndDispatchEvent(this._dragOver, pointerData
|
|
400
|
+
this.setupAndDispatchEvent(this._dragOver, pointerData, collision);
|
|
398
401
|
}
|
|
399
402
|
pointerData.collisionIsEnabledButton = isActiveButton;
|
|
400
403
|
}
|
|
@@ -561,14 +564,16 @@ var MouseManager = /** @class */ (function () {
|
|
|
561
564
|
// ---------------------------------------------------------------------
|
|
562
565
|
// Private.
|
|
563
566
|
// ---------------------------------------------------------------------
|
|
564
|
-
MouseManager.prototype.setUpEvent = function (event, collision, commonAncestor) {
|
|
567
|
+
MouseManager.prototype.setUpEvent = function (event, pointerData, collision, commonAncestor) {
|
|
565
568
|
var _a, _b;
|
|
566
569
|
if (commonAncestor === void 0) { commonAncestor = null; }
|
|
567
570
|
event._iAllowedToImmediatlyPropagate = true;
|
|
568
571
|
event._iAllowedToPropagate = true;
|
|
569
572
|
// 2D properties.
|
|
570
|
-
event.screenX =
|
|
571
|
-
event.screenY =
|
|
573
|
+
event.screenX = pointerData.screenX;
|
|
574
|
+
event.screenY = pointerData.screenY;
|
|
575
|
+
if (event instanceof AwayTouchEvent)
|
|
576
|
+
event.touchPointID = pointerData.id;
|
|
572
577
|
//console.log("event", event, collisionNode, collisionNode);
|
|
573
578
|
// 3D properties.
|
|
574
579
|
if (collision) {
|
|
@@ -725,21 +730,18 @@ var MouseManager = /** @class */ (function () {
|
|
|
725
730
|
this._stage.interactionHandler(event);
|
|
726
731
|
this._updateDirty = true;
|
|
727
732
|
var mouseData = this._pointerDataArray[0] || (this._pointerDataArray[0] = new PointerData(0, true));
|
|
728
|
-
|
|
733
|
+
mouseData.isMouse = (event instanceof MouseEvent);
|
|
734
|
+
var type = (mouseData.isMouse) ? event.type : MouseManager._touchToMouseDict[event.type];
|
|
729
735
|
this.queueDispatch(mouseData, MouseManager._pointerDict[type], event);
|
|
730
736
|
mouseData.screenX = this._stage.screenX;
|
|
731
737
|
mouseData.screenY = this._stage.screenY;
|
|
732
|
-
var touchPoints = this._stage.touchPoints;
|
|
733
|
-
for (var _i = 0, touchPoints_1 = touchPoints; _i < touchPoints_1.length; _i++) {
|
|
734
|
-
var touchPoint = touchPoints_1[_i];
|
|
735
|
-
var touchData = this._pointerDataArray[touchPoint.id] || (this._pointerDataArray[touchPoint.id] = new PointerData(touchPoint.id));
|
|
736
|
-
touchData.screenX = touchPoint.x;
|
|
737
|
-
touchData.screenY = touchPoint.y;
|
|
738
|
-
}
|
|
739
738
|
if (event.changedTouches) {
|
|
740
739
|
for (var i = 0; i < event.changedTouches.length; i++) {
|
|
741
740
|
var touch = event.changedTouches[i];
|
|
742
|
-
var touchData = this._pointerDataArray[touch.identifier];
|
|
741
|
+
var touchData = this._pointerDataArray[touch.identifier] || (this._pointerDataArray[touch.identifier] = new PointerData(touch.identifier));
|
|
742
|
+
var point = this._stage.mapWindowToStage(touch.clientX, touch.clientY);
|
|
743
|
+
touchData.screenX = point.x;
|
|
744
|
+
touchData.screenY = point.y;
|
|
743
745
|
this.queueDispatch(touchData, MouseManager._pointerDict[event.type], event);
|
|
744
746
|
}
|
|
745
747
|
}
|
package/index.ts
CHANGED
package/lib/events/TouchEvent.ts
CHANGED
|
@@ -51,6 +51,11 @@ export class TouchEvent extends PointerEvent {
|
|
|
51
51
|
*/
|
|
52
52
|
public static TOUCH_TAP: string = 'tap3d';
|
|
53
53
|
|
|
54
|
+
/**
|
|
55
|
+
* Unique identifier of associated touchPoint
|
|
56
|
+
*/
|
|
57
|
+
public touchPointID: number = 0;
|
|
58
|
+
|
|
54
59
|
/**
|
|
55
60
|
* Create a new touchEvent object.
|
|
56
61
|
* @param type The type of the touchEvent.
|
|
@@ -82,6 +87,7 @@ export class TouchEvent extends PointerEvent {
|
|
|
82
87
|
result.position = this.position;
|
|
83
88
|
result.normal = this.normal;
|
|
84
89
|
result.elementIndex = this.elementIndex;
|
|
90
|
+
result.touchPointID = this.touchPointID;
|
|
85
91
|
|
|
86
92
|
result.ctrlKey = this.ctrlKey;
|
|
87
93
|
result.shiftKey = this.shiftKey;
|
|
@@ -268,20 +268,21 @@ export class MouseManager {
|
|
|
268
268
|
}
|
|
269
269
|
}
|
|
270
270
|
|
|
271
|
-
private setupAndDispatchEvent(event: PointerEvent,
|
|
271
|
+
private setupAndDispatchEvent(event: PointerEvent, pointerData: PointerData,
|
|
272
272
|
collision: PickingCollision, commonAncestor: ContainerNode = null) {
|
|
273
273
|
|
|
274
|
+
const sourceEvent = pointerData.sourceEvent;
|
|
274
275
|
if (sourceEvent) {
|
|
275
276
|
if (event instanceof AwayMouseEvent) {
|
|
276
|
-
event.delta = sourceEvent.
|
|
277
|
-
event.buttons = sourceEvent.buttons;
|
|
277
|
+
event.delta = (<WheelEvent> sourceEvent).deltaY;
|
|
278
|
+
event.buttons = (<MouseEvent> sourceEvent).buttons;
|
|
278
279
|
}
|
|
279
280
|
event.ctrlKey = sourceEvent.ctrlKey;
|
|
280
281
|
event.altKey = sourceEvent.altKey;
|
|
281
282
|
event.shiftKey = sourceEvent.shiftKey;
|
|
282
283
|
}
|
|
283
284
|
|
|
284
|
-
event = this.setUpEvent(event, collision, commonAncestor);
|
|
285
|
+
event = this.setUpEvent(event, pointerData, collision, commonAncestor);
|
|
285
286
|
this.dispatchEvent(event, event.rootNode);
|
|
286
287
|
}
|
|
287
288
|
|
|
@@ -314,7 +315,7 @@ export class MouseManager {
|
|
|
314
315
|
event = pointerData.queuedEvents[i];
|
|
315
316
|
dispatcher = collision?.rootNode;
|
|
316
317
|
|
|
317
|
-
this.setUpEvent(event, collision);
|
|
318
|
+
this.setUpEvent(event, pointerData, collision);
|
|
318
319
|
|
|
319
320
|
if (event.type == pointerData.down.type) {
|
|
320
321
|
this._mouseDragging = true;
|
|
@@ -328,9 +329,10 @@ export class MouseManager {
|
|
|
328
329
|
|
|
329
330
|
// on Touch dispatch mouseOver Command
|
|
330
331
|
if (!pointerData.isMouse)
|
|
331
|
-
this.setupAndDispatchEvent(pointerData.over, pointerData
|
|
332
|
+
this.setupAndDispatchEvent(pointerData.over, pointerData, collision);
|
|
332
333
|
|
|
333
|
-
|
|
334
|
+
if (pointerData.id == 0)
|
|
335
|
+
this._mouseDragCollision = collision;
|
|
334
336
|
|
|
335
337
|
if (dispatcher) {
|
|
336
338
|
//console.log("onPress", dispatcher)
|
|
@@ -340,7 +342,7 @@ export class MouseManager {
|
|
|
340
342
|
|
|
341
343
|
if (this._mouseDragCollision) {
|
|
342
344
|
this.setFocus(this._mouseDragCollision?.rootNode);
|
|
343
|
-
this.setupAndDispatchEvent(this._dragStart,
|
|
345
|
+
this.setupAndDispatchEvent(this._dragStart, pointerData, this._mouseDragCollision);
|
|
344
346
|
}
|
|
345
347
|
|
|
346
348
|
} else if (event.type == pointerData.up.type) {
|
|
@@ -383,35 +385,35 @@ export class MouseManager {
|
|
|
383
385
|
|
|
384
386
|
if (upContainerNode) {
|
|
385
387
|
if (!this._isAVM1Dragging)
|
|
386
|
-
this.setupAndDispatchEvent(pointerData.click, pointerData
|
|
387
|
-
this.setupAndDispatchEvent(this._dragStop,
|
|
388
|
+
this.setupAndDispatchEvent(pointerData.click, pointerData, this._mouseDragCollision);
|
|
389
|
+
this.setupAndDispatchEvent(this._dragStop, pointerData, this._mouseDragCollision);
|
|
388
390
|
} else if (this._mouseDragging && this._mouseDragCollision) {
|
|
389
|
-
this.setupAndDispatchEvent(pointerData.upOutside,
|
|
391
|
+
this.setupAndDispatchEvent(pointerData.upOutside, pointerData, this._mouseDragCollision);
|
|
390
392
|
}
|
|
391
393
|
|
|
392
394
|
this._mouseDragCollision = null;
|
|
393
395
|
this._mouseDragging = false;
|
|
394
396
|
this._isAVM1Dragging = false;
|
|
395
397
|
|
|
398
|
+
//make sure to clear old touch references when no longer needed
|
|
399
|
+
if (pointerData.id != 0)
|
|
400
|
+
delete this._pointerDataArray[pointerData.id];
|
|
401
|
+
|
|
396
402
|
} else if (event.type == pointerData.move.type) {
|
|
397
403
|
|
|
398
404
|
// no event-bubbling. dispatch on stage first
|
|
399
|
-
if (!this._eventBubbling)
|
|
405
|
+
if (!this._eventBubbling)
|
|
400
406
|
this._stage.dispatchEvent(event);
|
|
401
|
-
}
|
|
402
407
|
|
|
403
408
|
// fire to picker
|
|
404
|
-
if (
|
|
405
|
-
this.dispatchEvent(event,
|
|
409
|
+
if (dispatcher) {
|
|
410
|
+
this.dispatchEvent(event, dispatcher);
|
|
411
|
+
} else if (this._eventBubbling) {
|
|
412
|
+
this._stage.dispatchEvent(event);
|
|
406
413
|
}
|
|
407
414
|
|
|
408
415
|
if (this._mouseDragCollision) {
|
|
409
|
-
this.setupAndDispatchEvent(this._dragMove,
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
// if bubling is exist, fire to stage late
|
|
413
|
-
if (this._eventBubbling) {
|
|
414
|
-
this._stage.dispatchEvent(event);
|
|
416
|
+
this.setupAndDispatchEvent(this._dragMove, pointerData, this._mouseDragCollision);
|
|
415
417
|
}
|
|
416
418
|
|
|
417
419
|
} else {
|
|
@@ -438,22 +440,22 @@ export class MouseManager {
|
|
|
438
440
|
// Store the info if the collision is a enabled Button (_collisionIsEnabledButton)
|
|
439
441
|
|
|
440
442
|
if (prevCollisionNode) {
|
|
441
|
-
this.setupAndDispatchEvent(pointerData.out, pointerData
|
|
443
|
+
this.setupAndDispatchEvent(pointerData.out, pointerData, pointerData.prevCollision);
|
|
442
444
|
|
|
443
445
|
if (this._mouseDragging && this._mouseDragCollision
|
|
444
446
|
&& this._mouseDragCollision.rootNode == prevCollisionNode)
|
|
445
|
-
this.setupAndDispatchEvent(this._dragOut, pointerData
|
|
447
|
+
this.setupAndDispatchEvent(this._dragOut, pointerData, pointerData.prevCollision);
|
|
446
448
|
}
|
|
447
449
|
|
|
448
450
|
if (!prevCollisionNode && collisionNode) {
|
|
449
451
|
// rollout / rollover easy case, can just bubble up
|
|
450
|
-
this.setupAndDispatchEvent(pointerData.rollOut, pointerData
|
|
451
|
-
this.setupAndDispatchEvent(pointerData.rollOver, pointerData
|
|
452
|
+
this.setupAndDispatchEvent(pointerData.rollOut, pointerData, pointerData.prevCollision);
|
|
453
|
+
this.setupAndDispatchEvent(pointerData.rollOver, pointerData, collision);
|
|
452
454
|
}
|
|
453
455
|
if (prevCollisionNode && !collisionNode) {
|
|
454
456
|
// rollout / rollover easy case, can just bubble up
|
|
455
|
-
this.setupAndDispatchEvent(pointerData.rollOut, pointerData
|
|
456
|
-
this.setupAndDispatchEvent(pointerData.rollOver, pointerData
|
|
457
|
+
this.setupAndDispatchEvent(pointerData.rollOut, pointerData, pointerData.prevCollision);
|
|
458
|
+
this.setupAndDispatchEvent(pointerData.rollOver, pointerData, collision);
|
|
457
459
|
}
|
|
458
460
|
if (prevCollisionNode && collisionNode) {
|
|
459
461
|
// rollout / rollover find common ancester and only bubble up to that point
|
|
@@ -475,21 +477,21 @@ export class MouseManager {
|
|
|
475
477
|
}
|
|
476
478
|
}
|
|
477
479
|
if (commonAncestor != prevCollisionNode)
|
|
478
|
-
this.setupAndDispatchEvent(pointerData.rollOut, pointerData
|
|
480
|
+
this.setupAndDispatchEvent(pointerData.rollOut, pointerData,
|
|
479
481
|
pointerData.prevCollision, commonAncestor);
|
|
480
482
|
|
|
481
483
|
if (commonAncestor != collisionNode)
|
|
482
|
-
this.setupAndDispatchEvent(pointerData.rollOver, pointerData
|
|
484
|
+
this.setupAndDispatchEvent(pointerData.rollOver, pointerData, collision, commonAncestor);
|
|
483
485
|
|
|
484
486
|
}
|
|
485
487
|
|
|
486
488
|
pointerData.collisionIsEnabledButton = collisionNode ? (<any> collisionNode).buttonEnabled : false;
|
|
487
489
|
|
|
488
490
|
if (collisionNode) {
|
|
489
|
-
this.setupAndDispatchEvent(pointerData.over, pointerData
|
|
491
|
+
this.setupAndDispatchEvent(pointerData.over, pointerData, collision);
|
|
490
492
|
|
|
491
493
|
if (this._mouseDragging)
|
|
492
|
-
this.setupAndDispatchEvent(this._dragOver, pointerData
|
|
494
|
+
this.setupAndDispatchEvent(this._dragOver, pointerData, collision);
|
|
493
495
|
}
|
|
494
496
|
|
|
495
497
|
pointerData.prevCollision = collision;
|
|
@@ -501,9 +503,9 @@ export class MouseManager {
|
|
|
501
503
|
|
|
502
504
|
if (pointerData.collisionIsEnabledButton != isActiveButton && isActiveButton) {
|
|
503
505
|
if (pointerData.isMouse)
|
|
504
|
-
this.setupAndDispatchEvent(pointerData.over, pointerData
|
|
506
|
+
this.setupAndDispatchEvent(pointerData.over, pointerData, collision);
|
|
505
507
|
else if (this._mouseDragCollision && this._mouseDragCollision.rootNode == collisionNode)
|
|
506
|
-
this.setupAndDispatchEvent(this._dragOver, pointerData
|
|
508
|
+
this.setupAndDispatchEvent(this._dragOver, pointerData, collision);
|
|
507
509
|
}
|
|
508
510
|
|
|
509
511
|
pointerData.collisionIsEnabledButton = isActiveButton;
|
|
@@ -674,13 +676,17 @@ export class MouseManager {
|
|
|
674
676
|
// ---------------------------------------------------------------------
|
|
675
677
|
// Private.
|
|
676
678
|
// ---------------------------------------------------------------------
|
|
677
|
-
private setUpEvent(event: PointerEvent,
|
|
679
|
+
private setUpEvent(event: PointerEvent, pointerData: PointerData,
|
|
678
680
|
collision: PickingCollision, commonAncestor: ContainerNode = null): PointerEvent {
|
|
679
681
|
event._iAllowedToImmediatlyPropagate = true;
|
|
680
682
|
event._iAllowedToPropagate = true;
|
|
681
683
|
// 2D properties.
|
|
682
|
-
event.screenX =
|
|
683
|
-
event.screenY =
|
|
684
|
+
event.screenX = pointerData.screenX;
|
|
685
|
+
event.screenY = pointerData.screenY;
|
|
686
|
+
|
|
687
|
+
if (event instanceof AwayTouchEvent)
|
|
688
|
+
event.touchPointID = pointerData.id;
|
|
689
|
+
|
|
684
690
|
//console.log("event", event, collisionNode, collisionNode);
|
|
685
691
|
|
|
686
692
|
// 3D properties.
|
|
@@ -870,23 +876,20 @@ export class MouseManager {
|
|
|
870
876
|
|
|
871
877
|
const mouseData = this._pointerDataArray[0] || (this._pointerDataArray[0] = new PointerData(0, true));
|
|
872
878
|
|
|
873
|
-
|
|
879
|
+
mouseData.isMouse = (event instanceof MouseEvent);
|
|
880
|
+
const type = (mouseData.isMouse) ? event.type : MouseManager._touchToMouseDict[event.type];
|
|
874
881
|
this.queueDispatch(mouseData, MouseManager._pointerDict[type], event);
|
|
875
882
|
|
|
876
883
|
mouseData.screenX = this._stage.screenX;
|
|
877
884
|
mouseData.screenY = this._stage.screenY;
|
|
878
885
|
|
|
879
|
-
const touchPoints = this._stage.touchPoints;
|
|
880
|
-
for (const touchPoint of touchPoints) {
|
|
881
|
-
const touchData = this._pointerDataArray[touchPoint.id] || (this._pointerDataArray[touchPoint.id] = new PointerData(touchPoint.id));
|
|
882
|
-
touchData.screenX = touchPoint.x;
|
|
883
|
-
touchData.screenY = touchPoint.y;
|
|
884
|
-
}
|
|
885
|
-
|
|
886
886
|
if ((<TouchEvent> event).changedTouches) {
|
|
887
887
|
for (let i: number = 0; i < (<TouchEvent> event).changedTouches.length; i++) {
|
|
888
888
|
const touch = (<TouchEvent> event).changedTouches[i];
|
|
889
|
-
const touchData = this._pointerDataArray[touch.identifier];
|
|
889
|
+
const touchData = this._pointerDataArray[touch.identifier] || (this._pointerDataArray[touch.identifier] = new PointerData(touch.identifier));
|
|
890
|
+
const point = this._stage.mapWindowToStage(touch.clientX, touch.clientY);
|
|
891
|
+
touchData.screenX = point.x;
|
|
892
|
+
touchData.screenY = point.y;
|
|
890
893
|
this.queueDispatch(touchData, MouseManager._pointerDict[event.type], event);
|
|
891
894
|
}
|
|
892
895
|
}
|