@woosh/meep-engine 2.87.1 → 2.87.2

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/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "description": "Fully featured ECS game engine written in JavaScript",
6
6
  "type": "module",
7
7
  "author": "Alexander Goldring",
8
- "version": "2.87.1",
8
+ "version": "2.87.2",
9
9
  "main": "build/meep.module.js",
10
10
  "module": "build/meep.module.js",
11
11
  "exports": {
@@ -0,0 +1,14 @@
1
+ /**
2
+ * @template T
3
+ * @param {QuadTreeNode<T>} tree
4
+ * @param {number} origin_x
5
+ * @param {number} origin_y
6
+ * @param {number} direction_x
7
+ * @param {number} direction_y
8
+ * @param {number} max_distance
9
+ * @param {function(data:T, origin_x:number, origin_y:number, direction_x:number, direction_y:number, max_distance2:number):boolean} [predicate]
10
+ * @param {*} [predicateContext]
11
+ * @returns {number}
12
+ */
13
+ export function qt_query_data_raycast<T>(tree: QuadTreeNode<T>, origin_x: number, origin_y: number, direction_x: number, direction_y: number, max_distance: number, predicate: any, predicateContext?: any): number;
14
+ //# sourceMappingURL=qt_query_data_raycast.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"qt_query_data_raycast.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/2d/quad-tree/qt_query_data_raycast.js"],"names":[],"mappings":"AAQA;;;;;;;;;;;GAWG;AACH,0EATW,MAAM,YACN,MAAM,eACN,MAAM,eACN,MAAM,gBACN,MAAM,2CAGJ,MAAM,CA6DlB"}
@@ -0,0 +1,80 @@
1
+ import { aabb2_distance_sqr_to_point } from "../aabb/aabb2_distance_sqr_to_point.js";
2
+
3
+ /**
4
+ *
5
+ * @type {QuadTreeNode[]}
6
+ */
7
+ const node_stack = [];
8
+
9
+ /**
10
+ * @template T
11
+ * @param {QuadTreeNode<T>} tree
12
+ * @param {number} origin_x
13
+ * @param {number} origin_y
14
+ * @param {number} direction_x
15
+ * @param {number} direction_y
16
+ * @param {number} max_distance
17
+ * @param {function(data:T, origin_x:number, origin_y:number, direction_x:number, direction_y:number, max_distance2:number):boolean} [predicate]
18
+ * @param {*} [predicateContext]
19
+ * @returns {number}
20
+ */
21
+ export function qt_query_data_raycast(
22
+ tree,
23
+ origin_x, origin_y,
24
+ direction_x, direction_y,
25
+ max_distance,
26
+ predicate, predicateContext
27
+ ) {
28
+
29
+ let stack_pointer = 0;
30
+
31
+ const max_distance2 = max_distance * max_distance;
32
+
33
+ node_stack[stack_pointer] = tree;
34
+ stack_pointer++;
35
+
36
+ let best_match = undefined;
37
+ let best_match_distance2 = max_distance2;
38
+
39
+ while (stack_pointer > 0) {
40
+
41
+ --stack_pointer;
42
+ const node = node_stack[stack_pointer];
43
+
44
+ const d2 = aabb2_distance_sqr_to_point(node.x0, node.y0, node.x1, node.y1, origin_x, origin_y);
45
+
46
+ if (d2 > best_match_distance2) {
47
+ // too far, not a match
48
+ continue;
49
+ }
50
+
51
+ const data = node.data;
52
+ const data_count = data.length;
53
+
54
+ for (let i = 0; i < data_count; i++) {
55
+ const datum = data[i];
56
+
57
+ const d2_to_datum = aabb2_distance_sqr_to_point(datum.x0, datum.y0, datum.x1, datum.y1, origin_x, origin_y);
58
+
59
+ if (d2_to_datum < best_match_distance2 && predicate.call(
60
+ predicateContext,
61
+ datum.data,
62
+ origin_x, origin_y,
63
+ direction_x, direction_y,
64
+ best_match_distance2
65
+ )) {
66
+ best_match = datum;
67
+ best_match_distance2 = d2_to_datum;
68
+ }
69
+ }
70
+
71
+ if (node.isSplit()) {
72
+ node_stack[stack_pointer++] = node.topLeft;
73
+ node_stack[stack_pointer++] = node.bottomLeft;
74
+ node_stack[stack_pointer++] = node.topRight;
75
+ node_stack[stack_pointer++] = node.bottomRight;
76
+ }
77
+ }
78
+
79
+ return best_match;
80
+ }