@woosh/meep-engine 2.109.26 → 2.110.0
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/build/meep.cjs +199 -435
- package/build/meep.min.js +1 -1
- package/build/meep.module.js +199 -435
- package/editor/tools/GridPaintTool.js +12 -11
- package/editor/tools/engine/ToolEngine.js +2 -1
- package/package.json +1 -1
- package/src/core/graph/Edge.js +1 -1
- package/src/core/math/interval/NumericInterval.d.ts +13 -7
- package/src/core/math/interval/NumericInterval.d.ts.map +1 -1
- package/src/core/math/interval/NumericInterval.js +35 -15
- package/src/engine/graphics/camera/makeOrbitalCameraController.d.ts.map +1 -1
- package/src/engine/graphics/camera/makeOrbitalCameraController.js +4 -4
- package/src/engine/graphics/geometry/VertexDataSpec.d.ts.map +1 -1
- package/src/engine/graphics/geometry/VertexDataSpec.js +4 -7
- package/src/engine/input/devices/LocationalInteractionMetadata.d.ts +4 -0
- package/src/engine/input/devices/LocationalInteractionMetadata.d.ts.map +1 -1
- package/src/engine/input/devices/LocationalInteractionMetadata.js +6 -1
- package/src/engine/input/devices/PointerDevice.d.ts +0 -3
- package/src/engine/input/devices/PointerDevice.d.ts.map +1 -1
- package/src/engine/input/devices/PointerDevice.js +49 -306
- package/src/engine/input/devices/events/PointerEvents.d.ts +14 -0
- package/src/engine/input/devices/events/PointerEvents.d.ts.map +1 -0
- package/src/engine/input/devices/events/PointerEvents.js +16 -0
- package/src/engine/input/devices/mouse/decodeMouseEventButtons.d.ts +10 -0
- package/src/engine/input/devices/mouse/decodeMouseEventButtons.d.ts.map +1 -0
- package/src/engine/input/devices/mouse/decodeMouseEventButtons.js +19 -0
- package/src/engine/input/devices/mouse/suppressContextMenu.d.ts +7 -0
- package/src/engine/input/devices/mouse/suppressContextMenu.d.ts.map +1 -0
- package/src/engine/input/devices/mouse/suppressContextMenu.js +11 -0
- package/src/engine/input/devices/touch/TouchDevice.d.ts +20 -0
- package/src/engine/input/devices/touch/TouchDevice.d.ts.map +1 -0
- package/src/engine/input/devices/touch/TouchDevice.js +95 -0
- package/src/engine/input/devices/touch/getTouchCenter.d.ts +7 -0
- package/src/engine/input/devices/touch/getTouchCenter.d.ts.map +1 -0
- package/src/engine/input/devices/touch/getTouchCenter.js +32 -0
- package/src/engine/input/devices/touch/observePinch.d.ts +12 -0
- package/src/engine/input/devices/touch/observePinch.d.ts.map +1 -0
- package/src/engine/input/devices/touch/observePinch.js +128 -0
|
@@ -3,88 +3,12 @@ import Signal from "../../../core/events/signal/Signal.js";
|
|
|
3
3
|
import Vector2 from "../../../core/geom/Vector2.js";
|
|
4
4
|
import Vector3 from "../../../core/geom/Vector3.js";
|
|
5
5
|
import { sign } from "../../../core/math/sign.js";
|
|
6
|
-
import {
|
|
6
|
+
import { current_time_in_seconds } from "../../../core/time/current_time_in_seconds.js";
|
|
7
7
|
import { MouseEvents } from "./events/MouseEvents.js";
|
|
8
|
-
import {
|
|
8
|
+
import { PointerEvents } from "./events/PointerEvents.js";
|
|
9
9
|
import { InputDeviceSwitch } from "./InputDeviceSwitch.js";
|
|
10
10
|
import { LocationalInteractionMetadata } from "./LocationalInteractionMetadata.js";
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
|
|
14
|
-
* @see https://w3c.github.io/uievents/#widl-MouseEvent-buttons
|
|
15
|
-
*
|
|
16
|
-
* @param {Number} value
|
|
17
|
-
* @return {boolean[]} array of booleans, boolean is true if mouse button is pressed, false otherwise
|
|
18
|
-
*/
|
|
19
|
-
export function decodeMouseEventButtons(value) {
|
|
20
|
-
const result = [];
|
|
21
|
-
|
|
22
|
-
for (let i = 0; i < 32; i++) {
|
|
23
|
-
|
|
24
|
-
const shiftedValue = value >> i;
|
|
25
|
-
|
|
26
|
-
result[i] = (shiftedValue & 1) !== 0;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
return result;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Prevent default context menu from showing up
|
|
34
|
-
* @param {Event} event
|
|
35
|
-
*/
|
|
36
|
-
function supressContextMenu(event) {
|
|
37
|
-
event.preventDefault();
|
|
38
|
-
event.stopPropagation();
|
|
39
|
-
|
|
40
|
-
return false;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
*
|
|
45
|
-
* @param {TouchList} touchList
|
|
46
|
-
* @param {function(Touch,number)} callback
|
|
47
|
-
*/
|
|
48
|
-
function forEachTouch(touchList, callback) {
|
|
49
|
-
const length = touchList.length;
|
|
50
|
-
for (let i = 0; i < length; i++) {
|
|
51
|
-
const touch = touchList.item(i);
|
|
52
|
-
callback(touch, i);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
*
|
|
58
|
-
* @param {TouchList} touchList
|
|
59
|
-
* @param {Vector2} result
|
|
60
|
-
*/
|
|
61
|
-
function getTouchCenter(touchList, result) {
|
|
62
|
-
const length = touchList.length;
|
|
63
|
-
|
|
64
|
-
let x = 0, y = 0;
|
|
65
|
-
|
|
66
|
-
if (length > 0) {
|
|
67
|
-
|
|
68
|
-
for (let i = 0; i < length; i++) {
|
|
69
|
-
const touch = touchList.item(i);
|
|
70
|
-
|
|
71
|
-
if (touch === null) {
|
|
72
|
-
continue;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
x += touch.clientX;
|
|
76
|
-
y += touch.clientY;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// average to get center
|
|
80
|
-
x /= length;
|
|
81
|
-
y /= length;
|
|
82
|
-
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
result.set(x, y);
|
|
86
|
-
|
|
87
|
-
}
|
|
11
|
+
import { suppressContextMenu } from "./mouse/suppressContextMenu.js";
|
|
88
12
|
|
|
89
13
|
|
|
90
14
|
/**
|
|
@@ -92,16 +16,18 @@ function getTouchCenter(touchList, result) {
|
|
|
92
16
|
* @param {Signal} up
|
|
93
17
|
* @param {Signal} down
|
|
94
18
|
* @param {Signal} move
|
|
95
|
-
* @param {number} maxDistance
|
|
19
|
+
* @param {number} [maxDistance] in pixels
|
|
20
|
+
* @param {number} [maxDelay] Maximum delay between down and up events in seconds
|
|
96
21
|
* @param {Signal} signal
|
|
97
22
|
*/
|
|
98
|
-
function observeTap(
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
23
|
+
function observeTap({
|
|
24
|
+
up,
|
|
25
|
+
down,
|
|
26
|
+
move = new Signal(),
|
|
27
|
+
maxDistance = 10,
|
|
28
|
+
maxDelay = 1,
|
|
29
|
+
signal
|
|
30
|
+
}) {
|
|
105
31
|
|
|
106
32
|
/**
|
|
107
33
|
*
|
|
@@ -116,7 +42,8 @@ function observeTap(
|
|
|
116
42
|
function reset(id) {
|
|
117
43
|
assert.isNonNegativeInteger(id, 'id');
|
|
118
44
|
|
|
119
|
-
|
|
45
|
+
const deleted = active.delete(id);
|
|
46
|
+
if (deleted) {
|
|
120
47
|
up.remove(handleUp);
|
|
121
48
|
move.remove(handleMove);
|
|
122
49
|
}
|
|
@@ -125,10 +52,10 @@ function observeTap(
|
|
|
125
52
|
/**
|
|
126
53
|
*
|
|
127
54
|
* @param {Vector2} position
|
|
128
|
-
* @param {
|
|
55
|
+
* @param {PointerEvent} event
|
|
129
56
|
*/
|
|
130
57
|
function handleUp(position, event) {
|
|
131
|
-
const id =
|
|
58
|
+
const id = event.pointerId;
|
|
132
59
|
|
|
133
60
|
const meta = active.get(id);
|
|
134
61
|
|
|
@@ -140,16 +67,25 @@ function observeTap(
|
|
|
140
67
|
|
|
141
68
|
reset(id);
|
|
142
69
|
|
|
70
|
+
const time_now = current_time_in_seconds();
|
|
71
|
+
|
|
72
|
+
const delay = time_now - meta.timestamp;
|
|
73
|
+
|
|
74
|
+
if (delay > maxDelay) {
|
|
75
|
+
// too much time has passed, swallow event
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
|
|
143
79
|
signal.send2(position, event);
|
|
144
80
|
}
|
|
145
81
|
|
|
146
82
|
/**
|
|
147
83
|
*
|
|
148
84
|
* @param {Vector2} position
|
|
149
|
-
* @param {
|
|
85
|
+
* @param {PointerEvent} event
|
|
150
86
|
*/
|
|
151
87
|
function handleMove(position, event) {
|
|
152
|
-
const id =
|
|
88
|
+
const id = event.pointerId;
|
|
153
89
|
|
|
154
90
|
const meta = active.get(id);
|
|
155
91
|
|
|
@@ -172,10 +108,10 @@ function observeTap(
|
|
|
172
108
|
/**
|
|
173
109
|
*
|
|
174
110
|
* @param {Vector2} position
|
|
175
|
-
* @param {
|
|
111
|
+
* @param {PointerEvent} event
|
|
176
112
|
*/
|
|
177
113
|
function handleDown(position, event) {
|
|
178
|
-
const id =
|
|
114
|
+
const id = event.pointerId;
|
|
179
115
|
|
|
180
116
|
// make sure to cancel previous pending resolution
|
|
181
117
|
reset(id);
|
|
@@ -191,119 +127,6 @@ function observeTap(
|
|
|
191
127
|
down.add(handleDown);
|
|
192
128
|
}
|
|
193
129
|
|
|
194
|
-
/**
|
|
195
|
-
*
|
|
196
|
-
* @param {Signal} touchStart
|
|
197
|
-
* @param {Signal} touchEnd
|
|
198
|
-
* @param {Signal} touchMove
|
|
199
|
-
* @param {Signal} pinch
|
|
200
|
-
* @param {Signal} pinchStart
|
|
201
|
-
* @param {Signal} pinchEnd
|
|
202
|
-
* @param {PointerDevice} device
|
|
203
|
-
*/
|
|
204
|
-
function observePinch({
|
|
205
|
-
touchStart,
|
|
206
|
-
touchEnd,
|
|
207
|
-
touchMove,
|
|
208
|
-
pinch,
|
|
209
|
-
pinchStart,
|
|
210
|
-
pinchEnd,
|
|
211
|
-
device
|
|
212
|
-
}) {
|
|
213
|
-
const center = new Vector2();
|
|
214
|
-
|
|
215
|
-
const v2 = new Vector2();
|
|
216
|
-
|
|
217
|
-
const pinchBox0 = new Vector2();
|
|
218
|
-
const pinchBox1 = new Vector2();
|
|
219
|
-
|
|
220
|
-
let pinchActive = false;
|
|
221
|
-
let touchCount = 0;
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
/**
|
|
225
|
-
*
|
|
226
|
-
* @param {TouchList} touchList
|
|
227
|
-
* @param {Vector2} pinchDimensions
|
|
228
|
-
*/
|
|
229
|
-
function computeTouchRadius(touchList, pinchDimensions) {
|
|
230
|
-
getTouchCenter(touchList, center);
|
|
231
|
-
|
|
232
|
-
const length = touchList.length;
|
|
233
|
-
|
|
234
|
-
pinchDimensions.set(0, 0);
|
|
235
|
-
|
|
236
|
-
for (let i = 0; i < length; i++) {
|
|
237
|
-
const touch = touchList.item(i);
|
|
238
|
-
|
|
239
|
-
device.readPointerPositionFromEvent(v2, touch);
|
|
240
|
-
|
|
241
|
-
v2.sub(center);
|
|
242
|
-
v2.abs();
|
|
243
|
-
|
|
244
|
-
pinchDimensions.add(v2);
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
return pinchDimensions.multiplyScalar(1 / length);
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
function touchRemoved(touch, event) {
|
|
251
|
-
touchCount--;
|
|
252
|
-
if (touchCount < 2 && pinchActive) {
|
|
253
|
-
handlePinchEnd(event);
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
function touchAdded(touch, event) {
|
|
258
|
-
touchCount++;
|
|
259
|
-
if (touchCount > 1 && !pinchActive) {
|
|
260
|
-
handlePinchStart(event);
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
function handlePinchStart(event) {
|
|
265
|
-
pinchActive = true;
|
|
266
|
-
|
|
267
|
-
computeTouchRadius(event.touches, pinchBox0);
|
|
268
|
-
|
|
269
|
-
touchMove.add(handleMove);
|
|
270
|
-
|
|
271
|
-
pinchStart.send1(pinchBox0);
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
/**
|
|
275
|
-
*
|
|
276
|
-
* @param {TouchEvent} event
|
|
277
|
-
*/
|
|
278
|
-
function handlePinchEnd(event) {
|
|
279
|
-
pinchActive = false;
|
|
280
|
-
|
|
281
|
-
touchMove.remove(handleMove);
|
|
282
|
-
|
|
283
|
-
pinchEnd.send0();
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
function handleDown(position, event) {
|
|
287
|
-
forEachTouch(event.changedTouches, function (touch) {
|
|
288
|
-
touchAdded(touch, event);
|
|
289
|
-
});
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
function handleUp(position, event) {
|
|
293
|
-
forEachTouch(event.changedTouches, function (touch) {
|
|
294
|
-
touchRemoved(touch, event);
|
|
295
|
-
});
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
function handleMove(position, event) {
|
|
299
|
-
computeTouchRadius(event.touches, pinchBox1);
|
|
300
|
-
pinch.send2(pinchBox1, pinchBox0);
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
touchEnd.add(handleUp);
|
|
304
|
-
touchStart.add(handleDown);
|
|
305
|
-
}
|
|
306
|
-
|
|
307
130
|
/**
|
|
308
131
|
*
|
|
309
132
|
* @param {Signal} up
|
|
@@ -395,18 +218,8 @@ export class PointerDevice {
|
|
|
395
218
|
*/
|
|
396
219
|
position = new Vector2();
|
|
397
220
|
|
|
398
|
-
/**
|
|
399
|
-
* @readonly
|
|
400
|
-
* @type {Vector2}
|
|
401
|
-
*/
|
|
402
|
-
#anchor_touch_last = new Vector2();
|
|
403
|
-
|
|
404
221
|
#globalUp = new Signal();
|
|
405
222
|
|
|
406
|
-
#touchStart = new Signal();
|
|
407
|
-
#touchEnd = new Signal();
|
|
408
|
-
#touchMove = new Signal();
|
|
409
|
-
|
|
410
223
|
/**
|
|
411
224
|
* @readonly
|
|
412
225
|
*/
|
|
@@ -497,41 +310,18 @@ export class PointerDevice {
|
|
|
497
310
|
this.#domElement = domElement;
|
|
498
311
|
|
|
499
312
|
|
|
500
|
-
this.#touchStart.add(this.on.down.send3, this.on.down);
|
|
501
|
-
|
|
502
|
-
this.#touchEnd.add(this.on.up.send3, this.on.up);
|
|
503
|
-
|
|
504
|
-
this.#touchMove.add(this.on.move.send3, this.on.move);
|
|
505
|
-
|
|
506
313
|
//constructed events
|
|
507
|
-
observeTap(this.on.up, this.on.down, this.on.move, 10, this.on.tap);
|
|
314
|
+
observeTap({ up: this.on.up, down: this.on.down, move: this.on.move, maxDistance: 10, signal: this.on.tap });
|
|
508
315
|
observeDrag(this.#globalUp, this.on.down, this.on.move, this.on.dragStart, this.on.dragEnd, this.on.drag);
|
|
509
|
-
observePinch({
|
|
510
|
-
touchStart: this.#touchStart,
|
|
511
|
-
touchEnd: this.#touchEnd,
|
|
512
|
-
touchMove: this.#touchMove,
|
|
513
|
-
pinch: this.on.pinch,
|
|
514
|
-
pinchStart: this.on.pinchStart,
|
|
515
|
-
pinchEnd: this.on.pinchEnd,
|
|
516
|
-
device: this
|
|
517
|
-
});
|
|
518
|
-
}
|
|
519
|
-
|
|
520
316
|
|
|
521
|
-
/**
|
|
522
|
-
*
|
|
523
|
-
* @param {TouchEvent} event
|
|
524
|
-
*/
|
|
525
|
-
#eventHandlerGlobalTouchEnd = (event) => {
|
|
526
|
-
getTouchCenter(event.touches, this.position);
|
|
527
|
-
this.#globalUp.send2(this.position, event);
|
|
528
317
|
}
|
|
529
318
|
|
|
319
|
+
|
|
530
320
|
/**
|
|
531
321
|
*
|
|
532
|
-
* @param {
|
|
322
|
+
* @param {PointerEvent} event
|
|
533
323
|
*/
|
|
534
|
-
#
|
|
324
|
+
#eventHandlerPointerDown = (event) => {
|
|
535
325
|
this.readPointerPositionFromEvent(this.position, event);
|
|
536
326
|
this.on.down.send2(this.position, event);
|
|
537
327
|
|
|
@@ -545,9 +335,9 @@ export class PointerDevice {
|
|
|
545
335
|
|
|
546
336
|
/**
|
|
547
337
|
*
|
|
548
|
-
* @param {
|
|
338
|
+
* @param {PointerEvent} event
|
|
549
339
|
*/
|
|
550
|
-
#
|
|
340
|
+
#eventHandlerPointerUp = (event) => {
|
|
551
341
|
this.readPointerPositionFromEvent(this.position, event);
|
|
552
342
|
this.on.up.send2(this.position, event);
|
|
553
343
|
}
|
|
@@ -556,7 +346,7 @@ export class PointerDevice {
|
|
|
556
346
|
*
|
|
557
347
|
* @param {MouseEvent} event
|
|
558
348
|
*/
|
|
559
|
-
#
|
|
349
|
+
#eventHandlerGlobalPointerUp = (event) => {
|
|
560
350
|
this.readPointerPositionFromEvent(this.position, event);
|
|
561
351
|
this.#globalUp.send2(this.position, event);
|
|
562
352
|
|
|
@@ -568,32 +358,6 @@ export class PointerDevice {
|
|
|
568
358
|
button?.release();
|
|
569
359
|
}
|
|
570
360
|
|
|
571
|
-
/**
|
|
572
|
-
*
|
|
573
|
-
* @param {TouchEvent} event
|
|
574
|
-
*/
|
|
575
|
-
#eventHandlerTouchEnd = (event) => {
|
|
576
|
-
getTouchCenter(event.touches, this.position);
|
|
577
|
-
this.#touchEnd.send2(this.position, event);
|
|
578
|
-
}
|
|
579
|
-
|
|
580
|
-
/**
|
|
581
|
-
*
|
|
582
|
-
* @param {TouchEvent} event
|
|
583
|
-
*/
|
|
584
|
-
#eventHandlerTouchMove = (event) => {
|
|
585
|
-
event.preventDefault();
|
|
586
|
-
|
|
587
|
-
getTouchCenter(event.touches, this.position);
|
|
588
|
-
|
|
589
|
-
const delta = new Vector2();
|
|
590
|
-
|
|
591
|
-
delta.subVectors(this.position, this.#anchor_touch_last);
|
|
592
|
-
|
|
593
|
-
this.#touchMove.send3(this.position, event, delta);
|
|
594
|
-
|
|
595
|
-
this.#anchor_touch_last.copy(this.position);
|
|
596
|
-
}
|
|
597
361
|
|
|
598
362
|
/**
|
|
599
363
|
*
|
|
@@ -617,20 +381,9 @@ export class PointerDevice {
|
|
|
617
381
|
|
|
618
382
|
/**
|
|
619
383
|
*
|
|
620
|
-
* @param {
|
|
384
|
+
* @param {PointerEvent} event
|
|
621
385
|
*/
|
|
622
|
-
#
|
|
623
|
-
getTouchCenter(event.touches, this.position);
|
|
624
|
-
this.#touchStart.send2(this.position, event);
|
|
625
|
-
|
|
626
|
-
this.#anchor_touch_last.copy(this.position);
|
|
627
|
-
}
|
|
628
|
-
|
|
629
|
-
/**
|
|
630
|
-
*
|
|
631
|
-
* @param {MouseEvent} event
|
|
632
|
-
*/
|
|
633
|
-
#eventHandlerMouseMove = (event) => {
|
|
386
|
+
#eventHandlerPointerMove = (event) => {
|
|
634
387
|
event.preventDefault();
|
|
635
388
|
|
|
636
389
|
this.#target = event.target;
|
|
@@ -704,16 +457,11 @@ export class PointerDevice {
|
|
|
704
457
|
assert.notEqual(domElement, null, "domElement is null");
|
|
705
458
|
assert.notEqual(domElement, undefined, "domElement is undefined");
|
|
706
459
|
|
|
707
|
-
domElement.addEventListener(
|
|
708
|
-
domElement.addEventListener(
|
|
709
|
-
domElement.addEventListener(
|
|
460
|
+
domElement.addEventListener(PointerEvents.Move, this.#eventHandlerPointerMove);
|
|
461
|
+
domElement.addEventListener(PointerEvents.Up, this.#eventHandlerPointerUp);
|
|
462
|
+
domElement.addEventListener(PointerEvents.Down, this.#eventHandlerPointerDown);
|
|
710
463
|
|
|
711
|
-
|
|
712
|
-
domElement.addEventListener(TouchEvents.End, this.#eventHandlerTouchEnd);
|
|
713
|
-
domElement.addEventListener(TouchEvents.Move, this.#eventHandlerTouchMove);
|
|
714
|
-
|
|
715
|
-
window.addEventListener(MouseEvents.Up, this.#eventHandlerGlobalMouseUp);
|
|
716
|
-
window.addEventListener(TouchEvents.End, this.#eventHandlerGlobalTouchEnd);
|
|
464
|
+
window.addEventListener(PointerEvents.Up, this.#eventHandlerGlobalPointerUp);
|
|
717
465
|
|
|
718
466
|
/*
|
|
719
467
|
In some cases wheel event gets registered as "passive" by default. This interferes with "preventDefault()"
|
|
@@ -722,7 +470,7 @@ export class PointerDevice {
|
|
|
722
470
|
domElement.addEventListener(MouseEvents.Wheel, this.#eventHandlerWheel, { passive: false });
|
|
723
471
|
|
|
724
472
|
|
|
725
|
-
domElement.addEventListener("contextmenu",
|
|
473
|
+
domElement.addEventListener("contextmenu", suppressContextMenu);
|
|
726
474
|
}
|
|
727
475
|
|
|
728
476
|
stop() {
|
|
@@ -737,20 +485,15 @@ export class PointerDevice {
|
|
|
737
485
|
|
|
738
486
|
const domElement = this.domElement;
|
|
739
487
|
|
|
740
|
-
domElement.removeEventListener(
|
|
741
|
-
domElement.removeEventListener(
|
|
742
|
-
domElement.removeEventListener(
|
|
743
|
-
|
|
744
|
-
domElement.removeEventListener(TouchEvents.Start, this.#eventHandlerTouchStart);
|
|
745
|
-
domElement.removeEventListener(TouchEvents.End, this.#eventHandlerTouchEnd);
|
|
746
|
-
domElement.removeEventListener(TouchEvents.Move, this.#eventHandlerTouchMove);
|
|
488
|
+
domElement.removeEventListener(PointerEvents.Move, this.#eventHandlerPointerMove);
|
|
489
|
+
domElement.removeEventListener(PointerEvents.Up, this.#eventHandlerPointerUp);
|
|
490
|
+
domElement.removeEventListener(PointerEvents.Down, this.#eventHandlerPointerDown);
|
|
747
491
|
|
|
748
|
-
window.removeEventListener(
|
|
749
|
-
window.removeEventListener(TouchEvents.End, this.#eventHandlerGlobalTouchEnd);
|
|
492
|
+
window.removeEventListener(PointerEvents.Up, this.#eventHandlerGlobalPointerUp);
|
|
750
493
|
|
|
751
494
|
domElement.removeEventListener(MouseEvents.Wheel, this.#eventHandlerWheel);
|
|
752
495
|
|
|
753
496
|
|
|
754
|
-
domElement.removeEventListener("contextmenu",
|
|
497
|
+
domElement.removeEventListener("contextmenu", suppressContextMenu);
|
|
755
498
|
}
|
|
756
499
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type PointerEvents = string;
|
|
2
|
+
export namespace PointerEvents {
|
|
3
|
+
let Up: string;
|
|
4
|
+
let Down: string;
|
|
5
|
+
let Move: string;
|
|
6
|
+
let Over: string;
|
|
7
|
+
let Out: string;
|
|
8
|
+
let Enter: string;
|
|
9
|
+
let Leave: string;
|
|
10
|
+
let Cancel: string;
|
|
11
|
+
let GotCapture: string;
|
|
12
|
+
let LostCapture: string;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=PointerEvents.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PointerEvents.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/input/devices/events/PointerEvents.js"],"names":[],"mappings":"4BAEU,MAAM"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @enum {string}
|
|
4
|
+
*/
|
|
5
|
+
export const PointerEvents = {
|
|
6
|
+
Up: "pointerup",
|
|
7
|
+
Down: "pointerdown",
|
|
8
|
+
Move: "pointermove",
|
|
9
|
+
Over: "pointerover",
|
|
10
|
+
Out: "pointerout",
|
|
11
|
+
Enter: "pointerenter",
|
|
12
|
+
Leave: "pointerleave",
|
|
13
|
+
Cancel: "pointercancel",
|
|
14
|
+
GotCapture: "gotpointercapture",
|
|
15
|
+
LostCapture: "lostpointercapture"
|
|
16
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
|
|
3
|
+
* @see https://w3c.github.io/uievents/#widl-MouseEvent-buttons
|
|
4
|
+
*
|
|
5
|
+
* @param {Number} value
|
|
6
|
+
* @param {boolean[]} [result]
|
|
7
|
+
* @return {boolean[]} array of booleans, boolean is true if mouse button is pressed, false otherwise
|
|
8
|
+
*/
|
|
9
|
+
export function decodeMouseEventButtons(value: number, result?: boolean[]): boolean[];
|
|
10
|
+
//# sourceMappingURL=decodeMouseEventButtons.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decodeMouseEventButtons.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/input/devices/mouse/decodeMouseEventButtons.js"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,gEAHW,OAAO,EAAE,GACR,OAAO,EAAE,CAYpB"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
|
|
3
|
+
* @see https://w3c.github.io/uievents/#widl-MouseEvent-buttons
|
|
4
|
+
*
|
|
5
|
+
* @param {Number} value
|
|
6
|
+
* @param {boolean[]} [result]
|
|
7
|
+
* @return {boolean[]} array of booleans, boolean is true if mouse button is pressed, false otherwise
|
|
8
|
+
*/
|
|
9
|
+
export function decodeMouseEventButtons(value, result = []) {
|
|
10
|
+
|
|
11
|
+
for (let i = 0; i < 32; i++) {
|
|
12
|
+
|
|
13
|
+
const shiftedValue = value >> i;
|
|
14
|
+
|
|
15
|
+
result[i] = (shiftedValue & 1) !== 0;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return result;
|
|
19
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"suppressContextMenu.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/input/devices/mouse/suppressContextMenu.js"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,2CAHW,KAAK,GACH,OAAO,CAOnB"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export class TouchDevice {
|
|
2
|
+
/**
|
|
3
|
+
* Current live position of the pointer
|
|
4
|
+
* @readonly
|
|
5
|
+
* @type {Vector2}
|
|
6
|
+
*/
|
|
7
|
+
readonly position: Vector2;
|
|
8
|
+
/**
|
|
9
|
+
* @readonly
|
|
10
|
+
*/
|
|
11
|
+
readonly on: {
|
|
12
|
+
pinch: Signal<any, any, any, any, any, any, any, any>;
|
|
13
|
+
pinchStart: Signal<any, any, any, any, any, any, any, any>;
|
|
14
|
+
pinchEnd: Signal<any, any, any, any, any, any, any, any>;
|
|
15
|
+
};
|
|
16
|
+
#private;
|
|
17
|
+
}
|
|
18
|
+
import Vector2 from "../../../../core/geom/Vector2.js";
|
|
19
|
+
import Signal from "../../../../core/events/signal/Signal.js";
|
|
20
|
+
//# sourceMappingURL=TouchDevice.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TouchDevice.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/input/devices/touch/TouchDevice.js"],"names":[],"mappings":"AAKA;IAEI;;;;OAIG;IACH,mBAFU,OAAO,CAEQ;IAezB;;OAEG;IACH;;;;MAIE;;CA4DL;oBA7FmB,kCAAkC;mBADnC,0CAA0C"}
|