@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
package/build/meep.cjs
CHANGED
|
@@ -54463,6 +54463,10 @@ class NumericInterval {
|
|
|
54463
54463
|
*/
|
|
54464
54464
|
this.max = max;
|
|
54465
54465
|
|
|
54466
|
+
/**
|
|
54467
|
+
* @readonly
|
|
54468
|
+
* @type {Signal<number, number, number, number>}
|
|
54469
|
+
*/
|
|
54466
54470
|
this.onChanged = new Signal();
|
|
54467
54471
|
}
|
|
54468
54472
|
|
|
@@ -54477,24 +54481,21 @@ class NumericInterval {
|
|
|
54477
54481
|
const oldMin = this.min;
|
|
54478
54482
|
const oldMax = this.max;
|
|
54479
54483
|
|
|
54480
|
-
if (min
|
|
54481
|
-
|
|
54482
|
-
|
|
54484
|
+
if (min === oldMin && max === oldMax) {
|
|
54485
|
+
return;
|
|
54486
|
+
}
|
|
54483
54487
|
|
|
54484
|
-
|
|
54485
|
-
|
|
54486
|
-
|
|
54488
|
+
this.min = min;
|
|
54489
|
+
this.max = max;
|
|
54490
|
+
|
|
54491
|
+
if (!this.onChanged.hasHandlers()) {
|
|
54492
|
+
return;
|
|
54487
54493
|
}
|
|
54488
|
-
}
|
|
54489
54494
|
|
|
54490
|
-
|
|
54491
|
-
*
|
|
54492
|
-
* @param {NumericInterval} other
|
|
54493
|
-
*/
|
|
54494
|
-
copy(other) {
|
|
54495
|
-
this.set(other.min, other.max);
|
|
54495
|
+
this.onChanged.send4(min, max, oldMin, oldMax);
|
|
54496
54496
|
}
|
|
54497
54497
|
|
|
54498
|
+
|
|
54498
54499
|
/**
|
|
54499
54500
|
*
|
|
54500
54501
|
* @param {number} value
|
|
@@ -54567,6 +54568,10 @@ class NumericInterval {
|
|
|
54567
54568
|
};
|
|
54568
54569
|
}
|
|
54569
54570
|
|
|
54571
|
+
toString() {
|
|
54572
|
+
return `NumericInterval{ min=${this.min}, max=${this.max} }`;
|
|
54573
|
+
}
|
|
54574
|
+
|
|
54570
54575
|
/**
|
|
54571
54576
|
*
|
|
54572
54577
|
* @param {BinaryBuffer} buffer
|
|
@@ -54585,6 +54590,14 @@ class NumericInterval {
|
|
|
54585
54590
|
this.max = buffer.readFloat64();
|
|
54586
54591
|
}
|
|
54587
54592
|
|
|
54593
|
+
/**
|
|
54594
|
+
*
|
|
54595
|
+
* @param {NumericInterval} other
|
|
54596
|
+
*/
|
|
54597
|
+
copy(other) {
|
|
54598
|
+
this.set(other.min, other.max);
|
|
54599
|
+
}
|
|
54600
|
+
|
|
54588
54601
|
/**
|
|
54589
54602
|
*
|
|
54590
54603
|
* @param {NumericInterval} other
|
|
@@ -54625,12 +54638,19 @@ NumericInterval.prototype.isNumericInterval = true;
|
|
|
54625
54638
|
* @readonly
|
|
54626
54639
|
* @type {NumericInterval}
|
|
54627
54640
|
*/
|
|
54628
|
-
NumericInterval.
|
|
54641
|
+
NumericInterval.zero_zero = Object.freeze(new NumericInterval(0, 0));
|
|
54642
|
+
|
|
54643
|
+
/**
|
|
54644
|
+
* @readonly
|
|
54645
|
+
* @type {NumericInterval}
|
|
54646
|
+
*/
|
|
54647
|
+
NumericInterval.zero_one = Object.freeze(new NumericInterval(0, 1));
|
|
54648
|
+
|
|
54629
54649
|
/**
|
|
54630
54650
|
* @readonly
|
|
54631
54651
|
* @type {NumericInterval}
|
|
54632
54652
|
*/
|
|
54633
|
-
NumericInterval.
|
|
54653
|
+
NumericInterval.one_one = Object.freeze(new NumericInterval(1, 1));
|
|
54634
54654
|
|
|
54635
54655
|
/**
|
|
54636
54656
|
*
|
|
@@ -71683,7 +71703,7 @@ class Edge {
|
|
|
71683
71703
|
}
|
|
71684
71704
|
|
|
71685
71705
|
toString() {
|
|
71686
|
-
return `Edge
|
|
71706
|
+
return `Edge{ first=${this.first}, second=${this.second}, direction=${objectKeyByValue(EdgeDirectionType, this.direction)} }`
|
|
71687
71707
|
}
|
|
71688
71708
|
|
|
71689
71709
|
}
|
|
@@ -91426,41 +91446,16 @@ class KeyboardDevice {
|
|
|
91426
91446
|
}
|
|
91427
91447
|
}
|
|
91428
91448
|
|
|
91449
|
+
//Use highest available resolution time source
|
|
91450
|
+
const source = typeof performance === "undefined" ? Date : performance;
|
|
91451
|
+
|
|
91429
91452
|
/**
|
|
91430
|
-
*
|
|
91431
|
-
* @param {TouchEvent|MouseEvent} event
|
|
91453
|
+
* Current time in seconds
|
|
91432
91454
|
* @returns {number}
|
|
91433
91455
|
*/
|
|
91434
|
-
function
|
|
91435
|
-
|
|
91436
|
-
|
|
91437
|
-
|
|
91438
|
-
if (event instanceof MouseEvent) {
|
|
91439
|
-
|
|
91440
|
-
// mouse
|
|
91441
|
-
|
|
91442
|
-
device_id = 1;
|
|
91443
|
-
source_id = event.button;
|
|
91444
|
-
|
|
91445
|
-
} else if (event instanceof TouchEvent) {
|
|
91446
|
-
|
|
91447
|
-
// touch
|
|
91448
|
-
|
|
91449
|
-
device_id = 2;
|
|
91450
|
-
const touches = event.changedTouches;
|
|
91451
|
-
const num_changes = touches.length;
|
|
91452
|
-
|
|
91453
|
-
if (num_changes > 0) {
|
|
91454
|
-
const touch = touches.item(0);
|
|
91455
|
-
|
|
91456
|
-
source_id = touch.identifier;
|
|
91457
|
-
}
|
|
91458
|
-
|
|
91459
|
-
}
|
|
91460
|
-
|
|
91461
|
-
return ((device_id & 0b11) << 29)
|
|
91462
|
-
| (source_id & 0b11111111111111111111111111111)
|
|
91463
|
-
;
|
|
91456
|
+
function current_time_in_seconds() {
|
|
91457
|
+
// time source produces value in milliseconds, we need to scale to seconds
|
|
91458
|
+
return source.now() * 1e-3;
|
|
91464
91459
|
}
|
|
91465
91460
|
|
|
91466
91461
|
/**
|
|
@@ -91483,20 +91478,28 @@ const MouseEvents = {
|
|
|
91483
91478
|
};
|
|
91484
91479
|
|
|
91485
91480
|
/**
|
|
91486
|
-
*
|
|
91487
|
-
* useful for .addEventListener and .removeEventListener
|
|
91488
|
-
* @readonly
|
|
91481
|
+
*
|
|
91489
91482
|
* @enum {string}
|
|
91490
91483
|
*/
|
|
91491
|
-
const
|
|
91492
|
-
|
|
91493
|
-
|
|
91494
|
-
Move: "
|
|
91495
|
-
|
|
91484
|
+
const PointerEvents = {
|
|
91485
|
+
Up: "pointerup",
|
|
91486
|
+
Down: "pointerdown",
|
|
91487
|
+
Move: "pointermove",
|
|
91488
|
+
Over: "pointerover",
|
|
91489
|
+
Out: "pointerout",
|
|
91490
|
+
Enter: "pointerenter",
|
|
91491
|
+
Leave: "pointerleave",
|
|
91492
|
+
Cancel: "pointercancel",
|
|
91493
|
+
GotCapture: "gotpointercapture",
|
|
91494
|
+
LostCapture: "lostpointercapture"
|
|
91496
91495
|
};
|
|
91497
91496
|
|
|
91498
91497
|
class LocationalInteractionMetadata {
|
|
91499
|
-
|
|
91498
|
+
/**
|
|
91499
|
+
* In seconds
|
|
91500
|
+
* @type {number}
|
|
91501
|
+
*/
|
|
91502
|
+
timestamp = current_time_in_seconds()
|
|
91500
91503
|
position = new Vector2()
|
|
91501
91504
|
|
|
91502
91505
|
/**
|
|
@@ -91512,99 +91515,35 @@ class LocationalInteractionMetadata {
|
|
|
91512
91515
|
}
|
|
91513
91516
|
}
|
|
91514
91517
|
|
|
91515
|
-
/**
|
|
91516
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
|
|
91517
|
-
* @see https://w3c.github.io/uievents/#widl-MouseEvent-buttons
|
|
91518
|
-
*
|
|
91519
|
-
* @param {Number} value
|
|
91520
|
-
* @return {boolean[]} array of booleans, boolean is true if mouse button is pressed, false otherwise
|
|
91521
|
-
*/
|
|
91522
|
-
function decodeMouseEventButtons(value) {
|
|
91523
|
-
const result = [];
|
|
91524
|
-
|
|
91525
|
-
for (let i = 0; i < 32; i++) {
|
|
91526
|
-
|
|
91527
|
-
const shiftedValue = value >> i;
|
|
91528
|
-
|
|
91529
|
-
result[i] = (shiftedValue & 1) !== 0;
|
|
91530
|
-
}
|
|
91531
|
-
|
|
91532
|
-
return result;
|
|
91533
|
-
}
|
|
91534
|
-
|
|
91535
91518
|
/**
|
|
91536
91519
|
* Prevent default context menu from showing up
|
|
91537
91520
|
* @param {Event} event
|
|
91521
|
+
* @returns {boolean}
|
|
91538
91522
|
*/
|
|
91539
|
-
function
|
|
91523
|
+
function suppressContextMenu(event) {
|
|
91540
91524
|
event.preventDefault();
|
|
91541
91525
|
event.stopPropagation();
|
|
91542
91526
|
|
|
91543
91527
|
return false;
|
|
91544
|
-
}
|
|
91545
|
-
|
|
91546
|
-
/**
|
|
91547
|
-
*
|
|
91548
|
-
* @param {TouchList} touchList
|
|
91549
|
-
* @param {function(Touch,number)} callback
|
|
91550
|
-
*/
|
|
91551
|
-
function forEachTouch(touchList, callback) {
|
|
91552
|
-
const length = touchList.length;
|
|
91553
|
-
for (let i = 0; i < length; i++) {
|
|
91554
|
-
const touch = touchList.item(i);
|
|
91555
|
-
callback(touch, i);
|
|
91556
|
-
}
|
|
91557
|
-
}
|
|
91558
|
-
|
|
91559
|
-
/**
|
|
91560
|
-
*
|
|
91561
|
-
* @param {TouchList} touchList
|
|
91562
|
-
* @param {Vector2} result
|
|
91563
|
-
*/
|
|
91564
|
-
function getTouchCenter(touchList, result) {
|
|
91565
|
-
const length = touchList.length;
|
|
91566
|
-
|
|
91567
|
-
let x = 0, y = 0;
|
|
91568
|
-
|
|
91569
|
-
if (length > 0) {
|
|
91570
|
-
|
|
91571
|
-
for (let i = 0; i < length; i++) {
|
|
91572
|
-
const touch = touchList.item(i);
|
|
91573
|
-
|
|
91574
|
-
if (touch === null) {
|
|
91575
|
-
continue;
|
|
91576
|
-
}
|
|
91577
|
-
|
|
91578
|
-
x += touch.clientX;
|
|
91579
|
-
y += touch.clientY;
|
|
91580
|
-
}
|
|
91581
|
-
|
|
91582
|
-
// average to get center
|
|
91583
|
-
x /= length;
|
|
91584
|
-
y /= length;
|
|
91585
|
-
|
|
91586
|
-
}
|
|
91587
|
-
|
|
91588
|
-
result.set(x, y);
|
|
91589
|
-
|
|
91590
|
-
}
|
|
91591
|
-
|
|
91592
|
-
|
|
91528
|
+
}
|
|
91529
|
+
|
|
91593
91530
|
/**
|
|
91594
91531
|
*
|
|
91595
91532
|
* @param {Signal} up
|
|
91596
91533
|
* @param {Signal} down
|
|
91597
91534
|
* @param {Signal} move
|
|
91598
|
-
* @param {number} maxDistance
|
|
91535
|
+
* @param {number} [maxDistance] in pixels
|
|
91536
|
+
* @param {number} [maxDelay] Maximum delay between down and up events in seconds
|
|
91599
91537
|
* @param {Signal} signal
|
|
91600
91538
|
*/
|
|
91601
|
-
function observeTap(
|
|
91602
|
-
|
|
91603
|
-
|
|
91604
|
-
|
|
91605
|
-
|
|
91606
|
-
|
|
91607
|
-
|
|
91539
|
+
function observeTap({
|
|
91540
|
+
up,
|
|
91541
|
+
down,
|
|
91542
|
+
move = new Signal(),
|
|
91543
|
+
maxDistance = 10,
|
|
91544
|
+
maxDelay = 1,
|
|
91545
|
+
signal
|
|
91546
|
+
}) {
|
|
91608
91547
|
|
|
91609
91548
|
/**
|
|
91610
91549
|
*
|
|
@@ -91618,7 +91557,8 @@ function observeTap(
|
|
|
91618
91557
|
*/
|
|
91619
91558
|
function reset(id) {
|
|
91620
91559
|
|
|
91621
|
-
|
|
91560
|
+
const deleted = active.delete(id);
|
|
91561
|
+
if (deleted) {
|
|
91622
91562
|
up.remove(handleUp);
|
|
91623
91563
|
move.remove(handleMove);
|
|
91624
91564
|
}
|
|
@@ -91627,10 +91567,10 @@ function observeTap(
|
|
|
91627
91567
|
/**
|
|
91628
91568
|
*
|
|
91629
91569
|
* @param {Vector2} position
|
|
91630
|
-
* @param {
|
|
91570
|
+
* @param {PointerEvent} event
|
|
91631
91571
|
*/
|
|
91632
91572
|
function handleUp(position, event) {
|
|
91633
|
-
const id =
|
|
91573
|
+
const id = event.pointerId;
|
|
91634
91574
|
|
|
91635
91575
|
const meta = active.get(id);
|
|
91636
91576
|
|
|
@@ -91641,16 +91581,25 @@ function observeTap(
|
|
|
91641
91581
|
|
|
91642
91582
|
reset(id);
|
|
91643
91583
|
|
|
91584
|
+
const time_now = current_time_in_seconds();
|
|
91585
|
+
|
|
91586
|
+
const delay = time_now - meta.timestamp;
|
|
91587
|
+
|
|
91588
|
+
if (delay > maxDelay) {
|
|
91589
|
+
// too much time has passed, swallow event
|
|
91590
|
+
return;
|
|
91591
|
+
}
|
|
91592
|
+
|
|
91644
91593
|
signal.send2(position, event);
|
|
91645
91594
|
}
|
|
91646
91595
|
|
|
91647
91596
|
/**
|
|
91648
91597
|
*
|
|
91649
91598
|
* @param {Vector2} position
|
|
91650
|
-
* @param {
|
|
91599
|
+
* @param {PointerEvent} event
|
|
91651
91600
|
*/
|
|
91652
91601
|
function handleMove(position, event) {
|
|
91653
|
-
const id =
|
|
91602
|
+
const id = event.pointerId;
|
|
91654
91603
|
|
|
91655
91604
|
const meta = active.get(id);
|
|
91656
91605
|
|
|
@@ -91672,10 +91621,10 @@ function observeTap(
|
|
|
91672
91621
|
/**
|
|
91673
91622
|
*
|
|
91674
91623
|
* @param {Vector2} position
|
|
91675
|
-
* @param {
|
|
91624
|
+
* @param {PointerEvent} event
|
|
91676
91625
|
*/
|
|
91677
91626
|
function handleDown(position, event) {
|
|
91678
|
-
const id =
|
|
91627
|
+
const id = event.pointerId;
|
|
91679
91628
|
|
|
91680
91629
|
// make sure to cancel previous pending resolution
|
|
91681
91630
|
reset(id);
|
|
@@ -91691,119 +91640,6 @@ function observeTap(
|
|
|
91691
91640
|
down.add(handleDown);
|
|
91692
91641
|
}
|
|
91693
91642
|
|
|
91694
|
-
/**
|
|
91695
|
-
*
|
|
91696
|
-
* @param {Signal} touchStart
|
|
91697
|
-
* @param {Signal} touchEnd
|
|
91698
|
-
* @param {Signal} touchMove
|
|
91699
|
-
* @param {Signal} pinch
|
|
91700
|
-
* @param {Signal} pinchStart
|
|
91701
|
-
* @param {Signal} pinchEnd
|
|
91702
|
-
* @param {PointerDevice} device
|
|
91703
|
-
*/
|
|
91704
|
-
function observePinch({
|
|
91705
|
-
touchStart,
|
|
91706
|
-
touchEnd,
|
|
91707
|
-
touchMove,
|
|
91708
|
-
pinch,
|
|
91709
|
-
pinchStart,
|
|
91710
|
-
pinchEnd,
|
|
91711
|
-
device
|
|
91712
|
-
}) {
|
|
91713
|
-
const center = new Vector2();
|
|
91714
|
-
|
|
91715
|
-
const v2 = new Vector2();
|
|
91716
|
-
|
|
91717
|
-
const pinchBox0 = new Vector2();
|
|
91718
|
-
const pinchBox1 = new Vector2();
|
|
91719
|
-
|
|
91720
|
-
let pinchActive = false;
|
|
91721
|
-
let touchCount = 0;
|
|
91722
|
-
|
|
91723
|
-
|
|
91724
|
-
/**
|
|
91725
|
-
*
|
|
91726
|
-
* @param {TouchList} touchList
|
|
91727
|
-
* @param {Vector2} pinchDimensions
|
|
91728
|
-
*/
|
|
91729
|
-
function computeTouchRadius(touchList, pinchDimensions) {
|
|
91730
|
-
getTouchCenter(touchList, center);
|
|
91731
|
-
|
|
91732
|
-
const length = touchList.length;
|
|
91733
|
-
|
|
91734
|
-
pinchDimensions.set(0, 0);
|
|
91735
|
-
|
|
91736
|
-
for (let i = 0; i < length; i++) {
|
|
91737
|
-
const touch = touchList.item(i);
|
|
91738
|
-
|
|
91739
|
-
device.readPointerPositionFromEvent(v2, touch);
|
|
91740
|
-
|
|
91741
|
-
v2.sub(center);
|
|
91742
|
-
v2.abs();
|
|
91743
|
-
|
|
91744
|
-
pinchDimensions.add(v2);
|
|
91745
|
-
}
|
|
91746
|
-
|
|
91747
|
-
return pinchDimensions.multiplyScalar(1 / length);
|
|
91748
|
-
}
|
|
91749
|
-
|
|
91750
|
-
function touchRemoved(touch, event) {
|
|
91751
|
-
touchCount--;
|
|
91752
|
-
if (touchCount < 2 && pinchActive) {
|
|
91753
|
-
handlePinchEnd();
|
|
91754
|
-
}
|
|
91755
|
-
}
|
|
91756
|
-
|
|
91757
|
-
function touchAdded(touch, event) {
|
|
91758
|
-
touchCount++;
|
|
91759
|
-
if (touchCount > 1 && !pinchActive) {
|
|
91760
|
-
handlePinchStart(event);
|
|
91761
|
-
}
|
|
91762
|
-
}
|
|
91763
|
-
|
|
91764
|
-
function handlePinchStart(event) {
|
|
91765
|
-
pinchActive = true;
|
|
91766
|
-
|
|
91767
|
-
computeTouchRadius(event.touches, pinchBox0);
|
|
91768
|
-
|
|
91769
|
-
touchMove.add(handleMove);
|
|
91770
|
-
|
|
91771
|
-
pinchStart.send1(pinchBox0);
|
|
91772
|
-
}
|
|
91773
|
-
|
|
91774
|
-
/**
|
|
91775
|
-
*
|
|
91776
|
-
* @param {TouchEvent} event
|
|
91777
|
-
*/
|
|
91778
|
-
function handlePinchEnd(event) {
|
|
91779
|
-
pinchActive = false;
|
|
91780
|
-
|
|
91781
|
-
touchMove.remove(handleMove);
|
|
91782
|
-
|
|
91783
|
-
pinchEnd.send0();
|
|
91784
|
-
}
|
|
91785
|
-
|
|
91786
|
-
function handleDown(position, event) {
|
|
91787
|
-
forEachTouch(event.changedTouches, function (touch) {
|
|
91788
|
-
touchAdded(touch, event);
|
|
91789
|
-
});
|
|
91790
|
-
}
|
|
91791
|
-
|
|
91792
|
-
function handleUp(position, event) {
|
|
91793
|
-
forEachTouch(event.changedTouches, function (touch) {
|
|
91794
|
-
touchRemoved();
|
|
91795
|
-
});
|
|
91796
|
-
}
|
|
91797
|
-
|
|
91798
|
-
function handleMove(position, event) {
|
|
91799
|
-
computeTouchRadius(event.touches, pinchBox1);
|
|
91800
|
-
pinch.send2(pinchBox1, pinchBox0);
|
|
91801
|
-
}
|
|
91802
|
-
|
|
91803
|
-
touchEnd.add(handleUp);
|
|
91804
|
-
touchStart.add(handleDown);
|
|
91805
|
-
}
|
|
91806
|
-
|
|
91807
91643
|
/**
|
|
91808
91644
|
*
|
|
91809
91645
|
* @param {Signal} up
|
|
@@ -91895,18 +91731,8 @@ class PointerDevice {
|
|
|
91895
91731
|
*/
|
|
91896
91732
|
position = new Vector2();
|
|
91897
91733
|
|
|
91898
|
-
/**
|
|
91899
|
-
* @readonly
|
|
91900
|
-
* @type {Vector2}
|
|
91901
|
-
*/
|
|
91902
|
-
#anchor_touch_last = new Vector2();
|
|
91903
|
-
|
|
91904
91734
|
#globalUp = new Signal();
|
|
91905
91735
|
|
|
91906
|
-
#touchStart = new Signal();
|
|
91907
|
-
#touchEnd = new Signal();
|
|
91908
|
-
#touchMove = new Signal();
|
|
91909
|
-
|
|
91910
91736
|
/**
|
|
91911
91737
|
* @readonly
|
|
91912
91738
|
*/
|
|
@@ -91996,41 +91822,18 @@ class PointerDevice {
|
|
|
91996
91822
|
this.#domElement = domElement;
|
|
91997
91823
|
|
|
91998
91824
|
|
|
91999
|
-
this.#touchStart.add(this.on.down.send3, this.on.down);
|
|
92000
|
-
|
|
92001
|
-
this.#touchEnd.add(this.on.up.send3, this.on.up);
|
|
92002
|
-
|
|
92003
|
-
this.#touchMove.add(this.on.move.send3, this.on.move);
|
|
92004
|
-
|
|
92005
91825
|
//constructed events
|
|
92006
|
-
observeTap(this.on.up, this.on.down, this.on.move, 10, this.on.tap);
|
|
91826
|
+
observeTap({ up: this.on.up, down: this.on.down, move: this.on.move, maxDistance: 10, signal: this.on.tap });
|
|
92007
91827
|
observeDrag(this.#globalUp, this.on.down, this.on.move, this.on.dragStart, this.on.dragEnd, this.on.drag);
|
|
92008
|
-
observePinch({
|
|
92009
|
-
touchStart: this.#touchStart,
|
|
92010
|
-
touchEnd: this.#touchEnd,
|
|
92011
|
-
touchMove: this.#touchMove,
|
|
92012
|
-
pinch: this.on.pinch,
|
|
92013
|
-
pinchStart: this.on.pinchStart,
|
|
92014
|
-
pinchEnd: this.on.pinchEnd,
|
|
92015
|
-
device: this
|
|
92016
|
-
});
|
|
92017
|
-
}
|
|
92018
|
-
|
|
92019
91828
|
|
|
92020
|
-
/**
|
|
92021
|
-
*
|
|
92022
|
-
* @param {TouchEvent} event
|
|
92023
|
-
*/
|
|
92024
|
-
#eventHandlerGlobalTouchEnd = (event) => {
|
|
92025
|
-
getTouchCenter(event.touches, this.position);
|
|
92026
|
-
this.#globalUp.send2(this.position, event);
|
|
92027
91829
|
}
|
|
92028
91830
|
|
|
91831
|
+
|
|
92029
91832
|
/**
|
|
92030
91833
|
*
|
|
92031
|
-
* @param {
|
|
91834
|
+
* @param {PointerEvent} event
|
|
92032
91835
|
*/
|
|
92033
|
-
#
|
|
91836
|
+
#eventHandlerPointerDown = (event) => {
|
|
92034
91837
|
this.readPointerPositionFromEvent(this.position, event);
|
|
92035
91838
|
this.on.down.send2(this.position, event);
|
|
92036
91839
|
|
|
@@ -92044,9 +91847,9 @@ class PointerDevice {
|
|
|
92044
91847
|
|
|
92045
91848
|
/**
|
|
92046
91849
|
*
|
|
92047
|
-
* @param {
|
|
91850
|
+
* @param {PointerEvent} event
|
|
92048
91851
|
*/
|
|
92049
|
-
#
|
|
91852
|
+
#eventHandlerPointerUp = (event) => {
|
|
92050
91853
|
this.readPointerPositionFromEvent(this.position, event);
|
|
92051
91854
|
this.on.up.send2(this.position, event);
|
|
92052
91855
|
}
|
|
@@ -92055,7 +91858,7 @@ class PointerDevice {
|
|
|
92055
91858
|
*
|
|
92056
91859
|
* @param {MouseEvent} event
|
|
92057
91860
|
*/
|
|
92058
|
-
#
|
|
91861
|
+
#eventHandlerGlobalPointerUp = (event) => {
|
|
92059
91862
|
this.readPointerPositionFromEvent(this.position, event);
|
|
92060
91863
|
this.#globalUp.send2(this.position, event);
|
|
92061
91864
|
|
|
@@ -92067,32 +91870,6 @@ class PointerDevice {
|
|
|
92067
91870
|
button?.release();
|
|
92068
91871
|
}
|
|
92069
91872
|
|
|
92070
|
-
/**
|
|
92071
|
-
*
|
|
92072
|
-
* @param {TouchEvent} event
|
|
92073
|
-
*/
|
|
92074
|
-
#eventHandlerTouchEnd = (event) => {
|
|
92075
|
-
getTouchCenter(event.touches, this.position);
|
|
92076
|
-
this.#touchEnd.send2(this.position, event);
|
|
92077
|
-
}
|
|
92078
|
-
|
|
92079
|
-
/**
|
|
92080
|
-
*
|
|
92081
|
-
* @param {TouchEvent} event
|
|
92082
|
-
*/
|
|
92083
|
-
#eventHandlerTouchMove = (event) => {
|
|
92084
|
-
event.preventDefault();
|
|
92085
|
-
|
|
92086
|
-
getTouchCenter(event.touches, this.position);
|
|
92087
|
-
|
|
92088
|
-
const delta = new Vector2();
|
|
92089
|
-
|
|
92090
|
-
delta.subVectors(this.position, this.#anchor_touch_last);
|
|
92091
|
-
|
|
92092
|
-
this.#touchMove.send3(this.position, event, delta);
|
|
92093
|
-
|
|
92094
|
-
this.#anchor_touch_last.copy(this.position);
|
|
92095
|
-
}
|
|
92096
91873
|
|
|
92097
91874
|
/**
|
|
92098
91875
|
*
|
|
@@ -92116,20 +91893,9 @@ class PointerDevice {
|
|
|
92116
91893
|
|
|
92117
91894
|
/**
|
|
92118
91895
|
*
|
|
92119
|
-
* @param {
|
|
92120
|
-
*/
|
|
92121
|
-
#eventHandlerTouchStart = (event) => {
|
|
92122
|
-
getTouchCenter(event.touches, this.position);
|
|
92123
|
-
this.#touchStart.send2(this.position, event);
|
|
92124
|
-
|
|
92125
|
-
this.#anchor_touch_last.copy(this.position);
|
|
92126
|
-
}
|
|
92127
|
-
|
|
92128
|
-
/**
|
|
92129
|
-
*
|
|
92130
|
-
* @param {MouseEvent} event
|
|
91896
|
+
* @param {PointerEvent} event
|
|
92131
91897
|
*/
|
|
92132
|
-
#
|
|
91898
|
+
#eventHandlerPointerMove = (event) => {
|
|
92133
91899
|
event.preventDefault();
|
|
92134
91900
|
|
|
92135
91901
|
this.#target = event.target;
|
|
@@ -92198,16 +91964,11 @@ class PointerDevice {
|
|
|
92198
91964
|
|
|
92199
91965
|
const domElement = this.#domElement;
|
|
92200
91966
|
|
|
92201
|
-
domElement.addEventListener(
|
|
92202
|
-
domElement.addEventListener(
|
|
92203
|
-
domElement.addEventListener(
|
|
92204
|
-
|
|
92205
|
-
domElement.addEventListener(TouchEvents.Start, this.#eventHandlerTouchStart);
|
|
92206
|
-
domElement.addEventListener(TouchEvents.End, this.#eventHandlerTouchEnd);
|
|
92207
|
-
domElement.addEventListener(TouchEvents.Move, this.#eventHandlerTouchMove);
|
|
91967
|
+
domElement.addEventListener(PointerEvents.Move, this.#eventHandlerPointerMove);
|
|
91968
|
+
domElement.addEventListener(PointerEvents.Up, this.#eventHandlerPointerUp);
|
|
91969
|
+
domElement.addEventListener(PointerEvents.Down, this.#eventHandlerPointerDown);
|
|
92208
91970
|
|
|
92209
|
-
window.addEventListener(
|
|
92210
|
-
window.addEventListener(TouchEvents.End, this.#eventHandlerGlobalTouchEnd);
|
|
91971
|
+
window.addEventListener(PointerEvents.Up, this.#eventHandlerGlobalPointerUp);
|
|
92211
91972
|
|
|
92212
91973
|
/*
|
|
92213
91974
|
In some cases wheel event gets registered as "passive" by default. This interferes with "preventDefault()"
|
|
@@ -92216,7 +91977,7 @@ class PointerDevice {
|
|
|
92216
91977
|
domElement.addEventListener(MouseEvents.Wheel, this.#eventHandlerWheel, { passive: false });
|
|
92217
91978
|
|
|
92218
91979
|
|
|
92219
|
-
domElement.addEventListener("contextmenu",
|
|
91980
|
+
domElement.addEventListener("contextmenu", suppressContextMenu);
|
|
92220
91981
|
}
|
|
92221
91982
|
|
|
92222
91983
|
stop() {
|
|
@@ -92231,21 +91992,16 @@ class PointerDevice {
|
|
|
92231
91992
|
|
|
92232
91993
|
const domElement = this.domElement;
|
|
92233
91994
|
|
|
92234
|
-
domElement.removeEventListener(
|
|
92235
|
-
domElement.removeEventListener(
|
|
92236
|
-
domElement.removeEventListener(
|
|
92237
|
-
|
|
92238
|
-
domElement.removeEventListener(TouchEvents.Start, this.#eventHandlerTouchStart);
|
|
92239
|
-
domElement.removeEventListener(TouchEvents.End, this.#eventHandlerTouchEnd);
|
|
92240
|
-
domElement.removeEventListener(TouchEvents.Move, this.#eventHandlerTouchMove);
|
|
91995
|
+
domElement.removeEventListener(PointerEvents.Move, this.#eventHandlerPointerMove);
|
|
91996
|
+
domElement.removeEventListener(PointerEvents.Up, this.#eventHandlerPointerUp);
|
|
91997
|
+
domElement.removeEventListener(PointerEvents.Down, this.#eventHandlerPointerDown);
|
|
92241
91998
|
|
|
92242
|
-
window.removeEventListener(
|
|
92243
|
-
window.removeEventListener(TouchEvents.End, this.#eventHandlerGlobalTouchEnd);
|
|
91999
|
+
window.removeEventListener(PointerEvents.Up, this.#eventHandlerGlobalPointerUp);
|
|
92244
92000
|
|
|
92245
92001
|
domElement.removeEventListener(MouseEvents.Wheel, this.#eventHandlerWheel);
|
|
92246
92002
|
|
|
92247
92003
|
|
|
92248
|
-
domElement.removeEventListener("contextmenu",
|
|
92004
|
+
domElement.removeEventListener("contextmenu", suppressContextMenu);
|
|
92249
92005
|
}
|
|
92250
92006
|
}
|
|
92251
92007
|
|
|
@@ -96704,18 +96460,6 @@ Stat.Process = {
|
|
|
96704
96460
|
*/
|
|
96705
96461
|
Stat.prototype.isStat = true;
|
|
96706
96462
|
|
|
96707
|
-
//Use highest available resolution time source
|
|
96708
|
-
const source = typeof performance === "undefined" ? Date : performance;
|
|
96709
|
-
|
|
96710
|
-
/**
|
|
96711
|
-
* Current time in seconds
|
|
96712
|
-
* @returns {number}
|
|
96713
|
-
*/
|
|
96714
|
-
function current_time_in_seconds() {
|
|
96715
|
-
// time source produces value in milliseconds, we need to scale to seconds
|
|
96716
|
-
return source.now() * 1e-3;
|
|
96717
|
-
}
|
|
96718
|
-
|
|
96719
96463
|
/**
|
|
96720
96464
|
*
|
|
96721
96465
|
* @param {Clock} clock
|
|
@@ -105379,6 +105123,95 @@ class EngineConfiguration {
|
|
|
105379
105123
|
}
|
|
105380
105124
|
}
|
|
105381
105125
|
|
|
105126
|
+
/**
|
|
105127
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
|
|
105128
|
+
* @see https://w3c.github.io/uievents/#widl-MouseEvent-buttons
|
|
105129
|
+
*
|
|
105130
|
+
* @param {Number} value
|
|
105131
|
+
* @param {boolean[]} [result]
|
|
105132
|
+
* @return {boolean[]} array of booleans, boolean is true if mouse button is pressed, false otherwise
|
|
105133
|
+
*/
|
|
105134
|
+
function decodeMouseEventButtons(value, result = []) {
|
|
105135
|
+
|
|
105136
|
+
for (let i = 0; i < 32; i++) {
|
|
105137
|
+
|
|
105138
|
+
const shiftedValue = value >> i;
|
|
105139
|
+
|
|
105140
|
+
result[i] = (shiftedValue & 1) !== 0;
|
|
105141
|
+
}
|
|
105142
|
+
|
|
105143
|
+
return result;
|
|
105144
|
+
}
|
|
105145
|
+
|
|
105146
|
+
class InputBinding {
|
|
105147
|
+
/**
|
|
105148
|
+
*
|
|
105149
|
+
* @param {string} path
|
|
105150
|
+
* @param {function} listener
|
|
105151
|
+
* @param {boolean} [exclusive=false]
|
|
105152
|
+
*/
|
|
105153
|
+
constructor({ path, listener, exclusive = false }) {
|
|
105154
|
+
|
|
105155
|
+
/**
|
|
105156
|
+
*
|
|
105157
|
+
* @type {string}
|
|
105158
|
+
*/
|
|
105159
|
+
this.path = path;
|
|
105160
|
+
/**
|
|
105161
|
+
*
|
|
105162
|
+
* @type {Function}
|
|
105163
|
+
*/
|
|
105164
|
+
this.listener = listener;
|
|
105165
|
+
/**
|
|
105166
|
+
* @deprecated don't use
|
|
105167
|
+
* @type {boolean}
|
|
105168
|
+
*/
|
|
105169
|
+
this.exclusive = exclusive;
|
|
105170
|
+
}
|
|
105171
|
+
}
|
|
105172
|
+
|
|
105173
|
+
class InputController {
|
|
105174
|
+
/**
|
|
105175
|
+
*
|
|
105176
|
+
* @param {Array} bindings
|
|
105177
|
+
* @constructor
|
|
105178
|
+
*/
|
|
105179
|
+
constructor(bindings = []) {
|
|
105180
|
+
|
|
105181
|
+
this.mapping = new List();
|
|
105182
|
+
|
|
105183
|
+
const inputControllerBindings = bindings.map(b => new InputBinding(b));
|
|
105184
|
+
|
|
105185
|
+
this.mapping.addAll(inputControllerBindings);
|
|
105186
|
+
|
|
105187
|
+
this.on = {
|
|
105188
|
+
unlinked: new Signal()
|
|
105189
|
+
};
|
|
105190
|
+
}
|
|
105191
|
+
|
|
105192
|
+
/**
|
|
105193
|
+
*
|
|
105194
|
+
* @param {Array} bindings
|
|
105195
|
+
*/
|
|
105196
|
+
static from(bindings) {
|
|
105197
|
+
const ic = new InputController();
|
|
105198
|
+
|
|
105199
|
+
const n = bindings.length;
|
|
105200
|
+
for (let i = 0; i < n; i++) {
|
|
105201
|
+
const binding = bindings[i];
|
|
105202
|
+
|
|
105203
|
+
const inputBinding = new InputBinding(binding);
|
|
105204
|
+
|
|
105205
|
+
ic.mapping.add(inputBinding);
|
|
105206
|
+
}
|
|
105207
|
+
|
|
105208
|
+
return ic;
|
|
105209
|
+
}
|
|
105210
|
+
}
|
|
105211
|
+
|
|
105212
|
+
InputController.typeName = "InputController";
|
|
105213
|
+
InputController.serializable = false;
|
|
105214
|
+
|
|
105382
105215
|
/**
|
|
105383
105216
|
*
|
|
105384
105217
|
* @param {number[]} mat4
|
|
@@ -105769,75 +105602,6 @@ TopDownCameraController.typeName = "TopDownCameraController";
|
|
|
105769
105602
|
TopDownCameraController.pan = pan;
|
|
105770
105603
|
TopDownCameraController.rotate = rotate_from_view;
|
|
105771
105604
|
|
|
105772
|
-
class InputBinding {
|
|
105773
|
-
/**
|
|
105774
|
-
*
|
|
105775
|
-
* @param {string} path
|
|
105776
|
-
* @param {function} listener
|
|
105777
|
-
* @param {boolean} [exclusive=false]
|
|
105778
|
-
*/
|
|
105779
|
-
constructor({ path, listener, exclusive = false }) {
|
|
105780
|
-
|
|
105781
|
-
/**
|
|
105782
|
-
*
|
|
105783
|
-
* @type {string}
|
|
105784
|
-
*/
|
|
105785
|
-
this.path = path;
|
|
105786
|
-
/**
|
|
105787
|
-
*
|
|
105788
|
-
* @type {Function}
|
|
105789
|
-
*/
|
|
105790
|
-
this.listener = listener;
|
|
105791
|
-
/**
|
|
105792
|
-
* @deprecated don't use
|
|
105793
|
-
* @type {boolean}
|
|
105794
|
-
*/
|
|
105795
|
-
this.exclusive = exclusive;
|
|
105796
|
-
}
|
|
105797
|
-
}
|
|
105798
|
-
|
|
105799
|
-
class InputController {
|
|
105800
|
-
/**
|
|
105801
|
-
*
|
|
105802
|
-
* @param {Array} bindings
|
|
105803
|
-
* @constructor
|
|
105804
|
-
*/
|
|
105805
|
-
constructor(bindings = []) {
|
|
105806
|
-
|
|
105807
|
-
this.mapping = new List();
|
|
105808
|
-
|
|
105809
|
-
const inputControllerBindings = bindings.map(b => new InputBinding(b));
|
|
105810
|
-
|
|
105811
|
-
this.mapping.addAll(inputControllerBindings);
|
|
105812
|
-
|
|
105813
|
-
this.on = {
|
|
105814
|
-
unlinked: new Signal()
|
|
105815
|
-
};
|
|
105816
|
-
}
|
|
105817
|
-
|
|
105818
|
-
/**
|
|
105819
|
-
*
|
|
105820
|
-
* @param {Array} bindings
|
|
105821
|
-
*/
|
|
105822
|
-
static from(bindings) {
|
|
105823
|
-
const ic = new InputController();
|
|
105824
|
-
|
|
105825
|
-
const n = bindings.length;
|
|
105826
|
-
for (let i = 0; i < n; i++) {
|
|
105827
|
-
const binding = bindings[i];
|
|
105828
|
-
|
|
105829
|
-
const inputBinding = new InputBinding(binding);
|
|
105830
|
-
|
|
105831
|
-
ic.mapping.add(inputBinding);
|
|
105832
|
-
}
|
|
105833
|
-
|
|
105834
|
-
return ic;
|
|
105835
|
-
}
|
|
105836
|
-
}
|
|
105837
|
-
|
|
105838
|
-
InputController.typeName = "InputController";
|
|
105839
|
-
InputController.serializable = false;
|
|
105840
|
-
|
|
105841
105605
|
/**
|
|
105842
105606
|
*
|
|
105843
105607
|
* @param {number} camera_entity
|