@woosh/meep-engine 2.64.0 → 2.66.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.
Files changed (92) hide show
  1. package/build/bundle-worker-terrain.js +1 -1
  2. package/build/meep.cjs +33388 -34714
  3. package/build/meep.min.js +1 -1
  4. package/build/meep.module.js +33388 -34714
  5. package/editor/ecs/component/editors/ecs/terrain/TerrainEditor.js +4 -10
  6. package/editor/process/symbolic/makeGridPositionSymbolDisplay.js +7 -7
  7. package/editor/tools/SelectionTool.js +6 -95
  8. package/package.json +1 -1
  9. package/src/core/bvh2/BinaryNode.js +14 -14
  10. package/src/core/bvh2/LeafNode.js +4 -4
  11. package/src/core/bvh2/binary/2/BinaryUint32BVH.js +118 -113
  12. package/src/core/bvh2/binary/2/BinaryUint32BVH.spec.js +54 -0
  13. package/src/core/bvh2/binary/2/bvh32_query_user_data_ray.js +98 -0
  14. package/src/core/bvh2/bvh3/{ExplicitBinaryBoundingVolumeHierarchy.d.ts → BVH.d.ts} +1 -1
  15. package/src/core/bvh2/bvh3/{ExplicitBinaryBoundingVolumeHierarchy.js → BVH.js} +2 -2
  16. package/src/core/bvh2/bvh3/{ExplicitBinaryBoundingVolumeHierarchy.spec.js → BVH.spec.js} +20 -20
  17. package/src/core/bvh2/bvh3/BvhClient.d.ts +11 -0
  18. package/src/core/bvh2/bvh3/{EBBVHLeafProxy.js → BvhClient.js} +22 -3
  19. package/src/core/bvh2/bvh3/BvhClient.spec.js +51 -0
  20. package/src/core/bvh2/bvh3/ebvh_build_for_geometry_incremental.js +2 -2
  21. package/src/core/bvh2/bvh3/ebvh_build_for_geometry_morton.js +4 -4
  22. package/src/core/bvh2/bvh3/ebvh_build_for_geometry_morton.spec.js +3 -3
  23. package/src/core/bvh2/bvh3/ebvh_sort_for_traversal_depth_first.js +2 -8
  24. package/src/core/bvh2/bvh3/query/BVHQuery.js +1 -1
  25. package/src/core/bvh2/bvh3/query/bvh_collect_user_data.js +2 -2
  26. package/src/core/bvh2/bvh3/query/bvh_query_leaves_generic.js +2 -2
  27. package/src/core/bvh2/bvh3/query/bvh_query_leaves_generic.spec.js +2 -2
  28. package/src/core/bvh2/bvh3/query/bvh_query_leaves_ray.js +3 -8
  29. package/src/core/bvh2/bvh3/query/bvh_query_leaves_ray.spec.js +2 -2
  30. package/src/core/bvh2/bvh3/query/bvh_query_user_data_generic.js +2 -2
  31. package/src/core/bvh2/bvh3/query/bvh_query_user_data_generic.spec.js +2 -2
  32. package/src/core/bvh2/bvh3/query/bvh_query_user_data_nearest_to_point.js +3 -3
  33. package/src/core/bvh2/bvh3/query/bvh_query_user_data_nearest_to_point.spec.js +3 -3
  34. package/src/core/bvh2/bvh3/query/bvh_query_user_data_overlaps_frustum.js +3 -3
  35. package/src/core/bvh2/bvh3/query/compute_tight_near_far_clipping_planes.js +4 -4
  36. package/src/core/bvh2/bvh3/query/compute_tight_near_far_clipping_planes.spec.js +3 -3
  37. package/src/core/collection/array/array_copy.js +6 -0
  38. package/src/core/geom/3d/aabb/aabb3_array_combine.js +17 -8
  39. package/src/core/geom/3d/aabb/aabb3_array_intersects_ray.js +5 -2
  40. package/src/core/geom/3d/aabb/aabb3_array_set.js +25 -0
  41. package/src/core/geom/3d/aabb/aabb3_compute_half_surface_area.js +3 -0
  42. package/src/core/geom/3d/triangle/computeTriangleRayIntersectionBarycentric.js +8 -1
  43. package/src/engine/EngineHarness.js +23 -25
  44. package/src/engine/ecs/renderable/RenderSystem.js +44 -32
  45. package/src/engine/ecs/renderable/Renderable.d.ts +2 -2
  46. package/src/engine/ecs/renderable/Renderable.js +12 -11
  47. package/src/engine/ecs/terrain/ecs/Terrain.js +83 -87
  48. package/src/engine/ecs/terrain/ecs/TerrainSystem.js +106 -57
  49. package/src/engine/ecs/terrain/ecs/makeTerrainWorkerProxy.js +5 -2
  50. package/src/engine/ecs/terrain/tiles/TerrainTile.js +122 -67
  51. package/src/engine/ecs/terrain/tiles/TerrainTileManager.js +162 -146
  52. package/src/engine/ecs/terrain/tiles/TileBuildWorker.js +16 -5
  53. package/src/engine/graphics/camera/testClippingPlaneComputation.js +3 -6
  54. package/src/engine/graphics/debug/VisualSymbolLine.js +1 -0
  55. package/src/engine/graphics/ecs/camera/CameraSystem.js +9 -9
  56. package/src/engine/graphics/ecs/camera/auto_set_camera_clipping_planes.js +3 -23
  57. package/src/engine/graphics/ecs/decal/v2/FPDecalSystem.js +22 -24
  58. package/src/engine/graphics/ecs/light/LightSystem.js +12 -48
  59. package/src/engine/graphics/ecs/mesh/Mesh.js +8 -8
  60. package/src/engine/graphics/ecs/mesh/MeshSystem.js +12 -36
  61. package/src/engine/graphics/ecs/mesh/updateNodeByTransformAndBBB.js +3 -43
  62. package/src/engine/graphics/ecs/mesh-v2/ShadedGeometry.js +6 -6
  63. package/src/engine/graphics/ecs/mesh-v2/ShadedGeometrySystem.d.ts +3 -3
  64. package/src/engine/graphics/ecs/mesh-v2/ShadedGeometrySystem.js +16 -18
  65. package/src/engine/graphics/ecs/mesh-v2/render/ShadedGeometryRendererContext.js +5 -5
  66. package/src/engine/graphics/ecs/trail2d/Trail2D.js +105 -106
  67. package/src/engine/graphics/ecs/trail2d/Trail2DSystem.js +60 -61
  68. package/src/engine/graphics/ecs/trail2d/makeGradientTrail.js +3 -3
  69. package/src/engine/graphics/ecs/water/WATER_SIZE.js +1 -0
  70. package/src/engine/graphics/ecs/water/Water.js +84 -42
  71. package/src/engine/graphics/ecs/water/WaterSystem.js +53 -105
  72. package/src/engine/graphics/geometry/bvh/buffered/BVHGeometryRaycaster.js +13 -7
  73. package/src/engine/graphics/geometry/bvh/buffered/bvh32_from_indexed_geometry.js +58 -0
  74. package/src/engine/graphics/particles/ecs/ParticleEmitterSystem.js +32 -62
  75. package/src/engine/graphics/particles/particular/engine/ParticularEngine.js +9 -11
  76. package/src/engine/graphics/particles/particular/engine/emitter/ParticleEmitter.js +4 -4
  77. package/src/engine/graphics/particles/particular/engine/renderers/billboard/prototypeBillboardRenderer.js +8 -11
  78. package/src/engine/graphics/render/forward_plus/LightManager.js +30 -32
  79. package/src/engine/graphics/render/forward_plus/LightRenderMetadata.js +3 -3
  80. package/src/engine/graphics/render/forward_plus/query/query_bvh_frustum_from_texture.js +21 -19
  81. package/src/engine/graphics/render/layers/RenderLayer.d.ts +8 -2
  82. package/src/engine/graphics/render/layers/RenderLayer.js +7 -65
  83. package/src/engine/graphics/render/make_bvh_visibility_builder.js +64 -0
  84. package/src/engine/graphics/sh3/LightProbeVolume.js +19 -19
  85. package/src/engine/graphics/sh3/path_tracer/GeometryBVHBatched.js +4 -6
  86. package/src/engine/graphics/sh3/path_tracer/PathTracer.js +17 -19
  87. package/src/engine/graphics/three/expand_aabb_by_transformed_three_object.js +4 -4
  88. package/src/engine/graphics/trail/x/RibbonX.js +26 -5
  89. package/src/engine/sound/ecs/emitter/SoundEmitter.js +18 -16
  90. package/src/engine/sound/ecs/emitter/SoundEmitterSystem.js +3 -5
  91. package/src/core/bvh2/binary/tiny/TinyBVH.js +0 -221
  92. package/src/engine/graphics/ecs/camera/CameraClippingPlaneComputer.js +0 -138
@@ -1,27 +1,27 @@
1
+ import { BVH_BINARY_NODE_SIZE, BVH_LEAF_NODE_SIZE } from "../../../../../core/bvh2/binary/2/BinaryUint32BVH.js";
2
+ import { SCRATCH_UINT32_TRAVERSAL_STACK } from "../../../../../core/collection/SCRATCH_UINT32_TRAVERSAL_STACK.js";
1
3
  import {
2
4
  aabb3_compute_distance_above_plane_max
3
5
  } from "../../../../../core/geom/3d/aabb/aabb3_compute_distance_above_plane_max.js";
4
6
  import { point_light_inside_volume } from "./point_light_inside_volume.js";
5
- import { BVH_BINARY_NODE_SIZE, BVH_LEAF_NODE_SIZE } from "../../../../../core/bvh2/binary/2/BinaryUint32BVH.js";
6
- import { SCRATCH_UINT32_TRAVERSAL_STACK } from "../../../../../core/collection/SCRATCH_UINT32_TRAVERSAL_STACK.js";
7
7
 
8
8
  const stack = SCRATCH_UINT32_TRAVERSAL_STACK;
9
9
 
10
10
  /**
11
11
  *
12
- * @param {DataView} data_view
12
+ * @param {Float32Array} data
13
13
  * @param {number} address
14
14
  * @param {ArrayLike<number>|number[]} planes
15
15
  * @return {boolean}
16
16
  */
17
- function frustum_check(data_view, address, planes) {
18
- const n_x0 = data_view.getFloat32(address);
19
- const n_y0 = data_view.getFloat32(address + 4);
20
- const n_z0 = data_view.getFloat32(address + 8);
17
+ function frustum_check(data, address, planes) {
18
+ const n_x0 = data[address];
19
+ const n_y0 = data[address + 1];
20
+ const n_z0 = data[address + 2];
21
21
 
22
- const n_x1 = data_view.getFloat32(address + 12);
23
- const n_y1 = data_view.getFloat32(address + 16);
24
- const n_z1 = data_view.getFloat32(address + 20);
22
+ const n_x1 = data[address + 3];
23
+ const n_y1 = data[address + 4];
24
+ const n_z1 = data[address + 5];
25
25
 
26
26
  for (let plane_address = 0; plane_address < 24; plane_address += 4) {
27
27
 
@@ -54,7 +54,7 @@ function frustum_check(data_view, address, planes) {
54
54
  * Most of the data is in flat continuous array for cache coherence
55
55
  * @param {number[]} destination
56
56
  * @param {number} destination_offset
57
- * @param {BinaryUint32BVH} root
57
+ * @param {BinaryUint32BVH} bvh
58
58
  * @param {number[]|Uint8ClampedArray} source_data
59
59
  * @param {number[]|Float32Array|Float64Array} planes
60
60
  * @param {number[]|Float32Array|Float64Array} points
@@ -63,13 +63,13 @@ function frustum_check(data_view, address, planes) {
63
63
  export function query_bvh_frustum_from_texture(
64
64
  destination,
65
65
  destination_offset,
66
- root,
66
+ bvh,
67
67
  source_data,
68
68
  planes, points
69
69
  ) {
70
70
  let result = 0;
71
71
 
72
- const binary_node_count = root.getBinaryNodeCount();
72
+ const binary_node_count = bvh.getBinaryNodeCount();
73
73
 
74
74
  if (binary_node_count <= 0) {
75
75
  // this should not happen
@@ -88,8 +88,10 @@ export function query_bvh_frustum_from_texture(
88
88
  */
89
89
  stack[stack_top] = 0;
90
90
 
91
- const last_valid_index = binary_node_count + root.getLeafNodeCount();
92
- const data_view = root.getDataView();
91
+ const last_valid_index = binary_node_count + bvh.getLeafNodeCount();
92
+
93
+ const float32 = bvh.float32;
94
+ const uint32 = bvh.uint32;
93
95
 
94
96
  do {
95
97
  stack.pointer--;
@@ -101,7 +103,7 @@ export function query_bvh_frustum_from_texture(
101
103
  // is intermediate node
102
104
  const node_address = node_index * BVH_BINARY_NODE_SIZE;
103
105
 
104
- if (!frustum_check(data_view, node_address, planes)) {
106
+ if (!frustum_check(float32, node_address, planes)) {
105
107
  continue;
106
108
  }
107
109
 
@@ -124,7 +126,7 @@ export function query_bvh_frustum_from_texture(
124
126
 
125
127
  const node_address = leaf_index * BVH_LEAF_NODE_SIZE + binary_node_count * BVH_BINARY_NODE_SIZE;
126
128
 
127
- const light_descriptor = data_view.getUint32(node_address + 24);
129
+ const light_descriptor = uint32[node_address + 6];
128
130
 
129
131
  const light_type = light_descriptor & 3;
130
132
 
@@ -148,7 +150,7 @@ export function query_bvh_frustum_from_texture(
148
150
  } else if (light_type === 3) {
149
151
  // decal
150
152
 
151
- if (!frustum_check(data_view, node_address, planes)) {
153
+ if (!frustum_check(float32, node_address, planes)) {
152
154
  continue;
153
155
  }
154
156
 
@@ -162,7 +164,7 @@ export function query_bvh_frustum_from_texture(
162
164
  result++;
163
165
  }
164
166
 
165
- }while (stack.pointer > stack_top)
167
+ } while (stack.pointer > stack_top)
166
168
 
167
169
  return result;
168
170
  }
@@ -1,15 +1,21 @@
1
- import {BinaryNode} from "../../../../core/bvh2/BinaryNode";
2
- import {RenderLayerState} from "./RenderLayerState";
3
1
  import {Object3D} from "three";
2
+ import {BinaryNode} from "../../../../core/bvh2/BinaryNode";
4
3
  import {IncrementalDeltaSet} from "../visibility/IncrementalDeltaSet";
4
+ import {RenderLayerState} from "./RenderLayerState";
5
5
 
6
6
  export class RenderLayer {
7
+ /**
8
+ * @deprecated
9
+ */
7
10
  bvh: BinaryNode
8
11
  name: string
9
12
  state: RenderLayerState
10
13
 
11
14
  managed: boolean
12
15
 
16
+ /**
17
+ * @deprecated
18
+ */
13
19
  extractRenderable(leafData: any): Object3D
14
20
 
15
21
  /**
@@ -4,18 +4,10 @@
4
4
 
5
5
 
6
6
  import { BinaryNode } from '../../../../core/bvh2/BinaryNode.js';
7
- import { RenderPassType } from "../RenderPassType.js";
8
- import { IncrementalDeltaSet } from "../visibility/IncrementalDeltaSet.js";
9
7
  import { passThrough } from "../../../../core/function/Functions.js";
10
- import { traverseBinaryNodeUsingVisitor } from "../../../../core/bvh2/traversal/traverseBinaryNodeUsingVisitor.js";
11
- import {
12
- ThreeClippingPlaneComputingBVHVisitor
13
- } from "../../../../core/bvh2/traversal/ThreeClippingPlaneComputingBVHVisitor.js";
14
- import { RenderLayerState } from "./RenderLayerState.js";
15
8
  import { compare_three_objects } from "../../three/compare_three_objects.js";
16
- import {
17
- queryBinaryNode_FrustumIntersections_Data
18
- } from "../../../../core/bvh2/traversal/queryBinaryNode_FrustumIntersections.js";
9
+ import { IncrementalDeltaSet } from "../visibility/IncrementalDeltaSet.js";
10
+ import { RenderLayerState } from "./RenderLayerState.js";
19
11
 
20
12
 
21
13
  /**
@@ -27,7 +19,7 @@ const scratch_array = [];
27
19
  export class RenderLayer {
28
20
  constructor() {
29
21
  /**
30
- *
22
+ * @deprecated
31
23
  * @type {BinaryNode}
32
24
  */
33
25
  this.bvh = new BinaryNode();
@@ -65,12 +57,6 @@ export class RenderLayer {
65
57
  * @type {IncrementalDeltaSet<THREE.Object3D>}
66
58
  */
67
59
  this.visibleSet = new IncrementalDeltaSet(compare_three_objects);
68
-
69
- /**
70
- *
71
- * @type {RenderPassType|number}
72
- */
73
- this.renderPass = RenderPassType.Opaque;
74
60
  }
75
61
 
76
62
  /**
@@ -92,6 +78,7 @@ export class RenderLayer {
92
78
  /**
93
79
  * Compute near and far clipping planes for a camera given a frustum.
94
80
  * Note: near plane is frustum.planes[4], far plane is frustum.planes[5]
81
+ * @deprecated
95
82
  * @param {Frustum} frustum
96
83
  * @param {number} near
97
84
  * @param {number} far
@@ -99,62 +86,17 @@ export class RenderLayer {
99
86
  * @param [thisArg]
100
87
  */
101
88
  computeNearFarClippingPlanes(frustum, near, far, callback, thisArg) {
102
- const tree = this.bvh;
103
-
104
- bvh_visitor_ClippingPlanes.setFrustum(frustum);
105
- bvh_visitor_ClippingPlanes.near = near;
106
- bvh_visitor_ClippingPlanes.far = far;
107
-
108
- if (!tree.isEmpty()) {
109
-
110
- // only do the actual traversal if the tree is not empty
111
- traverseBinaryNodeUsingVisitor(tree, bvh_visitor_ClippingPlanes);
112
-
113
- }
114
-
115
- callback.call(thisArg, bvh_visitor_ClippingPlanes.near, bvh_visitor_ClippingPlanes.far);
116
-
89
+ throw new Error('deprecated');
117
90
  }
118
91
 
119
92
  /**
120
- *
93
+ @deprecated
121
94
  * @param {THREE.Object3D[]} destination
122
95
  * @param {number} destination_offset
123
96
  * @param {CameraView} view
124
97
  * @returns {number} Number of records added to destination
125
98
  */
126
99
  buildVisibleSet(destination, destination_offset, view) {
127
- const frustum = view.frustum;
128
-
129
- const reader = this.extractRenderable;
130
-
131
- if (typeof reader !== "function") {
132
- // no reader method
133
- return 0;
134
- }
135
-
136
- const intersection_count = queryBinaryNode_FrustumIntersections_Data(scratch_array, 0, this.bvh, frustum);
137
-
138
- let additions = 0;
139
- let i = 0;
140
-
141
- for (; i < intersection_count; i++) {
142
- const datum = scratch_array[i];
143
-
144
- const object3D = reader(datum);
145
-
146
- if (!object3D) {
147
- // null or undefined
148
- continue;
149
- }
150
-
151
- destination[additions + destination_offset] = object3D;
152
-
153
- additions++;
154
- }
155
-
156
- return additions;
100
+ throw new Error('deprecated');
157
101
  }
158
102
  }
159
-
160
- const bvh_visitor_ClippingPlanes = new ThreeClippingPlaneComputingBVHVisitor();
@@ -0,0 +1,64 @@
1
+ import { assert } from "../../../core/assert.js";
2
+ import {
3
+ bvh_query_user_data_overlaps_frustum
4
+ } from "../../../core/bvh2/bvh3/query/bvh_query_user_data_overlaps_frustum.js";
5
+
6
+ /**
7
+ * Assumes that BVH stored entity IDs
8
+ * @param {EntityManager} em
9
+ * @param {BVH} bvh
10
+ * @param {function(Object3D[],number,number,EntityComponentDataset)} extract
11
+ * @param {*} [extract_context]
12
+ * @returns {(function(Object3D[], number, CameraView): number)|*}
13
+ */
14
+ export function make_bvh_visibility_builder(em, bvh, extract, extract_context) {
15
+ assert.defined(em, 'em');
16
+ assert.defined(bvh, 'bvh');
17
+ assert.isFunction(extract, 'extract');
18
+
19
+ const scratch_array = [];
20
+
21
+ /**
22
+ *
23
+ * @param {THREE.Object3D[]} destination
24
+ * @param {number} destination_offset
25
+ * @param {CameraView} view
26
+ * @returns {number} Number of records added to destination
27
+ */
28
+ function compute(destination, destination_offset, view) {
29
+
30
+ if (em === null) {
31
+ return 0;
32
+ }
33
+
34
+ const dataset = em.dataset;
35
+
36
+ if (dataset === null) {
37
+ return 0;
38
+ }
39
+
40
+ const matches = bvh_query_user_data_overlaps_frustum(
41
+ scratch_array, 0,
42
+ bvh, view.frustum
43
+ );
44
+
45
+ let additions = 0;
46
+
47
+ for (let i = 0; i < matches; i++) {
48
+ const entity = scratch_array[i];
49
+
50
+ const offset = destination_offset + additions;
51
+
52
+ const elements_from_entity = extract.call(extract_context, destination, offset, entity, dataset);
53
+
54
+ assert.isNonNegativeInteger(elements_from_entity, 'additions');
55
+
56
+ additions += elements_from_entity;
57
+ }
58
+
59
+ return additions;
60
+ }
61
+
62
+ return compute;
63
+
64
+ }
@@ -1,13 +1,3 @@
1
- import { TetrahedralMesh } from "../../../core/geom/3d/tetrahedra/TetrahedralMesh.js";
2
- import {
3
- compute_delaunay_tetrahedral_mesh
4
- } from "../../../core/geom/3d/tetrahedra/delaunay/compute_delaunay_tetrahedral_mesh.js";
5
- import { visualise_probe } from "./visualise_probe.js";
6
- import {
7
- build_tetrahedral_mesh_buffer_geometry
8
- } from "../../../core/geom/3d/tetrahedra/build_tetrahedral_mesh_buffer_geometry.js";
9
- import Entity from "../../ecs/Entity.js";
10
- import { ShadedGeometry } from "../ecs/mesh-v2/ShadedGeometry.js";
11
1
  import {
12
2
  CubeCamera,
13
3
  LinearEncoding,
@@ -17,19 +7,29 @@ import {
17
7
  Scene,
18
8
  WebGLCubeRenderTarget
19
9
  } from "three";
20
- import { DrawMode } from "../ecs/mesh-v2/DrawMode.js";
21
- import { Transform } from "../../ecs/transform/Transform.js";
22
10
  import { array_copy } from "../../../core/collection/array/array_copy.js";
11
+ import { sh3_basis_at } from "../../../core/geom/3d/sphere/harmonics/sh3_basis_at.js";
12
+ import { sh3_dering_optimize_positive } from "../../../core/geom/3d/sphere/harmonics/sh3_dering_optimize_positive.js";
23
13
  import { SurfacePoint3 } from "../../../core/geom/3d/SurfacePoint3.js";
24
- import { Light } from "../ecs/light/Light.js";
14
+ import {
15
+ build_tetrahedral_mesh_buffer_geometry
16
+ } from "../../../core/geom/3d/tetrahedra/build_tetrahedral_mesh_buffer_geometry.js";
17
+ import {
18
+ compute_delaunay_tetrahedral_mesh
19
+ } from "../../../core/geom/3d/tetrahedra/delaunay/compute_delaunay_tetrahedral_mesh.js";
20
+ import { TetrahedralMesh } from "../../../core/geom/3d/tetrahedra/TetrahedralMesh.js";
21
+ import { v3_length_sqr } from "../../../core/geom/vec3/v3_length_sqr.js";
22
+ import Entity from "../../ecs/Entity.js";
23
+ import { Transform } from "../../ecs/transform/Transform.js";
25
24
  import { threeMakeLight } from "../ecs/light/binding/three/threeMakeLight.js";
25
+ import { Light } from "../ecs/light/Light.js";
26
26
  import { ThreeLightCache } from "../ecs/light/three/ThreeLightCache.js";
27
- import { applyTransformToThreeObject } from "../ecs/mesh/applyTransformToThreeObject.js";
28
27
  import { build_three_object } from "../ecs/mesh-v2/build_three_object.js";
28
+ import { DrawMode } from "../ecs/mesh-v2/DrawMode.js";
29
+ import { ShadedGeometry } from "../ecs/mesh-v2/ShadedGeometry.js";
29
30
  import { ShadedGeometryFlags } from "../ecs/mesh-v2/ShadedGeometryFlags.js";
30
- import { v3_length_sqr } from "../../../core/geom/vec3/v3_length_sqr.js";
31
- import { sh3_dering_optimize_positive } from "../../../core/geom/3d/sphere/harmonics/sh3_dering_optimize_positive.js";
32
- import { sh3_basis_at } from "../../../core/geom/3d/sphere/harmonics/sh3_basis_at.js";
31
+ import { applyTransformToThreeObject } from "../ecs/mesh/applyTransformToThreeObject.js";
32
+ import { visualise_probe } from "./visualise_probe.js";
33
33
 
34
34
  const TEMP_CONTACT = new SurfacePoint3();
35
35
 
@@ -333,7 +333,7 @@ class Baker {
333
333
 
334
334
  /**
335
335
  *
336
- * @type {ExplicitBinaryBoundingVolumeHierarchy|null}
336
+ * @type {BVH|null}
337
337
  * @private
338
338
  */
339
339
  this.__bvh = null;
@@ -345,7 +345,7 @@ class Baker {
345
345
  }
346
346
 
347
347
  /**
348
- * @param {ExplicitBinaryBoundingVolumeHierarchy} bvh
348
+ * @param {BVH} bvh
349
349
  */
350
350
  set_bvh(bvh) {
351
351
  this.__bvh = bvh;
@@ -1,11 +1,9 @@
1
- import {
2
- ExplicitBinaryBoundingVolumeHierarchy
3
- } from "../../../../core/bvh2/bvh3/ExplicitBinaryBoundingVolumeHierarchy.js";
1
+ import { BVH } from "../../../../core/bvh2/bvh3/BVH.js";
2
+ import { ebvh_build_for_geometry_morton } from "../../../../core/bvh2/bvh3/ebvh_build_for_geometry_morton.js";
4
3
  import { bvh_query_leaves_ray } from "../../../../core/bvh2/bvh3/query/bvh_query_leaves_ray.js";
5
4
  import {
6
5
  aabb3_signed_distance_sqr_to_point
7
6
  } from "../../../../core/geom/3d/aabb/aabb3_signed_distance_sqr_to_point.js";
8
- import { ebvh_build_for_geometry_morton } from "../../../../core/bvh2/bvh3/ebvh_build_for_geometry_morton.js";
9
7
  import {
10
8
  computeTriangleRayIntersectionBarycentric
11
9
  } from "../../../../core/geom/3d/triangle/computeTriangleRayIntersectionBarycentric.js";
@@ -28,10 +26,10 @@ export class GeometryBVHBatched {
28
26
  constructor() {
29
27
  /**
30
28
  *
31
- * @type {ExplicitBinaryBoundingVolumeHierarchy}
29
+ * @type {BVH}
32
30
  * @private
33
31
  */
34
- this.__bvh = new ExplicitBinaryBoundingVolumeHierarchy();
32
+ this.__bvh = new BVH();
35
33
 
36
34
  /**
37
35
  *
@@ -1,15 +1,4 @@
1
- import {
2
- ExplicitBinaryBoundingVolumeHierarchy
3
- } from "../../../../core/bvh2/bvh3/ExplicitBinaryBoundingVolumeHierarchy.js";
4
- import { bvh_query_leaves_ray } from "../../../../core/bvh2/bvh3/query/bvh_query_leaves_ray.js";
5
- import { aabb3_matrix4_project } from "../../../../core/geom/3d/aabb/aabb3_matrix4_project.js";
6
- import { array_copy } from "../../../../core/collection/array/array_copy.js";
7
1
  import { mat4, vec3 } from "gl-matrix";
8
- import { ensureGeometryBoundingBox } from "../../util/ensureGeometryBoundingBox.js";
9
- import { GeometryBVHBatched } from "./GeometryBVHBatched.js";
10
- import { PathTracedMesh } from "./PathTracedMesh.js";
11
- import { TextureAttachmentsByMaterialType } from "../../../asset/loaders/material/TextureAttachmensByMaterialType.js";
12
- import { convertTexture2Sampler2D } from "../../texture/sampler/convertTexture2Sampler2D.js";
13
2
  import {
14
3
  LinearEncoding,
15
4
  LinearFilter,
@@ -19,16 +8,25 @@ import {
19
8
  sRGBEncoding,
20
9
  UnsignedByteType
21
10
  } from "three";
22
- import { linear_to_sRGB } from "../../../../core/color/sRGB/linear_to_sRGB.js";
23
- import { sample_triangle_attribute } from "./sample_triangle_attribute.js";
24
- import { vec3_uint8_to_float } from "./vec3_uint8_to_float.js";
25
- import { apply_texture_clamping_to_coordinate } from "./apply_texture_clamping_to_coordinate.js";
11
+ import { BVH } from "../../../../core/bvh2/bvh3/BVH.js";
26
12
  import { ebvh_sort_for_traversal_depth_first } from "../../../../core/bvh2/bvh3/ebvh_sort_for_traversal_depth_first.js";
13
+ import { bvh_query_leaves_ray } from "../../../../core/bvh2/bvh3/query/bvh_query_leaves_ray.js";
14
+ import { array_copy } from "../../../../core/collection/array/array_copy.js";
15
+ import { linear_to_sRGB } from "../../../../core/color/sRGB/linear_to_sRGB.js";
16
+ import { aabb3_matrix4_project } from "../../../../core/geom/3d/aabb/aabb3_matrix4_project.js";
17
+ import { ray3_array_compose } from "../../../../core/geom/3d/ray/ray3_array_compose.js";
27
18
  import { v3_dot } from "../../../../core/geom/vec3/v3_dot.js";
19
+ import { TextureAttachmentsByMaterialType } from "../../../asset/loaders/material/TextureAttachmensByMaterialType.js";
20
+ import { convertTexture2Sampler2D } from "../../texture/sampler/convertTexture2Sampler2D.js";
21
+ import { ensureGeometryBoundingBox } from "../../util/ensureGeometryBoundingBox.js";
22
+ import { apply_texture_clamping_to_coordinate } from "./apply_texture_clamping_to_coordinate.js";
23
+ import { GeometryBVHBatched } from "./GeometryBVHBatched.js";
24
+ import { getBiasedNormalSample } from "./getBiasedNormalSample.js";
28
25
  import { make_one_vector3 } from "./make_one_vector3.js";
26
+ import { PathTracedMesh } from "./PathTracedMesh.js";
29
27
  import { transform_normal_m4 } from "./ray_hit_apply_transform.js";
30
- import { ray3_array_compose } from "../../../../core/geom/3d/ray/ray3_array_compose.js";
31
- import { getBiasedNormalSample } from "./getBiasedNormalSample.js";
28
+ import { sample_triangle_attribute } from "./sample_triangle_attribute.js";
29
+ import { vec3_uint8_to_float } from "./vec3_uint8_to_float.js";
32
30
 
33
31
  /*
34
32
  Ray hit data layout:
@@ -69,9 +67,9 @@ export class PathTracer {
69
67
 
70
68
  /**
71
69
  *
72
- * @type {ExplicitBinaryBoundingVolumeHierarchy}
70
+ * @type {BVH}
73
71
  */
74
- this.bvh_top_level = new ExplicitBinaryBoundingVolumeHierarchy();
72
+ this.bvh_top_level = new BVH();
75
73
 
76
74
  /**
77
75
  *
@@ -1,8 +1,8 @@
1
- import { ensureGeometryBoundingBox } from "../util/ensureGeometryBoundingBox.js";
2
- import { aabb3_matrix4_project } from "../../../core/geom/3d/aabb/aabb3_matrix4_project.js";
3
1
  import { aabb3_array_combine } from "../../../core/geom/3d/aabb/aabb3_array_combine.js";
4
- import { m4_multiply } from "../../../core/geom/3d/matrix/m4_multiply.js";
5
2
  import { aabb3_from_threejs_geometry } from "../../../core/geom/3d/aabb/aabb3_from_threejs_geometry.js";
3
+ import { aabb3_matrix4_project } from "../../../core/geom/3d/aabb/aabb3_matrix4_project.js";
4
+ import { m4_multiply } from "../../../core/geom/3d/matrix/m4_multiply.js";
5
+ import { ensureGeometryBoundingBox } from "../util/ensureGeometryBoundingBox.js";
6
6
 
7
7
  const scratch_aabb3_array_0 = new Float32Array(6);
8
8
  const scratch_aabb3_array_1 = new Float32Array(6);
@@ -27,7 +27,7 @@ export function expand_aabb_by_transformed_three_object(result, object, transfor
27
27
 
28
28
  aabb3_matrix4_project(scratch_aabb3_array_1, scratch_aabb3_array_0, transform);
29
29
 
30
- aabb3_array_combine(result, result, scratch_aabb3_array_1);
30
+ aabb3_array_combine(result,0, result,0, scratch_aabb3_array_1,0);
31
31
  }
32
32
 
33
33
  const children = object.children;
@@ -5,7 +5,11 @@ import {
5
5
  InterleavedBuffer,
6
6
  InterleavedBufferAttribute
7
7
  } from "three";
8
+ import { assert } from "../../../../core/assert.js";
8
9
  import { RowFirstTable } from "../../../../core/collection/table/RowFirstTable.js";
10
+ import { aabb3_array_set } from "../../../../core/geom/3d/aabb/aabb3_array_set.js";
11
+ import { max2 } from "../../../../core/math/max2.js";
12
+ import { min2 } from "../../../../core/math/min2.js";
9
13
  import {
10
14
  RIBBON_ATTRIBUTE_ADDRESS_ALPHA,
11
15
  RIBBON_ATTRIBUTE_ADDRESS_COLOR,
@@ -16,7 +20,6 @@ import {
16
20
  RIBBON_ATTRIBUTE_ADDRESS_THICKNESS,
17
21
  ribbon_attributes_spec
18
22
  } from "./ribbon_attributes_spec.js";
19
- import { assert } from "../../../../core/assert.js";
20
23
 
21
24
 
22
25
  export class RibbonX {
@@ -438,16 +441,22 @@ export class RibbonX {
438
441
 
439
442
  /**
440
443
  * NOTE: takes trail thickness into account
441
- * @param {AABB3} result
444
+ * @param {AABB3|ArrayLike<number>} result
442
445
  */
443
446
  computeBoundingBox(result) {
444
447
 
445
448
  const n = this.getCount() * 2;
446
449
 
447
- result.setNegativelyInfiniteBounds();
448
-
449
450
  const data = this.__data;
450
451
 
452
+ let _x0 = Infinity;
453
+ let _y0 = Infinity;
454
+ let _z0 = Infinity;
455
+
456
+ let _x1 = -Infinity;
457
+ let _y1 = -Infinity;
458
+ let _z1 = -Infinity;
459
+
451
460
  for (let i = 0; i < n; i += 2) {
452
461
  const thickness = data.readCellValue(i, RIBBON_ATTRIBUTE_ADDRESS_THICKNESS);
453
462
  const half_thickness = thickness / 2;
@@ -456,9 +465,21 @@ export class RibbonX {
456
465
  const y = data.readCellValue(i, RIBBON_ATTRIBUTE_ADDRESS_POSITION + 1);
457
466
  const z = data.readCellValue(i, RIBBON_ATTRIBUTE_ADDRESS_POSITION + 2);
458
467
 
459
- result._expandToFit(x - half_thickness, y - half_thickness, z - half_thickness, x + half_thickness, y + half_thickness, z + half_thickness);
468
+ _x0 = min2(_x0, x - half_thickness);
469
+ _y0 = min2(_y0, y - half_thickness);
470
+ _z0 = min2(_z0, z - half_thickness);
471
+ _x1 = max2(_x1, x + half_thickness);
472
+ _y1 = max2(_y1, y + half_thickness);
473
+ _z1 = max2(_z1, z + half_thickness);
474
+
460
475
  }
461
476
 
477
+ aabb3_array_set(
478
+ result, 0,
479
+ _x0, _y0, _z0,
480
+ _x1, _y1, _z1
481
+ );
482
+
462
483
  }
463
484
 
464
485
 
@@ -3,25 +3,27 @@
3
3
  */
4
4
 
5
5
 
6
- import {EBBVHLeafProxy} from "../../../../core/bvh2/bvh3/EBBVHLeafProxy.js";
7
- import {computeHashIntegerArray} from "../../../../core/collection/array/computeHashIntegerArray.js";
6
+ import { BvhClient } from "../../../../core/bvh2/bvh3/BvhClient.js";
7
+ import { computeHashIntegerArray } from "../../../../core/collection/array/computeHashIntegerArray.js";
8
8
  import List from '../../../../core/collection/list/List.js';
9
- import {aabb3_array_compute_from_sphere} from "../../../../core/geom/3d/aabb/aabb3_array_compute_from_sphere.js";
9
+ import { aabb3_array_compute_from_sphere } from "../../../../core/geom/3d/aabb/aabb3_array_compute_from_sphere.js";
10
10
  import Vector1 from "../../../../core/geom/Vector1.js";
11
- import {interpolate_irradiance_linear} from "../../../../core/math/physics/irradiance/interpolate_irradiance_linear.js";
11
+ import {
12
+ interpolate_irradiance_linear
13
+ } from "../../../../core/math/physics/irradiance/interpolate_irradiance_linear.js";
12
14
  import {
13
15
  interpolate_irradiance_lograrithmic
14
16
  } from "../../../../core/math/physics/irradiance/interpolate_irradiance_lograrithmic.js";
15
- import {interpolate_irradiance_smith} from "../../../../core/math/physics/irradiance/interpolate_irradiance_smith.js";
16
- import {objectKeyByValue} from "../../../../core/model/object/objectKeyByValue.js";
17
- import {computeHashFloat} from "../../../../core/primitives/numbers/computeHashFloat.js";
18
- import {number_compare_ascending} from "../../../../core/primitives/numbers/number_compare_ascending.js";
19
- import {compareStrings} from "../../../../core/primitives/strings/compareStrings.js";
20
- import {computeStringHash} from "../../../../core/primitives/strings/computeStringHash.js";
21
- import {SoundAttenuationFunction} from "./SoundAttenuationFunction.js";
22
- import {SoundEmitterFlags} from "./SoundEmitterFlags.js";
23
- import {SoundPanningModelType} from "./SoundPanningModelType.js";
24
- import {SoundTrack} from "./SoundTrack.js";
17
+ import { interpolate_irradiance_smith } from "../../../../core/math/physics/irradiance/interpolate_irradiance_smith.js";
18
+ import { objectKeyByValue } from "../../../../core/model/object/objectKeyByValue.js";
19
+ import { computeHashFloat } from "../../../../core/primitives/numbers/computeHashFloat.js";
20
+ import { number_compare_ascending } from "../../../../core/primitives/numbers/number_compare_ascending.js";
21
+ import { compareStrings } from "../../../../core/primitives/strings/compareStrings.js";
22
+ import { computeStringHash } from "../../../../core/primitives/strings/computeStringHash.js";
23
+ import { SoundAttenuationFunction } from "./SoundAttenuationFunction.js";
24
+ import { SoundEmitterFlags } from "./SoundEmitterFlags.js";
25
+ import { SoundPanningModelType } from "./SoundPanningModelType.js";
26
+ import { SoundTrack } from "./SoundTrack.js";
25
27
 
26
28
  const DEFAULT_DISTANCE_MIN = 1;
27
29
  const DEFAULT_DISTANCE_MAX = 10000;
@@ -116,9 +118,9 @@ export class SoundEmitter {
116
118
 
117
119
  /**
118
120
  * @readonly
119
- * @type {EBBVHLeafProxy}
121
+ * @type {BvhClient}
120
122
  */
121
- bvh = new EBBVHLeafProxy();
123
+ bvh = new BvhClient();
122
124
 
123
125
  /**
124
126
  *
@@ -5,9 +5,7 @@
5
5
  */
6
6
 
7
7
 
8
- import {
9
- ExplicitBinaryBoundingVolumeHierarchy
10
- } from "../../../../core/bvh2/bvh3/ExplicitBinaryBoundingVolumeHierarchy.js";
8
+ import { BVH } from "../../../../core/bvh2/bvh3/BVH.js";
11
9
  import { bvh_query_user_data_generic } from "../../../../core/bvh2/bvh3/query/bvh_query_user_data_generic.js";
12
10
  import { BVHQueryIntersectsSphere } from "../../../../core/bvh2/bvh3/query/BVHQueryIntersectsSphere.js";
13
11
  import { invokeObjectCompare } from "../../../../core/model/object/invokeObjectCompare.js";
@@ -91,10 +89,10 @@ export class SoundEmitterSystem extends System {
91
89
 
92
90
  /**
93
91
  * Spatial index
94
- * @type {ExplicitBinaryBoundingVolumeHierarchy}
92
+ * @type {BVH}
95
93
  * @private
96
94
  */
97
- this.__bvh = new ExplicitBinaryBoundingVolumeHierarchy();
95
+ this.__bvh = new BVH();
98
96
 
99
97
  /**
100
98
  * Number of currently linked entities