@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.
- package/build/meep.cjs +207 -436
- package/build/meep.min.js +1 -1
- package/build/meep.module.js +207 -436
- 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/core/process/executor/ConcurrentExecutor.d.ts.map +1 -1
- package/src/core/process/executor/ConcurrentExecutor.js +11 -2
- 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.module.js
CHANGED
|
@@ -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
|
|
54479
|
-
|
|
54480
|
-
|
|
54482
|
+
if (min === oldMin && max === oldMax) {
|
|
54483
|
+
return;
|
|
54484
|
+
}
|
|
54481
54485
|
|
|
54482
|
-
|
|
54483
|
-
|
|
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.
|
|
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.
|
|
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
|
|
71704
|
+
return `Edge{ first=${this.first}, second=${this.second}, direction=${objectKeyByValue(EdgeDirectionType, this.direction)} }`
|
|
71685
71705
|
}
|
|
71686
71706
|
|
|
71687
71707
|
}
|
|
@@ -84101,6 +84121,8 @@ class ConcurrentExecutor {
|
|
|
84101
84121
|
task.state.set(TaskState.FAILED);
|
|
84102
84122
|
task.on.failed.send1(reason);
|
|
84103
84123
|
|
|
84124
|
+
if (!task.on.failed.hasHandlers()) ;
|
|
84125
|
+
|
|
84104
84126
|
this.resolveTasks();
|
|
84105
84127
|
|
|
84106
84128
|
this.on.task_completed.send1(task);
|
|
@@ -84188,7 +84210,12 @@ class ConcurrentExecutor {
|
|
|
84188
84210
|
try {
|
|
84189
84211
|
executionTime = this.#runTaskForTimeMonitored(task, sliceTimeLeft);
|
|
84190
84212
|
} catch (e) {
|
|
84191
|
-
|
|
84213
|
+
const error = new Error("Task threw an exception");
|
|
84214
|
+
|
|
84215
|
+
error.cause = e;
|
|
84216
|
+
|
|
84217
|
+
// console.error(`Task threw an exception`, task, e);
|
|
84218
|
+
this.#fail_task(task, error);
|
|
84192
84219
|
}
|
|
84193
84220
|
|
|
84194
84221
|
this.#cycle_count++;
|
|
@@ -91424,41 +91451,16 @@ class KeyboardDevice {
|
|
|
91424
91451
|
}
|
|
91425
91452
|
}
|
|
91426
91453
|
|
|
91454
|
+
//Use highest available resolution time source
|
|
91455
|
+
const source = typeof performance === "undefined" ? Date : performance;
|
|
91456
|
+
|
|
91427
91457
|
/**
|
|
91428
|
-
*
|
|
91429
|
-
* @param {TouchEvent|MouseEvent} event
|
|
91458
|
+
* Current time in seconds
|
|
91430
91459
|
* @returns {number}
|
|
91431
91460
|
*/
|
|
91432
|
-
function
|
|
91433
|
-
|
|
91434
|
-
|
|
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
|
-
;
|
|
91461
|
+
function current_time_in_seconds() {
|
|
91462
|
+
// time source produces value in milliseconds, we need to scale to seconds
|
|
91463
|
+
return source.now() * 1e-3;
|
|
91462
91464
|
}
|
|
91463
91465
|
|
|
91464
91466
|
/**
|
|
@@ -91481,20 +91483,28 @@ const MouseEvents = {
|
|
|
91481
91483
|
};
|
|
91482
91484
|
|
|
91483
91485
|
/**
|
|
91484
|
-
*
|
|
91485
|
-
* useful for .addEventListener and .removeEventListener
|
|
91486
|
-
* @readonly
|
|
91486
|
+
*
|
|
91487
91487
|
* @enum {string}
|
|
91488
91488
|
*/
|
|
91489
|
-
const
|
|
91490
|
-
|
|
91491
|
-
|
|
91492
|
-
Move: "
|
|
91493
|
-
|
|
91489
|
+
const PointerEvents = {
|
|
91490
|
+
Up: "pointerup",
|
|
91491
|
+
Down: "pointerdown",
|
|
91492
|
+
Move: "pointermove",
|
|
91493
|
+
Over: "pointerover",
|
|
91494
|
+
Out: "pointerout",
|
|
91495
|
+
Enter: "pointerenter",
|
|
91496
|
+
Leave: "pointerleave",
|
|
91497
|
+
Cancel: "pointercancel",
|
|
91498
|
+
GotCapture: "gotpointercapture",
|
|
91499
|
+
LostCapture: "lostpointercapture"
|
|
91494
91500
|
};
|
|
91495
91501
|
|
|
91496
91502
|
class LocationalInteractionMetadata {
|
|
91497
|
-
|
|
91503
|
+
/**
|
|
91504
|
+
* In seconds
|
|
91505
|
+
* @type {number}
|
|
91506
|
+
*/
|
|
91507
|
+
timestamp = current_time_in_seconds()
|
|
91498
91508
|
position = new Vector2()
|
|
91499
91509
|
|
|
91500
91510
|
/**
|
|
@@ -91510,99 +91520,35 @@ class LocationalInteractionMetadata {
|
|
|
91510
91520
|
}
|
|
91511
91521
|
}
|
|
91512
91522
|
|
|
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
91523
|
/**
|
|
91534
91524
|
* Prevent default context menu from showing up
|
|
91535
91525
|
* @param {Event} event
|
|
91526
|
+
* @returns {boolean}
|
|
91536
91527
|
*/
|
|
91537
|
-
function
|
|
91528
|
+
function suppressContextMenu(event) {
|
|
91538
91529
|
event.preventDefault();
|
|
91539
91530
|
event.stopPropagation();
|
|
91540
91531
|
|
|
91541
91532
|
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
|
-
|
|
91533
|
+
}
|
|
91534
|
+
|
|
91591
91535
|
/**
|
|
91592
91536
|
*
|
|
91593
91537
|
* @param {Signal} up
|
|
91594
91538
|
* @param {Signal} down
|
|
91595
91539
|
* @param {Signal} move
|
|
91596
|
-
* @param {number} maxDistance
|
|
91540
|
+
* @param {number} [maxDistance] in pixels
|
|
91541
|
+
* @param {number} [maxDelay] Maximum delay between down and up events in seconds
|
|
91597
91542
|
* @param {Signal} signal
|
|
91598
91543
|
*/
|
|
91599
|
-
function observeTap(
|
|
91600
|
-
|
|
91601
|
-
|
|
91602
|
-
|
|
91603
|
-
|
|
91604
|
-
|
|
91605
|
-
|
|
91544
|
+
function observeTap({
|
|
91545
|
+
up,
|
|
91546
|
+
down,
|
|
91547
|
+
move = new Signal(),
|
|
91548
|
+
maxDistance = 10,
|
|
91549
|
+
maxDelay = 1,
|
|
91550
|
+
signal
|
|
91551
|
+
}) {
|
|
91606
91552
|
|
|
91607
91553
|
/**
|
|
91608
91554
|
*
|
|
@@ -91616,7 +91562,8 @@ function observeTap(
|
|
|
91616
91562
|
*/
|
|
91617
91563
|
function reset(id) {
|
|
91618
91564
|
|
|
91619
|
-
|
|
91565
|
+
const deleted = active.delete(id);
|
|
91566
|
+
if (deleted) {
|
|
91620
91567
|
up.remove(handleUp);
|
|
91621
91568
|
move.remove(handleMove);
|
|
91622
91569
|
}
|
|
@@ -91625,10 +91572,10 @@ function observeTap(
|
|
|
91625
91572
|
/**
|
|
91626
91573
|
*
|
|
91627
91574
|
* @param {Vector2} position
|
|
91628
|
-
* @param {
|
|
91575
|
+
* @param {PointerEvent} event
|
|
91629
91576
|
*/
|
|
91630
91577
|
function handleUp(position, event) {
|
|
91631
|
-
const id =
|
|
91578
|
+
const id = event.pointerId;
|
|
91632
91579
|
|
|
91633
91580
|
const meta = active.get(id);
|
|
91634
91581
|
|
|
@@ -91639,16 +91586,25 @@ function observeTap(
|
|
|
91639
91586
|
|
|
91640
91587
|
reset(id);
|
|
91641
91588
|
|
|
91589
|
+
const time_now = current_time_in_seconds();
|
|
91590
|
+
|
|
91591
|
+
const delay = time_now - meta.timestamp;
|
|
91592
|
+
|
|
91593
|
+
if (delay > maxDelay) {
|
|
91594
|
+
// too much time has passed, swallow event
|
|
91595
|
+
return;
|
|
91596
|
+
}
|
|
91597
|
+
|
|
91642
91598
|
signal.send2(position, event);
|
|
91643
91599
|
}
|
|
91644
91600
|
|
|
91645
91601
|
/**
|
|
91646
91602
|
*
|
|
91647
91603
|
* @param {Vector2} position
|
|
91648
|
-
* @param {
|
|
91604
|
+
* @param {PointerEvent} event
|
|
91649
91605
|
*/
|
|
91650
91606
|
function handleMove(position, event) {
|
|
91651
|
-
const id =
|
|
91607
|
+
const id = event.pointerId;
|
|
91652
91608
|
|
|
91653
91609
|
const meta = active.get(id);
|
|
91654
91610
|
|
|
@@ -91670,10 +91626,10 @@ function observeTap(
|
|
|
91670
91626
|
/**
|
|
91671
91627
|
*
|
|
91672
91628
|
* @param {Vector2} position
|
|
91673
|
-
* @param {
|
|
91629
|
+
* @param {PointerEvent} event
|
|
91674
91630
|
*/
|
|
91675
91631
|
function handleDown(position, event) {
|
|
91676
|
-
const id =
|
|
91632
|
+
const id = event.pointerId;
|
|
91677
91633
|
|
|
91678
91634
|
// make sure to cancel previous pending resolution
|
|
91679
91635
|
reset(id);
|
|
@@ -91689,119 +91645,6 @@ function observeTap(
|
|
|
91689
91645
|
down.add(handleDown);
|
|
91690
91646
|
}
|
|
91691
91647
|
|
|
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
91648
|
/**
|
|
91806
91649
|
*
|
|
91807
91650
|
* @param {Signal} up
|
|
@@ -91893,18 +91736,8 @@ class PointerDevice {
|
|
|
91893
91736
|
*/
|
|
91894
91737
|
position = new Vector2();
|
|
91895
91738
|
|
|
91896
|
-
/**
|
|
91897
|
-
* @readonly
|
|
91898
|
-
* @type {Vector2}
|
|
91899
|
-
*/
|
|
91900
|
-
#anchor_touch_last = new Vector2();
|
|
91901
|
-
|
|
91902
91739
|
#globalUp = new Signal();
|
|
91903
91740
|
|
|
91904
|
-
#touchStart = new Signal();
|
|
91905
|
-
#touchEnd = new Signal();
|
|
91906
|
-
#touchMove = new Signal();
|
|
91907
|
-
|
|
91908
91741
|
/**
|
|
91909
91742
|
* @readonly
|
|
91910
91743
|
*/
|
|
@@ -91994,41 +91827,18 @@ class PointerDevice {
|
|
|
91994
91827
|
this.#domElement = domElement;
|
|
91995
91828
|
|
|
91996
91829
|
|
|
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
91830
|
//constructed events
|
|
92004
|
-
observeTap(this.on.up, this.on.down, this.on.move, 10, this.on.tap);
|
|
91831
|
+
observeTap({ up: this.on.up, down: this.on.down, move: this.on.move, maxDistance: 10, signal: this.on.tap });
|
|
92005
91832
|
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
91833
|
|
|
92018
|
-
/**
|
|
92019
|
-
*
|
|
92020
|
-
* @param {TouchEvent} event
|
|
92021
|
-
*/
|
|
92022
|
-
#eventHandlerGlobalTouchEnd = (event) => {
|
|
92023
|
-
getTouchCenter(event.touches, this.position);
|
|
92024
|
-
this.#globalUp.send2(this.position, event);
|
|
92025
91834
|
}
|
|
92026
91835
|
|
|
91836
|
+
|
|
92027
91837
|
/**
|
|
92028
91838
|
*
|
|
92029
|
-
* @param {
|
|
91839
|
+
* @param {PointerEvent} event
|
|
92030
91840
|
*/
|
|
92031
|
-
#
|
|
91841
|
+
#eventHandlerPointerDown = (event) => {
|
|
92032
91842
|
this.readPointerPositionFromEvent(this.position, event);
|
|
92033
91843
|
this.on.down.send2(this.position, event);
|
|
92034
91844
|
|
|
@@ -92042,9 +91852,9 @@ class PointerDevice {
|
|
|
92042
91852
|
|
|
92043
91853
|
/**
|
|
92044
91854
|
*
|
|
92045
|
-
* @param {
|
|
91855
|
+
* @param {PointerEvent} event
|
|
92046
91856
|
*/
|
|
92047
|
-
#
|
|
91857
|
+
#eventHandlerPointerUp = (event) => {
|
|
92048
91858
|
this.readPointerPositionFromEvent(this.position, event);
|
|
92049
91859
|
this.on.up.send2(this.position, event);
|
|
92050
91860
|
}
|
|
@@ -92053,7 +91863,7 @@ class PointerDevice {
|
|
|
92053
91863
|
*
|
|
92054
91864
|
* @param {MouseEvent} event
|
|
92055
91865
|
*/
|
|
92056
|
-
#
|
|
91866
|
+
#eventHandlerGlobalPointerUp = (event) => {
|
|
92057
91867
|
this.readPointerPositionFromEvent(this.position, event);
|
|
92058
91868
|
this.#globalUp.send2(this.position, event);
|
|
92059
91869
|
|
|
@@ -92065,32 +91875,6 @@ class PointerDevice {
|
|
|
92065
91875
|
button?.release();
|
|
92066
91876
|
}
|
|
92067
91877
|
|
|
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
91878
|
|
|
92095
91879
|
/**
|
|
92096
91880
|
*
|
|
@@ -92114,20 +91898,9 @@ class PointerDevice {
|
|
|
92114
91898
|
|
|
92115
91899
|
/**
|
|
92116
91900
|
*
|
|
92117
|
-
* @param {
|
|
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
|
|
91901
|
+
* @param {PointerEvent} event
|
|
92129
91902
|
*/
|
|
92130
|
-
#
|
|
91903
|
+
#eventHandlerPointerMove = (event) => {
|
|
92131
91904
|
event.preventDefault();
|
|
92132
91905
|
|
|
92133
91906
|
this.#target = event.target;
|
|
@@ -92196,16 +91969,11 @@ class PointerDevice {
|
|
|
92196
91969
|
|
|
92197
91970
|
const domElement = this.#domElement;
|
|
92198
91971
|
|
|
92199
|
-
domElement.addEventListener(
|
|
92200
|
-
domElement.addEventListener(
|
|
92201
|
-
domElement.addEventListener(
|
|
91972
|
+
domElement.addEventListener(PointerEvents.Move, this.#eventHandlerPointerMove);
|
|
91973
|
+
domElement.addEventListener(PointerEvents.Up, this.#eventHandlerPointerUp);
|
|
91974
|
+
domElement.addEventListener(PointerEvents.Down, this.#eventHandlerPointerDown);
|
|
92202
91975
|
|
|
92203
|
-
|
|
92204
|
-
domElement.addEventListener(TouchEvents.End, this.#eventHandlerTouchEnd);
|
|
92205
|
-
domElement.addEventListener(TouchEvents.Move, this.#eventHandlerTouchMove);
|
|
92206
|
-
|
|
92207
|
-
window.addEventListener(MouseEvents.Up, this.#eventHandlerGlobalMouseUp);
|
|
92208
|
-
window.addEventListener(TouchEvents.End, this.#eventHandlerGlobalTouchEnd);
|
|
91976
|
+
window.addEventListener(PointerEvents.Up, this.#eventHandlerGlobalPointerUp);
|
|
92209
91977
|
|
|
92210
91978
|
/*
|
|
92211
91979
|
In some cases wheel event gets registered as "passive" by default. This interferes with "preventDefault()"
|
|
@@ -92214,7 +91982,7 @@ class PointerDevice {
|
|
|
92214
91982
|
domElement.addEventListener(MouseEvents.Wheel, this.#eventHandlerWheel, { passive: false });
|
|
92215
91983
|
|
|
92216
91984
|
|
|
92217
|
-
domElement.addEventListener("contextmenu",
|
|
91985
|
+
domElement.addEventListener("contextmenu", suppressContextMenu);
|
|
92218
91986
|
}
|
|
92219
91987
|
|
|
92220
91988
|
stop() {
|
|
@@ -92229,21 +91997,16 @@ class PointerDevice {
|
|
|
92229
91997
|
|
|
92230
91998
|
const domElement = this.domElement;
|
|
92231
91999
|
|
|
92232
|
-
domElement.removeEventListener(
|
|
92233
|
-
domElement.removeEventListener(
|
|
92234
|
-
domElement.removeEventListener(
|
|
92235
|
-
|
|
92236
|
-
domElement.removeEventListener(TouchEvents.Start, this.#eventHandlerTouchStart);
|
|
92237
|
-
domElement.removeEventListener(TouchEvents.End, this.#eventHandlerTouchEnd);
|
|
92238
|
-
domElement.removeEventListener(TouchEvents.Move, this.#eventHandlerTouchMove);
|
|
92000
|
+
domElement.removeEventListener(PointerEvents.Move, this.#eventHandlerPointerMove);
|
|
92001
|
+
domElement.removeEventListener(PointerEvents.Up, this.#eventHandlerPointerUp);
|
|
92002
|
+
domElement.removeEventListener(PointerEvents.Down, this.#eventHandlerPointerDown);
|
|
92239
92003
|
|
|
92240
|
-
window.removeEventListener(
|
|
92241
|
-
window.removeEventListener(TouchEvents.End, this.#eventHandlerGlobalTouchEnd);
|
|
92004
|
+
window.removeEventListener(PointerEvents.Up, this.#eventHandlerGlobalPointerUp);
|
|
92242
92005
|
|
|
92243
92006
|
domElement.removeEventListener(MouseEvents.Wheel, this.#eventHandlerWheel);
|
|
92244
92007
|
|
|
92245
92008
|
|
|
92246
|
-
domElement.removeEventListener("contextmenu",
|
|
92009
|
+
domElement.removeEventListener("contextmenu", suppressContextMenu);
|
|
92247
92010
|
}
|
|
92248
92011
|
}
|
|
92249
92012
|
|
|
@@ -96702,18 +96465,6 @@ Stat.Process = {
|
|
|
96702
96465
|
*/
|
|
96703
96466
|
Stat.prototype.isStat = true;
|
|
96704
96467
|
|
|
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
96468
|
/**
|
|
96718
96469
|
*
|
|
96719
96470
|
* @param {Clock} clock
|
|
@@ -105377,6 +105128,95 @@ class EngineConfiguration {
|
|
|
105377
105128
|
}
|
|
105378
105129
|
}
|
|
105379
105130
|
|
|
105131
|
+
/**
|
|
105132
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
|
|
105133
|
+
* @see https://w3c.github.io/uievents/#widl-MouseEvent-buttons
|
|
105134
|
+
*
|
|
105135
|
+
* @param {Number} value
|
|
105136
|
+
* @param {boolean[]} [result]
|
|
105137
|
+
* @return {boolean[]} array of booleans, boolean is true if mouse button is pressed, false otherwise
|
|
105138
|
+
*/
|
|
105139
|
+
function decodeMouseEventButtons(value, result = []) {
|
|
105140
|
+
|
|
105141
|
+
for (let i = 0; i < 32; i++) {
|
|
105142
|
+
|
|
105143
|
+
const shiftedValue = value >> i;
|
|
105144
|
+
|
|
105145
|
+
result[i] = (shiftedValue & 1) !== 0;
|
|
105146
|
+
}
|
|
105147
|
+
|
|
105148
|
+
return result;
|
|
105149
|
+
}
|
|
105150
|
+
|
|
105151
|
+
class InputBinding {
|
|
105152
|
+
/**
|
|
105153
|
+
*
|
|
105154
|
+
* @param {string} path
|
|
105155
|
+
* @param {function} listener
|
|
105156
|
+
* @param {boolean} [exclusive=false]
|
|
105157
|
+
*/
|
|
105158
|
+
constructor({ path, listener, exclusive = false }) {
|
|
105159
|
+
|
|
105160
|
+
/**
|
|
105161
|
+
*
|
|
105162
|
+
* @type {string}
|
|
105163
|
+
*/
|
|
105164
|
+
this.path = path;
|
|
105165
|
+
/**
|
|
105166
|
+
*
|
|
105167
|
+
* @type {Function}
|
|
105168
|
+
*/
|
|
105169
|
+
this.listener = listener;
|
|
105170
|
+
/**
|
|
105171
|
+
* @deprecated don't use
|
|
105172
|
+
* @type {boolean}
|
|
105173
|
+
*/
|
|
105174
|
+
this.exclusive = exclusive;
|
|
105175
|
+
}
|
|
105176
|
+
}
|
|
105177
|
+
|
|
105178
|
+
class InputController {
|
|
105179
|
+
/**
|
|
105180
|
+
*
|
|
105181
|
+
* @param {Array} bindings
|
|
105182
|
+
* @constructor
|
|
105183
|
+
*/
|
|
105184
|
+
constructor(bindings = []) {
|
|
105185
|
+
|
|
105186
|
+
this.mapping = new List();
|
|
105187
|
+
|
|
105188
|
+
const inputControllerBindings = bindings.map(b => new InputBinding(b));
|
|
105189
|
+
|
|
105190
|
+
this.mapping.addAll(inputControllerBindings);
|
|
105191
|
+
|
|
105192
|
+
this.on = {
|
|
105193
|
+
unlinked: new Signal()
|
|
105194
|
+
};
|
|
105195
|
+
}
|
|
105196
|
+
|
|
105197
|
+
/**
|
|
105198
|
+
*
|
|
105199
|
+
* @param {Array} bindings
|
|
105200
|
+
*/
|
|
105201
|
+
static from(bindings) {
|
|
105202
|
+
const ic = new InputController();
|
|
105203
|
+
|
|
105204
|
+
const n = bindings.length;
|
|
105205
|
+
for (let i = 0; i < n; i++) {
|
|
105206
|
+
const binding = bindings[i];
|
|
105207
|
+
|
|
105208
|
+
const inputBinding = new InputBinding(binding);
|
|
105209
|
+
|
|
105210
|
+
ic.mapping.add(inputBinding);
|
|
105211
|
+
}
|
|
105212
|
+
|
|
105213
|
+
return ic;
|
|
105214
|
+
}
|
|
105215
|
+
}
|
|
105216
|
+
|
|
105217
|
+
InputController.typeName = "InputController";
|
|
105218
|
+
InputController.serializable = false;
|
|
105219
|
+
|
|
105380
105220
|
/**
|
|
105381
105221
|
*
|
|
105382
105222
|
* @param {number[]} mat4
|
|
@@ -105767,75 +105607,6 @@ TopDownCameraController.typeName = "TopDownCameraController";
|
|
|
105767
105607
|
TopDownCameraController.pan = pan;
|
|
105768
105608
|
TopDownCameraController.rotate = rotate_from_view;
|
|
105769
105609
|
|
|
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
105610
|
/**
|
|
105840
105611
|
*
|
|
105841
105612
|
* @param {number} camera_entity
|