@woosh/meep-engine 2.109.26 → 2.110.1

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 (40) hide show
  1. package/build/meep.cjs +207 -436
  2. package/build/meep.min.js +1 -1
  3. package/build/meep.module.js +207 -436
  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/core/process/executor/ConcurrentExecutor.d.ts.map +1 -1
  12. package/src/core/process/executor/ConcurrentExecutor.js +11 -2
  13. package/src/engine/graphics/camera/makeOrbitalCameraController.d.ts.map +1 -1
  14. package/src/engine/graphics/camera/makeOrbitalCameraController.js +4 -4
  15. package/src/engine/graphics/geometry/VertexDataSpec.d.ts.map +1 -1
  16. package/src/engine/graphics/geometry/VertexDataSpec.js +4 -7
  17. package/src/engine/input/devices/LocationalInteractionMetadata.d.ts +4 -0
  18. package/src/engine/input/devices/LocationalInteractionMetadata.d.ts.map +1 -1
  19. package/src/engine/input/devices/LocationalInteractionMetadata.js +6 -1
  20. package/src/engine/input/devices/PointerDevice.d.ts +0 -3
  21. package/src/engine/input/devices/PointerDevice.d.ts.map +1 -1
  22. package/src/engine/input/devices/PointerDevice.js +49 -306
  23. package/src/engine/input/devices/events/PointerEvents.d.ts +14 -0
  24. package/src/engine/input/devices/events/PointerEvents.d.ts.map +1 -0
  25. package/src/engine/input/devices/events/PointerEvents.js +16 -0
  26. package/src/engine/input/devices/mouse/decodeMouseEventButtons.d.ts +10 -0
  27. package/src/engine/input/devices/mouse/decodeMouseEventButtons.d.ts.map +1 -0
  28. package/src/engine/input/devices/mouse/decodeMouseEventButtons.js +19 -0
  29. package/src/engine/input/devices/mouse/suppressContextMenu.d.ts +7 -0
  30. package/src/engine/input/devices/mouse/suppressContextMenu.d.ts.map +1 -0
  31. package/src/engine/input/devices/mouse/suppressContextMenu.js +11 -0
  32. package/src/engine/input/devices/touch/TouchDevice.d.ts +20 -0
  33. package/src/engine/input/devices/touch/TouchDevice.d.ts.map +1 -0
  34. package/src/engine/input/devices/touch/TouchDevice.js +95 -0
  35. package/src/engine/input/devices/touch/getTouchCenter.d.ts +7 -0
  36. package/src/engine/input/devices/touch/getTouchCenter.d.ts.map +1 -0
  37. package/src/engine/input/devices/touch/getTouchCenter.js +32 -0
  38. package/src/engine/input/devices/touch/observePinch.d.ts +12 -0
  39. package/src/engine/input/devices/touch/observePinch.d.ts.map +1 -0
  40. 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 !== oldMin || max !== oldMax) {
54481
- this.min = min;
54482
- this.max = max;
54484
+ if (min === oldMin && max === oldMax) {
54485
+ return;
54486
+ }
54483
54487
 
54484
- if (this.onChanged.hasHandlers()) {
54485
- this.onChanged.send4(min, max, oldMin, oldMax);
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.one_one = Object.freeze(new NumericInterval(1, 1));
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.zero_zero = Object.freeze(new NumericInterval(0, 0));
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:{ first=${this.first}, second=${this.second}, direction=${objectKeyByValue(EdgeDirectionType, this.direction)} }`
71706
+ return `Edge{ first=${this.first}, second=${this.second}, direction=${objectKeyByValue(EdgeDirectionType, this.direction)} }`
71687
71707
  }
71688
71708
 
71689
71709
  }
@@ -84103,6 +84123,8 @@ class ConcurrentExecutor {
84103
84123
  task.state.set(TaskState.FAILED);
84104
84124
  task.on.failed.send1(reason);
84105
84125
 
84126
+ if (!task.on.failed.hasHandlers()) ;
84127
+
84106
84128
  this.resolveTasks();
84107
84129
 
84108
84130
  this.on.task_completed.send1(task);
@@ -84190,7 +84212,12 @@ class ConcurrentExecutor {
84190
84212
  try {
84191
84213
  executionTime = this.#runTaskForTimeMonitored(task, sliceTimeLeft);
84192
84214
  } catch (e) {
84193
- this.#fail_task(task, e);
84215
+ const error = new Error("Task threw an exception");
84216
+
84217
+ error.cause = e;
84218
+
84219
+ // console.error(`Task threw an exception`, task, e);
84220
+ this.#fail_task(task, error);
84194
84221
  }
84195
84222
 
84196
84223
  this.#cycle_count++;
@@ -91426,41 +91453,16 @@ class KeyboardDevice {
91426
91453
  }
91427
91454
  }
91428
91455
 
91456
+ //Use highest available resolution time source
91457
+ const source = typeof performance === "undefined" ? Date : performance;
91458
+
91429
91459
  /**
91430
- *
91431
- * @param {TouchEvent|MouseEvent} event
91460
+ * Current time in seconds
91432
91461
  * @returns {number}
91433
91462
  */
91434
- function eventToSourceIdentifier(event) {
91435
- let device_id = 0;
91436
- let source_id = 0;
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
- ;
91463
+ function current_time_in_seconds() {
91464
+ // time source produces value in milliseconds, we need to scale to seconds
91465
+ return source.now() * 1e-3;
91464
91466
  }
91465
91467
 
91466
91468
  /**
@@ -91483,20 +91485,28 @@ const MouseEvents = {
91483
91485
  };
91484
91486
 
91485
91487
  /**
91486
- * Event names for DOM {@link EventTarget} related to touch.
91487
- * useful for .addEventListener and .removeEventListener
91488
- * @readonly
91488
+ *
91489
91489
  * @enum {string}
91490
91490
  */
91491
- const TouchEvents = {
91492
- Start: "touchstart",
91493
- End: "touchend",
91494
- Move: "touchmove",
91495
- Cancel: "touchcancel",
91491
+ const PointerEvents = {
91492
+ Up: "pointerup",
91493
+ Down: "pointerdown",
91494
+ Move: "pointermove",
91495
+ Over: "pointerover",
91496
+ Out: "pointerout",
91497
+ Enter: "pointerenter",
91498
+ Leave: "pointerleave",
91499
+ Cancel: "pointercancel",
91500
+ GotCapture: "gotpointercapture",
91501
+ LostCapture: "lostpointercapture"
91496
91502
  };
91497
91503
 
91498
91504
  class LocationalInteractionMetadata {
91499
- timestamp = performance.now()
91505
+ /**
91506
+ * In seconds
91507
+ * @type {number}
91508
+ */
91509
+ timestamp = current_time_in_seconds()
91500
91510
  position = new Vector2()
91501
91511
 
91502
91512
  /**
@@ -91512,99 +91522,35 @@ class LocationalInteractionMetadata {
91512
91522
  }
91513
91523
  }
91514
91524
 
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
91525
  /**
91536
91526
  * Prevent default context menu from showing up
91537
91527
  * @param {Event} event
91528
+ * @returns {boolean}
91538
91529
  */
91539
- function supressContextMenu(event) {
91530
+ function suppressContextMenu(event) {
91540
91531
  event.preventDefault();
91541
91532
  event.stopPropagation();
91542
91533
 
91543
91534
  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
-
91535
+ }
91536
+
91593
91537
  /**
91594
91538
  *
91595
91539
  * @param {Signal} up
91596
91540
  * @param {Signal} down
91597
91541
  * @param {Signal} move
91598
- * @param {number} maxDistance
91542
+ * @param {number} [maxDistance] in pixels
91543
+ * @param {number} [maxDelay] Maximum delay between down and up events in seconds
91599
91544
  * @param {Signal} signal
91600
91545
  */
91601
- function observeTap(
91602
- up,
91603
- down,
91604
- move,
91605
- maxDistance,
91606
- signal
91607
- ) {
91546
+ function observeTap({
91547
+ up,
91548
+ down,
91549
+ move = new Signal(),
91550
+ maxDistance = 10,
91551
+ maxDelay = 1,
91552
+ signal
91553
+ }) {
91608
91554
 
91609
91555
  /**
91610
91556
  *
@@ -91618,7 +91564,8 @@ function observeTap(
91618
91564
  */
91619
91565
  function reset(id) {
91620
91566
 
91621
- if (active.delete(id)) {
91567
+ const deleted = active.delete(id);
91568
+ if (deleted) {
91622
91569
  up.remove(handleUp);
91623
91570
  move.remove(handleMove);
91624
91571
  }
@@ -91627,10 +91574,10 @@ function observeTap(
91627
91574
  /**
91628
91575
  *
91629
91576
  * @param {Vector2} position
91630
- * @param {MouseEvent|TouchEvent} event
91577
+ * @param {PointerEvent} event
91631
91578
  */
91632
91579
  function handleUp(position, event) {
91633
- const id = eventToSourceIdentifier(event);
91580
+ const id = event.pointerId;
91634
91581
 
91635
91582
  const meta = active.get(id);
91636
91583
 
@@ -91641,16 +91588,25 @@ function observeTap(
91641
91588
 
91642
91589
  reset(id);
91643
91590
 
91591
+ const time_now = current_time_in_seconds();
91592
+
91593
+ const delay = time_now - meta.timestamp;
91594
+
91595
+ if (delay > maxDelay) {
91596
+ // too much time has passed, swallow event
91597
+ return;
91598
+ }
91599
+
91644
91600
  signal.send2(position, event);
91645
91601
  }
91646
91602
 
91647
91603
  /**
91648
91604
  *
91649
91605
  * @param {Vector2} position
91650
- * @param {MouseEvent|TouchEvent} event
91606
+ * @param {PointerEvent} event
91651
91607
  */
91652
91608
  function handleMove(position, event) {
91653
- const id = eventToSourceIdentifier(event);
91609
+ const id = event.pointerId;
91654
91610
 
91655
91611
  const meta = active.get(id);
91656
91612
 
@@ -91672,10 +91628,10 @@ function observeTap(
91672
91628
  /**
91673
91629
  *
91674
91630
  * @param {Vector2} position
91675
- * @param {TouchEvent|MouseEvent} event
91631
+ * @param {PointerEvent} event
91676
91632
  */
91677
91633
  function handleDown(position, event) {
91678
- const id = eventToSourceIdentifier(event);
91634
+ const id = event.pointerId;
91679
91635
 
91680
91636
  // make sure to cancel previous pending resolution
91681
91637
  reset(id);
@@ -91691,119 +91647,6 @@ function observeTap(
91691
91647
  down.add(handleDown);
91692
91648
  }
91693
91649
 
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
91650
  /**
91808
91651
  *
91809
91652
  * @param {Signal} up
@@ -91895,18 +91738,8 @@ class PointerDevice {
91895
91738
  */
91896
91739
  position = new Vector2();
91897
91740
 
91898
- /**
91899
- * @readonly
91900
- * @type {Vector2}
91901
- */
91902
- #anchor_touch_last = new Vector2();
91903
-
91904
91741
  #globalUp = new Signal();
91905
91742
 
91906
- #touchStart = new Signal();
91907
- #touchEnd = new Signal();
91908
- #touchMove = new Signal();
91909
-
91910
91743
  /**
91911
91744
  * @readonly
91912
91745
  */
@@ -91996,41 +91829,18 @@ class PointerDevice {
91996
91829
  this.#domElement = domElement;
91997
91830
 
91998
91831
 
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
91832
  //constructed events
92006
- observeTap(this.on.up, this.on.down, this.on.move, 10, this.on.tap);
91833
+ observeTap({ up: this.on.up, down: this.on.down, move: this.on.move, maxDistance: 10, signal: this.on.tap });
92007
91834
  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
91835
 
92020
- /**
92021
- *
92022
- * @param {TouchEvent} event
92023
- */
92024
- #eventHandlerGlobalTouchEnd = (event) => {
92025
- getTouchCenter(event.touches, this.position);
92026
- this.#globalUp.send2(this.position, event);
92027
91836
  }
92028
91837
 
91838
+
92029
91839
  /**
92030
91840
  *
92031
- * @param {MouseEvent} event
91841
+ * @param {PointerEvent} event
92032
91842
  */
92033
- #eventHandlerMouseDown = (event) => {
91843
+ #eventHandlerPointerDown = (event) => {
92034
91844
  this.readPointerPositionFromEvent(this.position, event);
92035
91845
  this.on.down.send2(this.position, event);
92036
91846
 
@@ -92044,9 +91854,9 @@ class PointerDevice {
92044
91854
 
92045
91855
  /**
92046
91856
  *
92047
- * @param {MouseEvent} event
91857
+ * @param {PointerEvent} event
92048
91858
  */
92049
- #eventHandlerMouseUp = (event) => {
91859
+ #eventHandlerPointerUp = (event) => {
92050
91860
  this.readPointerPositionFromEvent(this.position, event);
92051
91861
  this.on.up.send2(this.position, event);
92052
91862
  }
@@ -92055,7 +91865,7 @@ class PointerDevice {
92055
91865
  *
92056
91866
  * @param {MouseEvent} event
92057
91867
  */
92058
- #eventHandlerGlobalMouseUp = (event) => {
91868
+ #eventHandlerGlobalPointerUp = (event) => {
92059
91869
  this.readPointerPositionFromEvent(this.position, event);
92060
91870
  this.#globalUp.send2(this.position, event);
92061
91871
 
@@ -92067,32 +91877,6 @@ class PointerDevice {
92067
91877
  button?.release();
92068
91878
  }
92069
91879
 
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
91880
 
92097
91881
  /**
92098
91882
  *
@@ -92116,20 +91900,9 @@ class PointerDevice {
92116
91900
 
92117
91901
  /**
92118
91902
  *
92119
- * @param {TouchEvent} event
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
91903
+ * @param {PointerEvent} event
92131
91904
  */
92132
- #eventHandlerMouseMove = (event) => {
91905
+ #eventHandlerPointerMove = (event) => {
92133
91906
  event.preventDefault();
92134
91907
 
92135
91908
  this.#target = event.target;
@@ -92198,16 +91971,11 @@ class PointerDevice {
92198
91971
 
92199
91972
  const domElement = this.#domElement;
92200
91973
 
92201
- domElement.addEventListener(MouseEvents.Move, this.#eventHandlerMouseMove);
92202
- domElement.addEventListener(MouseEvents.Up, this.#eventHandlerMouseUp);
92203
- domElement.addEventListener(MouseEvents.Down, this.#eventHandlerMouseDown);
91974
+ domElement.addEventListener(PointerEvents.Move, this.#eventHandlerPointerMove);
91975
+ domElement.addEventListener(PointerEvents.Up, this.#eventHandlerPointerUp);
91976
+ domElement.addEventListener(PointerEvents.Down, this.#eventHandlerPointerDown);
92204
91977
 
92205
- domElement.addEventListener(TouchEvents.Start, this.#eventHandlerTouchStart);
92206
- domElement.addEventListener(TouchEvents.End, this.#eventHandlerTouchEnd);
92207
- domElement.addEventListener(TouchEvents.Move, this.#eventHandlerTouchMove);
92208
-
92209
- window.addEventListener(MouseEvents.Up, this.#eventHandlerGlobalMouseUp);
92210
- window.addEventListener(TouchEvents.End, this.#eventHandlerGlobalTouchEnd);
91978
+ window.addEventListener(PointerEvents.Up, this.#eventHandlerGlobalPointerUp);
92211
91979
 
92212
91980
  /*
92213
91981
  In some cases wheel event gets registered as "passive" by default. This interferes with "preventDefault()"
@@ -92216,7 +91984,7 @@ class PointerDevice {
92216
91984
  domElement.addEventListener(MouseEvents.Wheel, this.#eventHandlerWheel, { passive: false });
92217
91985
 
92218
91986
 
92219
- domElement.addEventListener("contextmenu", supressContextMenu);
91987
+ domElement.addEventListener("contextmenu", suppressContextMenu);
92220
91988
  }
92221
91989
 
92222
91990
  stop() {
@@ -92231,21 +91999,16 @@ class PointerDevice {
92231
91999
 
92232
92000
  const domElement = this.domElement;
92233
92001
 
92234
- domElement.removeEventListener(MouseEvents.Move, this.#eventHandlerMouseMove);
92235
- domElement.removeEventListener(MouseEvents.Up, this.#eventHandlerMouseUp);
92236
- domElement.removeEventListener(MouseEvents.Down, this.#eventHandlerMouseDown);
92237
-
92238
- domElement.removeEventListener(TouchEvents.Start, this.#eventHandlerTouchStart);
92239
- domElement.removeEventListener(TouchEvents.End, this.#eventHandlerTouchEnd);
92240
- domElement.removeEventListener(TouchEvents.Move, this.#eventHandlerTouchMove);
92002
+ domElement.removeEventListener(PointerEvents.Move, this.#eventHandlerPointerMove);
92003
+ domElement.removeEventListener(PointerEvents.Up, this.#eventHandlerPointerUp);
92004
+ domElement.removeEventListener(PointerEvents.Down, this.#eventHandlerPointerDown);
92241
92005
 
92242
- window.removeEventListener(MouseEvents.Up, this.#eventHandlerGlobalMouseUp);
92243
- window.removeEventListener(TouchEvents.End, this.#eventHandlerGlobalTouchEnd);
92006
+ window.removeEventListener(PointerEvents.Up, this.#eventHandlerGlobalPointerUp);
92244
92007
 
92245
92008
  domElement.removeEventListener(MouseEvents.Wheel, this.#eventHandlerWheel);
92246
92009
 
92247
92010
 
92248
- domElement.removeEventListener("contextmenu", supressContextMenu);
92011
+ domElement.removeEventListener("contextmenu", suppressContextMenu);
92249
92012
  }
92250
92013
  }
92251
92014
 
@@ -96704,18 +96467,6 @@ Stat.Process = {
96704
96467
  */
96705
96468
  Stat.prototype.isStat = true;
96706
96469
 
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
96470
  /**
96720
96471
  *
96721
96472
  * @param {Clock} clock
@@ -105379,6 +105130,95 @@ class EngineConfiguration {
105379
105130
  }
105380
105131
  }
105381
105132
 
105133
+ /**
105134
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
105135
+ * @see https://w3c.github.io/uievents/#widl-MouseEvent-buttons
105136
+ *
105137
+ * @param {Number} value
105138
+ * @param {boolean[]} [result]
105139
+ * @return {boolean[]} array of booleans, boolean is true if mouse button is pressed, false otherwise
105140
+ */
105141
+ function decodeMouseEventButtons(value, result = []) {
105142
+
105143
+ for (let i = 0; i < 32; i++) {
105144
+
105145
+ const shiftedValue = value >> i;
105146
+
105147
+ result[i] = (shiftedValue & 1) !== 0;
105148
+ }
105149
+
105150
+ return result;
105151
+ }
105152
+
105153
+ class InputBinding {
105154
+ /**
105155
+ *
105156
+ * @param {string} path
105157
+ * @param {function} listener
105158
+ * @param {boolean} [exclusive=false]
105159
+ */
105160
+ constructor({ path, listener, exclusive = false }) {
105161
+
105162
+ /**
105163
+ *
105164
+ * @type {string}
105165
+ */
105166
+ this.path = path;
105167
+ /**
105168
+ *
105169
+ * @type {Function}
105170
+ */
105171
+ this.listener = listener;
105172
+ /**
105173
+ * @deprecated don't use
105174
+ * @type {boolean}
105175
+ */
105176
+ this.exclusive = exclusive;
105177
+ }
105178
+ }
105179
+
105180
+ class InputController {
105181
+ /**
105182
+ *
105183
+ * @param {Array} bindings
105184
+ * @constructor
105185
+ */
105186
+ constructor(bindings = []) {
105187
+
105188
+ this.mapping = new List();
105189
+
105190
+ const inputControllerBindings = bindings.map(b => new InputBinding(b));
105191
+
105192
+ this.mapping.addAll(inputControllerBindings);
105193
+
105194
+ this.on = {
105195
+ unlinked: new Signal()
105196
+ };
105197
+ }
105198
+
105199
+ /**
105200
+ *
105201
+ * @param {Array} bindings
105202
+ */
105203
+ static from(bindings) {
105204
+ const ic = new InputController();
105205
+
105206
+ const n = bindings.length;
105207
+ for (let i = 0; i < n; i++) {
105208
+ const binding = bindings[i];
105209
+
105210
+ const inputBinding = new InputBinding(binding);
105211
+
105212
+ ic.mapping.add(inputBinding);
105213
+ }
105214
+
105215
+ return ic;
105216
+ }
105217
+ }
105218
+
105219
+ InputController.typeName = "InputController";
105220
+ InputController.serializable = false;
105221
+
105382
105222
  /**
105383
105223
  *
105384
105224
  * @param {number[]} mat4
@@ -105769,75 +105609,6 @@ TopDownCameraController.typeName = "TopDownCameraController";
105769
105609
  TopDownCameraController.pan = pan;
105770
105610
  TopDownCameraController.rotate = rotate_from_view;
105771
105611
 
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
105612
  /**
105842
105613
  *
105843
105614
  * @param {number} camera_entity