@woosh/meep-engine 2.117.35 → 2.117.36
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 +25 -9
- package/build/meep.min.js +1 -1
- package/build/meep.module.js +25 -9
- package/package.json +1 -1
- package/src/core/bvh2/bvh3/ebvh_build_hierarchy.d.ts.map +1 -1
- package/src/core/bvh2/bvh3/ebvh_build_hierarchy.js +12 -3
- package/src/engine/graphics/geometry/buffered/query/GeometrySpatialQueryAccelerator.d.ts +78 -25
- package/src/engine/graphics/geometry/buffered/query/GeometrySpatialQueryAccelerator.d.ts.map +1 -1
- package/src/engine/graphics/geometry/buffered/query/GeometrySpatialQueryAccelerator.js +25 -9
package/build/meep.module.js
CHANGED
|
@@ -66531,13 +66531,19 @@ function bvh32_geometry_overlap_clipping_volume(
|
|
|
66531
66531
|
return false;
|
|
66532
66532
|
}
|
|
66533
66533
|
|
|
66534
|
+
/**
|
|
66535
|
+
* 4-tuples
|
|
66536
|
+
* @type {number[]}
|
|
66537
|
+
*/
|
|
66534
66538
|
const scratch_planes = [];
|
|
66535
66539
|
|
|
66536
66540
|
class GeometrySpatialQueryAccelerator {
|
|
66537
|
-
constructor(
|
|
66541
|
+
constructor(
|
|
66542
|
+
cache_size = 100 * 1024 * 1024
|
|
66543
|
+
) {
|
|
66538
66544
|
|
|
66539
66545
|
/**
|
|
66540
|
-
*
|
|
66546
|
+
* @private
|
|
66541
66547
|
* @type {Cache<THREE.BufferGeometry, BinaryUint32BVH>}
|
|
66542
66548
|
*/
|
|
66543
66549
|
this.cache = new Cache({
|
|
@@ -66583,8 +66589,7 @@ class GeometrySpatialQueryAccelerator {
|
|
|
66583
66589
|
*/
|
|
66584
66590
|
queryContainmentViaClippingPlanes(geometry, planes) {
|
|
66585
66591
|
|
|
66586
|
-
|
|
66587
|
-
const bvh = this.__acquireBVH(geometry);
|
|
66592
|
+
const bvh = this.acquire_bvh(geometry);
|
|
66588
66593
|
|
|
66589
66594
|
read_three_planes_to_array(planes, scratch_planes);
|
|
66590
66595
|
|
|
@@ -66658,7 +66663,7 @@ class GeometrySpatialQueryAccelerator {
|
|
|
66658
66663
|
let bvh;
|
|
66659
66664
|
|
|
66660
66665
|
try {
|
|
66661
|
-
bvh = this.
|
|
66666
|
+
bvh = this.acquire_bvh(geometry);
|
|
66662
66667
|
} catch (e) {
|
|
66663
66668
|
return false;
|
|
66664
66669
|
}
|
|
@@ -66723,11 +66728,22 @@ class GeometrySpatialQueryAccelerator {
|
|
|
66723
66728
|
}
|
|
66724
66729
|
|
|
66725
66730
|
/**
|
|
66726
|
-
*
|
|
66731
|
+
* Destroys cache for a given geometry, useful for when geometry changes and cache needs to be invalidated
|
|
66732
|
+
* @param {THREE.BufferGeometry} geometry
|
|
66733
|
+
* @returns {boolean}
|
|
66734
|
+
*/
|
|
66735
|
+
cache_remove_geometry(geometry) {
|
|
66736
|
+
|
|
66737
|
+
return this.cache.remove(geometry);
|
|
66738
|
+
|
|
66739
|
+
}
|
|
66740
|
+
|
|
66741
|
+
/**
|
|
66742
|
+
* NOTE: do not modify the BVH
|
|
66727
66743
|
* @param {THREE.BufferGeometry} geometry
|
|
66728
66744
|
* @returns {BinaryUint32BVH}
|
|
66729
66745
|
*/
|
|
66730
|
-
|
|
66746
|
+
acquire_bvh(geometry) {
|
|
66731
66747
|
|
|
66732
66748
|
const existing = this.cache.get(geometry);
|
|
66733
66749
|
|
|
@@ -66735,7 +66751,7 @@ class GeometrySpatialQueryAccelerator {
|
|
|
66735
66751
|
return existing;
|
|
66736
66752
|
}
|
|
66737
66753
|
|
|
66738
|
-
const bvh = this.
|
|
66754
|
+
const bvh = this.__build_bvh(geometry);
|
|
66739
66755
|
|
|
66740
66756
|
this.cache.put(geometry, bvh);
|
|
66741
66757
|
|
|
@@ -66747,7 +66763,7 @@ class GeometrySpatialQueryAccelerator {
|
|
|
66747
66763
|
* @param {THREE.BufferGeometry} geometry
|
|
66748
66764
|
* @returns {BinaryUint32BVH}
|
|
66749
66765
|
*/
|
|
66750
|
-
|
|
66766
|
+
__build_bvh(geometry) {
|
|
66751
66767
|
const bvh = new BinaryUint32BVH();
|
|
66752
66768
|
|
|
66753
66769
|
const position_attribute = geometry.getAttribute('position');
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ebvh_build_hierarchy.d.ts","sourceRoot":"","sources":["../../../../../src/core/bvh2/bvh3/ebvh_build_hierarchy.js"],"names":[],"mappings":"AAKA;;;;;;;;;;;GAWG;AACH,kEAPW,MAAM,EAAE,GAAC,WAAW,oBACpB,MAAM,aACN,MAAM,EAAE,GAAC,WAAW,oBACpB,MAAM,2BACN,MAAM,GACJ,MAAM,
|
|
1
|
+
{"version":3,"file":"ebvh_build_hierarchy.d.ts","sourceRoot":"","sources":["../../../../../src/core/bvh2/bvh3/ebvh_build_hierarchy.js"],"names":[],"mappings":"AAKA;;;;;;;;;;;GAWG;AACH,kEAPW,MAAM,EAAE,GAAC,WAAW,oBACpB,MAAM,aACN,MAAM,EAAE,GAAC,WAAW,oBACpB,MAAM,2BACN,MAAM,GACJ,MAAM,CA+ElB"}
|
|
@@ -35,13 +35,22 @@ export function ebvh_build_hierarchy(
|
|
|
35
35
|
while (unprocessed_node_count > 1) {
|
|
36
36
|
|
|
37
37
|
for (let i = 0; i < sah_optimization_level; i++) {
|
|
38
|
+
|
|
38
39
|
// sort intermediate nodes using small locality and SAH metric
|
|
39
|
-
const offset = (i<<1) & 3;
|
|
40
|
-
const swap_count = ebvh_nodes_sort_sah_local4(bvh, unprocessed_nodes, offset, unprocessed_node_count - offset);
|
|
41
40
|
|
|
42
|
-
|
|
41
|
+
const offset = (i << 1) & 3;
|
|
42
|
+
|
|
43
|
+
const swap_count = ebvh_nodes_sort_sah_local4(
|
|
44
|
+
bvh,
|
|
45
|
+
unprocessed_nodes,
|
|
46
|
+
offset,
|
|
47
|
+
unprocessed_node_count - offset
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
if (swap_count === 0) {
|
|
43
51
|
break;
|
|
44
52
|
}
|
|
53
|
+
|
|
45
54
|
}
|
|
46
55
|
|
|
47
56
|
let added_nodes = 0;
|
|
@@ -1,25 +1,78 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
):
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
*
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
1
|
+
export class GeometrySpatialQueryAccelerator {
|
|
2
|
+
constructor(cache_size?: number);
|
|
3
|
+
/**
|
|
4
|
+
* @private
|
|
5
|
+
* @type {Cache<THREE.BufferGeometry, BinaryUint32BVH>}
|
|
6
|
+
*/
|
|
7
|
+
private cache;
|
|
8
|
+
/**
|
|
9
|
+
*
|
|
10
|
+
* @param {number} value in bytes
|
|
11
|
+
*/
|
|
12
|
+
set cache_size(arg: number);
|
|
13
|
+
/**
|
|
14
|
+
*
|
|
15
|
+
* @return {number} in bytes
|
|
16
|
+
*/
|
|
17
|
+
get cache_size(): number;
|
|
18
|
+
/**
|
|
19
|
+
*
|
|
20
|
+
* @param {THREE.BufferGeometry} geometry
|
|
21
|
+
* @param {Plane[]} planes
|
|
22
|
+
* @returns {boolean} true means some overlap exists, false otherwise
|
|
23
|
+
*/
|
|
24
|
+
queryContainmentViaClippingPlanes(geometry: THREE.BufferGeometry, planes: Plane[]): boolean;
|
|
25
|
+
/**
|
|
26
|
+
*
|
|
27
|
+
* @param {SurfacePoint3} destination
|
|
28
|
+
* @param {THREE.BufferGeometry} geometry
|
|
29
|
+
* @param {number[]|ArrayLike<number>|Float32Array} ray 6 component vector, [origin_x, origin_y, origin_z, direction_x, direction_y, direction_z]
|
|
30
|
+
* @return {boolean}
|
|
31
|
+
*/
|
|
32
|
+
queryRaycastNearest_array(destination: SurfacePoint3, geometry: THREE.BufferGeometry, ray: number[] | ArrayLike<number> | Float32Array): boolean;
|
|
33
|
+
/**
|
|
34
|
+
*
|
|
35
|
+
* @param {SurfacePoint3} destination
|
|
36
|
+
* @param {THREE.BufferGeometry} geometry
|
|
37
|
+
* @param {number} ray_origin_x
|
|
38
|
+
* @param {number} ray_origin_y
|
|
39
|
+
* @param {number} ray_origin_z
|
|
40
|
+
* @param {number} ray_direction_x
|
|
41
|
+
* @param {number} ray_direction_y
|
|
42
|
+
* @param {number} ray_direction_z
|
|
43
|
+
* @return {boolean}
|
|
44
|
+
*/
|
|
45
|
+
queryRaycastNearest_primitive(destination: SurfacePoint3, geometry: THREE.BufferGeometry, ray_origin_x: number, ray_origin_y: number, ray_origin_z: number, ray_direction_x: number, ray_direction_y: number, ray_direction_z: number): boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Get the nearest ray intersection
|
|
48
|
+
* @param {SurfacePoint3} destination
|
|
49
|
+
* @param {THREE.BufferGeometry} geometry
|
|
50
|
+
* @param {Vector3} ray_origin
|
|
51
|
+
* @param {Vector3} ray_direction
|
|
52
|
+
* @returns {boolean} true if hit detected, false otherwise
|
|
53
|
+
*/
|
|
54
|
+
queryRaycastNearest(destination: SurfacePoint3, geometry: THREE.BufferGeometry, ray_origin: Vector3, ray_direction: Vector3): boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Destroys cache for a given geometry, useful for when geometry changes and cache needs to be invalidated
|
|
57
|
+
* @param {THREE.BufferGeometry} geometry
|
|
58
|
+
* @returns {boolean}
|
|
59
|
+
*/
|
|
60
|
+
cache_remove_geometry(geometry: THREE.BufferGeometry): boolean;
|
|
61
|
+
/**
|
|
62
|
+
* NOTE: do not modify the BVH
|
|
63
|
+
* @param {THREE.BufferGeometry} geometry
|
|
64
|
+
* @returns {BinaryUint32BVH}
|
|
65
|
+
*/
|
|
66
|
+
acquire_bvh(geometry: THREE.BufferGeometry): BinaryUint32BVH;
|
|
67
|
+
/**
|
|
68
|
+
* @private
|
|
69
|
+
* @param {THREE.BufferGeometry} geometry
|
|
70
|
+
* @returns {BinaryUint32BVH}
|
|
71
|
+
*/
|
|
72
|
+
private __build_bvh;
|
|
73
|
+
}
|
|
74
|
+
export namespace GeometrySpatialQueryAccelerator {
|
|
75
|
+
let INSTANCE: GeometrySpatialQueryAccelerator;
|
|
76
|
+
}
|
|
77
|
+
import { BinaryUint32BVH } from "../../../../../core/bvh2/binary/2/BinaryUint32BVH.js";
|
|
78
|
+
//# sourceMappingURL=GeometrySpatialQueryAccelerator.d.ts.map
|
package/src/engine/graphics/geometry/buffered/query/GeometrySpatialQueryAccelerator.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GeometrySpatialQueryAccelerator.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/graphics/geometry/buffered/query/GeometrySpatialQueryAccelerator.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"GeometrySpatialQueryAccelerator.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/graphics/geometry/buffered/query/GeometrySpatialQueryAccelerator.js"],"names":[],"mappings":"AAgBA;IACI,iCAyBC;IArBG;;;OAGG;IACH,cAeE;IAIN;;;OAGG;IACH,4BAEC;IAED;;;OAGG;IACH,yBAEC;IAED;;;;;OAKG;IACH,4CAJW,MAAM,cAAc,UACpB,OAAO,GACL,OAAO,CAuCnB;IAED;;;;;;OAMG;IACH,gEAJW,MAAM,cAAc,OACpB,MAAM,EAAE,GAAC,UAAU,MAAM,CAAC,GAAC,YAAY,GACtC,OAAO,CASlB;IAED;;;;;;;;;;;OAWG;IACH,oEATW,MAAM,cAAc,gBACpB,MAAM,gBACN,MAAM,gBACN,MAAM,mBACN,MAAM,mBACN,MAAM,mBACN,MAAM,GACL,OAAO,CAwDlB;IAED;;;;;;;OAOG;IACH,0DALW,MAAM,cAAc,gDAGlB,OAAO,CAcnB;IAED;;;;OAIG;IACH,gCAHW,MAAM,cAAc,GAClB,OAAO,CAMnB;IAED;;;;OAIG;IACH,sBAHW,MAAM,cAAc,GAClB,eAAe,CAiB3B;IAED;;;;OAIG;IACH,oBAoBC;CAEJ;;kBAIS,+BAA+B;;gCAlRT,sDAAsD"}
|
|
@@ -8,13 +8,19 @@ import { deinterleaveBufferAttribute } from "../deinterleaveBufferAttribute.js";
|
|
|
8
8
|
import { bvh32_geometry_overlap_clipping_volume } from "./bvh32_geometry_overlap_clipping_volume.js";
|
|
9
9
|
import { bvh32_geometry_raycast } from "./bvh32_geometry_raycast.js";
|
|
10
10
|
|
|
11
|
+
/**
|
|
12
|
+
* 4-tuples
|
|
13
|
+
* @type {number[]}
|
|
14
|
+
*/
|
|
11
15
|
const scratch_planes = []
|
|
12
16
|
|
|
13
17
|
export class GeometrySpatialQueryAccelerator {
|
|
14
|
-
constructor(
|
|
18
|
+
constructor(
|
|
19
|
+
cache_size = 100 * 1024 * 1024
|
|
20
|
+
) {
|
|
15
21
|
|
|
16
22
|
/**
|
|
17
|
-
*
|
|
23
|
+
* @private
|
|
18
24
|
* @type {Cache<THREE.BufferGeometry, BinaryUint32BVH>}
|
|
19
25
|
*/
|
|
20
26
|
this.cache = new Cache({
|
|
@@ -62,8 +68,7 @@ export class GeometrySpatialQueryAccelerator {
|
|
|
62
68
|
assert.notNull(geometry, 'geometry');
|
|
63
69
|
assert.defined(geometry, 'geometry');
|
|
64
70
|
|
|
65
|
-
|
|
66
|
-
const bvh = this.__acquireBVH(geometry);
|
|
71
|
+
const bvh = this.acquire_bvh(geometry);
|
|
67
72
|
|
|
68
73
|
read_three_planes_to_array(planes, scratch_planes);
|
|
69
74
|
|
|
@@ -139,7 +144,7 @@ export class GeometrySpatialQueryAccelerator {
|
|
|
139
144
|
let bvh;
|
|
140
145
|
|
|
141
146
|
try {
|
|
142
|
-
bvh = this.
|
|
147
|
+
bvh = this.acquire_bvh(geometry);
|
|
143
148
|
} catch (e) {
|
|
144
149
|
console.error(e);
|
|
145
150
|
return false;
|
|
@@ -205,11 +210,22 @@ export class GeometrySpatialQueryAccelerator {
|
|
|
205
210
|
}
|
|
206
211
|
|
|
207
212
|
/**
|
|
208
|
-
*
|
|
213
|
+
* Destroys cache for a given geometry, useful for when geometry changes and cache needs to be invalidated
|
|
214
|
+
* @param {THREE.BufferGeometry} geometry
|
|
215
|
+
* @returns {boolean}
|
|
216
|
+
*/
|
|
217
|
+
cache_remove_geometry(geometry) {
|
|
218
|
+
|
|
219
|
+
return this.cache.remove(geometry);
|
|
220
|
+
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* NOTE: do not modify the BVH
|
|
209
225
|
* @param {THREE.BufferGeometry} geometry
|
|
210
226
|
* @returns {BinaryUint32BVH}
|
|
211
227
|
*/
|
|
212
|
-
|
|
228
|
+
acquire_bvh(geometry) {
|
|
213
229
|
assert.notNull(geometry, 'geometry');
|
|
214
230
|
assert.defined(geometry, 'geometry');
|
|
215
231
|
|
|
@@ -219,7 +235,7 @@ export class GeometrySpatialQueryAccelerator {
|
|
|
219
235
|
return existing;
|
|
220
236
|
}
|
|
221
237
|
|
|
222
|
-
const bvh = this.
|
|
238
|
+
const bvh = this.__build_bvh(geometry);
|
|
223
239
|
|
|
224
240
|
this.cache.put(geometry, bvh);
|
|
225
241
|
|
|
@@ -231,7 +247,7 @@ export class GeometrySpatialQueryAccelerator {
|
|
|
231
247
|
* @param {THREE.BufferGeometry} geometry
|
|
232
248
|
* @returns {BinaryUint32BVH}
|
|
233
249
|
*/
|
|
234
|
-
|
|
250
|
+
__build_bvh(geometry) {
|
|
235
251
|
const bvh = new BinaryUint32BVH();
|
|
236
252
|
|
|
237
253
|
const position_attribute = geometry.getAttribute('position');
|