@woosh/meep-engine 2.67.0 → 2.69.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 (87) hide show
  1. package/build/bundle-worker-terrain.js +1 -1
  2. package/build/meep.cjs +698 -1270
  3. package/build/meep.min.js +1 -1
  4. package/build/meep.module.js +698 -1270
  5. package/package.json +1 -1
  6. package/src/core/bvh2/binary/2/BinaryUint32BVH.js +55 -28
  7. package/src/core/bvh2/binary/2/BinaryUint32BVH.spec.js +3 -3
  8. package/src/core/bvh2/binary/2/bvh32_query_user_data_overlaps_clipping_volume.js +94 -0
  9. package/src/core/bvh2/binary/2/bvh32_query_user_data_ray.js +17 -18
  10. package/src/core/bvh2/bvh3/query/BVHQueryIntersectsFrustum.js +4 -2
  11. package/src/core/geom/3d/aabb/AABB3.js +14 -14
  12. package/src/core/geom/3d/aabb/aabb3_array_intersects_clipping_volume_array.js +30 -0
  13. package/src/core/geom/3d/aabb/aabb3_intersects_clipping_volume_array.js +51 -0
  14. package/src/core/geom/3d/frustum/{read_frustum_planes_to_array.js → read_three_planes_to_array.js} +5 -3
  15. package/src/core/geom/3d/triangle/triangle_intersects_clipping_volume.js +51 -0
  16. package/src/engine/ecs/terrain/ecs/TerrainSystem.js +2 -2
  17. package/src/engine/ecs/terrain/ecs/makeTerrainWorkerProxy.js +1 -1
  18. package/src/engine/ecs/terrain/tiles/TerrainTile.js +9 -46
  19. package/src/engine/graphics/ecs/mesh/Mesh.d.ts +0 -1
  20. package/src/engine/graphics/ecs/mesh-v2/ShadedGeometry.d.ts +0 -5
  21. package/src/engine/graphics/ecs/mesh-v2/ShadedGeometry.js +0 -1
  22. package/src/engine/graphics/geometry/buffered/query/GeometrySpatialQueryAccelerator.d.ts +2 -2
  23. package/src/engine/graphics/geometry/buffered/query/GeometrySpatialQueryAccelerator.js +79 -36
  24. package/src/engine/graphics/geometry/buffered/query/bvh32_geometry_overlap_clipping_volume.js +88 -0
  25. package/src/engine/graphics/geometry/buffered/query/bvh32_geometry_raycast.js +108 -0
  26. package/src/engine/graphics/geometry/bvh/buffered/bvh32_from_indexed_geometry.js +4 -30
  27. package/src/engine/graphics/geometry/bvh/buffered/bvh32_from_unindexed_geometry.js +30 -0
  28. package/src/engine/graphics/geometry/bvh/buffered/bvh32_set_leaf_from_triangle.js +41 -0
  29. package/src/engine/graphics/material/optimization/prototypeMaterialOptimizer.js +16 -19
  30. package/src/engine/graphics/render/forward_plus/LightManager.js +2 -2
  31. package/src/engine/graphics/render/forward_plus/prototype/prototypeLightManager.js +46 -47
  32. package/src/engine/graphics/render/forward_plus/query/query_bvh_frustum_from_texture.js +2 -2
  33. package/src/engine/graphics/render/view/CameraView.js +8 -8
  34. package/src/core/bvh2/BVHTasks.js +0 -65
  35. package/src/core/bvh2/BinaryNode.d.ts +0 -13
  36. package/src/core/bvh2/BinaryNode.js +0 -1188
  37. package/src/core/bvh2/BinaryNode.spec.js +0 -309
  38. package/src/core/bvh2/LeafNode.d.ts +0 -7
  39. package/src/core/bvh2/LeafNode.js +0 -147
  40. package/src/core/bvh2/Node.d.ts +0 -9
  41. package/src/core/bvh2/Node.js +0 -196
  42. package/src/core/bvh2/NodeValidator.js +0 -197
  43. package/src/core/bvh2/StacklessTraverser.js +0 -154
  44. package/src/core/bvh2/StacklessTraverser.spec.js +0 -109
  45. package/src/core/bvh2/binary/BinaryBVH.js +0 -281
  46. package/src/core/bvh2/binary/IndexedBinaryBVH.js +0 -407
  47. package/src/core/bvh2/binary/IndexedBinaryBVH.spec.js +0 -27
  48. package/src/core/bvh2/binary/IndexedBinaryBVHVisitor.js +0 -11
  49. package/src/core/bvh2/binary/NodeType.js +0 -8
  50. package/src/core/bvh2/binary/RayLeafIntersectionVisitor.js +0 -59
  51. package/src/core/bvh2/serialization/deserializeBinaryNode.js +0 -40
  52. package/src/core/bvh2/serialization/deserializeBinaryNodeFromBinaryBuffer.js +0 -90
  53. package/src/core/bvh2/serialization/serializeBinaryNode.js +0 -31
  54. package/src/core/bvh2/serialization/serializeBinaryNodeToBinaryBuffer.js +0 -86
  55. package/src/core/bvh2/transform/BottomUpOptimizingRebuilder.js +0 -144
  56. package/src/core/bvh2/transform/RotationOptimizer.js +0 -123
  57. package/src/core/bvh2/transform/RotationOptimizer.spec.js +0 -303
  58. package/src/core/bvh2/transform/tryRotateSingleNode.js +0 -260
  59. package/src/core/bvh2/traversal/BVHVisitor.js +0 -30
  60. package/src/core/bvh2/traversal/RaycastBVHVisitor.js +0 -66
  61. package/src/core/bvh2/traversal/ThreeClippingPlaneComputingBVHVisitor.js +0 -384
  62. package/src/core/bvh2/traversal/ThreeFrustumsIntersectionBVHVisitor.js +0 -52
  63. package/src/core/bvh2/traversal/bvh_traverse_pre_order_using_stack.js +0 -43
  64. package/src/core/bvh2/traversal/queryBinaryNode_ClippingPlanes.d.ts +0 -5
  65. package/src/core/bvh2/traversal/queryBinaryNode_ClippingPlanes.js +0 -66
  66. package/src/core/bvh2/traversal/queryBinaryNode_CollectData.js +0 -49
  67. package/src/core/bvh2/traversal/queryBinaryNode_CollectLeaves.js +0 -51
  68. package/src/core/bvh2/traversal/queryBinaryNode_FrustumIntersections.js +0 -77
  69. package/src/core/bvh2/traversal/queryBinaryNode_SphereIntersections.js +0 -63
  70. package/src/core/bvh2/traversal/traverseBinaryNodeUsingVisitor.js +0 -50
  71. package/src/core/bvh2/traversal/traverseBinaryNodeUsingVisitor_DepthFirst_PreOrder.js +0 -34
  72. package/src/core/bvh2/util/find_least_common_ancestor.js +0 -34
  73. package/src/core/bvh2/visual/convert_bvh_to_dot_format_string.js +0 -50
  74. package/src/core/geom/2d/bvh/BinaryNode2.js +0 -152
  75. package/src/core/geom/2d/bvh/LeafNode2.js +0 -11
  76. package/src/core/geom/2d/bvh/Node2.js +0 -51
  77. package/src/core/geom/3d/aabb/aabb3_array_intersects_frustum_array.js +0 -20
  78. package/src/core/geom/3d/aabb/aabb3_intersects_frustum_array.js +0 -35
  79. package/src/engine/ecs/terrain/tiles/FirstRayIntersectionTerrainBVHVisitor.js +0 -74
  80. package/src/engine/graphics/geometry/buffered/query/ClippingPlaneContainmentComputingVisitor.js +0 -195
  81. package/src/engine/graphics/geometry/buffered/query/GeometryVisitor.js +0 -87
  82. package/src/engine/graphics/geometry/buffered/query/RaycastNearestHitComputingVisitor.js +0 -206
  83. package/src/engine/graphics/geometry/bvh/BVHFromGeometry.js +0 -72
  84. package/src/engine/graphics/geometry/bvh/buffered/BVHGeometryRaycaster.js +0 -240
  85. package/src/engine/graphics/geometry/bvh/buffered/BinaryBVHFromBufferGeometry.js +0 -123
  86. package/src/engine/graphics/geometry/bvh/buffered/IndexedTraingleBoundsComputer.js +0 -43
  87. package/src/engine/graphics/render/forward_plus/query/query_bvh_frustum_from_objects.js +0 -133
@@ -1,3 +1,5 @@
1
+ import { mat4 } from "gl-matrix";
2
+ import SimplexNoise from "simplex-noise";
1
3
  import {
2
4
  AmbientLight,
3
5
  BoxBufferGeometry,
@@ -16,56 +18,53 @@ import {
16
18
  Vector2,
17
19
  WebGLRenderer,
18
20
  } from "three";
19
- import { min2 } from "../../../../../core/math/min2.js";
20
- import { seededRandom } from "../../../../../core/math/random/seededRandom.js";
21
- import { PointLight } from "../model/PointLight.js";
22
- import { makeHelperSphereGeometry } from "../../../../../../editor/process/symbolic/makeHelperSphereGeometry.js";
23
21
  import { OrbitControls } from "three/examples/jsm/controls/OrbitControls.js";
24
- import { MouseEvents } from "../../../../input/devices/events/MouseEvents.js";
25
- import { RingBuffer } from "../../../../../core/collection/RingBuffer.js";
26
- import { query_bvh_frustum_from_objects } from "../query/query_bvh_frustum_from_objects.js";
27
- import { FPlusDebugMaterial } from "../materials/FPlusDebugMaterial.js";
28
- import { parse_color } from "../../../../../core/color/parse_color.js";
29
- import { buildLightClusterWidget } from "../debug/buildLightClusterWidget.js";
30
- import domify from "../../../../../view/DOM.js";
31
- import { createScreenGrid } from "../debug/createScreenGrid.js";
32
- import { createLayerSwitcher } from "../debug/createLayerSwitcher.js";
33
- import { FPlusStandardMaterial } from "../materials/FPlusStandardMaterial.js";
34
- import { LightManager } from "../LightManager.js";
35
- import ButtonView from "../../../../../view/elements/button/ButtonView.js";
36
- import { GLTFLoader } from "three/examples/jsm/loaders/GLTFLoader.js";
37
- import { traverseMaterialTextures } from "../../../../asset/loaders/material/traverseMaterialTextures.js";
38
- import Vector3 from "../../../../../core/geom/Vector3.js";
39
- import { MetricCollection } from "../../../../development/performance/MetricCollection.js";
40
- import { MetricStatistics } from "../../../../development/performance/MetricStatistics.js";
41
- import { SpotLight } from "../model/SpotLight.js";
42
- import { randomFloatBetween } from "../../../../../core/math/random/randomFloatBetween.js";
43
- import Signal from "../../../../../core/events/signal/Signal.js";
44
- import SimplexNoise from "simplex-noise";
45
22
  import Stats from "three/examples/jsm/libs/stats.module.js";
46
- import { threeUpdateTransform } from "../../../util/threeUpdateTransform.js";
47
- import { Decal } from "../model/Decal.js";
48
- import { mat4 } from "gl-matrix";
49
- import { Sampler2D } from "../../../texture/sampler/Sampler2D.js";
23
+ import { GLTFLoader } from "three/examples/jsm/loaders/GLTFLoader.js";
24
+ import { Float32BufferAttribute } from "three/src/core/BufferAttribute.js";
25
+ import { BufferGeometry } from "three/src/core/BufferGeometry.js";
26
+ import { DEG2RAD, smoothstep } from "three/src/math/MathUtils.js";
27
+ import '../../../../../../../../../css/game.scss'
50
28
  import { makeHelperBoxGeometry } from "../../../../../../editor/process/symbolic/makeHelperBoxGeometry.js";
29
+ import { makeHelperSphereGeometry } from "../../../../../../editor/process/symbolic/makeHelperSphereGeometry.js";
51
30
  import { array_copy } from "../../../../../core/collection/array/array_copy.js";
52
- import { BufferGeometry } from "three/src/core/BufferGeometry.js";
53
- import { Float32BufferAttribute } from "three/src/core/BufferAttribute.js";
31
+ import { RingBuffer } from "../../../../../core/collection/RingBuffer.js";
32
+ import { Color } from "../../../../../core/color/Color.js";
33
+ import { parse_color } from "../../../../../core/color/parse_color.js";
34
+ import Signal from "../../../../../core/events/signal/Signal.js";
54
35
  import Quaternion from "../../../../../core/geom/Quaternion.js";
55
36
  import { v2_distance } from "../../../../../core/geom/Vector2.js";
56
- import { DEG2RAD, smoothstep } from "three/src/math/MathUtils.js";
37
+ import Vector3 from "../../../../../core/geom/Vector3.js";
38
+ import { Localization } from "../../../../../core/localization/Localization.js";
39
+ import { min2 } from "../../../../../core/math/min2.js";
40
+ import { randomFloatBetween } from "../../../../../core/math/random/randomFloatBetween.js";
41
+ import { randomFromArray } from "../../../../../core/math/random/randomFromArray.js";
42
+ import { seededRandom } from "../../../../../core/math/random/seededRandom.js";
43
+ import { number_pretty_print } from "../../../../../core/primitives/numbers/number_pretty_print.js";
44
+ import domify from "../../../../../view/DOM.js";
45
+ import ButtonView from "../../../../../view/elements/button/ButtonView.js";
46
+ import { GMLEngine } from "../../../../../view/tooltip/gml/GMLEngine.js";
47
+ import { TooltipManager } from "../../../../../view/tooltip/TooltipManager.js";
57
48
  import { AssetManager } from "../../../../asset/AssetManager.js";
58
49
  import { ImageRGBADataLoader } from "../../../../asset/loaders/image/ImageRGBADataLoader.js";
59
- import { Color } from "../../../../../core/color/Color.js";
60
- import { TooltipManager } from "../../../../../view/tooltip/TooltipManager.js";
61
- import { GMLEngine } from "../../../../../view/tooltip/gml/GMLEngine.js";
50
+ import { traverseMaterialTextures } from "../../../../asset/loaders/material/traverseMaterialTextures.js";
51
+ import { MetricCollection } from "../../../../development/performance/MetricCollection.js";
52
+ import { MetricStatistics } from "../../../../development/performance/MetricStatistics.js";
53
+ import { MouseEvents } from "../../../../input/devices/events/MouseEvents.js";
62
54
  import { PointerDevice } from "../../../../input/devices/PointerDevice.js";
63
55
  import { StaticKnowledgeDatabase } from "../../../../knowledge/database/StaticKnowledgeDatabase.js";
64
- import { Localization } from "../../../../../core/localization/Localization.js";
65
- import '../../../../../../../../../css/game.scss'
66
- import { randomFromArray } from "../../../../../core/math/random/randomFromArray.js";
67
56
  import { debugAtlas } from "../../../particles/particular/engine/shader/debugAtlas.js";
68
- import { number_pretty_print } from "../../../../../core/primitives/numbers/number_pretty_print.js";
57
+ import { Sampler2D } from "../../../texture/sampler/Sampler2D.js";
58
+ import { threeUpdateTransform } from "../../../util/threeUpdateTransform.js";
59
+ import { buildLightClusterWidget } from "../debug/buildLightClusterWidget.js";
60
+ import { createLayerSwitcher } from "../debug/createLayerSwitcher.js";
61
+ import { createScreenGrid } from "../debug/createScreenGrid.js";
62
+ import { LightManager } from "../LightManager.js";
63
+ import { FPlusDebugMaterial } from "../materials/FPlusDebugMaterial.js";
64
+ import { FPlusStandardMaterial } from "../materials/FPlusStandardMaterial.js";
65
+ import { Decal } from "../model/Decal.js";
66
+ import { PointLight } from "../model/PointLight.js";
67
+ import { SpotLight } from "../model/SpotLight.js";
69
68
 
70
69
  document.body.style.margin = 0;
71
70
 
@@ -1532,20 +1531,20 @@ function print_perf_stats() {
1532
1531
  setInterval(print_perf_stats, 2000);
1533
1532
 
1534
1533
  function do_sample() {
1535
- query_bvh_frustum_from_objects.iteration_count = 0;
1536
- query_bvh_frustum_from_objects.rejection_count = 0;
1537
- query_bvh_frustum_from_objects.rejection_sphere_count = 0;
1538
- query_bvh_frustum_from_objects.plane_tests = 0;
1539
- query_bvh_frustum_from_objects.plane_tests_early_exits = 0;
1534
+ // query_bvh_frustum_from_objects.iteration_count = 0;
1535
+ // query_bvh_frustum_from_objects.rejection_count = 0;
1536
+ // query_bvh_frustum_from_objects.rejection_sphere_count = 0;
1537
+ // query_bvh_frustum_from_objects.plane_tests = 0;
1538
+ // query_bvh_frustum_from_objects.plane_tests_early_exits = 0;
1540
1539
 
1541
1540
  const t0 = performance.now();
1542
1541
  lm.buildTiles(camera);
1543
1542
  const t1 = performance.now();
1544
1543
 
1545
1544
  metrics.get("time").record(t1 - t0);
1546
- metrics.get("iterations").record(query_bvh_frustum_from_objects.iteration_count);
1547
- metrics.get("rejections").record(query_bvh_frustum_from_objects.rejection_count);
1548
- metrics.get("sphere_rejections").record(query_bvh_frustum_from_objects.rejection_sphere_count);
1545
+ // metrics.get("iterations").record(query_bvh_frustum_from_objects.iteration_count);
1546
+ // metrics.get("rejections").record(query_bvh_frustum_from_objects.rejection_count);
1547
+ // metrics.get("sphere_rejections").record(query_bvh_frustum_from_objects.rejection_sphere_count);
1549
1548
  }
1550
1549
 
1551
1550
  function draw_camera_view_planes() {
@@ -69,7 +69,7 @@ export function query_bvh_frustum_from_texture(
69
69
  ) {
70
70
  let result = 0;
71
71
 
72
- const binary_node_count = bvh.getBinaryNodeCount();
72
+ const binary_node_count = bvh.binary_node_count;
73
73
 
74
74
  if (binary_node_count <= 0) {
75
75
  // this should not happen
@@ -88,7 +88,7 @@ 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 + bvh.getLeafNodeCount();
91
+ const last_valid_index = binary_node_count + bvh.leaf_node_count;
92
92
 
93
93
  const float32 = bvh.float32;
94
94
  const uint32 = bvh.uint32;
@@ -1,13 +1,13 @@
1
- import { IncrementalDeltaSet } from "../visibility/IncrementalDeltaSet.js";
2
- import { AABB3 } from "../../../../core/geom/3d/aabb/AABB3.js";
3
- import { CameraViewFlags } from "./CameraViewFlags.js";
4
1
  import { Frustum } from "three";
5
- import { read_frustum_planes_to_array } from "../../../../core/geom/3d/frustum/read_frustum_planes_to_array.js";
6
- import Signal from "../../../../core/events/signal/Signal.js";
7
- import { compare_three_objects } from "../../three/compare_three_objects.js";
8
- import { frustum_from_camera } from "../../ecs/camera/frustum_from_camera.js";
9
2
  import { array_copy } from "../../../../core/collection/array/array_copy.js";
10
3
  import { array_remove_first } from "../../../../core/collection/array/array_remove_first.js";
4
+ import Signal from "../../../../core/events/signal/Signal.js";
5
+ import { AABB3 } from "../../../../core/geom/3d/aabb/AABB3.js";
6
+ import { read_three_planes_to_array } from "../../../../core/geom/3d/frustum/read_three_planes_to_array.js";
7
+ import { frustum_from_camera } from "../../ecs/camera/frustum_from_camera.js";
8
+ import { compare_three_objects } from "../../three/compare_three_objects.js";
9
+ import { IncrementalDeltaSet } from "../visibility/IncrementalDeltaSet.js";
10
+ import { CameraViewFlags } from "./CameraViewFlags.js";
11
11
 
12
12
  const DEFAULT_FLAGS = CameraViewFlags.Active
13
13
  | CameraViewFlags.AdaptivePlaneNear
@@ -97,7 +97,7 @@ export class CameraView {
97
97
  frustum_from_camera(camera, scratch_frustum, false);
98
98
 
99
99
  // update view definition
100
- read_frustum_planes_to_array(scratch_frustum.planes, this.frustum);
100
+ read_three_planes_to_array(scratch_frustum.planes, this.frustum);
101
101
 
102
102
  // read projection matrix
103
103
  // TODO
@@ -1,65 +0,0 @@
1
- import { RingBuffer } from "../collection/RingBuffer.js";
2
- import Task from "../process/task/Task.js";
3
- import { TaskSignal } from "../process/task/TaskSignal.js";
4
- import { optimize } from "./transform/RotationOptimizer.js";
5
-
6
-
7
- /**
8
- *
9
- * @param {BinaryNode} bvh
10
- * @param {number} iterationLength
11
- * @returns {Task}
12
- */
13
- export function buildTreeOptimizationTask(bvh, iterationLength) {
14
-
15
- const buffer = new RingBuffer(10);
16
-
17
- let cycles = 0;
18
- let sameChangeCountCycles = 0;
19
-
20
- //optimize bvh
21
- const task = new Task({
22
- name: "Optimization of Bounding Volume Hierarchy",
23
-
24
- initializer(task, executor) {
25
- cycles = 0;
26
- sameChangeCountCycles = 0;
27
- buffer.clear();
28
- },
29
-
30
- cycleFunction() {
31
- const optimizationsDone = optimize(bvh, iterationLength);
32
- if (optimizationsDone > 0) {
33
- console.log('otimization step.. changes: ', optimizationsDone);
34
-
35
- cycles += optimizationsDone;
36
- if (buffer.contains(optimizationsDone)) {
37
- sameChangeCountCycles++;
38
- if (sameChangeCountCycles > 100) {
39
- console.warn("detected optimization oscillation after 100 cycles, terminating");
40
- //stuck in oscillation, probably
41
- return TaskSignal.EndSuccess;
42
- }
43
- } else {
44
- //reset counter
45
- sameChangeCountCycles = 0;
46
- }
47
-
48
- buffer.push(optimizationsDone);
49
-
50
- return TaskSignal.Continue;
51
- } else {
52
- return TaskSignal.EndSuccess;
53
- }
54
- },
55
- computeProgress: function () {
56
- if (iterationLength <= 0) {
57
- return 0;
58
- } else {
59
- return cycles / iterationLength;
60
- }
61
- }
62
- });
63
-
64
- return task;
65
- }
@@ -1,13 +0,0 @@
1
- import {Node} from "./Node";
2
- import {LeafNode} from "./LeafNode";
3
-
4
- export class BinaryNode<T = any> extends Node<T> {
5
- left: Node<T>
6
- right: Node<T>
7
-
8
- traversePreOrderUsingStack(visitor: (node: Node<T>) => boolean, thisArg?: any): void
9
-
10
- insert(x0: number, y0: number, z0: number, x1: number, y1: number, z1: number, value: T): LeafNode<T>
11
-
12
- traverseRayLeafIntersections(startX: number, startY: number, startZ: number, directionX: number, directionY: number, directionZ: number, visitor: (node: LeafNode<T>) => any, thisArg?: any);
13
- }