@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,21 +1,42 @@
1
1
  /**
2
2
  * Created by Alex on 17/02/2017.
3
3
  */
4
- import { BackSide, Plane, PlaneBufferGeometry, Vector3 as ThreeVector3 } from 'three';
4
+ import { BackSide, PlaneBufferGeometry } from 'three';
5
+ import { BVH } from "../../../../core/bvh2/bvh3/BVH.js";
5
6
  import { System } from '../../../ecs/System.js';
6
- import Water from './Water.js';
7
- import { LeafNode } from '../../../../core/bvh2/LeafNode.js';
8
- import { buildPlanarRenderLayerClipPlaneComputationMethod } from "../../render/layers/RenderLayerUtils.js";
7
+ import { obtainTerrain } from "../../../ecs/terrain/util/obtainTerrain.js";
8
+ import { make_bvh_visibility_builder } from "../../render/make_bvh_visibility_builder.js";
9
+ import { StandardFrameBuffers } from "../../StandardFrameBuffers.js";
9
10
  import ThreeFactory from "../../three/ThreeFactory.js";
10
- import { RenderPassType } from "../../render/RenderPassType.js";
11
11
  import { makeAlexWaterMaterial } from "../water2/shader/AlexWaterShader.js";
12
- import { threeUpdateTransform } from "../../util/threeUpdateTransform.js";
13
- import { StandardFrameBuffers } from "../../StandardFrameBuffers.js";
14
- import { obtainTerrain } from "../../../ecs/terrain/util/obtainTerrain.js";
15
-
16
- const WATER_SIZE = 800;
12
+ import Water from './Water.js';
13
+ import { WATER_SIZE } from "./WATER_SIZE.js";
17
14
 
18
15
  class WaterSystem extends System {
16
+ dependencies = [Water];
17
+
18
+ /**
19
+ * @readonly
20
+ * @type {BVH}
21
+ */
22
+ bvh = new BVH();
23
+
24
+
25
+ cleaup = [];
26
+
27
+ /**
28
+ *
29
+ * @type {Water[]}
30
+ */
31
+ updateQueue = [];
32
+
33
+ /**
34
+ *
35
+ * @type {number}
36
+ * @private
37
+ */
38
+ __time_delta = 0;
39
+
19
40
  /**
20
41
  *
21
42
  * @param {GraphicsEngine} graphics
@@ -24,7 +45,6 @@ class WaterSystem extends System {
24
45
  constructor(graphics) {
25
46
  super();
26
47
 
27
- this.dependencies = [Water];
28
48
 
29
49
  this.graphicsEngine = graphics;
30
50
 
@@ -34,29 +54,6 @@ class WaterSystem extends System {
34
54
  */
35
55
  this.renderLayer = null;
36
56
 
37
- /**
38
- *
39
- * @type {BinaryNode}
40
- */
41
- this.bvh = null;
42
-
43
- //TODO override "computeFrustumClippingPlanes", this is a hack to get camera system to work as indeded when computing clipping planes
44
- //TODO come up with a less convoluted design
45
-
46
- this.cleaup = [];
47
-
48
- /**
49
- *
50
- * @type {Water[]}
51
- */
52
- this.updateQueue = [];
53
-
54
- /**
55
- *
56
- * @type {number}
57
- * @private
58
- */
59
- this.__time_delta = 0;
60
57
  }
61
58
 
62
59
 
@@ -81,43 +78,21 @@ class WaterSystem extends System {
81
78
 
82
79
  const viewport_size = graphicsEngine.viewport.size;
83
80
 
84
- this.renderLayer.extractRenderable = function (component) {
85
- return component.__threeObject;
86
- };
81
+ this.renderLayer.buildVisibleSet = make_bvh_visibility_builder(
82
+ this.entityManager, this.bvh,
83
+ (destination, offset, entity, ecd) => {
84
+ const component = ecd.getComponent(entity, Water);
87
85
 
88
- this.renderLayer.renderPass = RenderPassType.Transparent;
86
+ const mesh = component.__threeObject;
89
87
 
90
- /**
91
- *
92
- * @param {Frustum} frustum
93
- * @param {function(near:number, far:number)} visitor
94
- */
95
- this.renderLayer.computeNearFarClippingPlanes = buildPlanarRenderLayerClipPlaneComputationMethod(function (visitor) {
88
+ if (mesh === null) {
89
+ return 0
90
+ }
96
91
 
97
- /**
98
- *
99
- * @type {EntityComponentDataset}
100
- */
101
- const dataset = entityManager.dataset;
102
-
103
- /**
104
- *
105
- * @param {Water} water
106
- * @param entity
107
- */
108
- function componentVisitor(water, entity) {
109
-
110
- //determinate the plane
111
- const plane = new Plane(new ThreeVector3(0, 1, 0), water.level.getValue());
112
-
113
- visitor(plane);
92
+ destination[offset] = mesh;
93
+ return 1;
114
94
  }
115
-
116
- dataset.traverseComponents(Water, componentVisitor);
117
- });
118
-
119
-
120
- this.bvh = this.renderLayer.bvh;
95
+ )
121
96
 
122
97
 
123
98
  const self = this;
@@ -191,64 +166,37 @@ class WaterSystem extends System {
191
166
 
192
167
  water.side = BackSide;
193
168
 
194
- /**
195
- * @type {Object3D}
196
- */
197
- let mesh;
198
169
  if (component.__threeObject === null) {
199
170
  const geometry = new PlaneBufferGeometry(width, height, 1, 1);
200
171
 
201
- mesh = ThreeFactory.createMesh(
172
+ const mesh = ThreeFactory.createMesh(
202
173
  geometry,
203
174
  water
204
175
  );
205
176
 
206
-
207
177
  component.__threeObject = mesh;
208
- } else {
209
- mesh = component.__threeObject;
210
178
  }
211
179
 
212
- mesh.rotation.x = Math.PI * 0.5;
213
- mesh.position.x = width / 4;
214
- mesh.position.z = height / 4;
215
- mesh.position.y = component.level.getValue();
216
-
217
- threeUpdateTransform(mesh);
180
+ component.updateTransform();
218
181
 
219
- const leafNode = new LeafNode(
220
- component,
182
+ component.level.onChanged.add(component.updateTransform, component);
221
183
 
222
- -width / 4,
223
- component.level.getValue(),
224
- -height / 4,
225
- width * (3 / 4),
226
- component.level.getValue(),
227
- height * (3 / 4)
228
- );
229
-
230
- component.bvh = leafNode;
231
-
232
- function processLevelValue(v, oldV) {
233
- mesh.position.y = v;
234
- threeUpdateTransform(mesh);
235
-
236
- leafNode.move(0, 0, v - oldV);
237
- }
238
-
239
- component.level.onChanged.add(processLevelValue);
240
-
241
- this.bvh.insertNode(leafNode);
184
+ component.bvh.link(this.bvh, entity);
242
185
 
243
186
  this.cleaup[entity] = function () {
244
- component.level.onChanged.remove(processLevelValue);
187
+ component.level.onChanged.remove(component.updateTransform, component);
245
188
  };
246
189
 
247
190
  this.updateQueue.push(component);
248
191
  }
249
192
 
193
+ /**
194
+ *
195
+ * @param {Water} component
196
+ * @param {number} entity
197
+ */
250
198
  unlink(component, entity) {
251
- component.bvh.disconnect();
199
+ component.bvh.unlink();
252
200
 
253
201
  const cleaup = this.cleaup[entity];
254
202
  cleaup();
@@ -1,15 +1,15 @@
1
- import Vector3 from "../../../../../core/geom/Vector3.js";
1
+ import { mat4 } from "gl-matrix";
2
2
 
3
3
  import { Vector3 as ThreeVector3 } from 'three';
4
- import { rayTriangleIntersection } from "../../../../../core/geom/3d/triangle/rayTriangleIntersection.js";
5
- import { SurfacePoint3 } from "../../../../../core/geom/3d/SurfacePoint3.js";
6
4
  import { assert } from "../../../../../core/assert.js";
7
- import { v3_length } from "../../../../../core/geom/vec3/v3_length.js";
8
- import { ray3_array_apply_matrix4 } from "../../../../../core/geom/3d/ray/ray3_array_apply_matrix4.js";
9
- import { mat4 } from "gl-matrix";
10
- import { ray3_array_compose } from "../../../../../core/geom/3d/ray/ray3_array_compose.js";
11
5
  import { array_copy } from "../../../../../core/collection/array/array_copy.js";
12
6
  import { MATRIX_4_IDENTITY } from "../../../../../core/geom/3d/matrix/MATRIX_4_IDENTITY.js";
7
+ import { ray3_array_apply_matrix4 } from "../../../../../core/geom/3d/ray/ray3_array_apply_matrix4.js";
8
+ import { ray3_array_compose } from "../../../../../core/geom/3d/ray/ray3_array_compose.js";
9
+ import { SurfacePoint3 } from "../../../../../core/geom/3d/SurfacePoint3.js";
10
+ import { rayTriangleIntersection } from "../../../../../core/geom/3d/triangle/rayTriangleIntersection.js";
11
+ import { v3_length } from "../../../../../core/geom/vec3/v3_length.js";
12
+ import Vector3 from "../../../../../core/geom/Vector3.js";
13
13
 
14
14
  const hit = new ThreeVector3();
15
15
 
@@ -42,6 +42,12 @@ function bindGeometryFace(indices, vertices, index) {
42
42
 
43
43
  const vNormal = new Vector3();
44
44
 
45
+ /**
46
+ *
47
+ * @param {number[]} indices
48
+ * @param {number[]} normals
49
+ * @param {number} index
50
+ */
45
51
  function bindGeometryFaceNormal(indices, normals, index) {
46
52
 
47
53
  const index3 = index * 3;
@@ -0,0 +1,58 @@
1
+ import { max3 } from "../../../../../core/math/max3.js";
2
+ import { min3 } from "../../../../../core/math/min3.js";
3
+
4
+ /**
5
+ *
6
+ * @param {BinaryUint32BVH} bvh
7
+ * @param {Float32Array} vertices
8
+ * @param {Uint32Array} indices
9
+ */
10
+ export function bvh32_from_indexed_geometry(bvh, vertices, indices) {
11
+
12
+ const triangle_count = indices.length / 3;
13
+
14
+ bvh.setLeafCount(triangle_count);
15
+ bvh.initialize_structure();
16
+
17
+ for (let i = 0; i < triangle_count; i++) {
18
+
19
+ const index3 = i * 3;
20
+
21
+ // read triangle vertex indices
22
+ const iA = indices[index3];
23
+ const iB = indices[index3 + 1];
24
+ const iC = indices[index3 + 2];
25
+
26
+ const a = iA * 3;
27
+ const b = iB * 3;
28
+ const c = iC * 3;
29
+
30
+ // read actual positions of each vertex
31
+ const aX = vertices[a];
32
+ const aY = vertices[a + 1];
33
+ const aZ = vertices[a + 2];
34
+
35
+ const bX = vertices[b];
36
+ const bY = vertices[b + 1];
37
+ const bZ = vertices[b + 2];
38
+
39
+ const cX = vertices[c];
40
+ const cY = vertices[c + 1];
41
+ const cZ = vertices[c + 2];
42
+
43
+ // compute bounds of the triangle
44
+ const x0 = min3(aX, bX, cX);
45
+ const y0 = min3(aY, bY, cY);
46
+ const z0 = min3(aZ, bZ, cZ);
47
+
48
+ const x1 = max3(aX, bX, cX);
49
+ const y1 = max3(aY, bY, cY);
50
+ const z1 = max3(aZ, bZ, cZ);
51
+
52
+ bvh.setLeafData(i, i, x0, y0, z0, x1, y1, z1)
53
+ }
54
+
55
+ // finalize build
56
+ // bvh.sort_morton(MATRIX_4_IDENTITY);
57
+ bvh.build();
58
+ }
@@ -1,30 +1,30 @@
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
- import {ResourceAccessKind} from "../../../../core/model/ResourceAccessKind.js";
6
- import {ResourceAccessSpecification} from "../../../../core/model/ResourceAccessSpecification.js";
7
- import {ImageRGBADataLoader} from "../../../asset/loaders/image/ImageRGBADataLoader.js";
8
- import {System} from "../../../ecs/System.js";
9
- import {Transform} from "../../../ecs/transform/Transform.js";
10
- import {RenderPassType} from "../../render/RenderPassType.js";
11
- import {StandardFrameBuffers} from "../../StandardFrameBuffers.js";
12
- import {ParticleEmitter} from "../particular/engine/emitter/ParticleEmitter.js";
13
- import {ParticleEmitterFlag} from "../particular/engine/emitter/ParticleEmitterFlag.js";
14
- import {ParticularEngine} from "../particular/engine/ParticularEngine.js";
15
-
16
- /**
17
- *
18
- * @param {ParticleEmitter} emitter
19
- * @returns {Group|Object3D}
20
- */
21
- function extractRenderable(emitter) {
22
- return emitter.mesh;
23
- }
24
-
25
- const scratch_array = [];
1
+ import { assert } from "../../../../core/assert.js";
2
+ import { ResourceAccessKind } from "../../../../core/model/ResourceAccessKind.js";
3
+ import { ResourceAccessSpecification } from "../../../../core/model/ResourceAccessSpecification.js";
4
+ import { ImageRGBADataLoader } from "../../../asset/loaders/image/ImageRGBADataLoader.js";
5
+ import { System } from "../../../ecs/System.js";
6
+ import { Transform } from "../../../ecs/transform/Transform.js";
7
+ import { make_bvh_visibility_builder } from "../../render/make_bvh_visibility_builder.js";
8
+ import { StandardFrameBuffers } from "../../StandardFrameBuffers.js";
9
+ import { ParticleEmitter } from "../particular/engine/emitter/ParticleEmitter.js";
10
+ import { ParticleEmitterFlag } from "../particular/engine/emitter/ParticleEmitterFlag.js";
11
+ import { ParticularEngine } from "../particular/engine/ParticularEngine.js";
26
12
 
27
13
  export class ParticleEmitterSystem extends System {
14
+ dependencies = [ParticleEmitter, Transform];
15
+
16
+ components_used = [
17
+ ResourceAccessSpecification.from(ParticleEmitter, ResourceAccessKind.Read | ResourceAccessKind.Write)
18
+ ];
19
+
20
+ /**
21
+ *
22
+ * @type {RenderLayer|null}
23
+ */
24
+ renderLayer = null;
25
+
26
+ __handlers = [];
27
+
28
28
  /**
29
29
  *
30
30
  * @extends {System.<ParticleEmitter>}
@@ -37,12 +37,6 @@ export class ParticleEmitterSystem extends System {
37
37
  assert.defined(engine, 'engine');
38
38
  assert.equal(engine.isEngine, true, 'engine.isEngine !== true');
39
39
 
40
- this.dependencies = [ParticleEmitter, Transform];
41
-
42
- this.components_used = [
43
- ResourceAccessSpecification.from(ParticleEmitter, ResourceAccessKind.Read | ResourceAccessKind.Write)
44
- ];
45
-
46
40
  /**
47
41
  *
48
42
  * @type {GraphicsEngine}
@@ -61,13 +55,6 @@ export class ParticleEmitterSystem extends System {
61
55
  */
62
56
  this.particleEngine = new ParticularEngine(engine.assetManager, engine.graphics.getMaterialManager());
63
57
 
64
- /**
65
- *
66
- * @type {RenderLayer|null}
67
- */
68
- this.renderLayer = null;
69
-
70
- this.__handlers = [];
71
58
  }
72
59
 
73
60
  async startup(entityManager, readyCallback, errorCallback) {
@@ -87,33 +74,16 @@ export class ParticleEmitterSystem extends System {
87
74
 
88
75
  this.renderLayer = renderLayer;
89
76
 
90
- renderLayer.renderPass = RenderPassType.Transparent;
91
-
92
- renderLayer.buildVisibleSet = (destination, destination_offset, view) => {
77
+ renderLayer.buildVisibleSet = make_bvh_visibility_builder(
78
+ this.entityManager, this.particleEngine.bvh,
79
+ (destination, offset, entity, ecd) => {
80
+ const component = ecd.getComponent(entity, ParticleEmitter);
93
81
 
94
- const ecd = entityManager.dataset;
95
82
 
96
- if (ecd === null) {
97
- return 0;
83
+ destination[offset] = component.mesh;
84
+ return 1;
98
85
  }
99
-
100
- const view_frustum = view.frustum;
101
-
102
- const hit_count = bvh_query_user_data_overlaps_frustum(scratch_array, 0, this.particleEngine.bvh, view_frustum);
103
-
104
- for (let i = 0; i < hit_count; i++) {
105
- const id = scratch_array[i];
106
-
107
- /**
108
- * @type {ParticleEmitter}
109
- */
110
- const emitter = ecd.getComponent(id, ParticleEmitter);
111
-
112
- destination[destination_offset + i] = emitter.mesh;
113
- }
114
-
115
- return hit_count;
116
- };
86
+ );
117
87
 
118
88
  renderLayer.visibleSet.onAdded.add((points) => {
119
89
  /**
@@ -1,13 +1,11 @@
1
- import {
2
- ExplicitBinaryBoundingVolumeHierarchy
3
- } from "../../../../../core/bvh2/bvh3/ExplicitBinaryBoundingVolumeHierarchy.js";
1
+ import { BVH } from "../../../../../core/bvh2/bvh3/BVH.js";
4
2
  import List from "../../../../../core/collection/list/List.js";
5
- import {ParticleEmitterFlag} from "./emitter/ParticleEmitterFlag.js";
6
- import {ShaderManager} from "./shader/ShaderManager.js";
7
- import {SimulationStepApplyForce} from "./simulator/SimulationStepApplyForce.js";
8
- import {SimulationStepCurlNoiseAcceleration} from "./simulator/SimulationStepCurlNoiseAcceleration.js";
9
- import {SimulationStepCurlNoiseVelocity} from "./simulator/SimulationStepCurlNoiseVelocity.js";
10
- import {SimulationStepFixedPhysics} from "./simulator/SimulationStepFixedPhysics.js";
3
+ import { ParticleEmitterFlag } from "./emitter/ParticleEmitterFlag.js";
4
+ import { ShaderManager } from "./shader/ShaderManager.js";
5
+ import { SimulationStepApplyForce } from "./simulator/SimulationStepApplyForce.js";
6
+ import { SimulationStepCurlNoiseAcceleration } from "./simulator/SimulationStepCurlNoiseAcceleration.js";
7
+ import { SimulationStepCurlNoiseVelocity } from "./simulator/SimulationStepCurlNoiseVelocity.js";
8
+ import { SimulationStepFixedPhysics } from "./simulator/SimulationStepFixedPhysics.js";
11
9
 
12
10
 
13
11
  export class ParticularEngine {
@@ -25,9 +23,9 @@ export class ParticularEngine {
25
23
 
26
24
  /**
27
25
  * @readonly
28
- * @type {ExplicitBinaryBoundingVolumeHierarchy}
26
+ * @type {BVH}
29
27
  */
30
- bvh = new ExplicitBinaryBoundingVolumeHierarchy();
28
+ bvh = new BVH();
31
29
 
32
30
 
33
31
  /**
@@ -1,6 +1,6 @@
1
1
  import { Box3, BufferGeometry, Frustum, Points, PointsMaterial } from 'three';
2
2
  import { assert } from "../../../../../../core/assert.js";
3
- import { EBBVHLeafProxy } from "../../../../../../core/bvh2/bvh3/EBBVHLeafProxy.js";
3
+ import { BvhClient } from "../../../../../../core/bvh2/bvh3/BvhClient.js";
4
4
  import { computeHashIntegerArray } from "../../../../../../core/collection/array/computeHashIntegerArray.js";
5
5
  import List from "../../../../../../core/collection/list/List.js";
6
6
  import { AABB3 } from "../../../../../../core/geom/3d/aabb/AABB3.js";
@@ -144,9 +144,9 @@ export class ParticleEmitter {
144
144
 
145
145
  /**
146
146
  * @readonly
147
- * @type {EBBVHLeafProxy}
147
+ * @type {BvhClient}
148
148
  */
149
- bvh_leaf = new EBBVHLeafProxy();
149
+ bvh_leaf = new BvhClient();
150
150
 
151
151
 
152
152
  /**
@@ -516,7 +516,7 @@ export class ParticleEmitter {
516
516
  const ebb = this.emissionBounds;
517
517
  const pbb = this.particleBounds;
518
518
 
519
- aabb3_array_combine(this.bvh_leaf.bounds, ebb, pbb);
519
+ aabb3_array_combine(this.bvh_leaf.bounds,0, ebb,0, pbb,0);
520
520
 
521
521
  this.bvh_leaf.write_bounds();
522
522
 
@@ -1,18 +1,16 @@
1
- import { EngineHarness } from "../../../../../../EngineHarness.js";
2
- import { ParticlePool } from "../../emitter/ParticlePool.js";
3
- import { make_particle_billboard_shader } from "./ParticleBillboardMaterial.js";
4
1
  import { DataTexture, LinearFilter, LinearMipMapLinearFilter, Matrix4, Points } from "three";
5
- import { ManagedAtlas } from "../../../../../texture/atlas/ManagedTextureAtlas.js";
6
- import { writeSample2DDataToDataTexture } from "../../../../../texture/sampler/writeSampler2DDataToDataTexture.js";
2
+ import Vector3 from "../../../../../../../core/geom/Vector3.js";
7
3
  import { ImageRGBADataLoader } from "../../../../../../asset/loaders/image/ImageRGBADataLoader.js";
8
- import { EngineConfiguration } from "../../../../../../EngineConfiguration.js";
9
- import { MeshSystem } from "../../../../../ecs/mesh/MeshSystem.js";
10
4
  import Entity from "../../../../../../ecs/Entity.js";
11
5
  import { Transform } from "../../../../../../ecs/transform/Transform.js";
6
+ import { EngineConfiguration } from "../../../../../../EngineConfiguration.js";
7
+ import { EngineHarness } from "../../../../../../EngineHarness.js";
12
8
  import Mesh from "../../../../../ecs/mesh/Mesh.js";
13
- import Vector3 from "../../../../../../../core/geom/Vector3.js";
14
- import { RenderPassType } from "../../../../../render/RenderPassType.js";
9
+ import { MeshSystem } from "../../../../../ecs/mesh/MeshSystem.js";
15
10
  import { StandardFrameBuffers } from "../../../../../StandardFrameBuffers.js";
11
+ import { ManagedAtlas } from "../../../../../texture/atlas/ManagedTextureAtlas.js";
12
+ import { writeSample2DDataToDataTexture } from "../../../../../texture/sampler/writeSampler2DDataToDataTexture.js";
13
+ import { ParticlePool } from "../../emitter/ParticlePool.js";
16
14
  import {
17
15
  BILLBOARD_PARTICLE_ATTRIBUTE_BLEND,
18
16
  BILLBOARD_PARTICLE_ATTRIBUTE_COLOR,
@@ -21,6 +19,7 @@ import {
21
19
  BILLBOARD_PARTICLE_ATTRIBUTE_UV,
22
20
  BILLBOARD_PARTICLE_SPECIFICATION
23
21
  } from "./BILLBOARD_PARTICLE_SPECIFICATION.js";
22
+ import { make_particle_billboard_shader } from "./ParticleBillboardMaterial.js";
24
23
 
25
24
 
26
25
  const engineHarness = new EngineHarness();
@@ -113,8 +112,6 @@ async function main(engine) {
113
112
  layer.visibleSet.push(points);
114
113
  layer.visibleSet.finalizeUpdate();
115
114
 
116
- layer.renderPass = RenderPassType.Transparent;
117
-
118
115
  engine.graphics.on.visibilityConstructionStarted.add((renderer, camera, scene) => {
119
116
  renderer.getSize(shaderMaterial.uniforms.resolution.value);
120
117
 
@@ -1,4 +1,4 @@
1
- import { LightRenderMetadata } from "./LightRenderMetadata.js";
1
+ import { mat4 } from "gl-matrix";
2
2
  import {
3
3
  ClampToEdgeWrapping,
4
4
  DataTexture,
@@ -12,45 +12,43 @@ import {
12
12
  UnsignedByteType,
13
13
  UnsignedShortType
14
14
  } from "three";
15
- import Vector3 from "../../../../core/geom/Vector3.js";
16
- import { IncrementalDeltaSet } from "../visibility/IncrementalDeltaSet.js";
17
- import { computeFrustumCorners } from "./computeFrustumCorners.js";
18
- import { read_plane_pair } from "./cluster/read_plane_pair.js";
19
- import { read_frustum_planes_to_array } from "../../../../core/geom/3d/frustum/read_frustum_planes_to_array.js";
20
- import { compute_cluster_planes_from_points } from "./cluster/compute_cluster_planes_from_points.js";
21
- import { TextureBackedMemoryRegion } from "../../texture/TextureBackedMemoryRegion.js";
22
15
  import { assert } from "../../../../core/assert.js";
16
+ import { computeBinaryDataTypeByPrecision } from "../../../../core/binary/type/computeBinaryDataTypeByPrecision.js";
23
17
  import {
24
18
  DataType2TypedArrayConstructorMapping
25
19
  } from "../../../../core/binary/type/DataType2TypedArrayConstructorMapping.js";
26
- import { NumericType } from "../../../../core/math/NumericType.js";
27
- import { computeBinaryDataTypeByPrecision } from "../../../../core/binary/type/computeBinaryDataTypeByPrecision.js";
28
- import { computeThreeTextureTypeFromDataType } from "../../texture/computeThreeTextureTypeFromDataType.js";
29
- import {
30
- computeThreeTextureInternalFormatFromDataType
31
- } from "../../texture/computeThreeTextureInternalFormatFromDataType.js";
32
20
  import { BinaryUint32BVH } from "../../../../core/bvh2/binary/2/BinaryUint32BVH.js";
33
- import { mat4 } from "gl-matrix";
34
- import { TextureAtlas } from "../../texture/atlas/TextureAtlas.js";
35
- import { CachingTextureAtlas } from "../../texture/atlas/CachingTextureAtlas.js";
36
- import { writeSample2DDataToDataTexture } from "../../texture/sampler/writeSampler2DDataToDataTexture.js";
37
- import { Decal } from "./model/Decal.js";
38
- import { ReferencedTextureAtlas } from "../../texture/atlas/ReferencedTextureAtlas.js";
39
- import { v3_morton_encode_transformed } from "../../../../core/geom/3d/morton/v3_morton_encode_transformed.js";
40
- import { v3_distance } from "../../../../core/geom/vec3/v3_distance.js";
21
+ import { BVH } from "../../../../core/bvh2/bvh3/BVH.js";
22
+ import {
23
+ bvh_query_user_data_overlaps_frustum
24
+ } from "../../../../core/bvh2/bvh3/query/bvh_query_user_data_overlaps_frustum.js";
41
25
  import { array_copy } from "../../../../core/collection/array/array_copy.js";
42
26
  import { arrayQuickSort } from "../../../../core/collection/array/arrayQuickSort.js";
43
- import { frustum_from_camera } from "../../ecs/camera/frustum_from_camera.js";
44
27
  import { arraySwapElements } from "../../../../core/collection/array/arraySwapElements.js";
45
- import { slice_frustum_linear_to_points } from "../../../../core/geom/3d/frustum/slice_frustum_linear_to_points.js";
46
28
  import { read_cluster_frustum_corners } from "../../../../core/geom/3d/frustum/read_cluster_frustum_corners.js";
47
- import { assign_cluster, LOOKUP_CACHE, scratch_corners, scratch_frustum_planes } from "./assign_cluster.js";
48
- import {
49
- ExplicitBinaryBoundingVolumeHierarchy
50
- } from "../../../../core/bvh2/bvh3/ExplicitBinaryBoundingVolumeHierarchy.js";
29
+ import { read_frustum_planes_to_array } from "../../../../core/geom/3d/frustum/read_frustum_planes_to_array.js";
30
+ import { slice_frustum_linear_to_points } from "../../../../core/geom/3d/frustum/slice_frustum_linear_to_points.js";
31
+ import { v3_morton_encode_transformed } from "../../../../core/geom/3d/morton/v3_morton_encode_transformed.js";
32
+ import { v3_distance } from "../../../../core/geom/vec3/v3_distance.js";
33
+ import Vector3 from "../../../../core/geom/Vector3.js";
34
+ import { NumericType } from "../../../../core/math/NumericType.js";
35
+ import { frustum_from_camera } from "../../ecs/camera/frustum_from_camera.js";
36
+ import { CachingTextureAtlas } from "../../texture/atlas/CachingTextureAtlas.js";
37
+ import { ReferencedTextureAtlas } from "../../texture/atlas/ReferencedTextureAtlas.js";
38
+ import { TextureAtlas } from "../../texture/atlas/TextureAtlas.js";
51
39
  import {
52
- bvh_query_user_data_overlaps_frustum
53
- } from "../../../../core/bvh2/bvh3/query/bvh_query_user_data_overlaps_frustum.js";
40
+ computeThreeTextureInternalFormatFromDataType
41
+ } from "../../texture/computeThreeTextureInternalFormatFromDataType.js";
42
+ import { computeThreeTextureTypeFromDataType } from "../../texture/computeThreeTextureTypeFromDataType.js";
43
+ import { writeSample2DDataToDataTexture } from "../../texture/sampler/writeSampler2DDataToDataTexture.js";
44
+ import { TextureBackedMemoryRegion } from "../../texture/TextureBackedMemoryRegion.js";
45
+ import { IncrementalDeltaSet } from "../visibility/IncrementalDeltaSet.js";
46
+ import { assign_cluster, LOOKUP_CACHE, scratch_corners, scratch_frustum_planes } from "./assign_cluster.js";
47
+ import { compute_cluster_planes_from_points } from "./cluster/compute_cluster_planes_from_points.js";
48
+ import { read_plane_pair } from "./cluster/read_plane_pair.js";
49
+ import { computeFrustumCorners } from "./computeFrustumCorners.js";
50
+ import { LightRenderMetadata } from "./LightRenderMetadata.js";
51
+ import { Decal } from "./model/Decal.js";
54
52
  import { point_light_inside_volume } from "./query/point_light_inside_volume.js";
55
53
 
56
54
 
@@ -137,9 +135,9 @@ export class LightManager {
137
135
 
138
136
  /**
139
137
  * @readonly
140
- * @type {ExplicitBinaryBoundingVolumeHierarchy}
138
+ * @type {BVH}
141
139
  */
142
- #light_data_bvh = new ExplicitBinaryBoundingVolumeHierarchy();
140
+ #light_data_bvh = new BVH();
143
141
 
144
142
  /**
145
143
  * Mapping from a light/decal object ID internal metadata
@@ -1,4 +1,4 @@
1
- import { EBBVHLeafProxy } from "../../../../core/bvh2/bvh3/EBBVHLeafProxy.js";
1
+ import { BvhClient } from "../../../../core/bvh2/bvh3/BvhClient.js";
2
2
 
3
3
  export class LightRenderMetadata {
4
4
 
@@ -20,7 +20,7 @@ export class LightRenderMetadata {
20
20
  */
21
21
  this.address = 0;
22
22
 
23
- this.bvh_leaf = new EBBVHLeafProxy();
23
+ this.bvh_leaf = new BvhClient();
24
24
  }
25
25
 
26
26
  /**
@@ -42,7 +42,7 @@ export class LightRenderMetadata {
42
42
 
43
43
  /**
44
44
  *
45
- * @param {ExplicitBinaryBoundingVolumeHierarchy} bvh
45
+ * @param {BVH} bvh
46
46
  */
47
47
  link(bvh) {
48
48
  this.bvh_leaf.link(bvh, this.light.id);