@woosh/meep-engine 2.34.42 → 2.34.46

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 (69) hide show
  1. package/core/bvh2/BinaryNode.js +60 -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 +6 -2
  47. package/engine/graphics/compute_geometry_polycount.js +21 -0
  48. package/engine/graphics/ecs/light/binding/three/ThreeLightBinding.js +1 -1
  49. package/engine/graphics/ecs/mesh-v2/ShadedGeometrySystem.js +2 -2
  50. package/engine/graphics/ecs/mesh-v2/sample/prototypeShadedGeometry.js +77 -7
  51. package/engine/graphics/geometry/buffered/query/RaycastNearestHitComputingVisitor.js +2 -2
  52. package/engine/graphics/micron/build/buildMicronGeometryFromBufferGeometry.js +4 -0
  53. package/engine/graphics/micron/build/hierarchy/merge_patches.js +1 -1
  54. package/engine/graphics/micron/convert_three_object_to_micron.js +2 -0
  55. package/engine/graphics/micron/format/MicronGeometryPatchOccurance.js +3 -2
  56. package/engine/graphics/micron/plugin/GLTFAssetTransformer.js +176 -0
  57. package/engine/graphics/micron/plugin/MicronRenderPlugin.js +1 -135
  58. package/engine/graphics/micron/prototypeVirtualGeometry.js +12 -7
  59. package/engine/graphics/micron/render/PatchCacheKey.js +1 -1
  60. package/engine/graphics/micron/render/VirtualGeometryBuilder.js +16 -43
  61. package/engine/graphics/micron/render/instanced/ThreeInstancedAdapter.js +5 -1
  62. package/engine/graphics/micron/render/refinement/ActivePatchList.js +4 -10
  63. package/engine/graphics/micron/render/refinement/RefinementSpec.js +16 -20
  64. package/engine/graphics/particles/particular/engine/utils/volume/prototypeParticleVolume.js +316 -11
  65. package/engine/graphics/render/layers/RenderLayer.js +22 -14
  66. package/engine/graphics/render/visibility/IncrementalDeltaSet.js +18 -5
  67. package/engine/graphics/render/visibility/VisibilityComputer.js +11 -15
  68. package/package.json +1 -1
  69. package/core/bvh2/aabb3/AABB3Math.js +0 -579
@@ -1,579 +0,0 @@
1
- /**
2
- * Created by Alex on 25/05/2016.
3
- */
4
-
5
-
6
- import { max2 } from "../../math/max2.js";
7
- import { min2 } from "../../math/min2.js";
8
- import { intersects1D } from "../../math/intersects1D.js";
9
-
10
- /**
11
- * Float ABS, from standard C lib
12
- * @param {Number} val
13
- * @returns {number}
14
- */
15
- function fabsf(val) {
16
- return val >= 0 ? val : -val;
17
- }
18
-
19
- /**
20
- *
21
- * @param {number} x0
22
- * @param {number} y0
23
- * @param {number} z0
24
- * @param {number} x1
25
- * @param {number} y1
26
- * @param {number} z1
27
- * @param {number} startX
28
- * @param {number} startY
29
- * @param {number} startZ
30
- * @param {number} endX
31
- * @param {number} endY
32
- * @param {number} endZ
33
- * @returns {boolean}
34
- */
35
- function intersectSegment(
36
- x0, y0, z0,
37
- x1, y1, z1,
38
- startX, startY, startZ,
39
- endX, endY, endZ
40
- ) {
41
-
42
- let boxExtentsX,
43
- boxExtentsY,
44
- boxExtentsZ,
45
- diffX,
46
- diffY,
47
- diffZ,
48
- dirX,
49
- dirY,
50
- dirZ,
51
- centerX,
52
- centerY,
53
- centerZ;
54
- //
55
- let a, b, c;
56
-
57
- dirX = 0.5 * (endX - startX);
58
- boxExtentsX = (x1 - x0) / 2;
59
- centerX = x0 + boxExtentsX;
60
- diffX = (0.5 * (endX + startX)) - centerX;
61
- a = fabsf(dirX);
62
- if (fabsf(diffX) > boxExtentsX + a) return false;
63
- //
64
- dirY = 0.5 * (endY - startY);
65
- boxExtentsY = (y1 - y0) / 2;
66
- centerY = y0 + boxExtentsY;
67
- diffY = (0.5 * (endY + startY)) - centerY;
68
- b = fabsf(dirY);
69
- if (fabsf(diffY) > boxExtentsY + b) return false;
70
- //
71
- dirZ = 0.5 * (endZ - startZ);
72
- boxExtentsZ = (z1 - z0) / 2;
73
- centerZ = z0 + boxExtentsZ;
74
- diffZ = (0.5 * (endZ + startZ)) - centerZ;
75
- c = fabsf(dirZ);
76
- if (fabsf(diffZ) > boxExtentsZ + c) return false;
77
-
78
- //Dir.y = 0.5f * (segment.mP1.y - segment.mP0.y);
79
- //BoxExtents.y = aabb.GetExtents(1);
80
- //Diff.y = (0.5f * (segment.mP1.y + segment.mP0.y)) - aabb.GetCenter(1);
81
- //b = fabsf(Dir.y);
82
- //if(fabsf(Diff.y)>BoxExtents.y + b) return false;
83
-
84
- let f;
85
- f = dirY * diffZ - dirZ * diffY;
86
- if (fabsf(f) > boxExtentsY * c + boxExtentsZ * b) return false;
87
- f = dirZ * diffX - dirX * diffZ;
88
- if (fabsf(f) > boxExtentsX * c + boxExtentsZ * a) return false;
89
- f = dirX * diffY - dirY * diffX;
90
- if (fabsf(f) > boxExtentsX * b + boxExtentsY * a) return false;
91
-
92
- return true;
93
- }
94
-
95
- /**
96
- *
97
- * @param {number} ax0
98
- * @param {number} ay0
99
- * @param {number} az0
100
- * @param {number} ax1
101
- * @param {number} ay1
102
- * @param {number} az1
103
- * @param {number} bx0
104
- * @param {number} by0
105
- * @param {number} bz0
106
- * @param {number} bx1
107
- * @param {number} by1
108
- * @param {number} bz1
109
- * @returns {boolean}
110
- */
111
- export function aabb3_intersect_aabb3(
112
- ax0, ay0, az0,
113
- ax1, ay1, az1,
114
- bx0, by0, bz0,
115
- bx1, by1, bz1
116
- ) {
117
- return intersects1D(ax0, ax1, bx0, bx1)
118
- && intersects1D(ay0, ay1, by0, by1)
119
- && intersects1D(az0, az1, bz0, bz1);
120
- }
121
-
122
- /**
123
- * see: https://tavianator.com/fast-branchless-raybounding-box-intersections-part-2-nans/
124
- * NOTE: this solution forgoes consistent handling of NaNs in favor of execution speed
125
- * FIXME some manual tests have shown deviation in results between this implementation and others. Possible bugs?
126
- * @param {number} x0
127
- * @param {number} y0
128
- * @param {number} z0
129
- * @param {number} x1
130
- * @param {number} y1
131
- * @param {number} z1
132
- * @param {number} oX
133
- * @param {number} oY
134
- * @param {number} oZ
135
- * @param {number} dirX
136
- * @param {number} dirY
137
- * @param {number} dirZ
138
- * @returns {boolean}
139
- */
140
- function aabb3_intersectRay_slab(
141
- x0, y0, z0,
142
- x1, y1, z1,
143
- oX, oY, oZ,
144
- dirX, dirY, dirZ
145
- ) {
146
- /*
147
- Java CODE:
148
- bool intersection(box b, ray r) {
149
- double t1 = (b.min[0] - r.origin[0])*r.dir_inv[0];
150
- double t2 = (b.max[0] - r.origin[0])*r.dir_inv[0];
151
-
152
- double tmin = min(t1, t2);
153
- double tmax = max(t1, t2);
154
-
155
- for (int i = 1; i < 3; ++i) {
156
- t1 = (b.min[i] - r.origin[i])*r.dir_inv[i];
157
- t2 = (b.max[i] - r.origin[i])*r.dir_inv[i];
158
-
159
- tmin = max(tmin, min(t1, t2));
160
- tmax = min(tmax, max(t1, t2));
161
- }
162
-
163
- return tmax > max(tmin, 0.0);
164
- }
165
-
166
- */
167
- const dir_inv_x = -dirX;
168
- const dir_inv_y = -dirY;
169
- const dir_inv_z = -dirZ;
170
-
171
- const t1_x = (x0 - oX) * dir_inv_x;
172
- const t2_x = (x1 - oX) * dir_inv_x;
173
-
174
- const tMin_x = min2(t1_x, t2_x);
175
- const tMax_x = max2(t1_x, t2_x);
176
-
177
- const t1_y = (y0 - oY) * dir_inv_y;
178
- const t2_y = (y1 - oY) * dir_inv_y;
179
-
180
- const tMin_y = max2(tMin_x, min2(t1_y, t2_y));
181
- const tMax_y = min2(tMax_x, max2(t1_y, t2_y));
182
-
183
- const t1_z = (z0 - oZ) * dir_inv_z;
184
- const t2_z = (z1 - oZ) * dir_inv_z;
185
-
186
- const tMin_z = max2(tMin_y, min2(t1_z, t2_z));
187
- const tMax_z = min2(tMax_y, max2(t1_z, t2_z));
188
-
189
-
190
- return tMax_z > max2(tMin_z, 0.0);
191
- }
192
-
193
- /**
194
- * Fast Ray-Box intersection
195
- * From "Graphics Gems", Academic Press, 1990
196
- * ported from C
197
- * see: https://web.archive.org/web/20090803054252/http://tog.acm.org/resources/GraphicsGems/gems/RayBox.c
198
- * @param {number} x0
199
- * @param {number} y0
200
- * @param {number} z0
201
- * @param {number} x1
202
- * @param {number} y1
203
- * @param {number} z1
204
- * @param {number} oX
205
- * @param {number} oY
206
- * @param {number} oZ
207
- * @param {number} dirX
208
- * @param {number} dirY
209
- * @param {number} dirZ
210
- * @returns {boolean}
211
- */
212
- export function aabb3_intersectRay_fast(x0, y0, z0, x1, y1, z1, oX, oY, oZ, dirX, dirY, dirZ) {
213
- let inside = true;
214
-
215
- let quadrantX = 0;
216
- let quadrantY = 0;
217
- let quadrantZ = 0;
218
-
219
- let maxTX = 0;
220
- let maxTY = 0;
221
- let maxTZ = 0;
222
-
223
- let maxT = 0;
224
-
225
- let candidatePlaneX = 0;
226
- let candidatePlaneY = 0;
227
- let candidatePlaneZ = 0;
228
-
229
- let coordX = 0;
230
- let coordY = 0;
231
- let coordZ = 0;
232
-
233
- /*
234
- find candidate planes
235
- */
236
- if (oX < x0) {
237
- quadrantX = 1; //LEFT
238
- candidatePlaneX = x0;
239
- inside = false;
240
- } else if (oX > x1) {
241
- quadrantX = 0; //RIGHT
242
- candidatePlaneX = x1;
243
- inside = false;
244
- } else {
245
- quadrantX = 2; //MIDDLE
246
- }
247
-
248
- if (oY < y0) {
249
- quadrantY = 1; //LEFT
250
- candidatePlaneY = y0;
251
- inside = false;
252
- } else if (oY > y1) {
253
- quadrantY = 0; //RIGHT
254
- candidatePlaneY = y1;
255
- inside = false;
256
- } else {
257
- quadrantY = 2; //MIDDLE
258
- }
259
-
260
- if (oZ < z0) {
261
- quadrantZ = 1; //LEFT
262
- candidatePlaneZ = z0;
263
- inside = false;
264
- } else if (oZ > z1) {
265
- quadrantZ = 0; //RIGHT
266
- candidatePlaneZ = z1;
267
- inside = false;
268
- } else {
269
- quadrantZ = 2; //MIDDLE
270
- }
271
-
272
- // Ray origin inside the bounding box
273
- if (inside) {
274
- return true;
275
- }
276
-
277
- // Calculate T distances to candidate planes
278
- if (quadrantX !== 2 && dirX !== 0) {
279
- maxTX = (candidatePlaneX - oX) / dirX;
280
- } else {
281
- maxTX = -1;
282
- }
283
-
284
- if (quadrantY !== 2 && dirY !== 0) {
285
- maxTY = (candidatePlaneY - oY) / dirY;
286
- } else {
287
- maxTY = -1;
288
- }
289
-
290
- if (quadrantZ !== 2 && dirZ !== 0) {
291
- maxTZ = (candidatePlaneZ - oZ) / dirZ;
292
- } else {
293
- maxTZ = -1;
294
- }
295
-
296
- // Get largest of maxT's for final choice of intersection
297
- if (maxTX < maxTY) {
298
- if (maxTY < maxTZ) {
299
- maxT = maxTZ;
300
- // Check if final candidate actually inside the box
301
- if (maxT < 0) {
302
- return false;
303
- }
304
-
305
- coordX = oX + maxT * dirX;
306
- if (coordX < x0 || coordX > x1) {
307
- return false;
308
- }
309
-
310
- coordY = oY + maxT * dirY;
311
- if (coordY < y0 || coordY > y1) {
312
- return false;
313
- }
314
-
315
- } else {
316
- maxT = maxTY;
317
- // Check if final candidate actually inside the box
318
- if (maxT < 0) {
319
- return false;
320
- }
321
-
322
- coordX = oX + maxT * dirX;
323
- if (coordX < x0 || coordX > x1) {
324
- return false;
325
- }
326
-
327
- coordZ = oZ + maxT * dirZ;
328
- if (coordZ < z0 || coordZ > z1) {
329
- return false;
330
- }
331
- }
332
- } else if (maxTX < maxTZ) {
333
- maxT = maxTZ;
334
- // Check if final candidate actually inside the box
335
- if (maxT < 0) {
336
- return false;
337
- }
338
-
339
- coordX = oX + maxT * dirX;
340
- if (coordX < x0 || coordX > x1) {
341
- return false;
342
- }
343
-
344
- coordY = oY + maxT * dirY;
345
- if (coordY < y0 || coordY > y1) {
346
- return false;
347
- }
348
- } else {
349
- maxT = maxTX;
350
- // Check if final candidate actually inside the box
351
- if (maxT < 0) {
352
- return false;
353
- }
354
-
355
- coordY = oY + maxT * dirY;
356
- if (coordY < y0 || coordY > y1) {
357
- return false;
358
- }
359
-
360
- coordZ = oZ + maxT * dirZ;
361
- if (coordZ < z0 || coordZ > z1) {
362
- return false;
363
- }
364
- }
365
-
366
- //ray hits the box
367
- return true;
368
- }
369
-
370
- /**
371
- * NOTES:
372
- * https://web.archive.org/web/20090803054252/http://tog.acm.org/resources/GraphicsGems/gems/RayBox.c
373
- * https://tavianator.com/fast-branchless-raybounding-box-intersections/
374
- * https://gamedev.stackexchange.com/questions/18436/most-efficient-aabb-vs-ray-collision-algorithms
375
- *
376
- * @param {number} x0
377
- * @param {number} y0
378
- * @param {number} z0
379
- * @param {number} x1
380
- * @param {number} y1
381
- * @param {number} z1
382
- * @param {number} oX
383
- * @param {number} oY
384
- * @param {number} oZ
385
- * @param {number} dirX
386
- * @param {number} dirY
387
- * @param {number} dirZ
388
- * @returns {boolean}
389
- */
390
- function intersectRay(x0, y0, z0, x1, y1, z1, oX, oY, oZ, dirX, dirY, dirZ) {
391
-
392
- // Z Projection
393
- const boxExtentsX = (x1 - x0) / 2;
394
-
395
- const centerX = x0 + boxExtentsX;
396
-
397
- const diffX = oX - centerX;
398
-
399
-
400
- if (fabsf(diffX) > boxExtentsX && diffX * dirX >= 0.0) {
401
- return false;
402
- }
403
-
404
- // Y projection
405
- const boxExtentsY = (y1 - y0) / 2;
406
-
407
- const centerY = y0 + boxExtentsY;
408
-
409
- const diffY = oY - centerY;
410
-
411
-
412
- if (fabsf(diffY) > boxExtentsY && diffY * dirY >= 0.0) {
413
- return false;
414
- }
415
-
416
- // Z projection
417
- const boxExtentsZ = (z1 - z0) / 2;
418
-
419
- const centerZ = z0 + boxExtentsZ;
420
-
421
- const diffZ = oZ - centerZ;
422
-
423
-
424
- if (fabsf(diffZ) > boxExtentsZ && diffZ * dirZ >= 0.0) {
425
- return false;
426
- }
427
-
428
- //Dir.y = 0.5f * (segment.mP1.y - segment.mP0.y);
429
- //BoxExtents.y = aabb.GetExtents(1);
430
- //Diff.y = (0.5f * (segment.mP1.y + segment.mP0.y)) - aabb.GetCenter(1);
431
- //b = fabsf(Dir.y);
432
- //if(fabsf(Diff.y)>BoxExtents.y + b) return false;
433
-
434
- const a = fabsf(dirX);
435
- const b = fabsf(dirY);
436
- const c = fabsf(dirZ);
437
-
438
- const f0 = dirY * diffZ - dirZ * diffY;
439
-
440
- if (fabsf(f0) > boxExtentsY * c + boxExtentsZ * b) {
441
- return false;
442
- }
443
-
444
- const f1 = dirZ * diffX - dirX * diffZ;
445
-
446
- if (fabsf(f1) > boxExtentsX * c + boxExtentsZ * a) {
447
- return false;
448
- }
449
-
450
- const f2 = dirX * diffY - dirY * diffX;
451
-
452
- if (fabsf(f2) > boxExtentsX * b + boxExtentsY * a) {
453
- return false;
454
- }
455
-
456
- return true;
457
- }
458
-
459
- /**
460
- * Compute surface area for a box contain both inputs
461
- * @param {AABB3} a
462
- * @param {AABB3} b
463
- * @returns {number}
464
- */
465
- function scoreBoxesSAH(a, b) {
466
- let x0, y0, z0, x1, y1, z1;
467
-
468
- //
469
-
470
- const ax0 = a.x0;
471
- const ay0 = a.y0;
472
- const az0 = a.z0;
473
- const ax1 = a.x1;
474
- const ay1 = a.y1;
475
- const az1 = a.z1;
476
-
477
- const bx0 = b.x0;
478
- const by0 = b.y0;
479
- const bz0 = b.z0;
480
- const bx1 = b.x1;
481
- const by1 = b.y1;
482
- const bz1 = b.z1;
483
-
484
- //
485
-
486
- x0 = ax0 < bx0 ? ax0 : bx0;
487
- y0 = ay0 < by0 ? ay0 : by0;
488
- z0 = az0 < bz0 ? az0 : bz0;
489
-
490
- x1 = ax1 > bx1 ? ax1 : bx1;
491
- y1 = ay1 > by1 ? ay1 : by1;
492
- z1 = az1 > bz1 ? az1 : bz1;
493
-
494
- //
495
-
496
- return _boxSurfaceArea2(x0, y0, z0, x1, y1, z1);
497
- }
498
-
499
- function scoreBoxesSAHDelta(b0, b1) {
500
- let x0, y0, z0, x1, y1, z1;
501
- //
502
- const b0x0 = b0.x0;
503
- const b0y0 = b0.y0;
504
- const b0z0 = b0.z0;
505
- const b0x1 = b0.x1;
506
- const b0y1 = b0.y1;
507
- const b0z1 = b0.z1;
508
-
509
- const b1x0 = b1.x0;
510
- const b1y0 = b1.y0;
511
- const b1z0 = b1.z0;
512
- const b1x1 = b1.x1;
513
- const b1y1 = b1.y1;
514
- const b1z1 = b1.z1;
515
- //
516
- x0 = b0x0 < b1x0 ? b0x0 : b1x0;
517
- y0 = b0y0 < b1y0 ? b0y0 : b1y0;
518
- z0 = b0z0 < b1z0 ? b0z0 : b1z0;
519
- x1 = b0x1 > b1x1 ? b0x1 : b1x1;
520
- y1 = b0y1 > b1y1 ? b0y1 : b1y1;
521
- z1 = b0z1 > b1z1 ? b0z1 : b1z1;
522
- //
523
- const totalArea = _boxSurfaceArea2(x0, y0, z0, x1, y1, z1);
524
- const area0 = b0.getSurfaceArea();
525
- const area1 = b1.getSurfaceArea();
526
- return totalArea - Math.max(area0, area1);
527
- }
528
-
529
- /**
530
- *
531
- * @param {number} x0
532
- * @param {number} y0
533
- * @param {number} z0
534
- * @param {number} x1
535
- * @param {number} y1
536
- * @param {number} z1
537
- * @returns {number}
538
- */
539
- function boxSurfaceArea(x0, y0, z0, x1, y1, z1) {
540
- const dx = x1 - x0;
541
- const dy = y1 - y0;
542
- const dz = z1 - z0;
543
- return (dy * (dx + dz) + dz * dx) * 2; //2 of each side
544
- }
545
-
546
- /**
547
- *
548
- * @param {number} x0
549
- * @param {number} y0
550
- * @param {number} z0
551
- * @param {number} x1
552
- * @param {number} y1
553
- * @param {number} z1
554
- * @returns {number}
555
- */
556
- function _boxSurfaceArea2(x0, y0, z0, x1, y1, z1) {
557
- const dx = x1 - x0;
558
- const dy = y1 - y0;
559
- const dz = z1 - z0;
560
- return dy * (dx + dz) + dz * dx; //1 side, since it's a heuristic only
561
- }
562
-
563
- /**
564
- *
565
- * @param {AABB3} node
566
- * @returns {number}
567
- */
568
- function boxSurfaceArea2(node) {
569
- return _boxSurfaceArea2(node.x0, node.y0, node.z0, node.x1, node.y1, node.z1);
570
- }
571
-
572
- export {
573
- intersectSegment,
574
- intersectRay,
575
- scoreBoxesSAH,
576
- boxSurfaceArea,
577
- boxSurfaceArea2,
578
- _boxSurfaceArea2
579
- }