@awayjs/scene 0.13.266 → 0.13.267
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 +46 -43
- package/index.ts +1 -1
- package/lib/events/TouchEvent.ts +6 -0
- package/lib/managers/MouseManager.ts +49 -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.267');
|
|
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,10 @@ 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
|
+
//only allow dragging for mouse (or pseudo-mouse) interactions
|
|
248
|
+
if (pointerData.id != 0)
|
|
249
|
+
this._mouseDragCollision = collision;
|
|
247
250
|
if (dispatcher) {
|
|
248
251
|
//console.log("onPress", dispatcher)
|
|
249
252
|
this.dispatchEvent(event, dispatcher);
|
|
@@ -252,7 +255,7 @@ var MouseManager = /** @class */ (function () {
|
|
|
252
255
|
this._stage.dispatchEvent(event);
|
|
253
256
|
if (this._mouseDragCollision) {
|
|
254
257
|
this.setFocus((_a = this._mouseDragCollision) === null || _a === void 0 ? void 0 : _a.rootNode);
|
|
255
|
-
this.setupAndDispatchEvent(this._dragStart,
|
|
258
|
+
this.setupAndDispatchEvent(this._dragStart, pointerData, this._mouseDragCollision);
|
|
256
259
|
}
|
|
257
260
|
}
|
|
258
261
|
else if (event.type == pointerData.up.type) {
|
|
@@ -293,32 +296,33 @@ var MouseManager = /** @class */ (function () {
|
|
|
293
296
|
this._stage.dispatchEvent(event);
|
|
294
297
|
if (upContainerNode) {
|
|
295
298
|
if (!this._isAVM1Dragging)
|
|
296
|
-
this.setupAndDispatchEvent(pointerData.click, pointerData
|
|
297
|
-
this.setupAndDispatchEvent(this._dragStop,
|
|
299
|
+
this.setupAndDispatchEvent(pointerData.click, pointerData, this._mouseDragCollision);
|
|
300
|
+
this.setupAndDispatchEvent(this._dragStop, pointerData, this._mouseDragCollision);
|
|
298
301
|
}
|
|
299
302
|
else if (this._mouseDragging && this._mouseDragCollision) {
|
|
300
|
-
this.setupAndDispatchEvent(pointerData.upOutside,
|
|
303
|
+
this.setupAndDispatchEvent(pointerData.upOutside, pointerData, this._mouseDragCollision);
|
|
301
304
|
}
|
|
302
305
|
this._mouseDragCollision = null;
|
|
303
306
|
this._mouseDragging = false;
|
|
304
307
|
this._isAVM1Dragging = false;
|
|
308
|
+
//make sure to clear old touch references when no longer needed
|
|
309
|
+
if (pointerData.id != 0)
|
|
310
|
+
delete this._pointerDataArray[pointerData.id];
|
|
305
311
|
}
|
|
306
312
|
else if (event.type == pointerData.move.type) {
|
|
307
313
|
// no event-bubbling. dispatch on stage first
|
|
308
|
-
if (!this._eventBubbling)
|
|
314
|
+
if (!this._eventBubbling)
|
|
309
315
|
this._stage.dispatchEvent(event);
|
|
310
|
-
}
|
|
311
316
|
// fire to picker
|
|
312
|
-
if (
|
|
313
|
-
this.dispatchEvent(event,
|
|
314
|
-
}
|
|
315
|
-
if (this._mouseDragCollision) {
|
|
316
|
-
this.setupAndDispatchEvent(this._dragMove, event, this._mouseDragCollision);
|
|
317
|
+
if (dispatcher) {
|
|
318
|
+
this.dispatchEvent(event, dispatcher);
|
|
317
319
|
}
|
|
318
|
-
|
|
319
|
-
if (this._eventBubbling) {
|
|
320
|
+
else if (this._eventBubbling) {
|
|
320
321
|
this._stage.dispatchEvent(event);
|
|
321
322
|
}
|
|
323
|
+
if (this._mouseDragCollision) {
|
|
324
|
+
this.setupAndDispatchEvent(this._dragMove, pointerData, this._mouseDragCollision);
|
|
325
|
+
}
|
|
322
326
|
}
|
|
323
327
|
else {
|
|
324
328
|
// MouseEvent.MOUSE_OVER / MouseEvent.MOUSE_OUT / MouseEvent.DRAG_OVER / MouseEvent.DRAG_OUT
|
|
@@ -337,20 +341,20 @@ var MouseManager = /** @class */ (function () {
|
|
|
337
341
|
// (_mouseDragEntity)
|
|
338
342
|
// Store the info if the collision is a enabled Button (_collisionIsEnabledButton)
|
|
339
343
|
if (prevCollisionNode) {
|
|
340
|
-
this.setupAndDispatchEvent(pointerData.out, pointerData
|
|
344
|
+
this.setupAndDispatchEvent(pointerData.out, pointerData, pointerData.prevCollision);
|
|
341
345
|
if (this._mouseDragging && this._mouseDragCollision
|
|
342
346
|
&& this._mouseDragCollision.rootNode == prevCollisionNode)
|
|
343
|
-
this.setupAndDispatchEvent(this._dragOut, pointerData
|
|
347
|
+
this.setupAndDispatchEvent(this._dragOut, pointerData, pointerData.prevCollision);
|
|
344
348
|
}
|
|
345
349
|
if (!prevCollisionNode && collisionNode) {
|
|
346
350
|
// rollout / rollover easy case, can just bubble up
|
|
347
|
-
this.setupAndDispatchEvent(pointerData.rollOut, pointerData
|
|
348
|
-
this.setupAndDispatchEvent(pointerData.rollOver, pointerData
|
|
351
|
+
this.setupAndDispatchEvent(pointerData.rollOut, pointerData, pointerData.prevCollision);
|
|
352
|
+
this.setupAndDispatchEvent(pointerData.rollOver, pointerData, collision);
|
|
349
353
|
}
|
|
350
354
|
if (prevCollisionNode && !collisionNode) {
|
|
351
355
|
// rollout / rollover easy case, can just bubble up
|
|
352
|
-
this.setupAndDispatchEvent(pointerData.rollOut, pointerData
|
|
353
|
-
this.setupAndDispatchEvent(pointerData.rollOver, pointerData
|
|
356
|
+
this.setupAndDispatchEvent(pointerData.rollOut, pointerData, pointerData.prevCollision);
|
|
357
|
+
this.setupAndDispatchEvent(pointerData.rollOver, pointerData, collision);
|
|
354
358
|
}
|
|
355
359
|
if (prevCollisionNode && collisionNode) {
|
|
356
360
|
// rollout / rollover find common ancester and only bubble up to that point
|
|
@@ -373,15 +377,15 @@ var MouseManager = /** @class */ (function () {
|
|
|
373
377
|
}
|
|
374
378
|
}
|
|
375
379
|
if (commonAncestor != prevCollisionNode)
|
|
376
|
-
this.setupAndDispatchEvent(pointerData.rollOut, pointerData
|
|
380
|
+
this.setupAndDispatchEvent(pointerData.rollOut, pointerData, pointerData.prevCollision, commonAncestor);
|
|
377
381
|
if (commonAncestor != collisionNode)
|
|
378
|
-
this.setupAndDispatchEvent(pointerData.rollOver, pointerData
|
|
382
|
+
this.setupAndDispatchEvent(pointerData.rollOver, pointerData, collision, commonAncestor);
|
|
379
383
|
}
|
|
380
384
|
pointerData.collisionIsEnabledButton = collisionNode ? collisionNode.buttonEnabled : false;
|
|
381
385
|
if (collisionNode) {
|
|
382
|
-
this.setupAndDispatchEvent(pointerData.over, pointerData
|
|
386
|
+
this.setupAndDispatchEvent(pointerData.over, pointerData, collision);
|
|
383
387
|
if (this._mouseDragging)
|
|
384
|
-
this.setupAndDispatchEvent(this._dragOver, pointerData
|
|
388
|
+
this.setupAndDispatchEvent(this._dragOver, pointerData, collision);
|
|
385
389
|
}
|
|
386
390
|
pointerData.prevCollision = collision;
|
|
387
391
|
}
|
|
@@ -392,9 +396,9 @@ var MouseManager = /** @class */ (function () {
|
|
|
392
396
|
var isActiveButton = collisionNode ? collisionNode.buttonEnabled : false;
|
|
393
397
|
if (pointerData.collisionIsEnabledButton != isActiveButton && isActiveButton) {
|
|
394
398
|
if (pointerData.isMouse)
|
|
395
|
-
this.setupAndDispatchEvent(pointerData.over, pointerData
|
|
399
|
+
this.setupAndDispatchEvent(pointerData.over, pointerData, collision);
|
|
396
400
|
else if (this._mouseDragCollision && this._mouseDragCollision.rootNode == collisionNode)
|
|
397
|
-
this.setupAndDispatchEvent(this._dragOver, pointerData
|
|
401
|
+
this.setupAndDispatchEvent(this._dragOver, pointerData, collision);
|
|
398
402
|
}
|
|
399
403
|
pointerData.collisionIsEnabledButton = isActiveButton;
|
|
400
404
|
}
|
|
@@ -561,14 +565,16 @@ var MouseManager = /** @class */ (function () {
|
|
|
561
565
|
// ---------------------------------------------------------------------
|
|
562
566
|
// Private.
|
|
563
567
|
// ---------------------------------------------------------------------
|
|
564
|
-
MouseManager.prototype.setUpEvent = function (event, collision, commonAncestor) {
|
|
568
|
+
MouseManager.prototype.setUpEvent = function (event, pointerData, collision, commonAncestor) {
|
|
565
569
|
var _a, _b;
|
|
566
570
|
if (commonAncestor === void 0) { commonAncestor = null; }
|
|
567
571
|
event._iAllowedToImmediatlyPropagate = true;
|
|
568
572
|
event._iAllowedToPropagate = true;
|
|
569
573
|
// 2D properties.
|
|
570
|
-
event.screenX =
|
|
571
|
-
event.screenY =
|
|
574
|
+
event.screenX = pointerData.screenX;
|
|
575
|
+
event.screenY = pointerData.screenY;
|
|
576
|
+
if (event instanceof AwayTouchEvent)
|
|
577
|
+
event.touchPointID = pointerData.id;
|
|
572
578
|
//console.log("event", event, collisionNode, collisionNode);
|
|
573
579
|
// 3D properties.
|
|
574
580
|
if (collision) {
|
|
@@ -725,21 +731,18 @@ var MouseManager = /** @class */ (function () {
|
|
|
725
731
|
this._stage.interactionHandler(event);
|
|
726
732
|
this._updateDirty = true;
|
|
727
733
|
var mouseData = this._pointerDataArray[0] || (this._pointerDataArray[0] = new PointerData(0, true));
|
|
728
|
-
|
|
734
|
+
mouseData.isMouse = (event instanceof MouseEvent);
|
|
735
|
+
var type = (mouseData.isMouse) ? event.type : MouseManager._touchToMouseDict[event.type];
|
|
729
736
|
this.queueDispatch(mouseData, MouseManager._pointerDict[type], event);
|
|
730
737
|
mouseData.screenX = this._stage.screenX;
|
|
731
738
|
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
739
|
if (event.changedTouches) {
|
|
740
740
|
for (var i = 0; i < event.changedTouches.length; i++) {
|
|
741
741
|
var touch = event.changedTouches[i];
|
|
742
|
-
var touchData = this._pointerDataArray[touch.identifier];
|
|
742
|
+
var touchData = this._pointerDataArray[touch.identifier] || (this._pointerDataArray[touch.identifier] = new PointerData(touch.identifier));
|
|
743
|
+
var point = this._stage.mapWindowToStage(touch.clientX, touch.clientY);
|
|
744
|
+
touchData.screenX = point.x;
|
|
745
|
+
touchData.screenY = point.y;
|
|
743
746
|
this.queueDispatch(touchData, MouseManager._pointerDict[event.type], event);
|
|
744
747
|
}
|
|
745
748
|
}
|
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,11 @@ 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
|
+
//only allow dragging for mouse (or pseudo-mouse) interactions
|
|
335
|
+
if (pointerData.id != 0)
|
|
336
|
+
this._mouseDragCollision = collision;
|
|
334
337
|
|
|
335
338
|
if (dispatcher) {
|
|
336
339
|
//console.log("onPress", dispatcher)
|
|
@@ -340,7 +343,7 @@ export class MouseManager {
|
|
|
340
343
|
|
|
341
344
|
if (this._mouseDragCollision) {
|
|
342
345
|
this.setFocus(this._mouseDragCollision?.rootNode);
|
|
343
|
-
this.setupAndDispatchEvent(this._dragStart,
|
|
346
|
+
this.setupAndDispatchEvent(this._dragStart, pointerData, this._mouseDragCollision);
|
|
344
347
|
}
|
|
345
348
|
|
|
346
349
|
} else if (event.type == pointerData.up.type) {
|
|
@@ -383,35 +386,35 @@ export class MouseManager {
|
|
|
383
386
|
|
|
384
387
|
if (upContainerNode) {
|
|
385
388
|
if (!this._isAVM1Dragging)
|
|
386
|
-
this.setupAndDispatchEvent(pointerData.click, pointerData
|
|
387
|
-
this.setupAndDispatchEvent(this._dragStop,
|
|
389
|
+
this.setupAndDispatchEvent(pointerData.click, pointerData, this._mouseDragCollision);
|
|
390
|
+
this.setupAndDispatchEvent(this._dragStop, pointerData, this._mouseDragCollision);
|
|
388
391
|
} else if (this._mouseDragging && this._mouseDragCollision) {
|
|
389
|
-
this.setupAndDispatchEvent(pointerData.upOutside,
|
|
392
|
+
this.setupAndDispatchEvent(pointerData.upOutside, pointerData, this._mouseDragCollision);
|
|
390
393
|
}
|
|
391
394
|
|
|
392
395
|
this._mouseDragCollision = null;
|
|
393
396
|
this._mouseDragging = false;
|
|
394
397
|
this._isAVM1Dragging = false;
|
|
395
398
|
|
|
399
|
+
//make sure to clear old touch references when no longer needed
|
|
400
|
+
if (pointerData.id != 0)
|
|
401
|
+
delete this._pointerDataArray[pointerData.id];
|
|
402
|
+
|
|
396
403
|
} else if (event.type == pointerData.move.type) {
|
|
397
404
|
|
|
398
405
|
// no event-bubbling. dispatch on stage first
|
|
399
|
-
if (!this._eventBubbling)
|
|
406
|
+
if (!this._eventBubbling)
|
|
400
407
|
this._stage.dispatchEvent(event);
|
|
401
|
-
}
|
|
402
408
|
|
|
403
409
|
// fire to picker
|
|
404
|
-
if (
|
|
405
|
-
this.dispatchEvent(event,
|
|
410
|
+
if (dispatcher) {
|
|
411
|
+
this.dispatchEvent(event, dispatcher);
|
|
412
|
+
} else if (this._eventBubbling) {
|
|
413
|
+
this._stage.dispatchEvent(event);
|
|
406
414
|
}
|
|
407
415
|
|
|
408
416
|
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);
|
|
417
|
+
this.setupAndDispatchEvent(this._dragMove, pointerData, this._mouseDragCollision);
|
|
415
418
|
}
|
|
416
419
|
|
|
417
420
|
} else {
|
|
@@ -438,22 +441,22 @@ export class MouseManager {
|
|
|
438
441
|
// Store the info if the collision is a enabled Button (_collisionIsEnabledButton)
|
|
439
442
|
|
|
440
443
|
if (prevCollisionNode) {
|
|
441
|
-
this.setupAndDispatchEvent(pointerData.out, pointerData
|
|
444
|
+
this.setupAndDispatchEvent(pointerData.out, pointerData, pointerData.prevCollision);
|
|
442
445
|
|
|
443
446
|
if (this._mouseDragging && this._mouseDragCollision
|
|
444
447
|
&& this._mouseDragCollision.rootNode == prevCollisionNode)
|
|
445
|
-
this.setupAndDispatchEvent(this._dragOut, pointerData
|
|
448
|
+
this.setupAndDispatchEvent(this._dragOut, pointerData, pointerData.prevCollision);
|
|
446
449
|
}
|
|
447
450
|
|
|
448
451
|
if (!prevCollisionNode && collisionNode) {
|
|
449
452
|
// rollout / rollover easy case, can just bubble up
|
|
450
|
-
this.setupAndDispatchEvent(pointerData.rollOut, pointerData
|
|
451
|
-
this.setupAndDispatchEvent(pointerData.rollOver, pointerData
|
|
453
|
+
this.setupAndDispatchEvent(pointerData.rollOut, pointerData, pointerData.prevCollision);
|
|
454
|
+
this.setupAndDispatchEvent(pointerData.rollOver, pointerData, collision);
|
|
452
455
|
}
|
|
453
456
|
if (prevCollisionNode && !collisionNode) {
|
|
454
457
|
// rollout / rollover easy case, can just bubble up
|
|
455
|
-
this.setupAndDispatchEvent(pointerData.rollOut, pointerData
|
|
456
|
-
this.setupAndDispatchEvent(pointerData.rollOver, pointerData
|
|
458
|
+
this.setupAndDispatchEvent(pointerData.rollOut, pointerData, pointerData.prevCollision);
|
|
459
|
+
this.setupAndDispatchEvent(pointerData.rollOver, pointerData, collision);
|
|
457
460
|
}
|
|
458
461
|
if (prevCollisionNode && collisionNode) {
|
|
459
462
|
// rollout / rollover find common ancester and only bubble up to that point
|
|
@@ -475,21 +478,21 @@ export class MouseManager {
|
|
|
475
478
|
}
|
|
476
479
|
}
|
|
477
480
|
if (commonAncestor != prevCollisionNode)
|
|
478
|
-
this.setupAndDispatchEvent(pointerData.rollOut, pointerData
|
|
481
|
+
this.setupAndDispatchEvent(pointerData.rollOut, pointerData,
|
|
479
482
|
pointerData.prevCollision, commonAncestor);
|
|
480
483
|
|
|
481
484
|
if (commonAncestor != collisionNode)
|
|
482
|
-
this.setupAndDispatchEvent(pointerData.rollOver, pointerData
|
|
485
|
+
this.setupAndDispatchEvent(pointerData.rollOver, pointerData, collision, commonAncestor);
|
|
483
486
|
|
|
484
487
|
}
|
|
485
488
|
|
|
486
489
|
pointerData.collisionIsEnabledButton = collisionNode ? (<any> collisionNode).buttonEnabled : false;
|
|
487
490
|
|
|
488
491
|
if (collisionNode) {
|
|
489
|
-
this.setupAndDispatchEvent(pointerData.over, pointerData
|
|
492
|
+
this.setupAndDispatchEvent(pointerData.over, pointerData, collision);
|
|
490
493
|
|
|
491
494
|
if (this._mouseDragging)
|
|
492
|
-
this.setupAndDispatchEvent(this._dragOver, pointerData
|
|
495
|
+
this.setupAndDispatchEvent(this._dragOver, pointerData, collision);
|
|
493
496
|
}
|
|
494
497
|
|
|
495
498
|
pointerData.prevCollision = collision;
|
|
@@ -501,9 +504,9 @@ export class MouseManager {
|
|
|
501
504
|
|
|
502
505
|
if (pointerData.collisionIsEnabledButton != isActiveButton && isActiveButton) {
|
|
503
506
|
if (pointerData.isMouse)
|
|
504
|
-
this.setupAndDispatchEvent(pointerData.over, pointerData
|
|
507
|
+
this.setupAndDispatchEvent(pointerData.over, pointerData, collision);
|
|
505
508
|
else if (this._mouseDragCollision && this._mouseDragCollision.rootNode == collisionNode)
|
|
506
|
-
this.setupAndDispatchEvent(this._dragOver, pointerData
|
|
509
|
+
this.setupAndDispatchEvent(this._dragOver, pointerData, collision);
|
|
507
510
|
}
|
|
508
511
|
|
|
509
512
|
pointerData.collisionIsEnabledButton = isActiveButton;
|
|
@@ -674,13 +677,17 @@ export class MouseManager {
|
|
|
674
677
|
// ---------------------------------------------------------------------
|
|
675
678
|
// Private.
|
|
676
679
|
// ---------------------------------------------------------------------
|
|
677
|
-
private setUpEvent(event: PointerEvent,
|
|
680
|
+
private setUpEvent(event: PointerEvent, pointerData: PointerData,
|
|
678
681
|
collision: PickingCollision, commonAncestor: ContainerNode = null): PointerEvent {
|
|
679
682
|
event._iAllowedToImmediatlyPropagate = true;
|
|
680
683
|
event._iAllowedToPropagate = true;
|
|
681
684
|
// 2D properties.
|
|
682
|
-
event.screenX =
|
|
683
|
-
event.screenY =
|
|
685
|
+
event.screenX = pointerData.screenX;
|
|
686
|
+
event.screenY = pointerData.screenY;
|
|
687
|
+
|
|
688
|
+
if (event instanceof AwayTouchEvent)
|
|
689
|
+
event.touchPointID = pointerData.id;
|
|
690
|
+
|
|
684
691
|
//console.log("event", event, collisionNode, collisionNode);
|
|
685
692
|
|
|
686
693
|
// 3D properties.
|
|
@@ -870,23 +877,20 @@ export class MouseManager {
|
|
|
870
877
|
|
|
871
878
|
const mouseData = this._pointerDataArray[0] || (this._pointerDataArray[0] = new PointerData(0, true));
|
|
872
879
|
|
|
873
|
-
|
|
880
|
+
mouseData.isMouse = (event instanceof MouseEvent);
|
|
881
|
+
const type = (mouseData.isMouse) ? event.type : MouseManager._touchToMouseDict[event.type];
|
|
874
882
|
this.queueDispatch(mouseData, MouseManager._pointerDict[type], event);
|
|
875
883
|
|
|
876
884
|
mouseData.screenX = this._stage.screenX;
|
|
877
885
|
mouseData.screenY = this._stage.screenY;
|
|
878
886
|
|
|
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
887
|
if ((<TouchEvent> event).changedTouches) {
|
|
887
888
|
for (let i: number = 0; i < (<TouchEvent> event).changedTouches.length; i++) {
|
|
888
889
|
const touch = (<TouchEvent> event).changedTouches[i];
|
|
889
|
-
const touchData = this._pointerDataArray[touch.identifier];
|
|
890
|
+
const touchData = this._pointerDataArray[touch.identifier] || (this._pointerDataArray[touch.identifier] = new PointerData(touch.identifier));
|
|
891
|
+
const point = this._stage.mapWindowToStage(touch.clientX, touch.clientY);
|
|
892
|
+
touchData.screenX = point.x;
|
|
893
|
+
touchData.screenY = point.y;
|
|
890
894
|
this.queueDispatch(touchData, MouseManager._pointerDict[event.type], event);
|
|
891
895
|
}
|
|
892
896
|
}
|