@woosh/meep-engine 2.109.24 → 2.109.26
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 +248 -117
- package/build/meep.min.js +1 -1
- package/build/meep.module.js +248 -117
- package/package.json +1 -1
- package/src/core/collection/heap/{FastBinaryHeap.d.ts → BinaryHeap.d.ts} +16 -9
- package/src/core/collection/heap/BinaryHeap.d.ts.map +1 -0
- package/src/core/collection/heap/{FastBinaryHeap.js → BinaryHeap.js} +31 -21
- package/src/core/collection/heap/BinaryHeap.spec.d.ts +2 -0
- package/src/core/collection/heap/BinaryHeap.spec.d.ts.map +1 -0
- package/src/core/collection/heap/{FastBinaryHeap.spec.js → BinaryHeap.spec.js} +1 -1
- package/src/core/collection/heap/Uint32Heap.spec.d.ts +2 -0
- package/src/core/collection/heap/Uint32Heap.spec.d.ts.map +1 -0
- package/src/core/collection/table/RowFirstTable.d.ts +10 -7
- package/src/core/collection/table/RowFirstTable.d.ts.map +1 -1
- package/src/core/collection/table/RowFirstTable.js +23 -6
- package/src/core/geom/3d/normal/octahedron/encode_unit_to_octahedron.js +2 -2
- package/src/core/geom/3d/topology/simplify/simplifyTopoMesh.d.ts +1 -0
- package/src/core/geom/3d/topology/simplify/simplifyTopoMesh.d.ts.map +1 -1
- package/src/core/geom/3d/topology/simplify/simplifyTopoMesh.js +5 -5
- package/src/core/geom/3d/triangle/computeTriangleRayIntersectionBarycentricEdge.d.ts.map +1 -1
- package/src/core/geom/3d/triangle/computeTriangleRayIntersectionBarycentricEdge.js +14 -8
- package/src/core/geom/packing/max-rect/MaxRectanglesPacker.js +1 -1
- package/src/core/graph/Edge.d.ts +1 -0
- package/src/core/graph/Edge.d.ts.map +1 -1
- package/src/core/graph/Edge.js +5 -0
- package/src/core/graph/graph_compute_distance_matrix.js +2 -2
- package/src/core/graph/metis/cluster_mesh_metis.d.ts +9 -0
- package/src/core/graph/metis/cluster_mesh_metis.d.ts.map +1 -0
- package/src/core/graph/metis/cluster_mesh_metis.js +31 -0
- package/src/core/graph/metis/mesh_to_metis_graph.d.ts +10 -0
- package/src/core/graph/metis/mesh_to_metis_graph.d.ts.map +1 -0
- package/src/core/graph/metis/mesh_to_metis_graph.js +64 -0
- package/src/core/graph/metis/metis_cluster_bs.d.ts +12 -0
- package/src/core/graph/metis/metis_cluster_bs.d.ts.map +1 -0
- package/src/core/graph/{cluster_mesh_metis.js → metis/metis_cluster_bs.js} +12 -98
- package/src/core/graph/mn_graph_coarsen.d.ts.map +1 -1
- package/src/core/graph/mn_graph_coarsen.js +7 -3
- package/src/core/graph/mn_graph_coarsen.spec.js +2 -0
- package/src/engine/animation/async/TimeSeries.d.ts.map +1 -1
- package/src/engine/animation/async/TimeSeries.js +6 -2
- package/src/engine/animation/async/table_find_min_index_in_ordered_column.d.ts +9 -0
- package/src/engine/animation/async/table_find_min_index_in_ordered_column.d.ts.map +1 -0
- package/src/engine/animation/async/{findSampleIndex.js → table_find_min_index_in_ordered_column.js} +5 -4
- package/src/engine/asset/AssetManager.js +2 -2
- package/src/engine/graphics/sh3/gi/material/common.glsl +46 -55
- package/src/engine/graphics/sh3/gi/material/makeOctahedralDepthAtlas.d.ts.map +1 -1
- package/src/engine/graphics/sh3/gi/material/makeOctahedralDepthAtlas.js +5 -3
- package/src/engine/graphics/sh3/lpv/LightProbeVolume.js +1 -1
- package/src/engine/graphics/sh3/lpv/LightProbeVolumeBaker.js +1 -1
- package/src/engine/graphics/sh3/lpv/PathTracerProbeRenderer.d.ts.map +1 -1
- package/src/engine/graphics/sh3/lpv/PathTracerProbeRenderer.js +3 -2
- package/src/engine/graphics/sh3/lpv/depth/octahedral/bake_octahedral_depth_map.d.ts.map +1 -1
- package/src/engine/graphics/sh3/lpv/depth/octahedral/bake_octahedral_depth_map.js +19 -7
- package/src/engine/graphics/sh3/lpv/depth/octahedral/v2/visualise.frag.glsl +17 -15
- package/src/engine/graphics/sh3/lpv/probe_volume_to_textures.d.ts.map +1 -1
- package/src/engine/graphics/sh3/lpv/probe_volume_to_textures.js +6 -2
- package/src/engine/graphics/sh3/lpv/serialization/LightProbeVolumeSerializationAdapter.js +2 -2
- package/src/engine/graphics/sh3/path_tracer/PathTracedScene.d.ts.map +1 -1
- package/src/engine/graphics/sh3/path_tracer/PathTracedScene.js +10 -0
- package/src/engine/graphics/sh3/prototypeSH3Probe.js +3 -3
- package/src/engine/input/devices/InputDeviceSwitch.d.ts.map +1 -1
- package/src/engine/input/devices/InputDeviceSwitch.js +18 -0
- package/src/engine/input/devices/KeyboardDevice.d.ts.map +1 -1
- package/src/engine/input/devices/KeyboardDevice.js +4 -41
- package/src/engine/input/devices/LocationalInteractionMetadata.d.ts +11 -0
- package/src/engine/input/devices/LocationalInteractionMetadata.d.ts.map +1 -0
- package/src/engine/input/devices/LocationalInteractionMetadata.js +18 -0
- package/src/engine/input/devices/PointerDevice.d.ts.map +1 -1
- package/src/engine/input/devices/PointerDevice.js +90 -37
- package/src/engine/input/devices/events/eventToSourceIdentifier.d.ts +7 -0
- package/src/engine/input/devices/events/eventToSourceIdentifier.d.ts.map +1 -0
- package/src/engine/input/devices/events/eventToSourceIdentifier.js +36 -0
- package/src/engine/input/devices/isHTMLElementFocusable.d.ts +6 -0
- package/src/engine/input/devices/isHTMLElementFocusable.d.ts.map +1 -0
- package/src/engine/input/devices/isHTMLElementFocusable.js +34 -0
- package/src/engine/network/PriorityFetch.d.ts.map +1 -1
- package/src/engine/network/PriorityFetch.js +2 -2
- package/src/generation/grid/generation/discrete/GridTaskConnectRooms.js +1 -1
- package/src/generation/grid/generation/discrete/layer/GridTaskBuildSourceDistanceMap.d.ts.map +1 -1
- package/src/generation/grid/generation/discrete/layer/GridTaskBuildSourceDistanceMap.js +4 -4
- package/src/generation/grid/generation/discrete/layer/GridTaskDistanceToMarkers.d.ts.map +1 -1
- package/src/generation/grid/generation/discrete/layer/GridTaskDistanceToMarkers.js +2 -2
- package/src/generation/grid/generation/road/GridTaskGenerateRoads.js +1 -1
- package/src/core/collection/heap/FastBinaryHeap.d.ts.map +0 -1
- package/src/core/collection/heap/FastBinaryHeap.spec.d.ts +0 -2
- package/src/core/collection/heap/FastBinaryHeap.spec.d.ts.map +0 -1
- package/src/core/collection/heap/Uin32Heap.spec.d.ts +0 -2
- package/src/core/collection/heap/Uin32Heap.spec.d.ts.map +0 -1
- package/src/core/graph/cluster_mesh_metis.d.ts +0 -28
- package/src/core/graph/cluster_mesh_metis.d.ts.map +0 -1
- package/src/engine/animation/async/findSampleIndex.d.ts +0 -9
- package/src/engine/animation/async/findSampleIndex.d.ts.map +0 -1
- /package/src/core/collection/heap/{Uin32Heap.spec.js → Uint32Heap.spec.js} +0 -0
package/build/meep.cjs
CHANGED
|
@@ -71549,6 +71549,23 @@ class EntityObserver {
|
|
|
71549
71549
|
}
|
|
71550
71550
|
}
|
|
71551
71551
|
|
|
71552
|
+
/**
|
|
71553
|
+
* Given an object and a value, find the first property with matching value and returns name of that property
|
|
71554
|
+
* Useful for working with ENUM-like objects
|
|
71555
|
+
* @param {Object<T>} object
|
|
71556
|
+
* @param {T} value
|
|
71557
|
+
* @returns {string|undefined} name of the property, or undefined if property not found
|
|
71558
|
+
*/
|
|
71559
|
+
function objectKeyByValue(object, value) {
|
|
71560
|
+
for (let i in object) {
|
|
71561
|
+
if (object[i] === value) {
|
|
71562
|
+
return i;
|
|
71563
|
+
}
|
|
71564
|
+
}
|
|
71565
|
+
|
|
71566
|
+
return undefined;
|
|
71567
|
+
}
|
|
71568
|
+
|
|
71552
71569
|
/**
|
|
71553
71570
|
*
|
|
71554
71571
|
* @enum {number}
|
|
@@ -71665,6 +71682,10 @@ class Edge {
|
|
|
71665
71682
|
return [this.first, this.second];
|
|
71666
71683
|
}
|
|
71667
71684
|
|
|
71685
|
+
toString() {
|
|
71686
|
+
return `Edge:{ first=${this.first}, second=${this.second}, direction=${objectKeyByValue(EdgeDirectionType, this.direction)} }`
|
|
71687
|
+
}
|
|
71688
|
+
|
|
71668
71689
|
}
|
|
71669
71690
|
|
|
71670
71691
|
/**
|
|
@@ -78582,23 +78603,6 @@ class ShadedGeometrySystem extends System {
|
|
|
78582
78603
|
}
|
|
78583
78604
|
}
|
|
78584
78605
|
|
|
78585
|
-
/**
|
|
78586
|
-
* Given an object and a value, find the first property with matching value and returns name of that property
|
|
78587
|
-
* Useful for working with ENUM-like objects
|
|
78588
|
-
* @param {Object<T>} object
|
|
78589
|
-
* @param {T} value
|
|
78590
|
-
* @returns {string|undefined} name of the property, or undefined if property not found
|
|
78591
|
-
*/
|
|
78592
|
-
function objectKeyByValue(object, value) {
|
|
78593
|
-
for (let i in object) {
|
|
78594
|
-
if (object[i] === value) {
|
|
78595
|
-
return i;
|
|
78596
|
-
}
|
|
78597
|
-
}
|
|
78598
|
-
|
|
78599
|
-
return undefined;
|
|
78600
|
-
}
|
|
78601
|
-
|
|
78602
78606
|
/**
|
|
78603
78607
|
*
|
|
78604
78608
|
* @enum {string}
|
|
@@ -84590,10 +84594,23 @@ class ViewStack extends View {
|
|
|
84590
84594
|
}
|
|
84591
84595
|
|
|
84592
84596
|
/**
|
|
84593
|
-
* Min-Heap implementation with a score function.
|
|
84597
|
+
* Min-Heap implementation with a score function.
|
|
84598
|
+
* The data structure is a binary heap where elements are removed in order defined by scoring function
|
|
84594
84599
|
* @template T
|
|
84595
84600
|
*/
|
|
84596
84601
|
class BinaryHeap {
|
|
84602
|
+
/**
|
|
84603
|
+
* @private
|
|
84604
|
+
* @type {T[]}
|
|
84605
|
+
*/
|
|
84606
|
+
data = [];
|
|
84607
|
+
|
|
84608
|
+
/**
|
|
84609
|
+
* @private
|
|
84610
|
+
* @type {number}
|
|
84611
|
+
*/
|
|
84612
|
+
length = 0;
|
|
84613
|
+
|
|
84597
84614
|
/**
|
|
84598
84615
|
* @template T
|
|
84599
84616
|
* @param {function(el:T):number} scoreFunction
|
|
@@ -84607,17 +84624,6 @@ class BinaryHeap {
|
|
|
84607
84624
|
*/
|
|
84608
84625
|
this.scoreFunction = scoreFunction;
|
|
84609
84626
|
|
|
84610
|
-
/**
|
|
84611
|
-
*
|
|
84612
|
-
* @type {T[]}
|
|
84613
|
-
*/
|
|
84614
|
-
this.data = [];
|
|
84615
|
-
|
|
84616
|
-
/**
|
|
84617
|
-
* @private
|
|
84618
|
-
* @type {number}
|
|
84619
|
-
*/
|
|
84620
|
-
this.length = 0;
|
|
84621
84627
|
}
|
|
84622
84628
|
|
|
84623
84629
|
/**
|
|
@@ -84687,19 +84693,19 @@ class BinaryHeap {
|
|
|
84687
84693
|
if (right >= length) {
|
|
84688
84694
|
//right node doesn't exist
|
|
84689
84695
|
|
|
84690
|
-
|
|
84691
84696
|
if (scoreLeft >= scoreMin) {
|
|
84692
84697
|
break;
|
|
84693
84698
|
} else {
|
|
84694
84699
|
minIndex = left;
|
|
84695
84700
|
dataMin = dataLeft;
|
|
84696
84701
|
}
|
|
84702
|
+
|
|
84697
84703
|
} else {
|
|
84704
|
+
|
|
84698
84705
|
//both left and right nodes exist
|
|
84699
84706
|
const dataRight = data[right];
|
|
84700
84707
|
const scoreRight = this.scoreFunction(dataRight);
|
|
84701
84708
|
|
|
84702
|
-
//
|
|
84703
84709
|
if (scoreLeft <= scoreRight) {
|
|
84704
84710
|
if (scoreLeft >= scoreMin) {
|
|
84705
84711
|
break;
|
|
@@ -84715,6 +84721,7 @@ class BinaryHeap {
|
|
|
84715
84721
|
dataMin = dataRight;
|
|
84716
84722
|
}
|
|
84717
84723
|
}
|
|
84724
|
+
|
|
84718
84725
|
}
|
|
84719
84726
|
|
|
84720
84727
|
//swap positions
|
|
@@ -84732,7 +84739,6 @@ class BinaryHeap {
|
|
|
84732
84739
|
*/
|
|
84733
84740
|
pop() {
|
|
84734
84741
|
|
|
84735
|
-
|
|
84736
84742
|
this.length--;
|
|
84737
84743
|
|
|
84738
84744
|
const new_length = this.length;
|
|
@@ -84741,19 +84747,20 @@ class BinaryHeap {
|
|
|
84741
84747
|
|
|
84742
84748
|
if (new_length === 0) {
|
|
84743
84749
|
|
|
84750
|
+
// this was the last element in the heap
|
|
84751
|
+
|
|
84744
84752
|
return last;
|
|
84745
84753
|
|
|
84746
|
-
}
|
|
84754
|
+
}
|
|
84747
84755
|
|
|
84748
|
-
|
|
84756
|
+
const ret = this.data[0];
|
|
84749
84757
|
|
|
84750
|
-
|
|
84758
|
+
this.data[0] = last;
|
|
84751
84759
|
|
|
84752
|
-
|
|
84760
|
+
this.bubbleDown(0);
|
|
84753
84761
|
|
|
84754
|
-
|
|
84762
|
+
return ret;
|
|
84755
84763
|
|
|
84756
|
-
}
|
|
84757
84764
|
}
|
|
84758
84765
|
|
|
84759
84766
|
/**
|
|
@@ -84855,7 +84862,14 @@ class BinaryHeap {
|
|
|
84855
84862
|
|
|
84856
84863
|
this.bubbleUp(position);
|
|
84857
84864
|
}
|
|
84858
|
-
}
|
|
84865
|
+
}
|
|
84866
|
+
|
|
84867
|
+
/**
|
|
84868
|
+
* Useful for type checks
|
|
84869
|
+
* @readonly
|
|
84870
|
+
* @type {boolean}
|
|
84871
|
+
*/
|
|
84872
|
+
BinaryHeap.prototype.isBinaryHeap = true;
|
|
84859
84873
|
|
|
84860
84874
|
/**
|
|
84861
84875
|
* Decorator that wraps another map and lets you observe mutations
|
|
@@ -91139,6 +91153,59 @@ class InputDeviceSwitch {
|
|
|
91139
91153
|
* @type {boolean}
|
|
91140
91154
|
*/
|
|
91141
91155
|
is_down = false
|
|
91156
|
+
|
|
91157
|
+
press() {
|
|
91158
|
+
if (this.is_down) {
|
|
91159
|
+
return;
|
|
91160
|
+
}
|
|
91161
|
+
|
|
91162
|
+
this.is_down = true;
|
|
91163
|
+
this.down.send0();
|
|
91164
|
+
}
|
|
91165
|
+
|
|
91166
|
+
release() {
|
|
91167
|
+
if (!this.is_down) {
|
|
91168
|
+
return;
|
|
91169
|
+
}
|
|
91170
|
+
|
|
91171
|
+
this.is_down = false;
|
|
91172
|
+
this.up.send0();
|
|
91173
|
+
}
|
|
91174
|
+
}
|
|
91175
|
+
|
|
91176
|
+
/**
|
|
91177
|
+
*
|
|
91178
|
+
* @param thing
|
|
91179
|
+
* @param klass
|
|
91180
|
+
* @returns {boolean}
|
|
91181
|
+
*/
|
|
91182
|
+
function isInstanceOf$1(thing, klass) {
|
|
91183
|
+
if (klass === undefined) {
|
|
91184
|
+
return false;
|
|
91185
|
+
}
|
|
91186
|
+
if (klass === null) {
|
|
91187
|
+
return false;
|
|
91188
|
+
}
|
|
91189
|
+
|
|
91190
|
+
if (typeof klass !== "object") {
|
|
91191
|
+
return false;
|
|
91192
|
+
}
|
|
91193
|
+
|
|
91194
|
+
|
|
91195
|
+
return thing instanceof klass;
|
|
91196
|
+
}
|
|
91197
|
+
|
|
91198
|
+
/**
|
|
91199
|
+
* Based on the article about focusable events: https://stackoverflow.com/questions/1599660/which-html-elements-can-receive-focus
|
|
91200
|
+
* @param {Element} el
|
|
91201
|
+
*/
|
|
91202
|
+
function isHTMLElementFocusable(el) {
|
|
91203
|
+
return isInstanceOf$1(el, HTMLInputElement)
|
|
91204
|
+
|| isInstanceOf$1(el, HTMLSelectElement)
|
|
91205
|
+
|| isInstanceOf$1(el, HTMLTextAreaElement)
|
|
91206
|
+
|| isInstanceOf$1(el, HTMLAnchorElement)
|
|
91207
|
+
|| isInstanceOf$1(el, HTMLButtonElement)
|
|
91208
|
+
|| isInstanceOf$1(el, HTMLAreaElement)
|
|
91142
91209
|
}
|
|
91143
91210
|
|
|
91144
91211
|
/**
|
|
@@ -91248,41 +91315,6 @@ const KeyCodes = {
|
|
|
91248
91315
|
'back_quote': 223
|
|
91249
91316
|
};
|
|
91250
91317
|
|
|
91251
|
-
/**
|
|
91252
|
-
*
|
|
91253
|
-
* @param thing
|
|
91254
|
-
* @param klass
|
|
91255
|
-
* @returns {boolean}
|
|
91256
|
-
*/
|
|
91257
|
-
function isInstanceOf$1(thing, klass) {
|
|
91258
|
-
if (klass === undefined) {
|
|
91259
|
-
return false;
|
|
91260
|
-
}
|
|
91261
|
-
if (klass === null) {
|
|
91262
|
-
return false;
|
|
91263
|
-
}
|
|
91264
|
-
|
|
91265
|
-
if (typeof klass !== "object") {
|
|
91266
|
-
return false;
|
|
91267
|
-
}
|
|
91268
|
-
|
|
91269
|
-
|
|
91270
|
-
return thing instanceof klass;
|
|
91271
|
-
}
|
|
91272
|
-
|
|
91273
|
-
/**
|
|
91274
|
-
* Based on the article about focusable events: https://stackoverflow.com/questions/1599660/which-html-elements-can-receive-focus
|
|
91275
|
-
* @param {Element} el
|
|
91276
|
-
*/
|
|
91277
|
-
function isFocusable(el) {
|
|
91278
|
-
return isInstanceOf$1(el, HTMLInputElement)
|
|
91279
|
-
|| isInstanceOf$1(el, HTMLSelectElement)
|
|
91280
|
-
|| isInstanceOf$1(el, HTMLTextAreaElement)
|
|
91281
|
-
|| isInstanceOf$1(el, HTMLAnchorElement)
|
|
91282
|
-
|| isInstanceOf$1(el, HTMLButtonElement)
|
|
91283
|
-
|| isInstanceOf$1(el, HTMLAreaElement)
|
|
91284
|
-
}
|
|
91285
|
-
|
|
91286
91318
|
/**
|
|
91287
91319
|
* @readonly
|
|
91288
91320
|
* @type {string[]}
|
|
@@ -91315,7 +91347,7 @@ class KeyboardDevice {
|
|
|
91315
91347
|
Only element in focus receives keyboard events, so the element supplied here must be focusable in order to be able to receive events
|
|
91316
91348
|
*/
|
|
91317
91349
|
if (
|
|
91318
|
-
!
|
|
91350
|
+
!isHTMLElementFocusable(domElement)
|
|
91319
91351
|
&& domElement.getAttribute('tabindex') === null
|
|
91320
91352
|
) ;
|
|
91321
91353
|
|
|
@@ -91359,9 +91391,7 @@ class KeyboardDevice {
|
|
|
91359
91391
|
if (keyName !== undefined) {
|
|
91360
91392
|
const button = this.keys[keyName];
|
|
91361
91393
|
|
|
91362
|
-
button.
|
|
91363
|
-
button.down.send1(event);
|
|
91364
|
-
|
|
91394
|
+
button.press();
|
|
91365
91395
|
}
|
|
91366
91396
|
}
|
|
91367
91397
|
|
|
@@ -91381,8 +91411,7 @@ class KeyboardDevice {
|
|
|
91381
91411
|
if (keyName !== undefined) {
|
|
91382
91412
|
const button = this.keys[keyName];
|
|
91383
91413
|
|
|
91384
|
-
button.
|
|
91385
|
-
button.up.send1(event);
|
|
91414
|
+
button.release();
|
|
91386
91415
|
}
|
|
91387
91416
|
}
|
|
91388
91417
|
|
|
@@ -91397,6 +91426,43 @@ class KeyboardDevice {
|
|
|
91397
91426
|
}
|
|
91398
91427
|
}
|
|
91399
91428
|
|
|
91429
|
+
/**
|
|
91430
|
+
*
|
|
91431
|
+
* @param {TouchEvent|MouseEvent} event
|
|
91432
|
+
* @returns {number}
|
|
91433
|
+
*/
|
|
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
|
+
;
|
|
91464
|
+
}
|
|
91465
|
+
|
|
91400
91466
|
/**
|
|
91401
91467
|
* Event names for DOM {@link EventTarget} related to mouse.
|
|
91402
91468
|
* useful for .addEventListener and .removeEventListener
|
|
@@ -91429,6 +91495,23 @@ const TouchEvents = {
|
|
|
91429
91495
|
Cancel: "touchcancel",
|
|
91430
91496
|
};
|
|
91431
91497
|
|
|
91498
|
+
class LocationalInteractionMetadata {
|
|
91499
|
+
timestamp = performance.now()
|
|
91500
|
+
position = new Vector2()
|
|
91501
|
+
|
|
91502
|
+
/**
|
|
91503
|
+
*
|
|
91504
|
+
* @param {Vector2} p
|
|
91505
|
+
*/
|
|
91506
|
+
static from(p) {
|
|
91507
|
+
const r = new LocationalInteractionMetadata();
|
|
91508
|
+
|
|
91509
|
+
r.position.copy(p);
|
|
91510
|
+
|
|
91511
|
+
return r;
|
|
91512
|
+
}
|
|
91513
|
+
}
|
|
91514
|
+
|
|
91432
91515
|
/**
|
|
91433
91516
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
|
|
91434
91517
|
* @see https://w3c.github.io/uievents/#widl-MouseEvent-buttons
|
|
@@ -91506,6 +91589,7 @@ function getTouchCenter(touchList, result) {
|
|
|
91506
91589
|
|
|
91507
91590
|
}
|
|
91508
91591
|
|
|
91592
|
+
|
|
91509
91593
|
/**
|
|
91510
91594
|
*
|
|
91511
91595
|
* @param {Signal} up
|
|
@@ -91514,13 +91598,49 @@ function getTouchCenter(touchList, result) {
|
|
|
91514
91598
|
* @param {number} maxDistance
|
|
91515
91599
|
* @param {Signal} signal
|
|
91516
91600
|
*/
|
|
91517
|
-
function observeTap(
|
|
91601
|
+
function observeTap(
|
|
91602
|
+
up,
|
|
91603
|
+
down,
|
|
91604
|
+
move,
|
|
91605
|
+
maxDistance,
|
|
91606
|
+
signal
|
|
91607
|
+
) {
|
|
91518
91608
|
|
|
91519
|
-
|
|
91609
|
+
/**
|
|
91610
|
+
*
|
|
91611
|
+
* @type {Map<number, LocationalInteractionMetadata>}
|
|
91612
|
+
*/
|
|
91613
|
+
const active = new Map();
|
|
91614
|
+
|
|
91615
|
+
/**
|
|
91616
|
+
*
|
|
91617
|
+
* @param {number} id
|
|
91618
|
+
*/
|
|
91619
|
+
function reset(id) {
|
|
91520
91620
|
|
|
91621
|
+
if (active.delete(id)) {
|
|
91622
|
+
up.remove(handleUp);
|
|
91623
|
+
move.remove(handleMove);
|
|
91624
|
+
}
|
|
91625
|
+
}
|
|
91626
|
+
|
|
91627
|
+
/**
|
|
91628
|
+
*
|
|
91629
|
+
* @param {Vector2} position
|
|
91630
|
+
* @param {MouseEvent|TouchEvent} event
|
|
91631
|
+
*/
|
|
91521
91632
|
function handleUp(position, event) {
|
|
91522
|
-
|
|
91523
|
-
|
|
91633
|
+
const id = eventToSourceIdentifier(event);
|
|
91634
|
+
|
|
91635
|
+
const meta = active.get(id);
|
|
91636
|
+
|
|
91637
|
+
if (meta === undefined) {
|
|
91638
|
+
// this should not happen
|
|
91639
|
+
return;
|
|
91640
|
+
}
|
|
91641
|
+
|
|
91642
|
+
reset(id);
|
|
91643
|
+
|
|
91524
91644
|
signal.send2(position, event);
|
|
91525
91645
|
}
|
|
91526
91646
|
|
|
@@ -91530,20 +91650,42 @@ function observeTap(up, down, move, maxDistance, signal) {
|
|
|
91530
91650
|
* @param {MouseEvent|TouchEvent} event
|
|
91531
91651
|
*/
|
|
91532
91652
|
function handleMove(position, event) {
|
|
91533
|
-
|
|
91534
|
-
//we moved too far, abort tap
|
|
91535
|
-
move.remove(handleMove);
|
|
91653
|
+
const id = eventToSourceIdentifier(event);
|
|
91536
91654
|
|
|
91537
|
-
|
|
91655
|
+
const meta = active.get(id);
|
|
91656
|
+
|
|
91657
|
+
if (meta === undefined) {
|
|
91658
|
+
// this should not happen
|
|
91659
|
+
|
|
91660
|
+
reset(id);
|
|
91661
|
+
|
|
91662
|
+
return;
|
|
91538
91663
|
}
|
|
91664
|
+
|
|
91665
|
+
if (meta.position.distanceTo(position) > maxDistance) {
|
|
91666
|
+
//we moved too far, abort tap
|
|
91667
|
+
reset(id);
|
|
91668
|
+
}
|
|
91669
|
+
|
|
91539
91670
|
}
|
|
91540
91671
|
|
|
91541
|
-
|
|
91672
|
+
/**
|
|
91673
|
+
*
|
|
91674
|
+
* @param {Vector2} position
|
|
91675
|
+
* @param {TouchEvent|MouseEvent} event
|
|
91676
|
+
*/
|
|
91677
|
+
function handleDown(position, event) {
|
|
91678
|
+
const id = eventToSourceIdentifier(event);
|
|
91679
|
+
|
|
91680
|
+
// make sure to cancel previous pending resolution
|
|
91681
|
+
reset(id);
|
|
91682
|
+
|
|
91683
|
+
active.set(id, LocationalInteractionMetadata.from(position));
|
|
91684
|
+
|
|
91542
91685
|
up.addOne(handleUp);
|
|
91686
|
+
|
|
91543
91687
|
//track move
|
|
91544
91688
|
move.add(handleMove);
|
|
91545
|
-
|
|
91546
|
-
origin.copy(position);
|
|
91547
91689
|
}
|
|
91548
91690
|
|
|
91549
91691
|
down.add(handleDown);
|
|
@@ -91854,17 +91996,11 @@ class PointerDevice {
|
|
|
91854
91996
|
this.#domElement = domElement;
|
|
91855
91997
|
|
|
91856
91998
|
|
|
91857
|
-
this.#touchStart.add(
|
|
91858
|
-
this.on.down.send3(param0, param1, param2);
|
|
91859
|
-
});
|
|
91999
|
+
this.#touchStart.add(this.on.down.send3, this.on.down);
|
|
91860
92000
|
|
|
91861
|
-
this.#touchEnd.add(
|
|
91862
|
-
this.on.up.send3(param0, param1, param2);
|
|
91863
|
-
});
|
|
91864
|
-
this.#touchMove.add((param0, param1, param2) => {
|
|
91865
|
-
this.on.move.send3(param0, param1, param2);
|
|
91866
|
-
});
|
|
92001
|
+
this.#touchEnd.add(this.on.up.send3, this.on.up);
|
|
91867
92002
|
|
|
92003
|
+
this.#touchMove.add(this.on.move.send3, this.on.move);
|
|
91868
92004
|
|
|
91869
92005
|
//constructed events
|
|
91870
92006
|
observeTap(this.on.up, this.on.down, this.on.move, 10, this.on.tap);
|
|
@@ -91880,6 +92016,16 @@ class PointerDevice {
|
|
|
91880
92016
|
});
|
|
91881
92017
|
}
|
|
91882
92018
|
|
|
92019
|
+
|
|
92020
|
+
/**
|
|
92021
|
+
*
|
|
92022
|
+
* @param {TouchEvent} event
|
|
92023
|
+
*/
|
|
92024
|
+
#eventHandlerGlobalTouchEnd = (event) => {
|
|
92025
|
+
getTouchCenter(event.touches, this.position);
|
|
92026
|
+
this.#globalUp.send2(this.position, event);
|
|
92027
|
+
}
|
|
92028
|
+
|
|
91883
92029
|
/**
|
|
91884
92030
|
*
|
|
91885
92031
|
* @param {MouseEvent} event
|
|
@@ -91893,19 +92039,7 @@ class PointerDevice {
|
|
|
91893
92039
|
|
|
91894
92040
|
const button = this.buttons[button_index];
|
|
91895
92041
|
|
|
91896
|
-
|
|
91897
|
-
button.is_down = true;
|
|
91898
|
-
button.down.send0();
|
|
91899
|
-
}
|
|
91900
|
-
}
|
|
91901
|
-
|
|
91902
|
-
/**
|
|
91903
|
-
*
|
|
91904
|
-
* @param {TouchEvent} event
|
|
91905
|
-
*/
|
|
91906
|
-
#eventHandlerGlobalTouchEnd = (event) => {
|
|
91907
|
-
getTouchCenter(event.touches, this.position);
|
|
91908
|
-
this.#globalUp.send2(this.position, event);
|
|
92042
|
+
button?.press();
|
|
91909
92043
|
}
|
|
91910
92044
|
|
|
91911
92045
|
/**
|
|
@@ -91930,10 +92064,7 @@ class PointerDevice {
|
|
|
91930
92064
|
|
|
91931
92065
|
const button = this.buttons[button_index];
|
|
91932
92066
|
|
|
91933
|
-
|
|
91934
|
-
button.is_down = false;
|
|
91935
|
-
button.up.send0();
|
|
91936
|
-
}
|
|
92067
|
+
button?.release();
|
|
91937
92068
|
}
|
|
91938
92069
|
|
|
91939
92070
|
/**
|