@woosh/meep-engine 2.34.43 → 2.34.47

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 (68) hide show
  1. package/core/bvh2/BinaryNode.js +62 -32
  2. package/core/bvh2/LeafNode.js +2 -1
  3. package/core/bvh2/aabb3/AABB3.js +879 -1059
  4. package/core/bvh2/aabb3/AABB3.spec.js +5 -7
  5. package/core/bvh2/aabb3/aabb3_array_intersects_ray.js +2 -2
  6. package/core/bvh2/aabb3/aabb3_box_surface_area_2.js +10 -0
  7. package/core/bvh2/aabb3/aabb3_compute_half_surface_area.js +16 -0
  8. package/core/bvh2/aabb3/aabb3_compute_surface_area.js +18 -0
  9. package/core/bvh2/aabb3/aabb3_expand_array.js +15 -0
  10. package/core/bvh2/aabb3/aabb3_intersect_aabb3.js +28 -0
  11. package/core/bvh2/aabb3/aabb3_intersect_ray_slab.js +73 -0
  12. package/core/bvh2/aabb3/{aabb3_intersects_frustum.js → aabb3_intersects_frustum_array.js} +16 -1
  13. package/core/bvh2/aabb3/aabb3_intersects_line_segment.js +79 -0
  14. package/core/bvh2/aabb3/aabb3_intersects_ray.js +92 -0
  15. package/core/bvh2/aabb3/{AABB3Math.spec.js → aabb3_intersects_ray.spec.js} +3 -3
  16. package/core/bvh2/aabb3/aabb3_intersects_ray_fast.js +176 -0
  17. package/core/bvh2/aabb3/aabb3_score_boxes_SAH.js +43 -0
  18. package/core/bvh2/aabb3/aabb_score_boxes_SAH_delta.js +37 -0
  19. package/core/bvh2/aabb3/deserializeAABB3.js +17 -0
  20. package/core/bvh2/aabb3/deserializeAABB3Encoded_v0.js +73 -0
  21. package/core/bvh2/aabb3/deserializeAABB3Quantized16Uint.js +36 -0
  22. package/core/bvh2/aabb3/serializeAABB3.js +13 -0
  23. package/core/bvh2/aabb3/serializeAABB3Quantized16Uint.js +33 -0
  24. package/core/bvh2/binary/2/BinaryUint32BVH.js +3 -3
  25. package/core/bvh2/binary/BinaryBVH.js +2 -2
  26. package/core/bvh2/binary/RayLeafIntersectionVisitor.js +2 -2
  27. package/core/bvh2/serialization/deserializeBinaryNode.js +1 -1
  28. package/core/bvh2/serialization/deserializeBinaryNodeFromBinaryBuffer.js +2 -1
  29. package/core/bvh2/serialization/serializeBinaryNode.js +1 -1
  30. package/core/bvh2/serialization/serializeBinaryNodeToBinaryBuffer.js +2 -1
  31. package/core/bvh2/transform/BottomUpOptimizingRebuilder.js +6 -5
  32. package/core/bvh2/transform/tryRotateSingleNode.js +2 -1
  33. package/core/bvh2/traversal/bvh_traverse_pre_order_using_stack.js +43 -0
  34. package/core/bvh2/visual/convert_bvh_to_dot_format_string.js +50 -0
  35. package/core/geom/3d/frustum/{array_setFromProjectionMatrix.js → frustum_from_projection_matrix_array.js} +1 -1
  36. package/core/geom/3d/topology/TopoMesh.js +0 -8
  37. package/core/geom/3d/topology/TopoVertex.js +7 -6
  38. package/core/geom/3d/topology/simplify/quadratic/Quadratic3.js +93 -5
  39. package/core/geom/3d/topology/simplify/quadratic/build_vertex_quadratics.js +7 -4
  40. package/core/geom/3d/topology/simplify/quadratic/compute_edge_collapse_cost_quadratic.js +7 -1
  41. package/core/geom/3d/topology/simplify/simplifyTopoMesh.js +1 -14
  42. package/core/graph/convertGraphToDotString.js +4 -4
  43. package/core/graph/v2/Graph.js +4 -0
  44. package/core/math/fabsf.js +8 -0
  45. package/engine/development/performance/MetricCollection.js +6 -0
  46. package/engine/ecs/foliage/ecs/Foliage2System.js +7 -2
  47. package/engine/graphics/compute_geometry_polycount.js +21 -0
  48. package/engine/graphics/ecs/mesh-v2/ShadedGeometrySystem.js +2 -2
  49. package/engine/graphics/ecs/mesh-v2/sample/prototypeShadedGeometry.js +66 -9
  50. package/engine/graphics/geometry/buffered/query/RaycastNearestHitComputingVisitor.js +2 -2
  51. package/engine/graphics/micron/build/buildMicronGeometryFromBufferGeometry.js +4 -0
  52. package/engine/graphics/micron/build/hierarchy/merge_patches.js +1 -1
  53. package/engine/graphics/micron/convert_three_object_to_micron.js +2 -0
  54. package/engine/graphics/micron/format/MicronGeometryPatchOccurance.js +3 -2
  55. package/engine/graphics/micron/plugin/GLTFAssetTransformer.js +176 -0
  56. package/engine/graphics/micron/plugin/MicronRenderPlugin.js +1 -135
  57. package/engine/graphics/micron/prototypeVirtualGeometry.js +12 -7
  58. package/engine/graphics/micron/render/PatchCacheKey.js +1 -1
  59. package/engine/graphics/micron/render/VirtualGeometryBuilder.js +16 -43
  60. package/engine/graphics/micron/render/instanced/ThreeInstancedAdapter.js +5 -1
  61. package/engine/graphics/micron/render/refinement/ActivePatchList.js +4 -10
  62. package/engine/graphics/micron/render/refinement/RefinementSpec.js +16 -20
  63. package/engine/graphics/particles/particular/engine/utils/volume/prototypeParticleVolume.js +316 -11
  64. package/engine/graphics/render/layers/RenderLayer.js +22 -14
  65. package/engine/graphics/render/visibility/IncrementalDeltaSet.js +18 -5
  66. package/engine/graphics/render/visibility/VisibilityComputer.js +11 -15
  67. package/package.json +1 -1
  68. package/core/bvh2/aabb3/AABB3Math.js +0 -579
@@ -8,12 +8,14 @@ import { arrayQuickSort } from "../collection/array/arrayQuickSort.js";
8
8
  import { max2 } from "../math/max2.js";
9
9
  import { min2 } from "../math/min2.js";
10
10
  import { computeSampleStandardDeviation } from "../math/statistics/computeSampleStandardDeviation.js";
11
- import { _boxSurfaceArea2, aabb3_intersect_aabb3, boxSurfaceArea2 } from "./aabb3/AABB3Math.js";
12
11
  import { isLeaf, LeafNode } from "./LeafNode.js";
13
12
  import { Node } from "./Node.js";
14
13
  import { surfaceAreaHeuristic } from "./sah/surfaceAreaHeuristic.js";
15
14
  import { BVHVisitor } from "./traversal/BVHVisitor.js";
16
15
  import { traverseBinaryNodeUsingVisitor } from "./traversal/traverseBinaryNodeUsingVisitor.js";
16
+ import { aabb3_intersect_aabb3 } from "./aabb3/aabb3_intersect_aabb3.js";
17
+ import { aabb3_box_surface_area_2 } from "./aabb3/aabb3_box_surface_area_2.js";
18
+ import { aabb3_compute_half_surface_area } from "./aabb3/aabb3_compute_half_surface_area.js";
17
19
 
18
20
 
19
21
  /**
@@ -209,44 +211,62 @@ export class BinaryNode extends Node {
209
211
  */
210
212
  __insertion_findSiblingFor(box) {
211
213
 
212
- const open_set = [this];
213
- let cursor = 1;
214
+ let node = this;
215
+ let cost_left = 0;
216
+ let cost_right = 0;
214
217
 
215
- let best_cost = Infinity;
216
- let best_node = this;
218
+ while (node.isBinaryNode) {
219
+ const left = node.left;
220
+ const right = node.right;
217
221
 
218
- while (cursor > 0) {
219
- const node = open_set[--cursor];
222
+ const area = aabb3_box_surface_area_2(node);
220
223
 
221
- const cost = inclusion_surface_area_heuristic(node, box);
224
+ const combined_area = combined_surface_area(node, box);
222
225
 
223
- if (cost < best_cost) {
224
- best_cost = cost;
225
- best_node = node;
226
- }
226
+ //cost of creating a new parent for this node and the new leaf
227
+ const cost = combined_area;
227
228
 
228
- if (node.isBinaryNode) {
229
+ // minimum cost of pushing the leaf further down the tree
230
+ const inheritance_cost = combined_area - area;
229
231
 
230
- // consider pushing children into the queue
232
+ // cost of descending left
233
+ if (left !== null) {
234
+ if (left.isLeafNode) {
235
+ cost_left = combined_surface_area(left, box) + inheritance_cost;
236
+ } else {
237
+ cost_left = combined_surface_area(left, box) - aabb3_box_surface_area_2(left) + inheritance_cost;
238
+ }
239
+ } else {
240
+ cost_left = Infinity;
241
+ }
231
242
 
232
- // compute lower bound for cost
233
- const c_low = inclusion_cost_lower_bound(node, box);
243
+ // cost of descending right
244
+ if (right !== null) {
234
245
 
235
- if (c_low < best_cost) {
236
- // worth-while to explore children
237
- if (node.left !== null) {
238
- open_set[cursor++] = node.left;
239
- }
240
- if (node.right !== null) {
241
- open_set[cursor++] = node.right
242
- }
246
+ if (right.isLeafNode) {
247
+ cost_right = combined_surface_area(right, box) + inheritance_cost;
248
+ } else {
249
+ cost_right = combined_surface_area(right, box) - aabb3_box_surface_area_2(right) + inheritance_cost;
243
250
  }
251
+ } else {
252
+ cost_right = Infinity;
244
253
  }
245
254
 
255
+ if (cost < cost_left && cost < cost_right) {
256
+ // descending either branch is too expensive
257
+ break;
258
+ }
246
259
 
260
+ if (cost_left < cost_right && left !== null) {
261
+ node = left;
262
+ } else if (right !== null) {
263
+ node = right;
264
+ } else {
265
+ break;
266
+ }
247
267
  }
248
268
 
249
- return best_node;
269
+ return node;
250
270
  }
251
271
 
252
272
  /**
@@ -288,8 +308,8 @@ export class BinaryNode extends Node {
288
308
  }
289
309
 
290
310
  //change costs to be based on balance
291
- aCost = a.leafNodeCount / boxSurfaceArea2(a);
292
- bCost = b.leafNodeCount / boxSurfaceArea2(b);
311
+ aCost = a.leafNodeCount / aabb3_box_surface_area_2(a);
312
+ bCost = b.leafNodeCount / aabb3_box_surface_area_2(b);
293
313
  }
294
314
 
295
315
  if (aCost === bCost) {
@@ -480,7 +500,7 @@ export class BinaryNode extends Node {
480
500
  leftArea = 0;
481
501
  leftLeaves = 0;
482
502
  } else {
483
- leftArea = boxSurfaceArea2(left);
503
+ leftArea = aabb3_box_surface_area_2(left);
484
504
  leftLeaves = left.leafNodeCount;
485
505
  }
486
506
 
@@ -489,11 +509,11 @@ export class BinaryNode extends Node {
489
509
  rightArea = 0;
490
510
  rightLeaves = 0;
491
511
  } else {
492
- rightArea = boxSurfaceArea2(right);
512
+ rightArea = aabb3_box_surface_area_2(right);
493
513
  rightLeaves = right.leafNodeCount;
494
514
  }
495
515
 
496
- const thisArea = boxSurfaceArea2(this);
516
+ const thisArea = aabb3_box_surface_area_2(this);
497
517
 
498
518
  return surfaceAreaHeuristic(thisArea, leftArea, rightArea, leftLeaves, rightLeaves);
499
519
  }
@@ -1132,6 +1152,16 @@ BinaryNode.prototype.isBinaryNode = true;
1132
1152
  * @returns {number}
1133
1153
  */
1134
1154
  function inclusion_surface_area_heuristic(node, addition) {
1155
+ return combined_surface_area(node, addition) - aabb3_box_surface_area_2(node);
1156
+ }
1157
+
1158
+ /**
1159
+ *
1160
+ * @param {AABB3} node
1161
+ * @param {AABB3} addition
1162
+ * @returns {number}
1163
+ */
1164
+ function combined_surface_area(node, addition) {
1135
1165
  const x0 = min2(node.x0, addition.x0);
1136
1166
  const y0 = min2(node.y0, addition.y0);
1137
1167
  const z0 = min2(node.z0, addition.z0);
@@ -1140,7 +1170,7 @@ function inclusion_surface_area_heuristic(node, addition) {
1140
1170
  const y1 = max2(node.y1, addition.y1);
1141
1171
  const z1 = max2(node.z1, addition.z1);
1142
1172
 
1143
- return _boxSurfaceArea2(x0, y0, z0, x1, y1, z1) - boxSurfaceArea2(node);
1173
+ return aabb3_compute_half_surface_area(x0, y0, z0, x1, y1, z1);
1144
1174
  }
1145
1175
 
1146
1176
  /**
@@ -1150,7 +1180,7 @@ function inclusion_surface_area_heuristic(node, addition) {
1150
1180
  */
1151
1181
  function inclusion_cost_lower_bound(node, addition) {
1152
1182
  let n = node;
1153
- let r = boxSurfaceArea2(addition);
1183
+ let r = aabb3_box_surface_area_2(addition);
1154
1184
 
1155
1185
  while (n !== null) {
1156
1186
 
@@ -1,8 +1,9 @@
1
1
  /**
2
2
  * Created by Alex on 17/11/2014.
3
3
  */
4
- import { deserializeAABB3, serializeAABB3 } from "./aabb3/AABB3.js";
5
4
  import { Node } from "./Node.js";
5
+ import { serializeAABB3 } from "./aabb3/serializeAABB3.js";
6
+ import { deserializeAABB3 } from "./aabb3/deserializeAABB3.js";
6
7
 
7
8
 
8
9
  /**