@woosh/meep-engine 2.65.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 (56) hide show
  1. package/build/bundle-worker-terrain.js +1 -1
  2. package/build/meep.cjs +52474 -53800
  3. package/build/meep.min.js +1 -1
  4. package/build/meep.module.js +52474 -53800
  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/binary/2/BinaryUint32BVH.js +118 -113
  10. package/src/core/bvh2/binary/2/BinaryUint32BVH.spec.js +54 -0
  11. package/src/core/bvh2/binary/2/bvh32_query_user_data_ray.js +98 -0
  12. package/src/core/bvh2/bvh3/BVH.d.ts +1 -1
  13. package/src/core/bvh2/bvh3/BvhClient.d.ts +11 -0
  14. package/src/core/bvh2/bvh3/BvhClient.js +19 -0
  15. package/src/core/collection/array/array_copy.js +6 -0
  16. package/src/core/geom/3d/aabb/aabb3_array_combine.js +17 -8
  17. package/src/core/geom/3d/aabb/aabb3_array_intersects_ray.js +5 -2
  18. package/src/core/geom/3d/aabb/aabb3_array_set.js +25 -0
  19. package/src/core/geom/3d/aabb/aabb3_compute_half_surface_area.js +3 -0
  20. package/src/core/geom/3d/triangle/computeTriangleRayIntersectionBarycentric.js +8 -1
  21. package/src/engine/EngineHarness.js +23 -25
  22. package/src/engine/ecs/renderable/RenderSystem.js +44 -32
  23. package/src/engine/ecs/renderable/Renderable.d.ts +2 -2
  24. package/src/engine/ecs/renderable/Renderable.js +12 -11
  25. package/src/engine/ecs/terrain/ecs/Terrain.js +83 -87
  26. package/src/engine/ecs/terrain/ecs/TerrainSystem.js +106 -57
  27. package/src/engine/ecs/terrain/ecs/makeTerrainWorkerProxy.js +5 -2
  28. package/src/engine/ecs/terrain/tiles/TerrainTile.js +122 -67
  29. package/src/engine/ecs/terrain/tiles/TerrainTileManager.js +162 -146
  30. package/src/engine/ecs/terrain/tiles/TileBuildWorker.js +16 -5
  31. package/src/engine/graphics/camera/testClippingPlaneComputation.js +3 -6
  32. package/src/engine/graphics/debug/VisualSymbolLine.js +1 -0
  33. package/src/engine/graphics/ecs/camera/CameraSystem.js +9 -9
  34. package/src/engine/graphics/ecs/camera/auto_set_camera_clipping_planes.js +3 -23
  35. package/src/engine/graphics/ecs/light/LightSystem.js +12 -48
  36. package/src/engine/graphics/ecs/mesh/MeshSystem.js +9 -31
  37. package/src/engine/graphics/ecs/mesh/updateNodeByTransformAndBBB.js +3 -43
  38. package/src/engine/graphics/ecs/trail2d/Trail2D.js +105 -106
  39. package/src/engine/graphics/ecs/trail2d/Trail2DSystem.js +60 -61
  40. package/src/engine/graphics/ecs/trail2d/makeGradientTrail.js +3 -3
  41. package/src/engine/graphics/ecs/water/WATER_SIZE.js +1 -0
  42. package/src/engine/graphics/ecs/water/Water.js +84 -42
  43. package/src/engine/graphics/ecs/water/WaterSystem.js +53 -105
  44. package/src/engine/graphics/geometry/bvh/buffered/BVHGeometryRaycaster.js +13 -7
  45. package/src/engine/graphics/geometry/bvh/buffered/bvh32_from_indexed_geometry.js +58 -0
  46. package/src/engine/graphics/particles/ecs/ParticleEmitterSystem.js +32 -62
  47. package/src/engine/graphics/particles/particular/engine/emitter/ParticleEmitter.js +1 -1
  48. package/src/engine/graphics/particles/particular/engine/renderers/billboard/prototypeBillboardRenderer.js +8 -11
  49. package/src/engine/graphics/render/forward_plus/query/query_bvh_frustum_from_texture.js +21 -19
  50. package/src/engine/graphics/render/layers/RenderLayer.d.ts +8 -2
  51. package/src/engine/graphics/render/layers/RenderLayer.js +7 -65
  52. package/src/engine/graphics/render/make_bvh_visibility_builder.js +64 -0
  53. package/src/engine/graphics/three/expand_aabb_by_transformed_three_object.js +4 -4
  54. package/src/engine/graphics/trail/x/RibbonX.js +26 -5
  55. package/src/core/bvh2/binary/tiny/TinyBVH.js +0 -221
  56. package/src/engine/graphics/ecs/camera/CameraClippingPlaneComputer.js +0 -138
@@ -0,0 +1,98 @@
1
+ import { SCRATCH_UINT32_TRAVERSAL_STACK } from "../../../collection/SCRATCH_UINT32_TRAVERSAL_STACK.js";
2
+ import { aabb3_array_intersects_ray } from "../../../geom/3d/aabb/aabb3_array_intersects_ray.js";
3
+ import { BVH_BINARY_NODE_SIZE, BVH_LEAF_NODE_SIZE } from "./BinaryUint32BVH.js";
4
+
5
+ const stack = SCRATCH_UINT32_TRAVERSAL_STACK;
6
+
7
+ /**
8
+ *
9
+ * @param {BinaryUint32BVH} bvh
10
+ * @param {number[]} result
11
+ * @param {number} result_offset
12
+ * @param {number} origin_x
13
+ * @param {number} origin_y
14
+ * @param {number} origin_z
15
+ * @param {number} direction_x
16
+ * @param {number} direction_y
17
+ * @param {number} direction_z
18
+ * @returns {number}
19
+ */
20
+ export function bvh32_query_user_data_ray(
21
+ bvh,
22
+ result, result_offset,
23
+ origin_x, origin_y, origin_z,
24
+ direction_x, direction_y, direction_z
25
+ ) {
26
+ let hit_count = 0;
27
+
28
+ const binary_node_count = bvh.getBinaryNodeCount();
29
+
30
+ if (binary_node_count <= 0) {
31
+ // this should not happen
32
+ return 0;
33
+ }
34
+
35
+ /**
36
+ *
37
+ * @type {number}
38
+ */
39
+ const stack_top = stack.pointer++;
40
+
41
+ /**
42
+ * After performing empirical tests, stack-based depth-first traversal turns out faster than using a queue
43
+ * @type {number}
44
+ */
45
+ stack[stack_top] = 0;
46
+
47
+ const last_valid_index = binary_node_count + bvh.getLeafNodeCount();
48
+
49
+ const float32 = bvh.float32;
50
+ const uint32 = bvh.uint32;
51
+
52
+ do {
53
+ stack.pointer--;
54
+
55
+ // query_bvh_frustum_from_objects.iteration_count++;
56
+ const node_index = stack[stack.pointer];
57
+
58
+ if (node_index < binary_node_count) {
59
+ // is intermediate node
60
+ const node_address = node_index * BVH_BINARY_NODE_SIZE;
61
+
62
+ if (!aabb3_array_intersects_ray(
63
+ float32, node_address,
64
+ origin_x, origin_y, origin_z,
65
+ direction_x, direction_y, direction_z
66
+ )) {
67
+ continue;
68
+ }
69
+
70
+ const left_index = (node_index << 1) + 1;
71
+ const right_index = left_index + 1;
72
+
73
+ // left node ends up on top of the stack, which aligns with the desired access sequence
74
+ if (right_index < last_valid_index) {
75
+ stack[stack.pointer++] = right_index;
76
+ // micro-optimization, since we know that right node is valid and left appears before that, left is valid too
77
+ stack[stack.pointer++] = left_index;
78
+ } else if (left_index < last_valid_index) {
79
+ stack[stack.pointer++] = left_index;
80
+ }
81
+
82
+
83
+ } else {
84
+ // leaf node
85
+ const leaf_index = node_index - binary_node_count;
86
+
87
+ const node_address = leaf_index * BVH_LEAF_NODE_SIZE + binary_node_count * BVH_BINARY_NODE_SIZE;
88
+
89
+ // write to output
90
+ result[result_offset + hit_count] = uint32[node_address + 6];
91
+
92
+ hit_count++;
93
+ }
94
+
95
+ } while (stack.pointer > stack_top)
96
+
97
+ return hit_count;
98
+ }
@@ -1,4 +1,4 @@
1
- export class BVH {
1
+ export declare class BVH {
2
2
  readonly root: number
3
3
 
4
4
  node_capacity: number
@@ -0,0 +1,11 @@
1
+ import {BVH} from "./BVH";
2
+
3
+ export declare class BvhClient{
4
+ readonly is_linked:boolean
5
+ readonly bounds:ArrayLike<number>
6
+
7
+ write_bound():void
8
+
9
+ link(tree:BVH,data:number):void
10
+ unlink():void
11
+ }
@@ -1,4 +1,5 @@
1
1
  import { assert } from "../../assert.js";
2
+ import { aabb3_array_set } from "../../geom/3d/aabb/aabb3_array_set.js";
2
3
 
3
4
  /**
4
5
  * A convenience class to work with BVH leaf nodes
@@ -67,4 +68,22 @@ export class BvhClient {
67
68
 
68
69
  this.#tree.node_move_aabb(this.#node_id, this.bounds);
69
70
  }
71
+
72
+ /**
73
+ *
74
+ * @param {number} x0
75
+ * @param {number} y0
76
+ * @param {number} z0
77
+ * @param {number} x1
78
+ * @param {number} y1
79
+ * @param {number} z1
80
+ */
81
+ resize(x0, y0, z0, x1, y1, z1) {
82
+ aabb3_array_set(
83
+ this.bounds, 0,
84
+ x0, y0, z0, x1, y1, z1
85
+ );
86
+
87
+ this.write_bounds();
88
+ }
70
89
  }
@@ -1,3 +1,5 @@
1
+ import { assert } from "../../assert.js";
2
+
1
3
  /**
2
4
  * Copy data from one array to another
3
5
  * Follows Java System.arraycopy interface
@@ -15,6 +17,10 @@ export function array_copy(
15
17
  destination_position,
16
18
  length
17
19
  ) {
20
+ assert.isNonNegativeInteger(source_position, 'source_position');
21
+ assert.isNonNegativeInteger(destination_position, 'destination_position');
22
+ assert.isNonNegativeInteger(length, 'length');
23
+
18
24
  let i, j, k;
19
25
 
20
26
  for (k = 0; k < length; k++) {
@@ -1,20 +1,29 @@
1
1
  //
2
2
 
3
- import { min2 } from "../../../math/min2.js";
4
3
  import { max2 } from "../../../math/max2.js";
4
+ import { min2 } from "../../../math/min2.js";
5
5
 
6
6
  /**
7
7
  * Merge bounds of two axis-aligned bounding boxes, the result is a box that tightly bounds inputs
8
8
  * @param {ArrayLike<number>|number[]|Float32Array} result where resulting value is written to
9
+ * @param {number} result_offset
9
10
  * @param {ArrayLike<number>|number[]|Float32Array} a
11
+ * @param {number} a_offset
10
12
  * @param {ArrayLike<number>|number[]|Float32Array} b
13
+ * @param {number} b_offset
11
14
  */
12
- export function aabb3_array_combine(result, a, b) {
13
- result[0] = min2(a[0], b[0]);
14
- result[1] = min2(a[1], b[1]);
15
- result[2] = min2(a[2], b[2]);
15
+ export function aabb3_array_combine(
16
+ result, result_offset,
17
+ a, a_offset,
18
+ b, b_offset
19
+ ) {
20
+
21
+ result[result_offset + 0] = min2(a[a_offset + 0], b[b_offset + 0]);
22
+ result[result_offset + 1] = min2(a[a_offset + 1], b[b_offset + 1]);
23
+ result[result_offset + 2] = min2(a[a_offset + 2], b[b_offset + 2]);
24
+
25
+ result[result_offset + 3] = max2(a[a_offset + 3], b[b_offset + 3]);
26
+ result[result_offset + 4] = max2(a[a_offset + 4], b[b_offset + 4]);
27
+ result[result_offset + 5] = max2(a[a_offset + 5], b[b_offset + 5]);
16
28
 
17
- result[3] = max2(a[3], b[3]);
18
- result[4] = max2(a[4], b[4]);
19
- result[5] = max2(a[5], b[5]);
20
29
  }
@@ -5,6 +5,7 @@ import { aabb3_intersects_ray } from "./aabb3_intersects_ray.js";
5
5
  /**
6
6
  *
7
7
  * @param {ArrayLike<number>|number[]|Float32Array} aabb bounding box, order: x0,y0,z0,x1,y1,z1
8
+ * @param {number} aabb_offset
8
9
  * @param {number} origin_x
9
10
  * @param {number} origin_y
10
11
  * @param {number} origin_z
@@ -13,11 +14,13 @@ import { aabb3_intersects_ray } from "./aabb3_intersects_ray.js";
13
14
  * @param {number} direction_z
14
15
  */
15
16
  export function aabb3_array_intersects_ray(
16
- aabb,
17
+ aabb, aabb_offset,
17
18
  origin_x, origin_y, origin_z,
18
19
  direction_x, direction_y, direction_z
19
20
  ) {
20
- return aabb3_intersects_ray(aabb[0], aabb[1], aabb[2], aabb[3], aabb[4], aabb[5],
21
+ return aabb3_intersects_ray(
22
+ aabb[aabb_offset], aabb[aabb_offset+1], aabb[aabb_offset+2],
23
+ aabb[aabb_offset+3], aabb[aabb_offset+4], aabb[aabb_offset+5],
21
24
  origin_x, origin_y, origin_z,
22
25
  direction_x, direction_y, direction_z
23
26
  );
@@ -0,0 +1,25 @@
1
+ /**
2
+ *
3
+ * @param {ArrayLike<number>|Float32Array|number[]} result
4
+ * @param {number} result_offset
5
+ * @param {number} x0
6
+ * @param {number} y0
7
+ * @param {number} z0
8
+ * @param {number} x1
9
+ * @param {number} y1
10
+ * @param {number} z1
11
+ */
12
+ export function aabb3_array_set(
13
+ result, result_offset,
14
+ x0, y0, z0,
15
+ x1, y1, z1
16
+ ) {
17
+
18
+ result[result_offset + 0] = x0;
19
+ result[result_offset + 1] = y0;
20
+ result[result_offset + 2] = z0;
21
+
22
+ result[result_offset + 3] = x1;
23
+ result[result_offset + 4] = y1;
24
+ result[result_offset + 5] = z1;
25
+ }
@@ -9,8 +9,11 @@
9
9
  * @returns {number}
10
10
  */
11
11
  export function aabb3_compute_half_surface_area(x0, y0, z0, x1, y1, z1) {
12
+
12
13
  const dx = x1 - x0;
13
14
  const dy = y1 - y0;
14
15
  const dz = z1 - z0;
16
+
15
17
  return dy * (dx + dz) + dz * dx; //1 side, since it's a heuristic only
18
+
16
19
  }
@@ -83,5 +83,12 @@ export function computeTriangleRayIntersectionBarycentric(
83
83
  const edge2_y = cy - ay;
84
84
  const edge2_z = cz - az;
85
85
 
86
- return computeTriangleRayIntersectionBarycentricEdge(result, origin_x, origin_y, origin_z, direction_x, direction_y, direction_z, ax, ay, az, edge1_x, edge1_y, edge1_z, edge2_x, edge2_y, edge2_z);
86
+ return computeTriangleRayIntersectionBarycentricEdge(
87
+ result,
88
+ origin_x, origin_y, origin_z,
89
+ direction_x, direction_y, direction_z,
90
+ ax, ay, az,
91
+ edge1_x, edge1_y, edge1_z,
92
+ edge2_x, edge2_y, edge2_z
93
+ );
87
94
  }
@@ -1,36 +1,36 @@
1
- import Engine from "./Engine.js";
2
- import { MouseEvents } from "./input/devices/events/MouseEvents.js";
3
- import { Transform } from "./ecs/transform/Transform.js";
4
- import TopDownCameraController from "./graphics/ecs/camera/topdown/TopDownCameraController.js";
5
- import { Camera } from "./graphics/ecs/camera/Camera.js";
6
- import Entity from "./ecs/Entity.js";
7
- import { Light } from "./graphics/ecs/light/Light.js";
8
- import Vector3 from "../core/geom/Vector3.js";
9
- import Terrain from "./ecs/terrain/ecs/Terrain.js";
1
+ import Stats from "three/examples/jsm/libs/stats.module.js";
2
+ import { noop } from "../core/function/Functions.js";
10
3
  import Vector2 from "../core/geom/Vector2.js";
11
- import Water from "./graphics/ecs/water/Water.js";
12
- import { WebEnginePlatform } from "./platform/WebEnginePlatform.js";
13
- import Tag from "./ecs/components/Tag.js";
4
+ import Vector3 from "../core/geom/Vector3.js";
5
+ import EmptyView from "../view/elements/EmptyView.js";
6
+ import { JsonAssetLoader } from "./asset/loaders/JsonAssetLoader.js";
14
7
  import { SerializationMetadata } from "./ecs/components/SerializationMetadata.js";
8
+ import Tag from "./ecs/components/Tag.js";
9
+ import Entity from "./ecs/Entity.js";
15
10
  import { TerrainLayer } from "./ecs/terrain/ecs/layers/TerrainLayer.js";
11
+ import Terrain from "./ecs/terrain/ecs/Terrain.js";
12
+ import TerrainSystem from "./ecs/terrain/ecs/TerrainSystem.js";
13
+ import { Transform } from "./ecs/transform/Transform.js";
14
+ import Engine from "./Engine.js";
15
+ import { EngineConfiguration } from "./EngineConfiguration.js";
16
16
  import { makeOrbitalCameraController } from "./graphics/camera/makeOrbitalCameraController.js";
17
- import TopDownCameraControllerSystem from "./graphics/ecs/camera/topdown/TopDownCameraControllerSystem.js";
17
+ import { Camera } from "./graphics/ecs/camera/Camera.js";
18
18
  import { CameraSystem } from "./graphics/ecs/camera/CameraSystem.js";
19
+ import TopDownCameraController from "./graphics/ecs/camera/topdown/TopDownCameraController.js";
20
+ import TopDownCameraControllerSystem from "./graphics/ecs/camera/topdown/TopDownCameraControllerSystem.js";
21
+ import { Light } from "./graphics/ecs/light/Light.js";
19
22
  import LightSystem from "./graphics/ecs/light/LightSystem.js";
20
- import InputControllerSystem from "./input/ecs/systems/InputControllerSystem.js";
21
- import TerrainSystem from "./ecs/terrain/ecs/TerrainSystem.js";
23
+ import Water from "./graphics/ecs/water/Water.js";
22
24
  import WaterSystem from "./graphics/ecs/water/WaterSystem.js";
25
+ import { MouseEvents } from "./input/devices/events/MouseEvents.js";
23
26
  import KeyboardCameraController from "./input/ecs/controllers/KeyboardCameraController.js";
24
- import { EngineConfiguration } from "./EngineConfiguration.js";
25
- import { JsonAssetLoader } from "./asset/loaders/JsonAssetLoader.js";
26
- import { logger } from "./logging/GlobalLogger.js";
27
+ import InputControllerSystem from "./input/ecs/systems/InputControllerSystem.js";
27
28
  import { ConsoleLoggerBackend } from "./logging/ConsoleLoggerBackend.js";
28
- import { noop } from "../core/function/Functions.js";
29
- import SoundListenerSystem from "./sound/ecs/SoundListenerSystem.js";
30
- import SoundListener from "./sound/ecs/SoundListener.js";
29
+ import { logger } from "./logging/GlobalLogger.js";
31
30
  import { getURLHash } from "./platform/GetURLHash.js";
32
- import Stats from "three/examples/jsm/libs/stats.module.js";
33
- import EmptyView from "../view/elements/EmptyView.js";
31
+ import { WebEnginePlatform } from "./platform/WebEnginePlatform.js";
32
+ import SoundListener from "./sound/ecs/SoundListener.js";
33
+ import SoundListenerSystem from "./sound/ecs/SoundListenerSystem.js";
34
34
 
35
35
  /**
36
36
  *
@@ -438,7 +438,6 @@ export class EngineHarness {
438
438
  engine,
439
439
  size = new Vector2(10, 10),
440
440
  diffuse0 = "data/textures/utility/checkers_dark_grey_256x256.png",
441
- heightMap = "data/textures/utility/white_pixel.png",
442
441
  heightRange = 0,
443
442
  resolution = 10,
444
443
  waterLevel = 0,
@@ -464,7 +463,6 @@ export class EngineHarness {
464
463
  ));
465
464
  terrain.splat.resize(1, 1, 1);
466
465
  terrain.splat.fillLayerWeights(0, 255);
467
- terrain.heightMapURL = heightMap;
468
466
 
469
467
  terrain.build(engine.assetManager);
470
468
 
@@ -1,22 +1,44 @@
1
1
  /**
2
2
  * Created by Alex on 01/04/2014.
3
3
  */
4
- import { System } from '../System.js';
5
- import Renderable from './Renderable.js';
6
- import { Transform } from '../transform/Transform.js';
4
+ import { BVH } from "../../../core/bvh2/bvh3/BVH.js";
7
5
  import { SignalBinding } from "../../../core/events/signal/SignalBinding.js";
8
- import { RenderableFlags } from "./RenderableFlags.js";
9
- import { rootObject3DFastMatrixUpdate } from "../../graphics/ecs/mesh/rootObject3DFastMatrixUpdate.js";
10
- import { updateNodeByTransformAndBBB } from "../../graphics/ecs/mesh/updateNodeByTransformAndBBB.js";
11
- import { ResourceAccessSpecification } from "../../../core/model/ResourceAccessSpecification.js";
12
6
  import { ResourceAccessKind } from "../../../core/model/ResourceAccessKind.js";
7
+ import { ResourceAccessSpecification } from "../../../core/model/ResourceAccessSpecification.js";
13
8
  import { copy_transform_to_threejs_object } from "../../graphics/copy_transform_to_threejs_object.js";
9
+ import { rootObject3DFastMatrixUpdate } from "../../graphics/ecs/mesh/rootObject3DFastMatrixUpdate.js";
10
+ import { updateNodeByTransformAndBBB } from "../../graphics/ecs/mesh/updateNodeByTransformAndBBB.js";
11
+ import { make_bvh_visibility_builder } from "../../graphics/render/make_bvh_visibility_builder.js";
12
+ import { System } from '../System.js';
13
+ import { Transform } from '../transform/Transform.js';
14
+ import Renderable from './Renderable.js';
15
+ import { RenderableFlags } from "./RenderableFlags.js";
14
16
 
15
17
 
16
18
  /**
17
19
  * @deprecated use {@link ShadedGeometry} instead
18
20
  */
19
21
  class RenderSystem extends System {
22
+ dependencies = [Renderable, Transform];
23
+
24
+ components_used = [
25
+ ResourceAccessSpecification.from(Renderable, ResourceAccessKind.Read | ResourceAccessKind.Write)
26
+ ];
27
+
28
+ entityData = [];
29
+
30
+ /**
31
+ *
32
+ * @type {RenderLayer|null}
33
+ */
34
+ renderLayer = null;
35
+
36
+ /**
37
+ *
38
+ * @type {BVH}
39
+ */
40
+ bvh = new BVH();
41
+
20
42
  /**
21
43
  *
22
44
  * @param {GraphicsEngine} graphicsEngine
@@ -29,26 +51,6 @@ class RenderSystem extends System {
29
51
  * @type {GraphicsEngine}
30
52
  */
31
53
  this.graphics = graphicsEngine;
32
-
33
- this.dependencies = [Renderable, Transform];
34
-
35
- this.components_used = [
36
- ResourceAccessSpecification.from(Renderable, ResourceAccessKind.Read | ResourceAccessKind.Write)
37
- ];
38
-
39
- this.entityData = [];
40
-
41
- /**
42
- *
43
- * @type {RenderLayer|null}
44
- */
45
- this.renderLayer = null;
46
-
47
- /**
48
- *
49
- * @type {BinaryNode}
50
- */
51
- this.bvh = null;
52
54
  }
53
55
 
54
56
  startup(entityManager, readyCallback, errorCallback) {
@@ -56,7 +58,19 @@ class RenderSystem extends System {
56
58
 
57
59
  this.renderLayer = this.graphics.layers.create('render-system');
58
60
 
59
- this.bvh = this.renderLayer.bvh;
61
+ this.renderLayer.buildVisibleSet = make_bvh_visibility_builder(
62
+ this.entityManager, this.bvh,
63
+ (destination, offset, entity, ecd) => {
64
+ const component = ecd.getComponent(entity, Renderable);
65
+
66
+ if (component.object === null) {
67
+ return 0;
68
+ }
69
+
70
+ destination[offset] = component.object;
71
+ return 1;
72
+ }
73
+ )
60
74
 
61
75
  const visibleSet = this.renderLayer.visibleSet;
62
76
 
@@ -102,8 +116,6 @@ class RenderSystem extends System {
102
116
  * @param {int} entity
103
117
  */
104
118
  link(renderable, transform, entity) {
105
- //remember entity for fast lookup
106
- renderable.bvh.entity = entity;
107
119
 
108
120
  // create back-links to ECS
109
121
  renderable.object.__meep_ecs_component = renderable;
@@ -139,7 +151,7 @@ class RenderSystem extends System {
139
151
 
140
152
  handle_transform_change();
141
153
 
142
- this.bvh.insertNode(renderable.bvh);
154
+ renderable.bvh.link(this.bvh,entity);
143
155
  }
144
156
 
145
157
  /**
@@ -158,7 +170,7 @@ class RenderSystem extends System {
158
170
 
159
171
  delete this.entityData[entity];
160
172
 
161
- renderable.bvh.disconnect();
173
+ renderable.bvh.unlink();
162
174
 
163
175
  // cleanup resources
164
176
  renderable.dispose();
@@ -1,6 +1,6 @@
1
1
  import {Object3D} from "three";
2
+ import {BvhClient} from "../../../core/bvh2/bvh3/BvhClient";
2
3
  import {AABB3} from "../../../core/geom/3d/aabb/AABB3";
3
- import {LeafNode} from "../../../core/bvh2/LeafNode";
4
4
 
5
5
  export default class Renderable {
6
6
  readonly object: Object3D
@@ -9,7 +9,7 @@ export default class Renderable {
9
9
  matrixAutoUpdate: boolean
10
10
  boundingBoxNeedsUpdate: boolean
11
11
 
12
- readonly bvh: LeafNode<Object3D>
12
+ readonly bvh: BvhClient
13
13
 
14
14
  constructor(object: Object3D)
15
15
 
@@ -3,13 +3,13 @@
3
3
  */
4
4
 
5
5
 
6
- import { LeafNode } from "../../../core/bvh2/LeafNode.js";
6
+ import { BvhClient } from "../../../core/bvh2/bvh3/BvhClient.js";
7
7
  import { AABB3 } from "../../../core/geom/3d/aabb/AABB3.js";
8
- import { RenderableFlags } from "./RenderableFlags.js";
9
8
  import { MATRIX_4_IDENTITY } from "../../../core/geom/3d/matrix/MATRIX_4_IDENTITY.js";
10
9
  import {
11
10
  expand_aabb_by_transformed_three_object
12
11
  } from "../../graphics/three/expand_aabb_by_transformed_three_object.js";
12
+ import { RenderableFlags } from "./RenderableFlags.js";
13
13
 
14
14
  const DEFAULT_FLAGS = RenderableFlags.UpdateMatrix | RenderableFlags.BoundingBoxNeedsUpdate;
15
15
 
@@ -18,18 +18,19 @@ const DEFAULT_FLAGS = RenderableFlags.UpdateMatrix | RenderableFlags.BoundingBox
18
18
  @deprecated use {@link ShadedGeometry} instead
19
19
  */
20
20
  class Renderable {
21
- constructor(object) {
22
- this.object = object;
21
+ boundingBox = new AABB3(0, 0, 0, 0, 0, 0);
22
+
23
+ bvh = new BvhClient();
23
24
 
24
- this.boundingBox = new AABB3(0, 0, 0, 0, 0, 0);
25
+ /**
26
+ *
27
+ * @type {number}
28
+ */
29
+ flags = DEFAULT_FLAGS;
25
30
 
26
- this.bvh = new LeafNode(object, 0, 0, 0, 0, 0, 0);
31
+ constructor(object) {
32
+ this.object = object;
27
33
 
28
- /**
29
- *
30
- * @type {number}
31
- */
32
- this.flags = DEFAULT_FLAGS;
33
34
  }
34
35
 
35
36
  dispose() {