@woosh/meep-engine 2.48.21 → 2.48.23

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 (103) hide show
  1. package/editor/ecs/component/editors/three/BufferGeometryEditor.js +1 -1
  2. package/editor/ecs/component/editors/three/MeshEditor.js +1 -1
  3. package/editor/tools/SelectionTool.js +1 -1
  4. package/editor/view/library/MeshLibraryView.js +1 -1
  5. package/package.json +1 -1
  6. package/src/core/binary/32BitEncoder.js +1 -1
  7. package/src/core/bvh2/LeafNode.js +2 -2
  8. package/src/core/bvh2/Node.d.ts +1 -1
  9. package/src/core/bvh2/Node.js +1 -1
  10. package/src/core/bvh2/NodeValidator.js +1 -1
  11. package/src/core/bvh2/serialization/deserializeBinaryNode.js +1 -1
  12. package/src/core/bvh2/serialization/deserializeBinaryNodeFromBinaryBuffer.js +2 -2
  13. package/src/core/bvh2/serialization/serializeBinaryNode.js +1 -1
  14. package/src/core/bvh2/serialization/serializeBinaryNodeToBinaryBuffer.js +2 -2
  15. package/src/core/cache/Cache.js +4 -2
  16. package/src/core/codegen/LineBuilder.js +3 -0
  17. package/src/core/collection/HashMap.js +6 -0
  18. package/src/core/collection/heap/Uint32Heap.js +1 -0
  19. package/src/core/events/signal/Signal.js +7 -5
  20. package/src/core/events/signal/SignalBinding.js +56 -54
  21. package/src/core/events/signal/SignalFlags.js +7 -0
  22. package/src/core/function/Functions.js +1 -1
  23. package/src/core/geom/{Rectangle.js → 2d/Rectangle.js} +5 -5
  24. package/src/core/geom/{AABB2.js → 2d/aabb/AABB2.js} +10 -78
  25. package/src/core/geom/{AABB2.spec.js → 2d/aabb/AABB2.spec.js} +1 -1
  26. package/src/core/geom/2d/aabb/aabb2_compute_overlap.js +42 -0
  27. package/src/core/geom/2d/aabb/aabb2_contains.js +23 -0
  28. package/src/core/geom/2d/aabb/aabb2_distance_sqr_to_point.js +25 -0
  29. package/src/core/geom/2d/aabb/aabb2_distance_to_point.js +17 -0
  30. package/src/core/geom/2d/aabb/aabb2_distance_to_point.spec.js +17 -0
  31. package/src/core/geom/2d/aabb/aabb2_overlap_exists.js +18 -0
  32. package/src/core/geom/2d/aabb/aabb2_signed_distance_sqr_to_point.js +45 -0
  33. package/src/core/geom/2d/aabb/aabb2_signed_distance_sqr_to_point.spec.js +40 -0
  34. package/src/core/geom/2d/aabb/aabb2_signed_distance_to_point.js +27 -0
  35. package/src/core/geom/2d/convex-hull/fixed_convex_hull_humus.js +4 -0
  36. package/src/core/geom/2d/quad-tree/PointQuadTree.js +3 -0
  37. package/src/core/geom/2d/quad-tree/QuadTreeDatum.js +1 -1
  38. package/src/core/geom/2d/quad-tree/QuadTreeNode.js +3 -3
  39. package/src/core/geom/2d/quad-tree/qt_collect_by_circle.js +6 -8
  40. package/src/core/geom/2d/quad-tree/qt_match_data_by_circle.js +3 -3
  41. package/src/core/geom/2d/quad-tree/qt_query_data_nearest_to_point.js +3 -3
  42. package/src/core/{bvh2/aabb3 → geom/3d/aabb}/AABB3.d.ts +1 -1
  43. package/src/core/{bvh2/aabb3 → geom/3d/aabb}/AABB3.js +13 -13
  44. package/src/core/{bvh2/aabb3 → geom/3d/aabb}/AABB3.spec.js +1 -1
  45. package/src/core/geom/3d/aabb/aabb3_signed_distance_sqr_to_point.js +13 -9
  46. package/src/core/geom/3d/topology/util/compute_face_connection_weight.js +40 -0
  47. package/src/core/geom/packing/max-rect/MaxRectangles.js +1 -1
  48. package/src/core/geom/{GeometryMath.js → rayTriangleIntersection.js} +5 -1
  49. package/src/core/graph/GraphUtils.js +1 -1
  50. package/src/core/graph/build_face_graph_from_mesh.js +1 -3
  51. package/src/core/graph/layout/BoxLayouter.js +1 -1
  52. package/src/core/graph/layout/CircleLayout.js +2 -2
  53. package/src/core/model/node-graph/visual/NodeVisualData.js +1 -1
  54. package/src/engine/asset/loaders/GLTFAssetLoader.js +1 -1
  55. package/src/engine/asset/loaders/image/ImageRGBADataLoader.js +2 -2
  56. package/src/engine/asset/preloader/Preloader.js +3 -3
  57. package/src/engine/ecs/components/Renderable.d.ts +1 -1
  58. package/src/engine/ecs/components/Renderable.js +1 -1
  59. package/src/engine/ecs/gui/position/ViewportPositionSystem.js +1 -1
  60. package/src/engine/ecs/terrain/tiles/TerrainTile.js +1 -1
  61. package/src/engine/ecs/terrain/tiles/TerrainTileManager.js +2 -2
  62. package/src/engine/ecs/tooltip/TooltipComponentSystem.js +1 -1
  63. package/src/engine/graphics/camera/makeScreenScissorFrustum.d.ts +1 -1
  64. package/src/engine/graphics/ecs/light/LightSystem.js +1 -1
  65. package/src/engine/graphics/ecs/mesh/Mesh.d.ts +1 -1
  66. package/src/engine/graphics/ecs/mesh/Mesh.js +1 -1
  67. package/src/engine/graphics/ecs/mesh-v2/ShadedGeometry.d.ts +1 -1
  68. package/src/engine/graphics/ecs/mesh-v2/ShadedGeometry.js +1 -1
  69. package/src/engine/graphics/ecs/mesh-v2/aggregate/SGMesh.d.ts +1 -1
  70. package/src/engine/graphics/ecs/mesh-v2/sample/load_gltf.js +0 -3
  71. package/src/engine/graphics/ecs/mesh-v2/sg_hierarchy_compute_bounding_box_via_parent_entity.d.ts +1 -1
  72. package/src/engine/graphics/geometry/bvh/buffered/BVHGeometryRaycaster.js +1 -1
  73. package/src/engine/graphics/geometry/skining/computeSkinnedMeshBoundingVolumes.js +1 -1
  74. package/src/engine/graphics/particles/particular/engine/emitter/ParticleEmitter.js +1 -1
  75. package/src/engine/graphics/particles/particular/engine/emitter/ParticleLayer.js +1 -1
  76. package/src/engine/graphics/render/forward_plus/debug/createScreenGrid.js +1 -1
  77. package/src/engine/graphics/render/view/CameraView.js +1 -1
  78. package/src/engine/graphics/texture/atlas/AtlasPatch.js +2 -2
  79. package/src/engine/graphics/texture/atlas/TextureAtlas.spec.js +2 -2
  80. package/src/engine/graphics/util/makeMeshPreviewScene.js +1 -1
  81. package/src/engine/graphics/util/renderObjectToSampler2D.js +1 -1
  82. package/src/engine/ui/tiles2d/computeTileGridMove.js +3 -2
  83. package/src/engine/ui/tiles2d/computeTileGridMove.spec.js +1 -1
  84. package/src/generation/theme/AreaMask.js +1 -1
  85. package/src/view/View.js +1 -1
  86. package/src/view/elements/progress/RectangularPieProgressView.js +1 -1
  87. package/src/view/minimap/Minimap.js +1 -1
  88. package/src/view/minimap/gl/MinimapFogOfWar.js +1 -1
  89. package/src/view/tooltip/DomTooltipObserver.js +1 -1
  90. package/src/view/tooltip/TooltipManager.js +1 -1
  91. package/src/view/tooltip/TooltipView.js +1 -1
  92. package/src/view/util/DomSizeObserver.js +2 -2
  93. package/src/core/geom/2d/AABB2Math.js +0 -40
  94. package/src/core/geom/2d/AABB2Math.spec.js +0 -17
  95. /package/src/core/geom/{LineSegment2.js → 2d/LineSegment2.js} +0 -0
  96. /package/src/core/geom/{Rectangle.spec.js → 2d/Rectangle.spec.js} +0 -0
  97. /package/src/core/geom/{AABB2.d.ts → 2d/aabb/AABB2.d.ts} +0 -0
  98. /package/src/core/{bvh2/aabb3 → geom/3d/aabb}/deserializeAABB3.js +0 -0
  99. /package/src/core/{bvh2/aabb3 → geom/3d/aabb}/deserializeAABB3Encoded_v0.js +0 -0
  100. /package/src/core/{bvh2/aabb3 → geom/3d/aabb}/deserializeAABB3Quantized16Uint.js +0 -0
  101. /package/src/core/{bvh2/aabb3 → geom/3d/aabb}/serializeAABB3.js +0 -0
  102. /package/src/core/{bvh2/aabb3 → geom/3d/aabb}/serializeAABB3Encoded_v0.js +0 -0
  103. /package/src/core/{bvh2/aabb3 → geom/3d/aabb}/serializeAABB3Quantized16Uint.js +0 -0
@@ -0,0 +1,17 @@
1
+ import { aabb2_distance_sqr_to_point } from "./aabb2_distance_sqr_to_point.js";
2
+
3
+ /**
4
+ *
5
+ * @param {number} x0
6
+ * @param {number} y0
7
+ * @param {number} x1
8
+ * @param {number} y1
9
+ * @param {number} px
10
+ * @param {number} py
11
+ * @returns {number}
12
+ */
13
+ export function aabb2_distance_to_point(x0, y0, x1, y1, px, py) {
14
+ const sqrD = aabb2_distance_sqr_to_point(x0, y0, x1, y1, px, py);
15
+ return Math.sqrt(sqrD);
16
+ }
17
+
@@ -0,0 +1,17 @@
1
+ import { aabb2_distance_to_point } from "./aabb2_distance_to_point.js";
2
+
3
+ test('aabb2_distance_to_point', () => {
4
+ expect(aabb2_distance_to_point(0, 0, 0, 0, 0, 0)).toBeCloseTo(0);
5
+
6
+ expect(aabb2_distance_to_point(0, 0, 0, 0, 1, 0)).toBeCloseTo(1);
7
+ expect(aabb2_distance_to_point(0, 0, 0, 0, 0, 1)).toBeCloseTo(1);
8
+
9
+ expect(aabb2_distance_to_point(0, 0, 0, 0, 1, 1)).toBeCloseTo(1.41421356237);
10
+
11
+
12
+ expect(aabb2_distance_to_point(0, 0, 1, 1, 2, 0.5)).toBeCloseTo(1);
13
+ expect(aabb2_distance_to_point(0, 0, 1, 1, 0.5, 2)).toBeCloseTo(1);
14
+
15
+ expect(aabb2_distance_to_point(0, 0, 1, 1, -1, 0.5)).toBeCloseTo(1);
16
+ expect(aabb2_distance_to_point(0, 0, 1, 1, 0.5, -1)).toBeCloseTo(1);
17
+ });
@@ -0,0 +1,18 @@
1
+ import { overlap1D } from "../../../math/interval/overlap1D.js";
2
+
3
+ /**
4
+ *
5
+ * @param {number} ax0
6
+ * @param {number} ay0
7
+ * @param {number} ax1
8
+ * @param {number} ay1
9
+ * @param {number} bx0
10
+ * @param {number} by0
11
+ * @param {number} bx1
12
+ * @param {number} by1
13
+ * @returns {boolean} true if overlap exists, false if no overlap
14
+ */
15
+ export function aabb2_overlap_exists(ax0, ay0, ax1, ay1, bx0, by0, bx1, by1) {
16
+ return overlap1D(ax0, ax1, bx0, bx1)
17
+ && overlap1D(ay0, ay1, by0, by1);
18
+ }
@@ -0,0 +1,45 @@
1
+ import { max2 } from "../../../math/max2.js";
2
+
3
+ /**
4
+ * Compute squared distance to point, value is negative if the point is inside the box
5
+ * @param {number} x0
6
+ * @param {number} y0
7
+ * @param {number} x1
8
+ * @param {number} y1
9
+ * @param {number} point_x
10
+ * @param {number} point_y
11
+ * @returns {number}
12
+ */
13
+ export function aabb2_signed_distance_sqr_to_point(
14
+ x0, y0,
15
+ x1, y1,
16
+ point_x, point_y
17
+ ) {
18
+ //do projection
19
+ const xp0 = x0 - point_x;
20
+ const xp1 = point_x - x1;
21
+ const yp0 = y0 - point_y;
22
+ const yp1 = point_y - y1;
23
+
24
+ //calculate separation in each axis
25
+ let dx = max2(xp0, xp1);
26
+ let dy = max2(yp0, yp1);
27
+
28
+ if (dx >= 0 || dy >= 0) {
29
+ // non-penetrating, clamp axis
30
+ dx = max2(dx, 0);
31
+ dy = max2(dy, 0);
32
+
33
+ //straight-line distance
34
+ return (dx * dx + dy * dy);
35
+ } else {
36
+
37
+ //penetration, negative distance, pick nearest axis
38
+ if (Math.abs(dx) > Math.abs(dy)) {
39
+ return -(dy * dy)
40
+ } else {
41
+ return -dx * dx;
42
+ }
43
+
44
+ }
45
+ }
@@ -0,0 +1,40 @@
1
+ import { aabb2_signed_distance_sqr_to_point } from "./aabb2_signed_distance_sqr_to_point.js";
2
+
3
+ test("0 size bounding box", () => {
4
+
5
+ expect(aabb2_signed_distance_sqr_to_point(0, 0, 0, 0, 0, 0))
6
+ .toEqual(0);
7
+
8
+ expect(aabb2_signed_distance_sqr_to_point(0, 0, 0, 0, 1, 0))
9
+ .toEqual(1);
10
+
11
+ expect(aabb2_signed_distance_sqr_to_point(0, 0, 0, 0, -1, 0))
12
+ .toEqual(1);
13
+
14
+ expect(aabb2_signed_distance_sqr_to_point(0, 0, 0, 0, 0, 1))
15
+ .toEqual(1);
16
+
17
+ expect(aabb2_signed_distance_sqr_to_point(0, 0, 0, 0, 0, -1))
18
+ .toEqual(1);
19
+
20
+ expect(aabb2_signed_distance_sqr_to_point(0, 0, 0, 0, 1, 1))
21
+ .toEqual(2);
22
+
23
+ expect(aabb2_signed_distance_sqr_to_point(0, 0, 0, 0, 1, -1))
24
+ .toEqual(2);
25
+
26
+ expect(aabb2_signed_distance_sqr_to_point(0, 0, 0, 0, -1, 1))
27
+ .toEqual(2);
28
+
29
+ expect(aabb2_signed_distance_sqr_to_point(0, 0, 0, 0, -1, -1))
30
+ .toEqual(2);
31
+
32
+ });
33
+
34
+
35
+ test("inside the box", () => {
36
+
37
+ expect(aabb2_signed_distance_sqr_to_point(-1, -1, 1, 1, 0, 0))
38
+ .toBeCloseTo(-1);
39
+
40
+ });
@@ -0,0 +1,27 @@
1
+ //
2
+
3
+ import { aabb2_signed_distance_sqr_to_point } from "./aabb2_signed_distance_sqr_to_point.js";
4
+
5
+ /**
6
+ * Compute squared distance to point, value is negative if the point is inside the box
7
+ * @param {number} x0
8
+ * @param {number} y0
9
+ * @param {number} x1
10
+ * @param {number} y1
11
+ * @param {number} point_x
12
+ * @param {number} point_y
13
+ * @returns {number}
14
+ */
15
+ export function aabb2_signed_distance_to_point(
16
+ x0, y0,
17
+ x1, y1,
18
+ point_x, point_y
19
+ ) {
20
+ const sqr = aabb2_signed_distance_sqr_to_point(x0, y0, x1, y1, point_x, point_y);
21
+
22
+ if (sqr < 0) {
23
+ return -Math.sqrt(-sqr);
24
+ } else {
25
+ return Math.sqrt(sqr);
26
+ }
27
+ }
@@ -41,6 +41,10 @@ export function fixed_convex_hull_humus(
41
41
 
42
42
  const ArrayConstructor = UintArrayForCount(k);
43
43
 
44
+ /**
45
+ *
46
+ * @type {number[]}
47
+ */
44
48
  const s = new ArrayConstructor(k);
45
49
 
46
50
  let combos = 0;
@@ -71,6 +71,9 @@ Element.prototype.remove = function () {
71
71
  this.parentNode.removeElement(this);
72
72
  };
73
73
 
74
+ /**
75
+ * Prefer to use {@link QuadTreeNode} instead as that is more robust and has better performance
76
+ */
74
77
  class PointQuadTree {
75
78
  /**
76
79
  * @param {number} [x0]
@@ -1,5 +1,5 @@
1
1
  import { assert } from "../../../assert.js";
2
- import AABB2 from "../../AABB2.js";
2
+ import AABB2 from "../../2d/aabb/AABB2.js";
3
3
 
4
4
  /**
5
5
  * @template D
@@ -1,7 +1,7 @@
1
1
  import { assert } from "../../../assert.js";
2
2
  import { max2 } from "../../../math/max2.js";
3
3
  import { min2 } from "../../../math/min2.js";
4
- import AABB2 from "../../AABB2.js";
4
+ import AABB2 from "../../2d/aabb/AABB2.js";
5
5
  import { QuadTreeDatum } from "./QuadTreeDatum.js";
6
6
 
7
7
 
@@ -241,8 +241,8 @@ export class QuadTreeNode extends AABB2 {
241
241
  const x1 = this.x1;
242
242
  const y1 = this.y1;
243
243
 
244
- const xm = (x0 + x1) / 2;
245
- const ym = (y0 + y1) / 2;
244
+ const xm = (x0 + x1) * 0.5;
245
+ const ym = (y0 + y1) * 0.5;
246
246
 
247
247
  this.topLeft = new QuadTreeNode(x0, y0, xm, ym);
248
248
  this.topLeft.parentNode = this;
@@ -1,4 +1,4 @@
1
- import { aabb2_sqrDistanceToPoint } from "../AABB2Math.js";
1
+ import { aabb2_signed_distance_sqr_to_point } from "../aabb/aabb2_signed_distance_sqr_to_point.js";
2
2
 
3
3
  /**
4
4
  *
@@ -23,19 +23,17 @@ export function qt_collect_by_circle(
23
23
  ) {
24
24
  let result_cursor = result_offset;
25
25
 
26
- let stack_pointer = 0;
26
+ let stack_pointer = 1;
27
27
 
28
28
  const r2 = radius * radius;
29
29
 
30
- node_stack[stack_pointer] = tree;
31
- stack_pointer++;
30
+ node_stack[0] = tree;
32
31
 
33
- while (stack_pointer > 0) {
32
+ while (stack_pointer-- > 0) {
34
33
 
35
- --stack_pointer;
36
34
  const node = node_stack[stack_pointer];
37
35
 
38
- const d2 = aabb2_sqrDistanceToPoint(node.x0, node.y0, node.x1, node.y1, x, y);
36
+ const d2 = aabb2_signed_distance_sqr_to_point(node.x0, node.y0, node.x1, node.y1, x, y);
39
37
 
40
38
  if (d2 > r2) {
41
39
  // not a match
@@ -48,7 +46,7 @@ export function qt_collect_by_circle(
48
46
  for (let i = 0; i < data_count; i++) {
49
47
  const datum = data[i];
50
48
 
51
- const d2_to_datum = aabb2_sqrDistanceToPoint(datum.x0, datum.y0, datum.x1, datum.y1, x, y);
49
+ const d2_to_datum = aabb2_signed_distance_sqr_to_point(datum.x0, datum.y0, datum.x1, datum.y1, x, y);
52
50
 
53
51
  if (d2_to_datum <= r2) {
54
52
  result[result_cursor++] = datum;
@@ -1,4 +1,4 @@
1
- import { aabb2_sqrDistanceToPoint } from "../AABB2Math.js";
1
+ import { aabb2_distance_sqr_to_point } from "../aabb/aabb2_distance_sqr_to_point.js";
2
2
 
3
3
  /**
4
4
  *
@@ -38,7 +38,7 @@ export function qt_match_data_by_circle(
38
38
  --stack_pointer;
39
39
  const node = node_stack[stack_pointer];
40
40
 
41
- const d2 = aabb2_sqrDistanceToPoint(node.x0, node.y0, node.x1, node.y1, x, y);
41
+ const d2 = aabb2_distance_sqr_to_point(node.x0, node.y0, node.x1, node.y1, x, y);
42
42
 
43
43
  if (d2 > r2) {
44
44
  // not a match
@@ -51,7 +51,7 @@ export function qt_match_data_by_circle(
51
51
  for (let i = 0; i < data_count; i++) {
52
52
  const datum = data[i];
53
53
 
54
- const d2_to_datum = aabb2_sqrDistanceToPoint(datum.x0, datum.y0, datum.x1, datum.y1, x, y);
54
+ const d2_to_datum = aabb2_distance_sqr_to_point(datum.x0, datum.y0, datum.x1, datum.y1, x, y);
55
55
 
56
56
  if (d2_to_datum <= r2 && predicate.call(predicateContext, datum.data)) {
57
57
  result[result_cursor++] = datum;
@@ -1,5 +1,5 @@
1
- import { aabb2_sqrDistanceToPoint } from "../AABB2Math.js";
2
1
  import { max2 } from "../../../math/max2.js";
2
+ import { aabb2_distance_sqr_to_point } from "../aabb/aabb2_distance_sqr_to_point.js";
3
3
 
4
4
  /**
5
5
  *
@@ -30,7 +30,7 @@ export function qt_query_data_nearest_to_point(tree, x, y, max_distance = Infini
30
30
  --stack_pointer;
31
31
  const node = node_stack[stack_pointer];
32
32
 
33
- const distance_sqr = max2(0, aabb2_sqrDistanceToPoint(node.x0, node.y0, node.x1, node.y1, x, y));
33
+ const distance_sqr = max2(0, aabb2_distance_sqr_to_point(node.x0, node.y0, node.x1, node.y1, x, y));
34
34
 
35
35
  if (distance_sqr >= best_distance_sqr) {
36
36
  // too far
@@ -42,7 +42,7 @@ export function qt_query_data_nearest_to_point(tree, x, y, max_distance = Infini
42
42
  for (let i = 0; i < data.length; i++) {
43
43
  const datum = data[i];
44
44
 
45
- const distance_sqr = max2(0, aabb2_sqrDistanceToPoint(datum.x0, datum.y0, datum.x1, datum.y1, x, y));
45
+ const distance_sqr = max2(0, aabb2_distance_sqr_to_point(datum.x0, datum.y0, datum.x1, datum.y1, x, y));
46
46
 
47
47
  if (distance_sqr < best_distance_sqr) {
48
48
  best_leaf_data = datum;
@@ -1,4 +1,4 @@
1
- import Vector3 from "../../geom/Vector3";
1
+ import Vector3 from "../../Vector3";
2
2
 
3
3
  export class AABB3 {
4
4
  x0: number
@@ -3,19 +3,19 @@
3
3
  */
4
4
 
5
5
 
6
- import { aabb3_compute_distance_above_plane_max } from "../../geom/3d/aabb/aabb3_compute_distance_above_plane_max.js";
7
- import { aabb3_compute_plane_side } from "../../geom/3d/aabb/aabb3_compute_plane_side.js";
8
- import computeMortonCode from "../../geom/3d/morton/Morton.js";
9
- import { aabb3_build_corners } from "../../geom/3d/aabb/aabb3_build_corners.js";
10
- import { assert } from "../../assert.js";
11
- import { aabb3_intersects_frustum_degree } from "../../geom/3d/aabb/aabb3_intersects_frustum_degree.js";
12
- import { aabb3_intersects_line_segment } from "../../geom/3d/aabb/aabb3_intersects_line_segment.js";
13
- import { aabb3_intersects_ray } from "../../geom/3d/aabb/aabb3_intersects_ray.js";
14
- import { aabb3_compute_surface_area } from "../../geom/3d/aabb/aabb3_compute_surface_area.js";
15
- import { aabb3_intersects_frustum_array } from "../../geom/3d/aabb/aabb3_intersects_frustum_array.js";
16
- import { aabb3_matrix4_project } from "../../geom/3d/aabb/aabb3_matrix4_project.js";
17
- import { aabb3_signed_distance_sqr_to_point } from "../../geom/3d/aabb/aabb3_signed_distance_sqr_to_point.js";
18
- import { aabb3_array_contains_point } from "../../geom/3d/aabb/aabb3_array_contains_point.js";
6
+ import { aabb3_compute_distance_above_plane_max } from "./aabb3_compute_distance_above_plane_max.js";
7
+ import { aabb3_compute_plane_side } from "./aabb3_compute_plane_side.js";
8
+ import computeMortonCode from "../morton/Morton.js";
9
+ import { aabb3_build_corners } from "./aabb3_build_corners.js";
10
+ import { assert } from "../../../assert.js";
11
+ import { aabb3_intersects_frustum_degree } from "./aabb3_intersects_frustum_degree.js";
12
+ import { aabb3_intersects_line_segment } from "./aabb3_intersects_line_segment.js";
13
+ import { aabb3_intersects_ray } from "./aabb3_intersects_ray.js";
14
+ import { aabb3_compute_surface_area } from "./aabb3_compute_surface_area.js";
15
+ import { aabb3_intersects_frustum_array } from "./aabb3_intersects_frustum_array.js";
16
+ import { aabb3_matrix4_project } from "./aabb3_matrix4_project.js";
17
+ import { aabb3_signed_distance_sqr_to_point } from "./aabb3_signed_distance_sqr_to_point.js";
18
+ import { aabb3_array_contains_point } from "./aabb3_array_contains_point.js";
19
19
 
20
20
 
21
21
  export class AABB3 {
@@ -1,4 +1,4 @@
1
- import { BinaryBuffer } from "../../binary/BinaryBuffer.js";
1
+ import { BinaryBuffer } from "../../../binary/BinaryBuffer.js";
2
2
  import { AABB3 } from "./AABB3.js";
3
3
  import { serializeAABB3Quantized16Uint } from "./serializeAABB3Quantized16Uint.js";
4
4
  import { deserializeAABB3Quantized16Uint } from "./deserializeAABB3Quantized16Uint.js";
@@ -23,17 +23,21 @@ export function aabb3_signed_distance_sqr_to_point(x0, y0, z0, x1, y1, z1, point
23
23
  const zp1 = point_z - z1;
24
24
 
25
25
  //calculate separation in each axis
26
- const dx = max2(xp0, xp1);
27
- const dy = max2(yp0, yp1);
28
- const dz = max2(zp0, zp1);
26
+ let dx = max2(xp0, xp1);
27
+ let dy = max2(yp0, yp1);
28
+ let dz = max2(zp0, zp1);
29
29
 
30
- //straight-line distance
31
- const distance_sqr = dx * dx + dy * dy + dz * dz;
32
30
 
33
- if (dx < 0 && dy < 0 && dz < 0) {
34
- //penetration, negative distance
35
- return -distance_sqr;
31
+ if (dx > 0 || dy > 0 || dz > 0) {
32
+ // non-penetrating, clamp axis
33
+ dx = max2(dx, 0);
34
+ dy = max2(dy, 0);
35
+ dz = max2(dz, 0);
36
+
37
+ //straight-line distance
38
+ return dx * dx + dy * dy + dz * dz;
36
39
  } else {
37
- return distance_sqr;
40
+ //penetration, negative distance
41
+ return -(dx * dx + dy * dy + dz * dz);
38
42
  }
39
43
  }
@@ -0,0 +1,40 @@
1
+ import { v3_distance_sqr } from "../../../v3_distance_sqr";
2
+ import { v3_dot } from "../../../v3_dot.js";
3
+
4
+ /**
5
+ *
6
+ * @param {TopoTriangle} f0
7
+ * @param {TopoTriangle} f1
8
+ * @returns {number}
9
+ */
10
+ export function compute_face_connection_weight(f0, f1) {
11
+ const vertices_0 = f0.vertices;
12
+ const vertices_1 = f1.vertices;
13
+
14
+ // compute center
15
+ const f0_center_x = (vertices_0[0].x + vertices_0[1].x + vertices_0[2].x) * 0.333;
16
+ const f0_center_y = (vertices_0[0].y + vertices_0[1].y + vertices_0[2].y) * 0.333;
17
+ const f0_center_z = (vertices_0[0].z + vertices_0[1].z + vertices_0[2].z) * 0.333;
18
+
19
+ const f1_center_x = (vertices_1[0].x + vertices_1[1].x + vertices_1[2].x) * 0.333;
20
+ const f1_center_y = (vertices_1[0].y + vertices_1[1].y + vertices_1[2].y) * 0.333;
21
+ const f1_center_z = (vertices_1[0].z + vertices_1[1].z + vertices_1[2].z) * 0.333;
22
+
23
+ const distance_sqr = v3_distance_sqr(
24
+ f0_center_x, f0_center_y, f0_center_z,
25
+ f1_center_x, f1_center_y, f1_center_z
26
+ );
27
+
28
+ // compute normal dot
29
+ const n0 = f0.normal;
30
+ const n1 = f1.normal;
31
+
32
+ const dot = v3_dot(
33
+ n0[0], n0[1], n0[2],
34
+ n1[0], n1[1], n1[2],
35
+ );
36
+
37
+ const distance_weight = distance_sqr !== 0 ? 0.01 / distance_sqr : 10000;
38
+
39
+ return 2 + distance_weight + dot * 0.1;
40
+ }
@@ -4,7 +4,7 @@ import { max2 } from "../../../math/max2.js";
4
4
  import { min2 } from "../../../math/min2.js";
5
5
  import { QuadTreeDatum } from "../../2d/quad-tree/QuadTreeDatum.js";
6
6
  import { QuadTreeNode } from "../../2d/quad-tree/QuadTreeNode.js";
7
- import AABB2 from "../../AABB2.js";
7
+ import AABB2 from "../../2d/aabb/AABB2.js";
8
8
  import Vector2 from "../../Vector2.js";
9
9
  import { removeRedundantBoxesArray } from "./removeRedundantBoxesArray.js";
10
10
  import { removeRedundantBoxes } from "./removeRedundantBoxes.js";
@@ -15,7 +15,11 @@ const sp3 = new SurfacePoint3();
15
15
  * @param {Vector3} c
16
16
  * @returns {boolean}
17
17
  */
18
- export function rayTriangleIntersection(result, rayOrigin, rayDirection, a, b, c) {
18
+ export function rayTriangleIntersection(
19
+ result,
20
+ rayOrigin, rayDirection,
21
+ a, b, c
22
+ ) {
19
23
 
20
24
  const hit_found = computeTriangleRayIntersection(
21
25
  sp3,
@@ -3,7 +3,7 @@
3
3
  */
4
4
 
5
5
 
6
- import { computeLine2Intersection } from "../geom/LineSegment2.js";
6
+ import { computeLine2Intersection } from "../geom/2d/LineSegment2.js";
7
7
 
8
8
  const Utils = {};
9
9
 
@@ -1,8 +1,6 @@
1
1
  import { Graph } from "./v2/Graph.js";
2
2
  import { MultiNode } from "./MultiNode.js";
3
- import {
4
- compute_face_connection_weight
5
- } from "../../engine/graphics/micron/build/clustering/compute_face_connection_weight.js";
3
+ import { compute_face_connection_weight } from "../geom/3d/topology/util/compute_face_connection_weight.js";
6
4
  import { WeightedEdge } from "./WeightedEdge.js";
7
5
  import { graph_compute_disconnected_clusters } from "./graph_compute_disconnected_clusters.js";
8
6
 
@@ -4,7 +4,7 @@
4
4
  */
5
5
 
6
6
 
7
- import AABB2 from "../../geom/AABB2.js";
7
+ import AABB2 from "../../geom/2d/aabb/AABB2.js";
8
8
  import Vector2 from "../../geom/Vector2.js";
9
9
  import { computeDisconnectedSubGraphs } from "./computeDisconnectedSubGraphs.js";
10
10
  import { Connection } from "./Connection.js";
@@ -5,8 +5,8 @@
5
5
  */
6
6
  import { assert } from "../../assert.js";
7
7
  import Circle from "../../geom/2d/circle/Circle.js";
8
- import AABB2 from "../../geom/AABB2.js";
9
- import { line2SegmentsIntersect } from "../../geom/LineSegment2.js";
8
+ import AABB2 from "../../geom/2d/aabb/AABB2.js";
9
+ import { line2SegmentsIntersect } from "../../geom/2d/LineSegment2.js";
10
10
  import Vector2, { v2_distance } from "../../geom/Vector2.js";
11
11
  import { max2 } from "../../math/max2.js";
12
12
  import { min2 } from "../../math/min2.js";
@@ -1,5 +1,5 @@
1
1
  import List from "../../../collection/list/List.js";
2
- import Rectangle from "../../../geom/Rectangle.js";
2
+ import Rectangle from "../../../geom/2d/Rectangle.js";
3
3
  import { PortVisualData } from "./PortVisualData.js";
4
4
 
5
5
  export class NodeVisualData {
@@ -2,7 +2,7 @@ import { Transform } from "../../ecs/transform/Transform.js";
2
2
  import { Asset } from "../Asset.js";
3
3
  import { prepareMaterial, prepareObject } from "../../graphics/three/ThreeFactory.js";
4
4
  import { GLTFLoader } from "three/examples/jsm/loaders/GLTFLoader.js";
5
- import { AABB3 } from "../../../core/bvh2/aabb3/AABB3.js";
5
+ import { AABB3 } from "../../../core/geom/3d/aabb/AABB3.js";
6
6
  import { StaticMaterialCache } from "./material/StaticMaterialCache.js";
7
7
  import { DDSLoader } from "three/examples/jsm/loaders/DDSLoader.js";
8
8
  import { AnimationOptimizer } from "../../ecs/animation/AnimationOptimizer.js";
@@ -23,10 +23,10 @@ export class ImageRGBADataLoader extends AssetLoader {
23
23
  async link(assetManager, engine) {
24
24
 
25
25
  if (assetManager.getLoaderByType(ASSET_TYPE_ARRAY_BUFFER) === undefined) {
26
- assetManager.registerLoader(ASSET_TYPE_ARRAY_BUFFER, new ArrayBufferLoader());
26
+ await assetManager.registerLoader(ASSET_TYPE_ARRAY_BUFFER, new ArrayBufferLoader());
27
27
  }
28
28
 
29
- super.link(assetManager, engine);
29
+ await super.link(assetManager, engine);
30
30
  }
31
31
 
32
32
  /**
@@ -86,7 +86,7 @@ Preloader.prototype.add = function (uri, type, level, priority) {
86
86
  }
87
87
  assets[level].push(def);
88
88
  this.totalAssetCount++;
89
- this.on.added.dispatch(def, level);
89
+ this.on.added.send2(def, level);
90
90
  return this;
91
91
  };
92
92
 
@@ -108,7 +108,7 @@ Preloader.prototype.load = function (assetManager) {
108
108
  count: batch.length
109
109
  };
110
110
  });
111
- on.loadStart.dispatch(initEvent);
111
+ on.loadStart.send1(initEvent);
112
112
  const numAssets = this.totalAssetCount;
113
113
  let numAssetsLoaded = 0;
114
114
 
@@ -178,7 +178,7 @@ Preloader.prototype.load = function (assetManager) {
178
178
  // console.log("requesting load of level ",levelToLoad);
179
179
  loadBatch(levelToLoad);
180
180
  } else {
181
- on.completed.dispatch();
181
+ on.completed.send0();
182
182
  }
183
183
  }
184
184
 
@@ -1,5 +1,5 @@
1
1
  import {Object3D} from "three";
2
- import {AABB3} from "../../../core/bvh2/aabb3/AABB3";
2
+ import {AABB3} from "../../../core/geom/3d/aabb/AABB3";
3
3
  import {LeafNode} from "../../../core/bvh2/LeafNode";
4
4
 
5
5
  export default class Renderable {
@@ -4,7 +4,7 @@
4
4
 
5
5
 
6
6
  import { LeafNode } from "../../../core/bvh2/LeafNode.js";
7
- import { AABB3 } from "../../../core/bvh2/aabb3/AABB3.js";
7
+ import { AABB3 } from "../../../core/geom/3d/aabb/AABB3.js";
8
8
  import { Vector3 as ThreeVector3 } from "three";
9
9
  import { max2 } from "../../../core/math/max2.js";
10
10
  import { min2 } from "../../../core/math/min2.js";
@@ -6,7 +6,7 @@ import ViewportPosition from './ViewportPosition.js';
6
6
  import GUIElement from "../GUIElement.js";
7
7
  import { assert } from "../../../../core/assert.js";
8
8
  import { SignalBinding } from "../../../../core/events/signal/SignalBinding.js";
9
- import AABB2 from "../../../../core/geom/AABB2.js";
9
+ import AABB2 from "../../../../core/geom/2d/aabb/AABB2.js";
10
10
  import { GUIElementEvent } from "../GUIElementEvent.js";
11
11
  import { EPSILON } from "../../../../core/math/EPSILON.js";
12
12
  import { ResourceAccessSpecification } from "../../../../core/model/ResourceAccessSpecification.js";
@@ -24,7 +24,7 @@ import ObservedInteger from "../../../../core/model/ObservedInteger.js";
24
24
  import { SurfacePoint3 } from "../../../../core/geom/3d/SurfacePoint3.js";
25
25
  import Signal from "../../../../core/events/signal/Signal.js";
26
26
  import { mat4 } from "gl-matrix";
27
- import { AABB3 } from "../../../../core/bvh2/aabb3/AABB3.js";
27
+ import { AABB3 } from "../../../../core/geom/3d/aabb/AABB3.js";
28
28
  import { NumericInterval } from "../../../../core/math/interval/NumericInterval.js";
29
29
  import { array_copy } from "../../../../core/collection/array/copyArray.js";
30
30
  import { passThrough } from "../../../../core/function/Functions.js";
@@ -19,12 +19,12 @@ import { SurfacePoint3 } from "../../../../core/geom/3d/SurfacePoint3.js";
19
19
  import { RaycastBVHVisitor } from "../../../../core/bvh2/traversal/RaycastBVHVisitor.js";
20
20
  import { FirstRayIntersectionTerrainBVHVisitor } from "./FirstRayIntersectionTerrainBVHVisitor.js";
21
21
  import { traverseBinaryNodeUsingVisitor } from "../../../../core/bvh2/traversal/traverseBinaryNodeUsingVisitor.js";
22
- import { aabb2_overlapExists } from "../../../../core/geom/AABB2.js";
23
22
  import ObservedInteger from "../../../../core/model/ObservedInteger.js";
24
23
  import { NumericInterval } from "../../../../core/math/interval/NumericInterval.js";
25
24
  import { randomFloatBetween } from "../../../../core/math/random/randomFloatBetween.js";
26
25
  import { mat4, vec3 } from "gl-matrix";
27
26
  import { isArrayEqualStrict } from "../../../../core/collection/array/isArrayEqualStrict.js";
27
+ import { aabb2_overlap_exists } from "../../../../core/geom/2d/aabb/aabb2_overlap_exists.js";
28
28
 
29
29
  class TerrainTileManager {
30
30
  /**
@@ -296,7 +296,7 @@ class TerrainTileManager {
296
296
  const tx1 = tx0 + tile.size.x;
297
297
  const ty1 = ty0 + tile.size.y;
298
298
  if (
299
- aabb2_overlapExists(
299
+ aabb2_overlap_exists(
300
300
  x0, y0, x1, y1,
301
301
  tx0, ty0, tx1, ty1
302
302
  )
@@ -4,7 +4,7 @@ import Vector3 from "../../../core/geom/Vector3.js";
4
4
  import { MeshSystem } from "../../graphics/ecs/mesh/MeshSystem.js";
5
5
  import { SurfacePoint3 } from "../../../core/geom/3d/SurfacePoint3.js";
6
6
  import { VisualTip } from "../../../view/tooltip/VisualTip.js";
7
- import Rectangle from "../../../core/geom/Rectangle.js";
7
+ import Rectangle from "../../../core/geom/2d/Rectangle.js";
8
8
  import { modelHitTest } from "../../graphics/util/modelHitTest.js";
9
9
  import { ResourceAccessSpecification } from "../../../core/model/ResourceAccessSpecification.js";
10
10
  import { ResourceAccessKind } from "../../../core/model/ResourceAccessKind.js";
@@ -1,4 +1,4 @@
1
1
  import {Camera, Frustum} from "three";
2
- import AABB2 from "../../../core/geom/AABB2";
2
+ import AABB2 from "../../../core/geom/2d/aabb/AABB2";
3
3
 
4
4
  export function makeScreenScissorFrustum(frustum: Frustum, box: AABB2, camera: Camera)