@woosh/meep-engine 2.109.23 → 2.109.25
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 +231 -104
- package/build/meep.min.js +1 -1
- package/build/meep.module.js +231 -104
- package/package.json +1 -1
- package/src/core/collection/heap/FastBinaryHeap.d.ts +17 -10
- package/src/core/collection/heap/FastBinaryHeap.d.ts.map +1 -1
- package/src/core/collection/heap/FastBinaryHeap.js +33 -23
- package/src/core/collection/heap/FastBinaryHeap.spec.js +10 -10
- 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/collection/table/bind/TableRecord.d.ts.map +1 -1
- package/src/core/collection/table/bind/TableRecord.js +4 -0
- package/src/core/geom/3d/normal/octahedron/encode_unit_to_octahedron.js +2 -2
- package/src/core/geom/packing/max-rect/MaxRectanglesPacker.js +2 -2
- package/src/core/model/validate_enum_schema.d.ts +10 -0
- package/src/core/model/validate_enum_schema.d.ts.map +1 -0
- package/src/core/model/validate_enum_schema.js +31 -0
- package/src/engine/animation/async/TimeSeries.d.ts +76 -0
- package/src/engine/animation/async/TimeSeries.d.ts.map +1 -0
- package/src/engine/animation/async/TimeSeries.js +289 -0
- package/src/engine/animation/async/prototypeAsyncAnimation.js +31 -83
- 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/table_find_min_index_in_ordered_column.js +32 -0
- package/src/engine/asset/AssetManager.js +1 -1
- package/src/engine/graphics/particles/particular/engine/emitter/ParticleEmitter.d.ts.map +1 -1
- package/src/engine/graphics/particles/particular/engine/emitter/ParticleEmitter.js +14 -11
- package/src/engine/graphics/particles/particular/engine/emitter/ParticlePool.js +1 -1
- package/src/engine/graphics/sh3/gi/material/common.glsl +1 -1
- package/src/engine/graphics/sh3/lpv/LightProbeVolume.js +1 -1
- 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 +5 -0
- package/src/engine/graphics/sh3/prototypeSH3Probe.js +2 -2
- 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/eventToSourceIdentifier.d.ts +7 -0
- package/src/engine/input/devices/eventToSourceIdentifier.d.ts.map +1 -0
- package/src/engine/input/devices/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/generation/grid/generation/discrete/GridTaskConnectRooms.js +3 -3
- package/src/generation/grid/generation/discrete/layer/GridTaskBuildSourceDistanceMap.d.ts.map +1 -1
- package/src/generation/grid/generation/discrete/layer/GridTaskBuildSourceDistanceMap.js +5 -5
- package/src/generation/grid/generation/discrete/layer/GridTaskDistanceToMarkers.d.ts.map +1 -1
- package/src/generation/grid/generation/discrete/layer/GridTaskDistanceToMarkers.js +3 -3
- package/src/generation/grid/generation/road/GridTaskGenerateRoads.js +2 -2
package/build/meep.module.js
CHANGED
|
@@ -84588,10 +84588,23 @@ class ViewStack extends View {
|
|
|
84588
84588
|
}
|
|
84589
84589
|
|
|
84590
84590
|
/**
|
|
84591
|
-
* Min-Heap implementation with a score function.
|
|
84591
|
+
* Min-Heap implementation with a score function.
|
|
84592
|
+
* The data structure is a binary heap where elements are removed in order defined by scoring function
|
|
84592
84593
|
* @template T
|
|
84593
84594
|
*/
|
|
84594
|
-
class
|
|
84595
|
+
class FastBinaryHeap {
|
|
84596
|
+
/**
|
|
84597
|
+
* @private
|
|
84598
|
+
* @type {T[]}
|
|
84599
|
+
*/
|
|
84600
|
+
data = [];
|
|
84601
|
+
|
|
84602
|
+
/**
|
|
84603
|
+
* @private
|
|
84604
|
+
* @type {number}
|
|
84605
|
+
*/
|
|
84606
|
+
length = 0;
|
|
84607
|
+
|
|
84595
84608
|
/**
|
|
84596
84609
|
* @template T
|
|
84597
84610
|
* @param {function(el:T):number} scoreFunction
|
|
@@ -84605,17 +84618,6 @@ class BinaryHeap {
|
|
|
84605
84618
|
*/
|
|
84606
84619
|
this.scoreFunction = scoreFunction;
|
|
84607
84620
|
|
|
84608
|
-
/**
|
|
84609
|
-
*
|
|
84610
|
-
* @type {T[]}
|
|
84611
|
-
*/
|
|
84612
|
-
this.data = [];
|
|
84613
|
-
|
|
84614
|
-
/**
|
|
84615
|
-
* @private
|
|
84616
|
-
* @type {number}
|
|
84617
|
-
*/
|
|
84618
|
-
this.length = 0;
|
|
84619
84621
|
}
|
|
84620
84622
|
|
|
84621
84623
|
/**
|
|
@@ -84685,19 +84687,19 @@ class BinaryHeap {
|
|
|
84685
84687
|
if (right >= length) {
|
|
84686
84688
|
//right node doesn't exist
|
|
84687
84689
|
|
|
84688
|
-
|
|
84689
84690
|
if (scoreLeft >= scoreMin) {
|
|
84690
84691
|
break;
|
|
84691
84692
|
} else {
|
|
84692
84693
|
minIndex = left;
|
|
84693
84694
|
dataMin = dataLeft;
|
|
84694
84695
|
}
|
|
84696
|
+
|
|
84695
84697
|
} else {
|
|
84698
|
+
|
|
84696
84699
|
//both left and right nodes exist
|
|
84697
84700
|
const dataRight = data[right];
|
|
84698
84701
|
const scoreRight = this.scoreFunction(dataRight);
|
|
84699
84702
|
|
|
84700
|
-
//
|
|
84701
84703
|
if (scoreLeft <= scoreRight) {
|
|
84702
84704
|
if (scoreLeft >= scoreMin) {
|
|
84703
84705
|
break;
|
|
@@ -84713,6 +84715,7 @@ class BinaryHeap {
|
|
|
84713
84715
|
dataMin = dataRight;
|
|
84714
84716
|
}
|
|
84715
84717
|
}
|
|
84718
|
+
|
|
84716
84719
|
}
|
|
84717
84720
|
|
|
84718
84721
|
//swap positions
|
|
@@ -84730,7 +84733,6 @@ class BinaryHeap {
|
|
|
84730
84733
|
*/
|
|
84731
84734
|
pop() {
|
|
84732
84735
|
|
|
84733
|
-
|
|
84734
84736
|
this.length--;
|
|
84735
84737
|
|
|
84736
84738
|
const new_length = this.length;
|
|
@@ -84739,19 +84741,20 @@ class BinaryHeap {
|
|
|
84739
84741
|
|
|
84740
84742
|
if (new_length === 0) {
|
|
84741
84743
|
|
|
84744
|
+
// this was the last element in the heap
|
|
84745
|
+
|
|
84742
84746
|
return last;
|
|
84743
84747
|
|
|
84744
|
-
}
|
|
84748
|
+
}
|
|
84745
84749
|
|
|
84746
|
-
|
|
84750
|
+
const ret = this.data[0];
|
|
84747
84751
|
|
|
84748
|
-
|
|
84752
|
+
this.data[0] = last;
|
|
84749
84753
|
|
|
84750
|
-
|
|
84754
|
+
this.bubbleDown(0);
|
|
84751
84755
|
|
|
84752
|
-
|
|
84756
|
+
return ret;
|
|
84753
84757
|
|
|
84754
|
-
}
|
|
84755
84758
|
}
|
|
84756
84759
|
|
|
84757
84760
|
/**
|
|
@@ -84853,7 +84856,14 @@ class BinaryHeap {
|
|
|
84853
84856
|
|
|
84854
84857
|
this.bubbleUp(position);
|
|
84855
84858
|
}
|
|
84856
|
-
}
|
|
84859
|
+
}
|
|
84860
|
+
|
|
84861
|
+
/**
|
|
84862
|
+
* Useful for type checks
|
|
84863
|
+
* @readonly
|
|
84864
|
+
* @type {boolean}
|
|
84865
|
+
*/
|
|
84866
|
+
FastBinaryHeap.prototype.isFastBinaryHeap = true;
|
|
84857
84867
|
|
|
84858
84868
|
/**
|
|
84859
84869
|
* Decorator that wraps another map and lets you observe mutations
|
|
@@ -86043,7 +86053,7 @@ let Response$1 = class Response {
|
|
|
86043
86053
|
};
|
|
86044
86054
|
|
|
86045
86055
|
/**
|
|
86046
|
-
* Used by the priority queue, so the priority is inverted as the
|
|
86056
|
+
* Used by the priority queue, so the priority is inverted as the FastBinaryHeap returns elements in ascending score order (from lowest)
|
|
86047
86057
|
* @param {PendingAsset} pending_asset
|
|
86048
86058
|
* @returns {number}
|
|
86049
86059
|
*/
|
|
@@ -86078,7 +86088,7 @@ class AssetManager {
|
|
|
86078
86088
|
* @type {BinaryHeap<PendingAsset>}
|
|
86079
86089
|
* @private
|
|
86080
86090
|
*/
|
|
86081
|
-
#pending_asset_wait_queue = new
|
|
86091
|
+
#pending_asset_wait_queue = new FastBinaryHeap(get_pending_asset_priority_score);
|
|
86082
86092
|
/**
|
|
86083
86093
|
* Assets currently being processed by #loaders
|
|
86084
86094
|
* @type {Set<PendingAsset>}
|
|
@@ -91137,6 +91147,59 @@ class InputDeviceSwitch {
|
|
|
91137
91147
|
* @type {boolean}
|
|
91138
91148
|
*/
|
|
91139
91149
|
is_down = false
|
|
91150
|
+
|
|
91151
|
+
press() {
|
|
91152
|
+
if (this.is_down) {
|
|
91153
|
+
return;
|
|
91154
|
+
}
|
|
91155
|
+
|
|
91156
|
+
this.is_down = true;
|
|
91157
|
+
this.down.send0();
|
|
91158
|
+
}
|
|
91159
|
+
|
|
91160
|
+
release() {
|
|
91161
|
+
if (!this.is_down) {
|
|
91162
|
+
return;
|
|
91163
|
+
}
|
|
91164
|
+
|
|
91165
|
+
this.is_down = false;
|
|
91166
|
+
this.up.send0();
|
|
91167
|
+
}
|
|
91168
|
+
}
|
|
91169
|
+
|
|
91170
|
+
/**
|
|
91171
|
+
*
|
|
91172
|
+
* @param thing
|
|
91173
|
+
* @param klass
|
|
91174
|
+
* @returns {boolean}
|
|
91175
|
+
*/
|
|
91176
|
+
function isInstanceOf$1(thing, klass) {
|
|
91177
|
+
if (klass === undefined) {
|
|
91178
|
+
return false;
|
|
91179
|
+
}
|
|
91180
|
+
if (klass === null) {
|
|
91181
|
+
return false;
|
|
91182
|
+
}
|
|
91183
|
+
|
|
91184
|
+
if (typeof klass !== "object") {
|
|
91185
|
+
return false;
|
|
91186
|
+
}
|
|
91187
|
+
|
|
91188
|
+
|
|
91189
|
+
return thing instanceof klass;
|
|
91190
|
+
}
|
|
91191
|
+
|
|
91192
|
+
/**
|
|
91193
|
+
* Based on the article about focusable events: https://stackoverflow.com/questions/1599660/which-html-elements-can-receive-focus
|
|
91194
|
+
* @param {Element} el
|
|
91195
|
+
*/
|
|
91196
|
+
function isHTMLElementFocusable(el) {
|
|
91197
|
+
return isInstanceOf$1(el, HTMLInputElement)
|
|
91198
|
+
|| isInstanceOf$1(el, HTMLSelectElement)
|
|
91199
|
+
|| isInstanceOf$1(el, HTMLTextAreaElement)
|
|
91200
|
+
|| isInstanceOf$1(el, HTMLAnchorElement)
|
|
91201
|
+
|| isInstanceOf$1(el, HTMLButtonElement)
|
|
91202
|
+
|| isInstanceOf$1(el, HTMLAreaElement)
|
|
91140
91203
|
}
|
|
91141
91204
|
|
|
91142
91205
|
/**
|
|
@@ -91246,41 +91309,6 @@ const KeyCodes = {
|
|
|
91246
91309
|
'back_quote': 223
|
|
91247
91310
|
};
|
|
91248
91311
|
|
|
91249
|
-
/**
|
|
91250
|
-
*
|
|
91251
|
-
* @param thing
|
|
91252
|
-
* @param klass
|
|
91253
|
-
* @returns {boolean}
|
|
91254
|
-
*/
|
|
91255
|
-
function isInstanceOf$1(thing, klass) {
|
|
91256
|
-
if (klass === undefined) {
|
|
91257
|
-
return false;
|
|
91258
|
-
}
|
|
91259
|
-
if (klass === null) {
|
|
91260
|
-
return false;
|
|
91261
|
-
}
|
|
91262
|
-
|
|
91263
|
-
if (typeof klass !== "object") {
|
|
91264
|
-
return false;
|
|
91265
|
-
}
|
|
91266
|
-
|
|
91267
|
-
|
|
91268
|
-
return thing instanceof klass;
|
|
91269
|
-
}
|
|
91270
|
-
|
|
91271
|
-
/**
|
|
91272
|
-
* Based on the article about focusable events: https://stackoverflow.com/questions/1599660/which-html-elements-can-receive-focus
|
|
91273
|
-
* @param {Element} el
|
|
91274
|
-
*/
|
|
91275
|
-
function isFocusable(el) {
|
|
91276
|
-
return isInstanceOf$1(el, HTMLInputElement)
|
|
91277
|
-
|| isInstanceOf$1(el, HTMLSelectElement)
|
|
91278
|
-
|| isInstanceOf$1(el, HTMLTextAreaElement)
|
|
91279
|
-
|| isInstanceOf$1(el, HTMLAnchorElement)
|
|
91280
|
-
|| isInstanceOf$1(el, HTMLButtonElement)
|
|
91281
|
-
|| isInstanceOf$1(el, HTMLAreaElement)
|
|
91282
|
-
}
|
|
91283
|
-
|
|
91284
91312
|
/**
|
|
91285
91313
|
* @readonly
|
|
91286
91314
|
* @type {string[]}
|
|
@@ -91313,7 +91341,7 @@ class KeyboardDevice {
|
|
|
91313
91341
|
Only element in focus receives keyboard events, so the element supplied here must be focusable in order to be able to receive events
|
|
91314
91342
|
*/
|
|
91315
91343
|
if (
|
|
91316
|
-
!
|
|
91344
|
+
!isHTMLElementFocusable(domElement)
|
|
91317
91345
|
&& domElement.getAttribute('tabindex') === null
|
|
91318
91346
|
) ;
|
|
91319
91347
|
|
|
@@ -91357,9 +91385,7 @@ class KeyboardDevice {
|
|
|
91357
91385
|
if (keyName !== undefined) {
|
|
91358
91386
|
const button = this.keys[keyName];
|
|
91359
91387
|
|
|
91360
|
-
button.
|
|
91361
|
-
button.down.send1(event);
|
|
91362
|
-
|
|
91388
|
+
button.press();
|
|
91363
91389
|
}
|
|
91364
91390
|
}
|
|
91365
91391
|
|
|
@@ -91379,8 +91405,7 @@ class KeyboardDevice {
|
|
|
91379
91405
|
if (keyName !== undefined) {
|
|
91380
91406
|
const button = this.keys[keyName];
|
|
91381
91407
|
|
|
91382
|
-
button.
|
|
91383
|
-
button.up.send1(event);
|
|
91408
|
+
button.release();
|
|
91384
91409
|
}
|
|
91385
91410
|
}
|
|
91386
91411
|
|
|
@@ -91427,6 +91452,60 @@ const TouchEvents = {
|
|
|
91427
91452
|
Cancel: "touchcancel",
|
|
91428
91453
|
};
|
|
91429
91454
|
|
|
91455
|
+
/**
|
|
91456
|
+
*
|
|
91457
|
+
* @param {TouchEvent|MouseEvent} event
|
|
91458
|
+
* @returns {number}
|
|
91459
|
+
*/
|
|
91460
|
+
function eventToSourceIdentifier(event) {
|
|
91461
|
+
let device_id = 0;
|
|
91462
|
+
let source_id = 0;
|
|
91463
|
+
|
|
91464
|
+
if (event instanceof MouseEvent) {
|
|
91465
|
+
|
|
91466
|
+
// mouse
|
|
91467
|
+
|
|
91468
|
+
device_id = 1;
|
|
91469
|
+
source_id = event.button;
|
|
91470
|
+
|
|
91471
|
+
} else if (event instanceof TouchEvent) {
|
|
91472
|
+
|
|
91473
|
+
// touch
|
|
91474
|
+
|
|
91475
|
+
device_id = 2;
|
|
91476
|
+
const touches = event.changedTouches;
|
|
91477
|
+
const num_changes = touches.length;
|
|
91478
|
+
|
|
91479
|
+
if (num_changes > 0) {
|
|
91480
|
+
const touch = touches.item(0);
|
|
91481
|
+
|
|
91482
|
+
source_id = touch.identifier;
|
|
91483
|
+
}
|
|
91484
|
+
|
|
91485
|
+
}
|
|
91486
|
+
|
|
91487
|
+
return ((device_id & 0b11) << 29)
|
|
91488
|
+
| (source_id & 0b11111111111111111111111111111)
|
|
91489
|
+
;
|
|
91490
|
+
}
|
|
91491
|
+
|
|
91492
|
+
class LocationalInteractionMetadata {
|
|
91493
|
+
timestamp = performance.now()
|
|
91494
|
+
position = new Vector2()
|
|
91495
|
+
|
|
91496
|
+
/**
|
|
91497
|
+
*
|
|
91498
|
+
* @param {Vector2} p
|
|
91499
|
+
*/
|
|
91500
|
+
static from(p) {
|
|
91501
|
+
const r = new LocationalInteractionMetadata();
|
|
91502
|
+
|
|
91503
|
+
r.position.copy(p);
|
|
91504
|
+
|
|
91505
|
+
return r;
|
|
91506
|
+
}
|
|
91507
|
+
}
|
|
91508
|
+
|
|
91430
91509
|
/**
|
|
91431
91510
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
|
|
91432
91511
|
* @see https://w3c.github.io/uievents/#widl-MouseEvent-buttons
|
|
@@ -91504,6 +91583,7 @@ function getTouchCenter(touchList, result) {
|
|
|
91504
91583
|
|
|
91505
91584
|
}
|
|
91506
91585
|
|
|
91586
|
+
|
|
91507
91587
|
/**
|
|
91508
91588
|
*
|
|
91509
91589
|
* @param {Signal} up
|
|
@@ -91512,13 +91592,49 @@ function getTouchCenter(touchList, result) {
|
|
|
91512
91592
|
* @param {number} maxDistance
|
|
91513
91593
|
* @param {Signal} signal
|
|
91514
91594
|
*/
|
|
91515
|
-
function observeTap(
|
|
91595
|
+
function observeTap(
|
|
91596
|
+
up,
|
|
91597
|
+
down,
|
|
91598
|
+
move,
|
|
91599
|
+
maxDistance,
|
|
91600
|
+
signal
|
|
91601
|
+
) {
|
|
91516
91602
|
|
|
91517
|
-
|
|
91603
|
+
/**
|
|
91604
|
+
*
|
|
91605
|
+
* @type {Map<number, LocationalInteractionMetadata>}
|
|
91606
|
+
*/
|
|
91607
|
+
const active = new Map();
|
|
91608
|
+
|
|
91609
|
+
/**
|
|
91610
|
+
*
|
|
91611
|
+
* @param {number} id
|
|
91612
|
+
*/
|
|
91613
|
+
function reset(id) {
|
|
91614
|
+
|
|
91615
|
+
if (active.delete(id)) {
|
|
91616
|
+
up.remove(handleUp);
|
|
91617
|
+
move.remove(handleMove);
|
|
91618
|
+
}
|
|
91619
|
+
}
|
|
91518
91620
|
|
|
91621
|
+
/**
|
|
91622
|
+
*
|
|
91623
|
+
* @param {Vector2} position
|
|
91624
|
+
* @param {MouseEvent|TouchEvent} event
|
|
91625
|
+
*/
|
|
91519
91626
|
function handleUp(position, event) {
|
|
91520
|
-
|
|
91521
|
-
|
|
91627
|
+
const id = eventToSourceIdentifier(event);
|
|
91628
|
+
|
|
91629
|
+
const meta = active.get(id);
|
|
91630
|
+
|
|
91631
|
+
if (meta === undefined) {
|
|
91632
|
+
// this should not happen
|
|
91633
|
+
return;
|
|
91634
|
+
}
|
|
91635
|
+
|
|
91636
|
+
reset(id);
|
|
91637
|
+
|
|
91522
91638
|
signal.send2(position, event);
|
|
91523
91639
|
}
|
|
91524
91640
|
|
|
@@ -91528,20 +91644,42 @@ function observeTap(up, down, move, maxDistance, signal) {
|
|
|
91528
91644
|
* @param {MouseEvent|TouchEvent} event
|
|
91529
91645
|
*/
|
|
91530
91646
|
function handleMove(position, event) {
|
|
91531
|
-
|
|
91532
|
-
//we moved too far, abort tap
|
|
91533
|
-
move.remove(handleMove);
|
|
91647
|
+
const id = eventToSourceIdentifier(event);
|
|
91534
91648
|
|
|
91535
|
-
|
|
91649
|
+
const meta = active.get(id);
|
|
91650
|
+
|
|
91651
|
+
if (meta === undefined) {
|
|
91652
|
+
// this should not happen
|
|
91653
|
+
|
|
91654
|
+
reset(id);
|
|
91655
|
+
|
|
91656
|
+
return;
|
|
91657
|
+
}
|
|
91658
|
+
|
|
91659
|
+
if (meta.position.distanceTo(position) > maxDistance) {
|
|
91660
|
+
//we moved too far, abort tap
|
|
91661
|
+
reset(id);
|
|
91536
91662
|
}
|
|
91663
|
+
|
|
91537
91664
|
}
|
|
91538
91665
|
|
|
91539
|
-
|
|
91666
|
+
/**
|
|
91667
|
+
*
|
|
91668
|
+
* @param {Vector2} position
|
|
91669
|
+
* @param {TouchEvent|MouseEvent} event
|
|
91670
|
+
*/
|
|
91671
|
+
function handleDown(position, event) {
|
|
91672
|
+
const id = eventToSourceIdentifier(event);
|
|
91673
|
+
|
|
91674
|
+
// make sure to cancel previous pending resolution
|
|
91675
|
+
reset(id);
|
|
91676
|
+
|
|
91677
|
+
active.set(id, LocationalInteractionMetadata.from(position));
|
|
91678
|
+
|
|
91540
91679
|
up.addOne(handleUp);
|
|
91680
|
+
|
|
91541
91681
|
//track move
|
|
91542
91682
|
move.add(handleMove);
|
|
91543
|
-
|
|
91544
|
-
origin.copy(position);
|
|
91545
91683
|
}
|
|
91546
91684
|
|
|
91547
91685
|
down.add(handleDown);
|
|
@@ -91852,17 +91990,11 @@ class PointerDevice {
|
|
|
91852
91990
|
this.#domElement = domElement;
|
|
91853
91991
|
|
|
91854
91992
|
|
|
91855
|
-
this.#touchStart.add(
|
|
91856
|
-
this.on.down.send3(param0, param1, param2);
|
|
91857
|
-
});
|
|
91993
|
+
this.#touchStart.add(this.on.down.send3, this.on.down);
|
|
91858
91994
|
|
|
91859
|
-
this.#touchEnd.add(
|
|
91860
|
-
this.on.up.send3(param0, param1, param2);
|
|
91861
|
-
});
|
|
91862
|
-
this.#touchMove.add((param0, param1, param2) => {
|
|
91863
|
-
this.on.move.send3(param0, param1, param2);
|
|
91864
|
-
});
|
|
91995
|
+
this.#touchEnd.add(this.on.up.send3, this.on.up);
|
|
91865
91996
|
|
|
91997
|
+
this.#touchMove.add(this.on.move.send3, this.on.move);
|
|
91866
91998
|
|
|
91867
91999
|
//constructed events
|
|
91868
92000
|
observeTap(this.on.up, this.on.down, this.on.move, 10, this.on.tap);
|
|
@@ -91878,6 +92010,16 @@ class PointerDevice {
|
|
|
91878
92010
|
});
|
|
91879
92011
|
}
|
|
91880
92012
|
|
|
92013
|
+
|
|
92014
|
+
/**
|
|
92015
|
+
*
|
|
92016
|
+
* @param {TouchEvent} event
|
|
92017
|
+
*/
|
|
92018
|
+
#eventHandlerGlobalTouchEnd = (event) => {
|
|
92019
|
+
getTouchCenter(event.touches, this.position);
|
|
92020
|
+
this.#globalUp.send2(this.position, event);
|
|
92021
|
+
}
|
|
92022
|
+
|
|
91881
92023
|
/**
|
|
91882
92024
|
*
|
|
91883
92025
|
* @param {MouseEvent} event
|
|
@@ -91891,19 +92033,7 @@ class PointerDevice {
|
|
|
91891
92033
|
|
|
91892
92034
|
const button = this.buttons[button_index];
|
|
91893
92035
|
|
|
91894
|
-
|
|
91895
|
-
button.is_down = true;
|
|
91896
|
-
button.down.send0();
|
|
91897
|
-
}
|
|
91898
|
-
}
|
|
91899
|
-
|
|
91900
|
-
/**
|
|
91901
|
-
*
|
|
91902
|
-
* @param {TouchEvent} event
|
|
91903
|
-
*/
|
|
91904
|
-
#eventHandlerGlobalTouchEnd = (event) => {
|
|
91905
|
-
getTouchCenter(event.touches, this.position);
|
|
91906
|
-
this.#globalUp.send2(this.position, event);
|
|
92036
|
+
button?.press();
|
|
91907
92037
|
}
|
|
91908
92038
|
|
|
91909
92039
|
/**
|
|
@@ -91928,10 +92058,7 @@ class PointerDevice {
|
|
|
91928
92058
|
|
|
91929
92059
|
const button = this.buttons[button_index];
|
|
91930
92060
|
|
|
91931
|
-
|
|
91932
|
-
button.is_down = false;
|
|
91933
|
-
button.up.send0();
|
|
91934
|
-
}
|
|
92061
|
+
button?.release();
|
|
91935
92062
|
}
|
|
91936
92063
|
|
|
91937
92064
|
/**
|
|
@@ -108035,7 +108162,7 @@ class MaxRectanglesPacker {
|
|
|
108035
108162
|
return -Math.min(box.getWidth(), box.getHeight());
|
|
108036
108163
|
}
|
|
108037
108164
|
|
|
108038
|
-
const heap = new
|
|
108165
|
+
const heap = new FastBinaryHeap(scoreBoxByMinSide);
|
|
108039
108166
|
|
|
108040
108167
|
for (let i = 0; i < numBoxes; i++) {
|
|
108041
108168
|
heap.push(i);
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
export default
|
|
1
|
+
export default FastBinaryHeap;
|
|
2
2
|
/**
|
|
3
|
-
* Min-Heap implementation with a score function.
|
|
3
|
+
* Min-Heap implementation with a score function.
|
|
4
|
+
* The data structure is a binary heap where elements are removed in order defined by scoring function
|
|
4
5
|
* @template T
|
|
5
6
|
*/
|
|
6
|
-
declare class
|
|
7
|
+
declare class FastBinaryHeap<T> {
|
|
7
8
|
/**
|
|
8
9
|
* @template T
|
|
9
10
|
* @param {function(el:T):number} scoreFunction
|
|
@@ -11,20 +12,20 @@ declare class BinaryHeap<T> {
|
|
|
11
12
|
*/
|
|
12
13
|
constructor(scoreFunction: any);
|
|
13
14
|
/**
|
|
14
|
-
*
|
|
15
|
-
* @type {function(T): number}
|
|
16
|
-
*/
|
|
17
|
-
scoreFunction: (arg0: T_1) => number;
|
|
18
|
-
/**
|
|
19
|
-
*
|
|
15
|
+
* @private
|
|
20
16
|
* @type {T[]}
|
|
21
17
|
*/
|
|
22
|
-
data
|
|
18
|
+
private data;
|
|
23
19
|
/**
|
|
24
20
|
* @private
|
|
25
21
|
* @type {number}
|
|
26
22
|
*/
|
|
27
23
|
private length;
|
|
24
|
+
/**
|
|
25
|
+
*
|
|
26
|
+
* @type {function(T): number}
|
|
27
|
+
*/
|
|
28
|
+
scoreFunction: (arg0: T_1) => number;
|
|
28
29
|
/**
|
|
29
30
|
* @private
|
|
30
31
|
* @param {number} pos
|
|
@@ -87,5 +88,11 @@ declare class BinaryHeap<T> {
|
|
|
87
88
|
* @param {T} el
|
|
88
89
|
*/
|
|
89
90
|
push(el: T): void;
|
|
91
|
+
/**
|
|
92
|
+
* Useful for type checks
|
|
93
|
+
* @readonly
|
|
94
|
+
* @type {boolean}
|
|
95
|
+
*/
|
|
96
|
+
readonly isFastBinaryHeap: boolean;
|
|
90
97
|
}
|
|
91
98
|
//# sourceMappingURL=FastBinaryHeap.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FastBinaryHeap.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/heap/FastBinaryHeap.js"],"names":[],"mappings":";AAEA
|
|
1
|
+
{"version":3,"file":"FastBinaryHeap.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/heap/FastBinaryHeap.js"],"names":[],"mappings":";AAEA;;;;GAIG;AACH;IAaI;;;;OAIG;IACH,gCAQC;IAzBD;;;OAGG;IACH,aAAU;IAEV;;;OAGG;IACH,eAAW;IASP;;;OAGG;IACH,8BAFuB,MAAM,CAEK;IAItC;;;OAGG;IACH,iBA8BC;IAED;;;OAGG;IACH,mBAmEC;IAED;;;OAGG;IACH,OAFY,CAAC,CA0BZ;IAED;;;OAGG;IACH,QAFa,CAAC,GAAC,SAAS,CAIvB;IAED;;;;OAIG;IACH,aAHW,CAAC,GACC,OAAO,CAYnB;IAED;;;OAGG;IACH,iBAFW,MAAM,QAOhB;IAED;;OAEG;IACH,cAGC;IAED;;;;OAIG;IACH,eAHW,CAAC,GACC,OAAO,CAKnB;IAED;;;OAGG;IACH,WAFa,OAAO,CAInB;IAED;;;OAGG;IACH,QAFa,MAAM,CAIlB;IAED;;;;OAIG;IACH,yBAHW,CAAC,GACC,OAAO,CAWnB;IAED;;;OAGG;IACH,SAFW,CAAC,QAUX;IAGL;;;;OAIG;IACH,2BAFU,OAAO,CAEwB;CAPxC"}
|
|
@@ -1,10 +1,23 @@
|
|
|
1
1
|
import { assert } from "../../assert.js";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* Min-Heap implementation with a score function.
|
|
4
|
+
* Min-Heap implementation with a score function.
|
|
5
|
+
* The data structure is a binary heap where elements are removed in order defined by scoring function
|
|
5
6
|
* @template T
|
|
6
7
|
*/
|
|
7
|
-
class
|
|
8
|
+
class FastBinaryHeap {
|
|
9
|
+
/**
|
|
10
|
+
* @private
|
|
11
|
+
* @type {T[]}
|
|
12
|
+
*/
|
|
13
|
+
data = [];
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @private
|
|
17
|
+
* @type {number}
|
|
18
|
+
*/
|
|
19
|
+
length = 0;
|
|
20
|
+
|
|
8
21
|
/**
|
|
9
22
|
* @template T
|
|
10
23
|
* @param {function(el:T):number} scoreFunction
|
|
@@ -18,17 +31,6 @@ class BinaryHeap {
|
|
|
18
31
|
*/
|
|
19
32
|
this.scoreFunction = scoreFunction;
|
|
20
33
|
|
|
21
|
-
/**
|
|
22
|
-
*
|
|
23
|
-
* @type {T[]}
|
|
24
|
-
*/
|
|
25
|
-
this.data = [];
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* @private
|
|
29
|
-
* @type {number}
|
|
30
|
-
*/
|
|
31
|
-
this.length = 0;
|
|
32
34
|
}
|
|
33
35
|
|
|
34
36
|
/**
|
|
@@ -100,19 +102,19 @@ class BinaryHeap {
|
|
|
100
102
|
if (right >= length) {
|
|
101
103
|
//right node doesn't exist
|
|
102
104
|
|
|
103
|
-
|
|
104
105
|
if (scoreLeft >= scoreMin) {
|
|
105
106
|
break;
|
|
106
107
|
} else {
|
|
107
108
|
minIndex = left;
|
|
108
109
|
dataMin = dataLeft;
|
|
109
110
|
}
|
|
111
|
+
|
|
110
112
|
} else {
|
|
113
|
+
|
|
111
114
|
//both left and right nodes exist
|
|
112
115
|
const dataRight = data[right];
|
|
113
116
|
const scoreRight = this.scoreFunction(dataRight);
|
|
114
117
|
|
|
115
|
-
//
|
|
116
118
|
if (scoreLeft <= scoreRight) {
|
|
117
119
|
if (scoreLeft >= scoreMin) {
|
|
118
120
|
break;
|
|
@@ -128,6 +130,7 @@ class BinaryHeap {
|
|
|
128
130
|
dataMin = dataRight;
|
|
129
131
|
}
|
|
130
132
|
}
|
|
133
|
+
|
|
131
134
|
}
|
|
132
135
|
|
|
133
136
|
//swap positions
|
|
@@ -145,7 +148,6 @@ class BinaryHeap {
|
|
|
145
148
|
*/
|
|
146
149
|
pop() {
|
|
147
150
|
|
|
148
|
-
|
|
149
151
|
this.length--;
|
|
150
152
|
|
|
151
153
|
const new_length = this.length;
|
|
@@ -154,19 +156,20 @@ class BinaryHeap {
|
|
|
154
156
|
|
|
155
157
|
if (new_length === 0) {
|
|
156
158
|
|
|
159
|
+
// this was the last element in the heap
|
|
160
|
+
|
|
157
161
|
return last;
|
|
158
162
|
|
|
159
|
-
}
|
|
163
|
+
}
|
|
160
164
|
|
|
161
|
-
|
|
165
|
+
const ret = this.data[0];
|
|
162
166
|
|
|
163
|
-
|
|
167
|
+
this.data[0] = last;
|
|
164
168
|
|
|
165
|
-
|
|
169
|
+
this.bubbleDown(0);
|
|
166
170
|
|
|
167
|
-
|
|
171
|
+
return ret;
|
|
168
172
|
|
|
169
|
-
}
|
|
170
173
|
}
|
|
171
174
|
|
|
172
175
|
/**
|
|
@@ -270,4 +273,11 @@ class BinaryHeap {
|
|
|
270
273
|
}
|
|
271
274
|
}
|
|
272
275
|
|
|
273
|
-
|
|
276
|
+
/**
|
|
277
|
+
* Useful for type checks
|
|
278
|
+
* @readonly
|
|
279
|
+
* @type {boolean}
|
|
280
|
+
*/
|
|
281
|
+
FastBinaryHeap.prototype.isFastBinaryHeap = true;
|
|
282
|
+
|
|
283
|
+
export default FastBinaryHeap;
|