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