@woosh/meep-engine 2.117.35 → 2.117.37

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.
Files changed (26) hide show
  1. package/build/meep.cjs +25 -9
  2. package/build/meep.min.js +1 -1
  3. package/build/meep.module.js +25 -9
  4. package/package.json +1 -1
  5. package/src/core/bvh2/bvh3/ebvh_build_hierarchy.d.ts.map +1 -1
  6. package/src/core/bvh2/bvh3/ebvh_build_hierarchy.js +12 -3
  7. package/src/core/geom/3d/Ray3.js +2 -2
  8. package/src/core/geom/3d/plane/plane3_matrix4_project.d.ts +12 -0
  9. package/src/core/geom/3d/plane/plane3_matrix4_project.d.ts.map +1 -0
  10. package/src/core/geom/3d/plane/plane3_matrix4_project.js +33 -0
  11. package/src/core/geom/vec3/v3_array_matrix4_rotate.d.ts +11 -0
  12. package/src/core/geom/vec3/v3_array_matrix4_rotate.d.ts.map +1 -0
  13. package/src/core/geom/vec3/v3_array_matrix4_rotate.js +22 -0
  14. package/src/core/geom/vec3/v3_matrix4_rotate.d.ts +4 -3
  15. package/src/core/geom/vec3/v3_matrix4_rotate.d.ts.map +1 -1
  16. package/src/core/geom/vec3/v3_matrix4_rotate.js +6 -7
  17. package/src/core/geom/vec3/v3_multiply_scalar.d.ts +11 -0
  18. package/src/core/geom/vec3/v3_multiply_scalar.d.ts.map +1 -0
  19. package/src/core/geom/vec3/v3_multiply_scalar.js +19 -0
  20. package/src/engine/graphics/geometry/buffered/geometry_compute_vertex_normals_unindexed.d.ts.map +1 -1
  21. package/src/engine/graphics/geometry/buffered/geometry_compute_vertex_normals_unindexed.js +1 -4
  22. package/src/engine/graphics/geometry/buffered/query/GeometrySpatialQueryAccelerator.d.ts +78 -25
  23. package/src/engine/graphics/geometry/buffered/query/GeometrySpatialQueryAccelerator.d.ts.map +1 -1
  24. package/src/engine/graphics/geometry/buffered/query/GeometrySpatialQueryAccelerator.js +25 -9
  25. package/src/engine/graphics/sh3/path_tracer/ray_hit_apply_transform.js +2 -2
  26. package/src/engine/graphics/sh3/path_tracer/texture/sample_material.js +2 -2
@@ -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(cache_size = 100 * 1024 * 1024) {
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.__acquireBVH(geometry);
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
- * @private
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
- __acquireBVH(geometry) {
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.__buildBVH(geometry);
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
- __buildBVH(geometry) {
66766
+ __build_bvh(geometry) {
66751
66767
  const bvh = new BinaryUint32BVH();
66752
66768
 
66753
66769
  const position_attribute = geometry.getAttribute('position');
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.117.35",
8
+ "version": "2.117.37",
9
9
  "main": "build/meep.module.js",
10
10
  "module": "build/meep.module.js",
11
11
  "exports": {
@@ -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,CAsElB"}
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
- if(swap_count === 0){
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;
@@ -2,9 +2,9 @@ import { assert } from "../../assert.js";
2
2
  import { array_copy } from "../../collection/array/array_copy.js";
3
3
  import { array_range_equal_strict } from "../../collection/array/array_range_equal_strict.js";
4
4
  import { computeHashFloatArray } from "../../math/hash/computeHashFloatArray.js";
5
+ import { v3_array_matrix4_rotate } from "../vec3/v3_array_matrix4_rotate.js";
5
6
  import { v3_array_normalize } from "../vec3/v3_array_normalize.js";
6
7
  import { v3_matrix4_multiply } from "../vec3/v3_matrix4_multiply.js";
7
- import { v3_matrix4_rotate } from "../vec3/v3_matrix4_rotate.js";
8
8
  import { ray3_interval_array_apply_matrix4 } from "./ray/ray3_interval_array_apply_matrix4.js";
9
9
 
10
10
  /**
@@ -175,7 +175,7 @@ export class Ray3 extends Float32Array {
175
175
 
176
176
  // special case
177
177
  v3_matrix4_multiply(this, 0, this, 0, m4);
178
- v3_matrix4_rotate(this, 3, this, 3, m4);
178
+ v3_array_matrix4_rotate(this, 3, this, 3, m4);
179
179
 
180
180
  }
181
181
  }
@@ -0,0 +1,12 @@
1
+ /**
2
+ *
3
+ * @param {number[]|Float64Array|Float32Array} destination
4
+ * @param {number} destination_offset
5
+ * @param {number[]|Float32Array|Float64Array} matrix
6
+ * @param {number} x
7
+ * @param {number} y
8
+ * @param {number} z
9
+ * @param {number} w
10
+ */
11
+ export function plane3_matrix4_project(destination: number[] | Float64Array | Float32Array, destination_offset: number, matrix: number[] | Float32Array | Float64Array, x: number, y: number, z: number, w: number): void;
12
+ //# sourceMappingURL=plane3_matrix4_project.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plane3_matrix4_project.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/plane/plane3_matrix4_project.js"],"names":[],"mappings":"AAOA;;;;;;;;;GASG;AACH,oDARW,MAAM,EAAE,GAAC,YAAY,GAAC,YAAY,sBAClC,MAAM,UACN,MAAM,EAAE,GAAC,YAAY,GAAC,YAAY,KAClC,MAAM,KACN,MAAM,KACN,MAAM,KACN,MAAM,QAiBhB"}
@@ -0,0 +1,33 @@
1
+ import { v3_dot_array_array } from "../../vec3/v3_dot_array_array.js";
2
+ import { v3_matrix4_multiply } from "../../vec3/v3_matrix4_multiply.js";
3
+ import { v3_matrix4_rotate } from "../../vec3/v3_matrix4_rotate.js";
4
+ import { v3_multiply_scalar } from "../../vec3/v3_multiply_scalar.js";
5
+
6
+ const scratch_v3_0 = new Float32Array(3);
7
+
8
+ /**
9
+ *
10
+ * @param {number[]|Float64Array|Float32Array} destination
11
+ * @param {number} destination_offset
12
+ * @param {number[]|Float32Array|Float64Array} matrix
13
+ * @param {number} x
14
+ * @param {number} y
15
+ * @param {number} z
16
+ * @param {number} w
17
+ */
18
+ export function plane3_matrix4_project(
19
+ destination, destination_offset,
20
+ matrix,
21
+ x, y, z, w,
22
+ ) {
23
+
24
+ // build reference point in the new pane
25
+ v3_multiply_scalar(scratch_v3_0, 0, x, y, z, -w);
26
+ v3_matrix4_multiply(scratch_v3_0, 0, scratch_v3_0, 0, matrix);
27
+
28
+ // construct rotation matrix for the normal
29
+ v3_matrix4_rotate(destination, destination_offset, x, y, z, matrix);
30
+
31
+ // figure out new planar offset using new orientation and a reference point
32
+ destination[destination_offset + 3] = -v3_dot_array_array(scratch_v3_0, 0, destination, destination_offset);
33
+ }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Perform rotation on a direction vector using 3x3 portion of a 4x4 matrix
3
+ * NOTE: produces a normalized vector
4
+ * @param {number[]|Float32Array} output
5
+ * @param {number} output_offset
6
+ * @param {number[]|Float32Array} input
7
+ * @param {number} input_offset
8
+ * @param {number[]|Float32Array} m4
9
+ */
10
+ export function v3_array_matrix4_rotate(output: number[] | Float32Array, output_offset: number, input: number[] | Float32Array, input_offset: number, m4: number[] | Float32Array): void;
11
+ //# sourceMappingURL=v3_array_matrix4_rotate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"v3_array_matrix4_rotate.d.ts","sourceRoot":"","sources":["../../../../../src/core/geom/vec3/v3_array_matrix4_rotate.js"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,gDANW,MAAM,EAAE,GAAC,YAAY,iBACrB,MAAM,SACN,MAAM,EAAE,GAAC,YAAY,gBACrB,MAAM,MACN,MAAM,EAAE,GAAC,YAAY,QAY/B"}
@@ -0,0 +1,22 @@
1
+ import { v3_matrix4_rotate } from "./v3_matrix4_rotate.js";
2
+
3
+ /**
4
+ * Perform rotation on a direction vector using 3x3 portion of a 4x4 matrix
5
+ * NOTE: produces a normalized vector
6
+ * @param {number[]|Float32Array} output
7
+ * @param {number} output_offset
8
+ * @param {number[]|Float32Array} input
9
+ * @param {number} input_offset
10
+ * @param {number[]|Float32Array} m4
11
+ */
12
+ export function v3_array_matrix4_rotate(
13
+ output, output_offset,
14
+ input, input_offset,
15
+ m4
16
+ ) {
17
+ const x = input[input_offset];
18
+ const y = input[input_offset + 1];
19
+ const z = input[input_offset + 2];
20
+
21
+ v3_matrix4_rotate(output,output_offset,x,y,z,m4);
22
+ }
@@ -2,9 +2,10 @@
2
2
  * Perform rotation on a direction vector using 3x3 portion of a 4x4 matrix
3
3
  * @param {number[]|Float32Array} output
4
4
  * @param {number} output_offset
5
- * @param {number[]|Float32Array} input
6
- * @param {number} input_offset
5
+ * @param {number} x
6
+ * @param {number} y
7
+ * @param {number} z
7
8
  * @param {number[]|Float32Array} m4
8
9
  */
9
- export function v3_matrix4_rotate(output: number[] | Float32Array, output_offset: number, input: number[] | Float32Array, input_offset: number, m4: number[] | Float32Array): void;
10
+ export function v3_matrix4_rotate(output: number[] | Float32Array, output_offset: number, x: number, y: number, z: number, m4: number[] | Float32Array): void;
10
11
  //# sourceMappingURL=v3_matrix4_rotate.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"v3_matrix4_rotate.d.ts","sourceRoot":"","sources":["../../../../../src/core/geom/vec3/v3_matrix4_rotate.js"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,0CANW,MAAM,EAAE,GAAC,YAAY,iBACrB,MAAM,SACN,MAAM,EAAE,GAAC,YAAY,gBACrB,MAAM,MACN,MAAM,EAAE,GAAC,YAAY,QAoB/B"}
1
+ {"version":3,"file":"v3_matrix4_rotate.d.ts","sourceRoot":"","sources":["../../../../../src/core/geom/vec3/v3_matrix4_rotate.js"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,0CAPW,MAAM,EAAE,GAAC,YAAY,iBACrB,MAAM,KACN,MAAM,KACN,MAAM,KACN,MAAM,MACN,MAAM,EAAE,GAAC,YAAY,QAkB/B"}
@@ -4,26 +4,25 @@ import { v3_length } from "./v3_length.js";
4
4
  * Perform rotation on a direction vector using 3x3 portion of a 4x4 matrix
5
5
  * @param {number[]|Float32Array} output
6
6
  * @param {number} output_offset
7
- * @param {number[]|Float32Array} input
8
- * @param {number} input_offset
7
+ * @param {number} x
8
+ * @param {number} y
9
+ * @param {number} z
9
10
  * @param {number[]|Float32Array} m4
10
11
  */
11
12
  export function v3_matrix4_rotate(
12
13
  output, output_offset,
13
- input, input_offset,
14
+ x, y, z,
14
15
  m4
15
16
  ) {
16
- const x = input[input_offset];
17
- const y = input[input_offset + 1];
18
- const z = input[input_offset + 2];
19
17
 
20
18
  const _x = m4[0] * x + m4[4] * y + m4[8] * z;
21
19
  const _y = m4[1] * x + m4[5] * y + m4[9] * z;
22
20
  const _z = m4[2] * x + m4[6] * y + m4[10] * z;
23
21
 
22
+ // perform normalization
24
23
  const norm = 1 / v3_length(_x, _y, _z);
25
24
 
26
25
  output[output_offset] = _x * norm;
27
26
  output[output_offset + 1] = _y * norm;
28
27
  output[output_offset + 2] = _z * norm;
29
- }
28
+ }
@@ -0,0 +1,11 @@
1
+ /**
2
+ *
3
+ * @param {number[]|Float64Array|Float32Array} result
4
+ * @param {number} result_offset
5
+ * @param {number} x
6
+ * @param {number} y
7
+ * @param {number} z
8
+ * @param {number} scalar
9
+ */
10
+ export function v3_multiply_scalar(result: number[] | Float64Array | Float32Array, result_offset: number, x: number, y: number, z: number, scalar: number): void;
11
+ //# sourceMappingURL=v3_multiply_scalar.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"v3_multiply_scalar.d.ts","sourceRoot":"","sources":["../../../../../src/core/geom/vec3/v3_multiply_scalar.js"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,2CAPW,MAAM,EAAE,GAAC,YAAY,GAAC,YAAY,iBAClC,MAAM,KACN,MAAM,KACN,MAAM,KACN,MAAM,UACN,MAAM,QAWhB"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ *
3
+ * @param {number[]|Float64Array|Float32Array} result
4
+ * @param {number} result_offset
5
+ * @param {number} x
6
+ * @param {number} y
7
+ * @param {number} z
8
+ * @param {number} scalar
9
+ */
10
+ export function v3_multiply_scalar(
11
+ result, result_offset,
12
+ x, y, z, scalar
13
+ ) {
14
+
15
+ result[result_offset] = x * scalar;
16
+ result[result_offset + 1] = y * scalar;
17
+ result[result_offset + 2] = z * scalar;
18
+
19
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"geometry_compute_vertex_normals_unindexed.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/geometry/buffered/geometry_compute_vertex_normals_unindexed.js"],"names":[],"mappings":"AAMA;;;;GAIG;AACH,qEAJW,MAAO,MAAM,CAAC,GAAC,YAAY,WAC3B,MAAO,MAAM,CAAC,GAAC,YAAY,gBAC3B,MAAM,QAgChB"}
1
+ {"version":3,"file":"geometry_compute_vertex_normals_unindexed.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/geometry/buffered/geometry_compute_vertex_normals_unindexed.js"],"names":[],"mappings":"AAKA;;;;GAIG;AACH,qEAJW,MAAO,MAAM,CAAC,GAAC,YAAY,WAC3B,MAAO,MAAM,CAAC,GAAC,YAAY,gBAC3B,MAAM,QA8BhB"}
@@ -1,6 +1,5 @@
1
1
  import { array_copy } from "../../../../core/collection/array/array_copy.js";
2
2
  import { geometry_construct_triangle_normal } from "../geometry_construct_triangle_normal.js";
3
- import { v3_array_normalize_many } from "./v3_array_normalize_many.js";
4
3
 
5
4
  const scratch_v3 = new Float64Array(3);
6
5
 
@@ -36,7 +35,5 @@ export function geometry_compute_vertex_normals_unindexed(
36
35
 
37
36
  }
38
37
 
39
- // ensure unit magnitude
40
-
41
- v3_array_normalize_many(normals);
38
+ // no need to normalize, that's already handled during normal construction for each triangle
42
39
  }
@@ -1,25 +1,78 @@
1
- import {BufferGeometry, Plane} from "three";
2
- import {SurfacePoint3} from "../../../../../core/geom/3d/SurfacePoint3";
3
- import Vector3 from "../../../../../core/geom/Vector3";
4
-
5
- export class GeometrySpatialQueryAccelerator {
6
- constructor(cache_size?: number)
7
-
8
- queryContainmentViaClippingPlanes(geometry: BufferGeometry, planes: Plane[]): boolean
9
-
10
- queryRaycastNearest(destination: SurfacePoint3, geometry: BufferGeometry, ray_origin: Vector3, ray_direction: Vector3): boolean
11
-
12
- queryRaycastNearest_primitive(
13
- destination: SurfacePoint3,
14
- geometry: BufferGeometry,
15
- origin_x: number, origin_y: number, origin_z: number,
16
- direction_x: number, direction_y: number, direction_z: number
17
- ): boolean
18
-
19
- /**
20
- * In bytes
21
- */
22
- cache_size: number
23
-
24
- static INSTANCE: GeometrySpatialQueryAccelerator;
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
@@ -1 +1 @@
1
- {"version":3,"file":"GeometrySpatialQueryAccelerator.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/graphics/geometry/buffered/query/GeometrySpatialQueryAccelerator.js"],"names":[],"mappings":"AAYA;IACI,iCAuBC;IArBG;;;OAGG;IACH,OAFU,MAAM,MAAM,cAAc,EAAE,eAAe,CAAC,CAiBpD;IAIN;;;OAGG;IACH,4BAEC;IAED;;;OAGG;IACH,yBAEC;IAED;;;;;OAKG;IACH,4CAJW,MAAM,cAAc,UACpB,OAAO,GACL,OAAO,CAwCnB;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,qBAeC;IAED;;;;OAIG;IACH,mBAoBC;CAEJ;;kBAIS,+BAA+B;;sBAjQnB,oCAAoC;gCAD1B,sDAAsD"}
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(cache_size = 100 * 1024 * 1024) {
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.__acquireBVH(geometry);
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
- * @private
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
- __acquireBVH(geometry) {
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.__buildBVH(geometry);
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
- __buildBVH(geometry) {
250
+ __build_bvh(geometry) {
235
251
  const bvh = new BinaryUint32BVH();
236
252
 
237
253
  const position_attribute = geometry.getAttribute('position');
@@ -1,4 +1,4 @@
1
- import { v3_matrix4_rotate } from "../../../../core/geom/vec3/v3_matrix4_rotate.js";
1
+ import { v3_array_matrix4_rotate } from "../../../../core/geom/vec3/v3_array_matrix4_rotate.js";
2
2
 
3
3
 
4
4
  /**
@@ -26,6 +26,6 @@ export function ray_hit_apply_transform(output, hit, m) {
26
26
  output[2] = result_p_z;
27
27
 
28
28
  // transform normal
29
- v3_matrix4_rotate(output, 3, hit, 3, m);
29
+ v3_array_matrix4_rotate(output, 3, hit, 3, m);
30
30
 
31
31
  }
@@ -1,7 +1,7 @@
1
1
  import { vec3 } from "gl-matrix";
2
2
  import { dataTypeFromTypedArray } from "../../../../../core/binary/type/dataTypeFromTypedArray.js";
3
+ import { v3_array_matrix4_rotate } from "../../../../../core/geom/vec3/v3_array_matrix4_rotate.js";
3
4
  import { v3_distance_sqr } from "../../../../../core/geom/vec3/v3_distance_sqr.js";
4
- import { v3_matrix4_rotate } from "../../../../../core/geom/vec3/v3_matrix4_rotate.js";
5
5
  import { decode_attribute_value } from "../../../geometry/decode_attribute_value.js";
6
6
  import { geometry_construct_triangle_normal } from "../../../geometry/geometry_construct_triangle_normal.js";
7
7
  import { sample_triangle_attribute } from "../geometry/sample_triangle_attribute.js";
@@ -86,7 +86,7 @@ export function sample_material(
86
86
  }
87
87
 
88
88
  // apply transform
89
- v3_matrix4_rotate(out, 3, out, 3, mesh.transform);
89
+ v3_array_matrix4_rotate(out, 3, out, 3, mesh.transform);
90
90
 
91
91
  material.normal.sample(normal, texture_uv[0], texture_uv[1]);
92
92