@woosh/meep-engine 2.87.3 → 2.87.4
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 -4
- package/build/meep.min.js +1 -1
- package/build/meep.module.js +4 -4
- package/package.json +1 -1
- package/src/core/binary/align_4.d.ts +7 -0
- package/src/core/binary/align_4.d.ts.map +1 -0
- package/src/core/binary/align_4.js +14 -0
- package/src/core/geom/2d/aabb/aabb2_intersects_ray.d.ts +14 -0
- package/src/core/geom/2d/aabb/aabb2_intersects_ray.d.ts.map +1 -0
- package/src/core/geom/2d/aabb/aabb2_intersects_ray.js +53 -0
- package/src/core/geom/2d/aabb/aabb2_intersects_ray.spec.d.ts +2 -0
- package/src/core/geom/2d/aabb/aabb2_intersects_ray.spec.d.ts.map +1 -0
- package/src/core/geom/2d/aabb/aabb2_intersects_ray.spec.js +28 -0
- package/src/core/geom/2d/hash-grid/SpatialHashGrid.d.ts +52 -0
- package/src/core/geom/2d/hash-grid/SpatialHashGrid.d.ts.map +1 -0
- package/src/core/geom/2d/hash-grid/SpatialHashGrid.js +317 -0
- package/src/core/geom/2d/hash-grid/SpatialHashGrid.spec.d.ts +2 -0
- package/src/core/geom/2d/hash-grid/SpatialHashGrid.spec.d.ts.map +1 -0
- package/src/core/geom/2d/hash-grid/SpatialHashGrid.spec.js +158 -0
- package/src/core/geom/2d/hash-grid/shg_query_raycast.d.ts +14 -0
- package/src/core/geom/2d/hash-grid/shg_query_raycast.d.ts.map +1 -0
- package/src/core/geom/2d/hash-grid/shg_query_raycast.js +21 -0
- package/src/core/geom/2d/lt-grid/LooseTightGrid.d.ts +55 -0
- package/src/core/geom/2d/lt-grid/LooseTightGrid.d.ts.map +1 -0
- package/src/core/geom/2d/lt-grid/LooseTightGrid.js +221 -0
- package/src/core/geom/2d/quad-tree/QuadTreeNode.js +3 -3
- package/src/core/geom/2d/quad-tree/qt_query_data_raycast.d.ts.map +1 -1
- package/src/core/geom/2d/quad-tree/qt_query_data_raycast.js +17 -8
- package/src/core/geom/2d/quad-tree-binary/QuadTree.d.ts +94 -0
- package/src/core/geom/2d/quad-tree-binary/QuadTree.d.ts.map +1 -0
- package/src/core/geom/2d/quad-tree-binary/QuadTree.js +715 -0
- package/src/core/geom/2d/quad-tree-binary/QuadTree.spec.d.ts +2 -0
- package/src/core/geom/2d/quad-tree-binary/QuadTree.spec.d.ts.map +1 -0
- package/src/core/geom/2d/quad-tree-binary/QuadTree.spec.js +53 -0
- package/src/core/geom/3d/morton/de_interleave_2_bits.spec.d.ts +2 -0
- package/src/core/geom/3d/morton/de_interleave_2_bits.spec.d.ts.map +1 -0
- package/src/core/geom/3d/morton/de_interleave_2_bits.spec.js +21 -0
- package/src/core/geom/3d/morton/de_interleave_bits_by_2.d.ts +7 -0
- package/src/core/geom/3d/morton/de_interleave_bits_by_2.d.ts.map +1 -0
- package/src/core/geom/3d/morton/de_interleave_bits_by_2.js +15 -0
- package/src/core/geom/3d/morton/split_by_2.d.ts +1 -1
- package/src/core/geom/3d/morton/split_by_2.js +1 -1
- package/src/core/geom/3d/morton/split_by_3.d.ts +1 -1
- package/src/core/geom/3d/morton/split_by_3.js +1 -1
- package/src/core/geom/3d/topology/struct/binary/BinaryElementPool.d.ts +7 -0
- package/src/core/geom/3d/topology/struct/binary/BinaryElementPool.d.ts.map +1 -1
- package/src/core/geom/3d/topology/struct/binary/BinaryElementPool.js +14 -14
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { QT_NULL_POINTER, QuadTree } from "./QuadTree.js";
|
|
2
|
+
|
|
3
|
+
test("constructor does not throw", () => {
|
|
4
|
+
|
|
5
|
+
new QuadTree();
|
|
6
|
+
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
test("root is set after insert operation", () => {
|
|
10
|
+
|
|
11
|
+
const tree = new QuadTree();
|
|
12
|
+
|
|
13
|
+
const el = tree.element_allocate();
|
|
14
|
+
|
|
15
|
+
tree.element_set_bounds_primitive(el, 0, 0, 0, 0);
|
|
16
|
+
|
|
17
|
+
tree.element_insert(el);
|
|
18
|
+
|
|
19
|
+
expect(tree.root).not.toEqual(QT_NULL_POINTER)
|
|
20
|
+
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
test("removing last element clears out root", () => {
|
|
24
|
+
const tree = new QuadTree();
|
|
25
|
+
|
|
26
|
+
const el = tree.element_allocate();
|
|
27
|
+
|
|
28
|
+
tree.element_set_bounds_primitive(el, 0, 0, 0, 0);
|
|
29
|
+
|
|
30
|
+
tree.element_insert(el);
|
|
31
|
+
tree.element_remove(el);
|
|
32
|
+
|
|
33
|
+
expect(tree.root).toEqual(QT_NULL_POINTER)
|
|
34
|
+
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
test("inserting multiple elements into the tree does not throw",()=>{
|
|
38
|
+
|
|
39
|
+
const tree = new QuadTree();
|
|
40
|
+
|
|
41
|
+
const a = tree.element_allocate();
|
|
42
|
+
|
|
43
|
+
tree.element_set_bounds_primitive(a, 0, 0, 0, 0);
|
|
44
|
+
|
|
45
|
+
tree.element_insert(a);
|
|
46
|
+
|
|
47
|
+
const b = tree.element_allocate();
|
|
48
|
+
|
|
49
|
+
tree.element_set_bounds_primitive(b, 0, 0, 0, 0);
|
|
50
|
+
|
|
51
|
+
tree.element_insert(b);
|
|
52
|
+
|
|
53
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"de_interleave_2_bits.spec.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/morton/de_interleave_2_bits.spec.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { de_interleave_2_bits } from "./de_interleave_bits_by_2.js";
|
|
2
|
+
|
|
3
|
+
test("deinterleave 0", () => {
|
|
4
|
+
|
|
5
|
+
const bits = de_interleave_2_bits(0);
|
|
6
|
+
|
|
7
|
+
expect(bits).toBe(0);
|
|
8
|
+
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
test("deinterleave 3 and 7", () => {
|
|
12
|
+
|
|
13
|
+
const interleaved_3 = 0b101;
|
|
14
|
+
const interleaved_4 = 0b10000;
|
|
15
|
+
|
|
16
|
+
const interleaved = (interleaved_3 << 1) | interleaved_4;
|
|
17
|
+
|
|
18
|
+
expect(de_interleave_2_bits(interleaved)).toBe(4);
|
|
19
|
+
expect(de_interleave_2_bits(interleaved >> 1)).toBe(3);
|
|
20
|
+
|
|
21
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ABABAB gets turned into BBB
|
|
3
|
+
* @param {number} interleaved
|
|
4
|
+
* @returns {number} Odd bits end up in lower 16 bits, even bits end up in top part
|
|
5
|
+
*/
|
|
6
|
+
export function de_interleave_2_bits(interleaved: number): number;
|
|
7
|
+
//# sourceMappingURL=de_interleave_bits_by_2.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"de_interleave_bits_by_2.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/morton/de_interleave_bits_by_2.js"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,kDAHW,MAAM,GACJ,MAAM,CAWlB"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ABABAB gets turned into BBB
|
|
3
|
+
* @param {number} interleaved
|
|
4
|
+
* @returns {number} Odd bits end up in lower 16 bits, even bits end up in top part
|
|
5
|
+
*/
|
|
6
|
+
export function de_interleave_2_bits(interleaved) {
|
|
7
|
+
let x = interleaved & 0x55555555;
|
|
8
|
+
|
|
9
|
+
x = (x | (x >> 1)) & 0x33333333;
|
|
10
|
+
x = (x | (x >> 2)) & 0x0f0f0f0f;
|
|
11
|
+
x = (x | (x >> 4)) & 0x00ff00ff;
|
|
12
|
+
x = (x | (x >> 8)) & 0x0000ffff;
|
|
13
|
+
|
|
14
|
+
return x;
|
|
15
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* method to separate bits from a given integer 2 positions apart
|
|
3
3
|
*
|
|
4
|
-
* @example when input is ABC, output bits are
|
|
4
|
+
* @example when input is ABC, output bits are 0A0B0C
|
|
5
5
|
* @see https://github.com/Forceflow/libmorton/blob/234a443ca8e2c64f6385f1a9d6ee10a70d08a3fa/include/libmorton/morton2D.h#L99
|
|
6
6
|
* @param {number} a
|
|
7
7
|
* @returns {number}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* method to separate bits from a given integer 2 positions apart
|
|
3
3
|
*
|
|
4
|
-
* @example when input is ABC, output bits are
|
|
4
|
+
* @example when input is ABC, output bits are 0A0B0C
|
|
5
5
|
* @see https://github.com/Forceflow/libmorton/blob/234a443ca8e2c64f6385f1a9d6ee10a70d08a3fa/include/libmorton/morton2D.h#L99
|
|
6
6
|
* @param {number} a
|
|
7
7
|
* @returns {number}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* method to separate bits from a given integer 3 positions apart
|
|
3
3
|
* we only look at the first 10 bits
|
|
4
4
|
*
|
|
5
|
-
* @example when input is ABC, output bits are
|
|
5
|
+
* @example when input is ABC, output bits are 00A00B00C
|
|
6
6
|
* @param {number} a
|
|
7
7
|
* @returns {number}
|
|
8
8
|
*/
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* method to separate bits from a given integer 3 positions apart
|
|
3
3
|
* we only look at the first 10 bits
|
|
4
4
|
*
|
|
5
|
-
* @example when input is ABC, output bits are
|
|
5
|
+
* @example when input is ABC, output bits are 00A00B00C
|
|
6
6
|
* @param {number} a
|
|
7
7
|
* @returns {number}
|
|
8
8
|
*/
|
|
@@ -70,6 +70,13 @@ export class BinaryElementPool {
|
|
|
70
70
|
* @return {number}
|
|
71
71
|
*/
|
|
72
72
|
element_address(id: number): number;
|
|
73
|
+
/**
|
|
74
|
+
* Returns word-offset of element
|
|
75
|
+
* Word size is 4, so this is the same as `element_address(id) / 4`
|
|
76
|
+
* @param {number} id
|
|
77
|
+
* @return {number}
|
|
78
|
+
*/
|
|
79
|
+
element_word(id: number): number;
|
|
73
80
|
/**
|
|
74
81
|
* Used alongside iterators to check if element is actually allocated or not
|
|
75
82
|
* @param {number} id
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BinaryElementPool.d.ts","sourceRoot":"","sources":["../../../../../../../../src/core/geom/3d/topology/struct/binary/BinaryElementPool.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"BinaryElementPool.d.ts","sourceRoot":"","sources":["../../../../../../../../src/core/geom/3d/topology/struct/binary/BinaryElementPool.js"],"names":[],"mappings":"AAwBA;;GAEG;AACH;IAEI;;;;OAIG;IACH,uBAHW,MAAM,qBACN,MAAM,EA0ChB;IApCG;;;;OAIG;IACH,oBAA4B;IAE5B;;;;OAIG;IACH,eAAgB;IAEhB;;;;;OAKG;IACH,uBAAuB;IAEvB,2BAA2E;IAC3E,yBAAsD;IACtD,2BAAwD;IACxD,6BAA0D;IAC1D,oBAAiD;IAEjD,mBAAkC;IAElC;;;;OAIG;IACH,eAAe;IAGnB;;;;OAIG;IACH,mBAEC;IAED;;;OAGG;IACH,uBAEC;IAED;;;OAGG;IACH,+BAEC;IAED;;;OAGG;IACH,iCAEC;IAED;;OAEG;IACH,aAEC;IAED;;;;OAIG;IACH,oBAHW,MAAM,GACL,MAAM,CAMjB;IAED;;;;;OAKG;IACH,iBAHW,MAAM,GACL,MAAM,CAIjB;IAED;;;;OAIG;IACH,iBAHW,MAAM,GACL,OAAO,CAsBlB;IAED;;;;OAIG;IACH,uBAsBC;IAED;;;;OAIG;IACH,wBAQC;IAED;;;OAGG;IACH,0BAFW,MAAM,QAMhB;IAGD;;;OAGG;IACH,YAFY,MAAM,CAqBjB;IAED;;;;OAIG;IACH,2BAHW,MAAM,GACL,MAAM,CAcjB;IAED;;;;OAIG;IACH,YAFW,MAAM,QAYhB;IAED;;OAEG;IACH,cAGC;CACJ"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { max3 } from "../../../../../math/max3.js";
|
|
2
1
|
import { assert } from "../../../../../assert.js";
|
|
2
|
+
import { align_4 } from "../../../../../binary/align_4.js";
|
|
3
3
|
import { typed_array_copy } from "../../../../../collection/array/typed/typed_array_copy.js";
|
|
4
|
+
import { max3 } from "../../../../../math/max3.js";
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* How many items to reserve by default
|
|
@@ -21,19 +22,6 @@ const CAPACITY_GROW_MULTIPLIER = 1.2;
|
|
|
21
22
|
*/
|
|
22
23
|
const CAPACITY_GROW_MIN_STEP = 32;
|
|
23
24
|
|
|
24
|
-
/**
|
|
25
|
-
* Align on 4 byte boundary
|
|
26
|
-
* @param {number} n
|
|
27
|
-
* @return {number}
|
|
28
|
-
*/
|
|
29
|
-
function align_4(n) {
|
|
30
|
-
const result = ((n + 0x3) >> 2) << 2;
|
|
31
|
-
|
|
32
|
-
assert.greaterThanOrEqual(result, n, 'aligned result must be >= input');
|
|
33
|
-
|
|
34
|
-
return result;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
25
|
/**
|
|
38
26
|
* @see https://github.com/blender/blender/blob/master/source/blender/blenlib/intern/BLI_mempool.c
|
|
39
27
|
*/
|
|
@@ -137,12 +125,24 @@ export class BinaryElementPool {
|
|
|
137
125
|
return this.__item_size * id;
|
|
138
126
|
}
|
|
139
127
|
|
|
128
|
+
/**
|
|
129
|
+
* Returns word-offset of element
|
|
130
|
+
* Word size is 4, so this is the same as `element_address(id) / 4`
|
|
131
|
+
* @param {number} id
|
|
132
|
+
* @return {number}
|
|
133
|
+
*/
|
|
134
|
+
element_word(id) {
|
|
135
|
+
return this.element_address(id) >> 2;
|
|
136
|
+
}
|
|
137
|
+
|
|
140
138
|
/**
|
|
141
139
|
* Used alongside iterators to check if element is actually allocated or not
|
|
142
140
|
* @param {number} id
|
|
143
141
|
* @return {boolean}
|
|
144
142
|
*/
|
|
145
143
|
is_allocated(id) {
|
|
144
|
+
assert.isNonNegativeInteger(id, 'id');
|
|
145
|
+
|
|
146
146
|
if (id >= this.__size) {
|
|
147
147
|
// ID is past allocated region
|
|
148
148
|
return false;
|