@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
@@ -1,138 +0,0 @@
1
- import { Frustum as ThreeFrustum } from "three";
2
- import { v3_dot } from "../../../../core/geom/vec3/v3_dot.js";
3
- import { isValueBetweenInclusive } from "../../../../core/math/interval/isValueBetweenInclusive.js";
4
- import { frustum_from_camera } from "./frustum_from_camera.js";
5
- import { is_valid_distance_value } from "./is_valid_distance_value.js";
6
-
7
- const CLIPPING_EPSILON = 0.001;
8
-
9
- const CLIPPING_NEAR_MIN = 0.5;
10
-
11
- const CLIPPING_FAR_DEFAULT = 100;
12
-
13
- export class CameraClippingPlaneComputer {
14
- constructor() {
15
- /**
16
- *
17
- * @type {Camera}
18
- */
19
- this.camera = null;
20
-
21
- /**
22
- *
23
- * @type {RenderLayerManager}
24
- */
25
- this.layers = null;
26
-
27
- /**
28
- * Prevents minor shrinkage of the frustum. This variable controls the threshold at which the shrinkage should occur.
29
- * @example value 0 would result is unconditional shrinkage
30
- * @example value 1 would result in shrinkage occurring never
31
- * @type {number}
32
- */
33
- this.hysteresis = 0.5;
34
-
35
- /**
36
- *
37
- * @type {Frustum}
38
- * @private
39
- */
40
- this.__frustum = new ThreeFrustum();
41
-
42
-
43
- this.near = 0;
44
- this.far = 0;
45
- }
46
-
47
- /**
48
- *
49
- * @param {RenderLayer} layer
50
- * @private
51
- */
52
- __processLayer(layer) {
53
- if (!layer.state.visible) {
54
- return;
55
- }
56
-
57
- layer.computeNearFarClippingPlanes(this.__frustum, this.near, this.far, this.__updateClippingPlanes, this);
58
- }
59
-
60
- /**
61
- *
62
- * @param {number} z0
63
- * @param {number} z1
64
- * @private
65
- */
66
- __updateClippingPlanes(z0, z1) {
67
- if (z0 < this.near && z0 !== Number.NEGATIVE_INFINITY) {
68
- this.near = z0;
69
- }
70
- if (z1 > this.far && z1 !== Number.POSITIVE_INFINITY) {
71
- this.far = z1;
72
- }
73
- }
74
-
75
- compute() {
76
- const camera = this.camera;
77
-
78
- /**
79
- *
80
- * @type {number}
81
- */
82
- const hysteresis = this.hysteresis;
83
-
84
- //quantify hysteresis
85
- const oldNear = camera.near;
86
- const oldFar = camera.far;
87
- const oldClippingPlaneDistance = Math.abs(oldFar - oldNear);
88
-
89
- const shrinkThreshold = hysteresis * oldClippingPlaneDistance;
90
-
91
- frustum_from_camera(camera, this.__frustum);
92
-
93
- // compute plane constant (D) to move "near" plane to intersect camera position
94
- const nearPlane = this.__frustum.planes[5];
95
- const near_plane_normal = nearPlane.normal;
96
- const camera_position = camera.position;
97
-
98
- nearPlane.constant = -v3_dot(
99
- camera_position.x,
100
- camera_position.y,
101
- camera_position.z,
102
- near_plane_normal.x,
103
- near_plane_normal.y,
104
- near_plane_normal.z
105
- );
106
-
107
- this.far = Number.NEGATIVE_INFINITY;
108
- this.near = Number.POSITIVE_INFINITY;
109
-
110
- this.layers.traverse(this.__processLayer, this);
111
-
112
- //offset clipping planes by a small margin to prevent clipping of parallel planar surfaces
113
- this.near -= CLIPPING_EPSILON;
114
- this.far += CLIPPING_EPSILON;
115
-
116
- //clip near
117
- if (!is_valid_distance_value(this.near) || this.near < CLIPPING_NEAR_MIN) {
118
- //use a default
119
- //NOTE: values smaller than 0.001 seem to lead to glitchy rendering where polygons clip through one another
120
- this.near = CLIPPING_NEAR_MIN;
121
- }
122
-
123
- if (!is_valid_distance_value(this.far) || this.far < 0) {
124
- //use a default
125
- this.far = CLIPPING_FAR_DEFAULT;
126
- }
127
-
128
- //hysteresis check
129
- if (isValueBetweenInclusive(this.near - oldNear, 0, shrinkThreshold)) {
130
- this.near = oldNear;
131
- }
132
-
133
- if (isValueBetweenInclusive(oldFar - this.far, 0, shrinkThreshold)) {
134
- this.far = oldFar;
135
- }
136
-
137
- }
138
- }