@woosh/meep-engine 2.113.16 → 2.114.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/meep.cjs +4 -2
- package/build/meep.module.js +4 -2
- package/package.json +1 -1
- package/src/core/collection/array/array_filter_by_multiple.d.ts +2 -0
- package/src/core/collection/array/array_filter_by_multiple.d.ts.map +1 -1
- package/src/core/collection/array/array_filter_by_multiple.js +11 -4
- package/src/core/collection/array/array_group_by.d.ts +10 -0
- package/src/core/collection/array/array_group_by.d.ts.map +1 -0
- package/src/core/collection/array/{groupArrayBy.js → array_group_by.js} +3 -3
- package/src/core/collection/array/array_sort_quick.d.ts +13 -0
- package/src/core/collection/array/array_sort_quick.d.ts.map +1 -0
- package/src/core/collection/array/{arrayQuickSort.js → array_sort_quick.js} +5 -1
- package/src/engine/graphics/render/forward_plus/LightManager.js +2 -2
- package/src/engine/graphics/sh3/path_tracer/sorting/sort_bvh_nodes_by_distance_to_point.js +2 -2
- package/src/engine/graphics/texture/virtual/VirtualTextureTileLoader.js +2 -2
- package/src/generation/grid/generation/road/GridTaskGenerateRoads.js +2 -2
- package/src/core/collection/array/arrayQuickSort.d.ts +0 -12
- package/src/core/collection/array/arrayQuickSort.d.ts.map +0 -1
- package/src/core/collection/array/array_remove_element.d.ts +0 -11
- package/src/core/collection/array/array_remove_element.d.ts.map +0 -1
- package/src/core/collection/array/array_remove_element.js +0 -16
- package/src/core/collection/array/groupArrayBy.d.ts +0 -10
- package/src/core/collection/array/groupArrayBy.d.ts.map +0 -1
package/build/meep.cjs
CHANGED
|
@@ -106398,6 +106398,7 @@ function computeBinaryDataTypeByPrecision(type, precision) {
|
|
|
106398
106398
|
const stack$1 = [];
|
|
106399
106399
|
|
|
106400
106400
|
/**
|
|
106401
|
+
* Quicksort implementation, instead of compare operator, uses scoring function
|
|
106401
106402
|
* @template T
|
|
106402
106403
|
* @param {T[]|ArrayLike<number>|Uint32Array} data
|
|
106403
106404
|
* @param {function(T):number} score_function
|
|
@@ -106407,12 +106408,13 @@ const stack$1 = [];
|
|
|
106407
106408
|
* @param {function(T[],number, number):*} [swap_operator]
|
|
106408
106409
|
* @param {*} [swap_context]
|
|
106409
106410
|
*/
|
|
106410
|
-
function
|
|
106411
|
+
function array_sort_quick(
|
|
106411
106412
|
data,
|
|
106412
106413
|
score_function, score_function_context,
|
|
106413
106414
|
start = 0, end = data.length - 1,
|
|
106414
106415
|
swap_operator = array_swap_one, swap_context = undefined
|
|
106415
106416
|
) {
|
|
106417
|
+
|
|
106416
106418
|
if (start >= end) {
|
|
106417
106419
|
// section of 0 size, nothing to sort
|
|
106418
106420
|
return;
|
|
@@ -111353,7 +111355,7 @@ class LightManager {
|
|
|
111353
111355
|
array_copy(visible_light_set.elements, 0, sorted_lights, 0, visible_light_count);
|
|
111354
111356
|
array_copy(visible_decal_set.elements, 0, sorted_lights, visible_light_count, visible_decal_count);
|
|
111355
111357
|
|
|
111356
|
-
|
|
111358
|
+
array_sort_quick(sorted_lights, this.__sort_visible_light_score, this, 0, expected_sorted_size - 1);
|
|
111357
111359
|
}
|
|
111358
111360
|
|
|
111359
111361
|
__update_visible_bvh() {
|
package/build/meep.module.js
CHANGED
|
@@ -106396,6 +106396,7 @@ function computeBinaryDataTypeByPrecision(type, precision) {
|
|
|
106396
106396
|
const stack$1 = [];
|
|
106397
106397
|
|
|
106398
106398
|
/**
|
|
106399
|
+
* Quicksort implementation, instead of compare operator, uses scoring function
|
|
106399
106400
|
* @template T
|
|
106400
106401
|
* @param {T[]|ArrayLike<number>|Uint32Array} data
|
|
106401
106402
|
* @param {function(T):number} score_function
|
|
@@ -106405,12 +106406,13 @@ const stack$1 = [];
|
|
|
106405
106406
|
* @param {function(T[],number, number):*} [swap_operator]
|
|
106406
106407
|
* @param {*} [swap_context]
|
|
106407
106408
|
*/
|
|
106408
|
-
function
|
|
106409
|
+
function array_sort_quick(
|
|
106409
106410
|
data,
|
|
106410
106411
|
score_function, score_function_context,
|
|
106411
106412
|
start = 0, end = data.length - 1,
|
|
106412
106413
|
swap_operator = array_swap_one, swap_context = undefined
|
|
106413
106414
|
) {
|
|
106415
|
+
|
|
106414
106416
|
if (start >= end) {
|
|
106415
106417
|
// section of 0 size, nothing to sort
|
|
106416
106418
|
return;
|
|
@@ -111351,7 +111353,7 @@ class LightManager {
|
|
|
111351
111353
|
array_copy(visible_light_set.elements, 0, sorted_lights, 0, visible_light_count);
|
|
111352
111354
|
array_copy(visible_decal_set.elements, 0, sorted_lights, visible_light_count, visible_decal_count);
|
|
111353
111355
|
|
|
111354
|
-
|
|
111356
|
+
array_sort_quick(sorted_lights, this.__sort_visible_light_score, this, 0, expected_sorted_size - 1);
|
|
111355
111357
|
}
|
|
111356
111358
|
|
|
111357
111359
|
__update_visible_bvh() {
|
package/package.json
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* Similar to standard {@link Array.prototype.filter}, but allows multiple filters. They work as an "AND".
|
|
3
|
+
* Useful to save allocations when multiple filters need to be applied, as the {@link Array.prototype.filter} allocates a new array for each call
|
|
2
4
|
* @template T
|
|
3
5
|
* @param {T[]} input_items
|
|
4
6
|
* @param {((T)=>boolean)[]} filters
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array_filter_by_multiple.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/array/array_filter_by_multiple.js"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"array_filter_by_multiple.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/array/array_filter_by_multiple.js"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,oFAHiB,OAAO,UAqCvB"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* Similar to standard {@link Array.prototype.filter}, but allows multiple filters. They work as an "AND".
|
|
3
|
+
* Useful to save allocations when multiple filters need to be applied, as the {@link Array.prototype.filter} allocates a new array for each call
|
|
2
4
|
* @template T
|
|
3
5
|
* @param {T[]} input_items
|
|
4
6
|
* @param {((T)=>boolean)[]} filters
|
|
@@ -13,23 +15,28 @@ export function array_filter_by_multiple(input_items, filters) {
|
|
|
13
15
|
return input_items;
|
|
14
16
|
}
|
|
15
17
|
|
|
18
|
+
/**
|
|
19
|
+
*
|
|
20
|
+
* @type {T[]}
|
|
21
|
+
*/
|
|
16
22
|
const filtered = [];
|
|
17
23
|
|
|
18
24
|
const input_item_count = input_items.length;
|
|
19
25
|
|
|
20
|
-
|
|
21
26
|
main_loop:for (let i = 0; i < input_item_count; i++) {
|
|
22
|
-
const
|
|
27
|
+
const datum = input_items[i];
|
|
28
|
+
|
|
23
29
|
for (let j = 0; j < filter_count; j++) {
|
|
24
30
|
const filter = filters[j];
|
|
25
31
|
|
|
26
|
-
if (filter(
|
|
32
|
+
if (filter(datum) === false) {
|
|
33
|
+
// filter rejected, let's move onto next element
|
|
27
34
|
continue main_loop;
|
|
28
35
|
}
|
|
29
36
|
}
|
|
30
37
|
|
|
31
38
|
// filters passed
|
|
32
|
-
filtered.push(
|
|
39
|
+
filtered.push(datum);
|
|
33
40
|
}
|
|
34
41
|
|
|
35
42
|
return filtered;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @template T,K
|
|
3
|
+
* @param {T[]} array
|
|
4
|
+
* @param {function(T):K} grouping_key_producer given an element from input array, returns a grouping key. Can be an object, if it implements .equals method keys can be compared that way as well
|
|
5
|
+
* @param keyHashFunction
|
|
6
|
+
* @returns {Map<K,T[]>}
|
|
7
|
+
*/
|
|
8
|
+
export function array_group_by<T, K>(array: T[], grouping_key_producer: (arg0: T) => K, keyHashFunction?: typeof returnZero): Map<K, T[]>;
|
|
9
|
+
import { returnZero } from "../../function/returnZero.js";
|
|
10
|
+
//# sourceMappingURL=array_group_by.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array_group_by.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/array/array_group_by.js"],"names":[],"mappings":"AAGA;;;;;;GAMG;AACH,0IA+BC;2BAzC0B,8BAA8B"}
|
|
@@ -4,11 +4,11 @@ import { HashMap } from "../map/HashMap.js";
|
|
|
4
4
|
/**
|
|
5
5
|
* @template T,K
|
|
6
6
|
* @param {T[]} array
|
|
7
|
-
* @param {function(T):K}
|
|
7
|
+
* @param {function(T):K} grouping_key_producer given an element from input array, returns a grouping key. Can be an object, if it implements .equals method keys can be compared that way as well
|
|
8
8
|
* @param keyHashFunction
|
|
9
9
|
* @returns {Map<K,T[]>}
|
|
10
10
|
*/
|
|
11
|
-
export function
|
|
11
|
+
export function array_group_by(array, grouping_key_producer, keyHashFunction = returnZero) {
|
|
12
12
|
const result = new HashMap({
|
|
13
13
|
keyHashFunction,
|
|
14
14
|
keyEqualityFunction(a, b) {
|
|
@@ -27,7 +27,7 @@ export function groupArrayBy(array, groupingFunction, keyHashFunction = returnZe
|
|
|
27
27
|
for (let i = 0; i < array.length; i++) {
|
|
28
28
|
const element = array[i];
|
|
29
29
|
|
|
30
|
-
const groupKey =
|
|
30
|
+
const groupKey = grouping_key_producer(element);
|
|
31
31
|
|
|
32
32
|
const group = result.get(groupKey);
|
|
33
33
|
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Quicksort implementation, instead of compare operator, uses scoring function
|
|
3
|
+
* @template T
|
|
4
|
+
* @param {T[]|ArrayLike<number>|Uint32Array} data
|
|
5
|
+
* @param {function(T):number} score_function
|
|
6
|
+
* @param {*} [score_function_context]
|
|
7
|
+
* @param {number} [start]
|
|
8
|
+
* @param {number} [end]
|
|
9
|
+
* @param {function(T[],number, number):*} [swap_operator]
|
|
10
|
+
* @param {*} [swap_context]
|
|
11
|
+
*/
|
|
12
|
+
export function array_sort_quick<T>(data: ArrayLike<number> | Uint32Array | T[], score_function: (arg0: T) => number, score_function_context?: any, start?: number, end?: number, swap_operator?: (arg0: T[], arg1: number, arg2: number) => any, swap_context?: any): void;
|
|
13
|
+
//# sourceMappingURL=array_sort_quick.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array_sort_quick.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/array/array_sort_quick.js"],"names":[],"mappings":"AAKA;;;;;;;;;;GAUG;AACH,8GAPuB,MAAM,wCAElB,MAAM,QACN,MAAM,oCACO,MAAM,QAAE,MAAM,oCAmErC"}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { assert } from "../../assert.js";
|
|
1
2
|
import { array_swap_one } from "./array_swap_one.js";
|
|
2
3
|
|
|
3
4
|
const stack = [];
|
|
4
5
|
|
|
5
6
|
/**
|
|
7
|
+
* Quicksort implementation, instead of compare operator, uses scoring function
|
|
6
8
|
* @template T
|
|
7
9
|
* @param {T[]|ArrayLike<number>|Uint32Array} data
|
|
8
10
|
* @param {function(T):number} score_function
|
|
@@ -12,12 +14,14 @@ const stack = [];
|
|
|
12
14
|
* @param {function(T[],number, number):*} [swap_operator]
|
|
13
15
|
* @param {*} [swap_context]
|
|
14
16
|
*/
|
|
15
|
-
export function
|
|
17
|
+
export function array_sort_quick(
|
|
16
18
|
data,
|
|
17
19
|
score_function, score_function_context,
|
|
18
20
|
start = 0, end = data.length - 1,
|
|
19
21
|
swap_operator = array_swap_one, swap_context = undefined
|
|
20
22
|
) {
|
|
23
|
+
assert.isFunction(score_function, 'score_function');
|
|
24
|
+
|
|
21
25
|
if (start >= end) {
|
|
22
26
|
// section of 0 size, nothing to sort
|
|
23
27
|
return;
|
|
@@ -23,8 +23,8 @@ import {
|
|
|
23
23
|
bvh_query_user_data_overlaps_frustum
|
|
24
24
|
} from "../../../../core/bvh2/bvh3/query/bvh_query_user_data_overlaps_frustum.js";
|
|
25
25
|
import { array_copy } from "../../../../core/collection/array/array_copy.js";
|
|
26
|
+
import { array_sort_quick } from "../../../../core/collection/array/array_sort_quick.js";
|
|
26
27
|
import { array_swap_one } from "../../../../core/collection/array/array_swap_one.js";
|
|
27
|
-
import { arrayQuickSort } from "../../../../core/collection/array/arrayQuickSort.js";
|
|
28
28
|
import { read_cluster_frustum_corners } from "../../../../core/geom/3d/frustum/read_cluster_frustum_corners.js";
|
|
29
29
|
import { read_three_planes_to_array } from "../../../../core/geom/3d/frustum/read_three_planes_to_array.js";
|
|
30
30
|
import { slice_frustum_linear_to_points } from "../../../../core/geom/3d/frustum/slice_frustum_linear_to_points.js";
|
|
@@ -680,7 +680,7 @@ export class LightManager {
|
|
|
680
680
|
array_copy(visible_light_set.elements, 0, sorted_lights, 0, visible_light_count);
|
|
681
681
|
array_copy(visible_decal_set.elements, 0, sorted_lights, visible_light_count, visible_decal_count);
|
|
682
682
|
|
|
683
|
-
|
|
683
|
+
array_sort_quick(sorted_lights, this.__sort_visible_light_score, this, 0, expected_sorted_size - 1);
|
|
684
684
|
}
|
|
685
685
|
|
|
686
686
|
__update_visible_bvh() {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ELEMENT_WORD_COUNT } from "../../../../../core/bvh2/bvh3/BVH.js";
|
|
2
|
-
import {
|
|
2
|
+
import { array_sort_quick } from "../../../../../core/collection/array/array_sort_quick.js";
|
|
3
3
|
import {
|
|
4
4
|
aabb3_unsigned_distance_sqr_to_point
|
|
5
5
|
} from "../../../../../core/geom/3d/aabb/aabb3_unsigned_distance_sqr_to_point.js";
|
|
@@ -28,7 +28,7 @@ export function sort_bvh_nodes_by_distance_to_point(
|
|
|
28
28
|
For performance, we bind data directly to avoid extra copies required to read out AABB
|
|
29
29
|
*/
|
|
30
30
|
const float32 = bvh.__data_float32;
|
|
31
|
-
|
|
31
|
+
array_sort_quick(node_list, (node) => {
|
|
32
32
|
const address = node * ELEMENT_WORD_COUNT;
|
|
33
33
|
|
|
34
34
|
const aabb_distance_sqr = aabb3_unsigned_distance_sqr_to_point(
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { assert } from "../../../../core/assert.js";
|
|
2
|
-
import {
|
|
2
|
+
import { array_sort_quick } from "../../../../core/collection/array/array_sort_quick.js";
|
|
3
3
|
import Signal from "../../../../core/events/signal/Signal.js";
|
|
4
4
|
import { AssetManager } from "../../../asset/AssetManager.js";
|
|
5
5
|
import { GameAssetType } from "../../../asset/GameAssetType.js";
|
|
@@ -142,7 +142,7 @@ export class VirtualTextureTileLoader {
|
|
|
142
142
|
*/
|
|
143
143
|
const score = (fingerprint) => -usage.getCountByFingerprint(fingerprint);
|
|
144
144
|
|
|
145
|
-
|
|
145
|
+
array_sort_quick(
|
|
146
146
|
this.#queue,
|
|
147
147
|
score, null,
|
|
148
148
|
0, this.#queue.length - 1
|
|
@@ -2,7 +2,7 @@ import { GridTags } from "../../../../../samples/generation/grid/GridTags.js";
|
|
|
2
2
|
import { MirGridLayers } from "../../../../../samples/generation/grid/MirGridLayers.js";
|
|
3
3
|
import { matcher_tag_traversable } from "../../../../../samples/generation/rules/matcher_tag_traversable.js";
|
|
4
4
|
import { BitSet } from "../../../../core/binary/BitSet.js";
|
|
5
|
-
import {
|
|
5
|
+
import { array_group_by } from "../../../../core/collection/array/array_group_by.js";
|
|
6
6
|
import { collectIteratorValueToArray } from "../../../../core/collection/collectIteratorValueToArray.js";
|
|
7
7
|
import BinaryHeap from "../../../../core/collection/heap/BinaryHeap.js";
|
|
8
8
|
import { QuadTreeNode } from "../../../../core/geom/2d/quad-tree/QuadTreeNode.js";
|
|
@@ -169,7 +169,7 @@ function buildPaths(
|
|
|
169
169
|
const tBuildNodeGroups = actionTask(() => {
|
|
170
170
|
|
|
171
171
|
//group nodes
|
|
172
|
-
const groupMap =
|
|
172
|
+
const groupMap = array_group_by(nodes, readMarkerNodeGroupId);
|
|
173
173
|
|
|
174
174
|
/**
|
|
175
175
|
*
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @template T
|
|
3
|
-
* @param {T[]|ArrayLike<number>|Uint32Array} data
|
|
4
|
-
* @param {function(T):number} score_function
|
|
5
|
-
* @param {*} [score_function_context]
|
|
6
|
-
* @param {number} [start]
|
|
7
|
-
* @param {number} [end]
|
|
8
|
-
* @param {function(T[],number, number):*} [swap_operator]
|
|
9
|
-
* @param {*} [swap_context]
|
|
10
|
-
*/
|
|
11
|
-
export function arrayQuickSort<T>(data: ArrayLike<number> | Uint32Array | T[], score_function: (arg0: T) => number, score_function_context?: any, start?: number, end?: number, swap_operator?: (arg0: T[], arg1: number, arg2: number) => any, swap_context?: any): void;
|
|
12
|
-
//# sourceMappingURL=arrayQuickSort.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"arrayQuickSort.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/array/arrayQuickSort.js"],"names":[],"mappings":"AAIA;;;;;;;;;GASG;AACH,4GAPuB,MAAM,wCAElB,MAAM,QACN,MAAM,oCACO,MAAM,QAAE,MAAM,oCAiErC"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @deprecated
|
|
3
|
-
* @template T
|
|
4
|
-
* @param {T[]} array
|
|
5
|
-
* @param {number} start_index
|
|
6
|
-
* @param {number} end_index
|
|
7
|
-
* @param {T} element
|
|
8
|
-
* @return {boolean}
|
|
9
|
-
*/
|
|
10
|
-
export function array_remove_element<T>(array: T[], start_index: number, end_index: number, element: T): boolean;
|
|
11
|
-
//# sourceMappingURL=array_remove_element.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"array_remove_element.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/array/array_remove_element.js"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,iEALW,MAAM,aACN,MAAM,eAEL,OAAO,CAMlB"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { array_remove_first } from "./array_remove_first.js";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @deprecated
|
|
5
|
-
* @template T
|
|
6
|
-
* @param {T[]} array
|
|
7
|
-
* @param {number} start_index
|
|
8
|
-
* @param {number} end_index
|
|
9
|
-
* @param {T} element
|
|
10
|
-
* @return {boolean}
|
|
11
|
-
*/
|
|
12
|
-
export function array_remove_element(array, start_index, end_index, element) {
|
|
13
|
-
console.warn('deprecated, use array_remove_first instead');
|
|
14
|
-
|
|
15
|
-
array_remove_first(array, element, start_index, end_index - start_index);
|
|
16
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @template T,K
|
|
3
|
-
* @param {T[]} array
|
|
4
|
-
* @param {function(T):K} groupingFunction
|
|
5
|
-
* @param keyHashFunction
|
|
6
|
-
* @returns {Map<K,T[]>}
|
|
7
|
-
*/
|
|
8
|
-
export function groupArrayBy<T, K>(array: T[], groupingFunction: (arg0: T) => K, keyHashFunction?: typeof returnZero): Map<K, T[]>;
|
|
9
|
-
import { returnZero } from "../../function/returnZero.js";
|
|
10
|
-
//# sourceMappingURL=groupArrayBy.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"groupArrayBy.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/array/groupArrayBy.js"],"names":[],"mappings":"AAGA;;;;;;GAMG;AACH,mIA+BC;2BAzC0B,8BAA8B"}
|