@woosh/meep-engine 2.49.8 → 2.50.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 (197) hide show
  1. package/editor/actions/concrete/ArrayCopyAction.js +1 -1
  2. package/package.json +1 -1
  3. package/src/core/binary/BinaryBuffer.js +1 -1
  4. package/src/core/binary/BinaryBuffer.spec.js +128 -0
  5. package/src/core/binary/int32_to_binary_string.js +4 -1
  6. package/src/core/binary/int32_to_binary_string.spec.js +9 -0
  7. package/src/core/bvh2/BinaryNode.js +0 -30
  8. package/src/core/bvh2/binary/2/BinaryUint32BVH.js +1 -1
  9. package/src/core/bvh2/binary/IndexedBinaryBVH.js +1 -1
  10. package/src/core/bvh2/bvh3/ExplicitBinaryBoundingVolumeHierarchy.js +1 -1
  11. package/src/core/bvh2/bvh3/query/compute_tight_near_far_clipping_planes.js +1 -1
  12. package/src/core/cache/Cache.js +31 -29
  13. package/src/core/cache/Cache.spec.js +4 -1
  14. package/src/core/collection/HashMap.js +1 -1
  15. package/src/core/collection/array/{copyArray.js → array_copy.js} +1 -24
  16. package/src/core/collection/array/array_copy_entire.js +21 -0
  17. package/src/core/collection/array/typed/typed_array_copy.js +1 -1
  18. package/src/core/collection/queue/Deque.d.ts +4 -0
  19. package/src/core/collection/queue/Deque.js +5 -7
  20. package/src/core/collection/queue/Deque.spec.js +107 -0
  21. package/src/core/collection/table/RowFirstTable.js +1 -1
  22. package/src/core/geom/2d/aabb/AABB2.d.ts +14 -0
  23. package/src/core/geom/2d/aabb/AABB2.js +9 -7
  24. package/src/core/geom/2d/aabb/AABB2.spec.js +100 -0
  25. package/src/core/geom/2d/aabb/aabb2_compute_center_from_multiple.spec.js +11 -0
  26. package/src/core/geom/2d/aabb/aabb2_compute_overlap.spec.js +56 -0
  27. package/src/core/geom/2d/aabb/aabb2_contains.spec.js +40 -0
  28. package/src/core/geom/2d/bvh/Node2.js +1 -1
  29. package/src/core/geom/2d/convex-hull/fixed_convex_hull_humus.js +1 -1
  30. package/src/core/geom/2d/convex-hull/fixed_convex_hull_relaxation.js +1 -1
  31. package/src/core/geom/2d/line/line_segment_compute_line_segment_intersection_2d.js +35 -0
  32. package/src/core/geom/2d/line/line_segment_compute_line_segment_intersection_array_2d.js +51 -0
  33. package/src/core/geom/2d/line/line_segment_compute_line_segment_intersection_vectors_2d.js +15 -0
  34. package/src/core/geom/2d/line/line_segment_compute_line_segment_intersection_vectors_array_2d.js +30 -0
  35. package/src/core/geom/2d/line/line_segment_line_segment_intersection_exists_2d.js +29 -0
  36. package/src/core/geom/3d/aabb/AABB3.d.ts +4 -0
  37. package/src/core/geom/3d/aabb/AABB3.spec.js +30 -0
  38. package/src/core/geom/3d/matrix/m4_make_translation.js +1 -1
  39. package/src/core/geom/3d/sphere/harmonics/sh3_dering_optimize_positive.js +1 -1
  40. package/src/core/geom/3d/tetrahedra/TetrahedralMesh.js +1 -1
  41. package/src/core/geom/3d/tetrahedra/compute_circumsphere.js +1 -1
  42. package/src/core/geom/3d/tetrahedra/delaunay/fill_in_a_cavity.js +1 -1
  43. package/src/core/geom/3d/topology/bounds/computeTriangleClusterNormalBoundingCone.js +1 -1
  44. package/src/core/geom/3d/topology/expandConnectivityByLocality.js +1 -1
  45. package/src/core/geom/3d/topology/struct/binary/BinaryTopology.js +1 -1
  46. package/src/core/geom/Quaternion.d.ts +11 -0
  47. package/src/core/geom/Quaternion.js +36 -27
  48. package/src/core/geom/Quaternion.spec.js +141 -0
  49. package/src/core/geom/Vector2.d.ts +5 -1
  50. package/src/core/geom/Vector2.js +24 -0
  51. package/src/core/geom/Vector3.d.ts +4 -0
  52. package/src/core/geom/Vector3.spec.js +60 -0
  53. package/src/core/graph/GraphUtils.js +4 -2
  54. package/src/core/graph/layout/CircleLayout.js +4 -2
  55. package/src/core/math/bessel_i0.spec.js +43 -0
  56. package/src/core/math/bessel_j0.js +30 -0
  57. package/src/core/math/hash/murmur3_32.spec.js +8 -0
  58. package/src/core/math/hash/squirrel3.spec.js +16 -0
  59. package/src/core/math/interval/NumericInterval.js +1 -0
  60. package/src/core/math/{bessel_i0.js → modified_bessel_i0.js} +5 -2
  61. package/src/core/math/noise/{create_noise_2d.js → create_simplex_noise_2d.js} +2 -2
  62. package/src/core/math/noise/create_simplex_noise_2d.spec.js +21 -0
  63. package/src/core/math/physics/irradiance/interpolate_irradiance_linear.spec.js +20 -0
  64. package/src/core/math/physics/irradiance/interpolate_irradiance_lograrithmic.js +4 -4
  65. package/src/core/math/physics/irradiance/interpolate_irradiance_lograrithmic.spec.js +18 -0
  66. package/src/core/math/physics/irradiance/interpolate_irradiance_smith.js +1 -1
  67. package/src/core/math/physics/irradiance/interpolate_irradiance_smith.spec.js +20 -0
  68. package/src/core/math/random/seededRandomMersenneTwister.spec.js +10 -0
  69. package/src/core/math/spline/spline_bezier3.js +1 -1
  70. package/src/core/math/spline/spline_bezier3_bounds.js +2 -1
  71. package/src/core/math/spline/spline_bezier3_bounds.spec.js +37 -0
  72. package/src/core/math/statistics/computeSampleSize_Cochran.spec.js +12 -0
  73. package/src/core/math/statistics/computeStatisticalPartialMedian.js +4 -0
  74. package/src/core/math/statistics/computeStatisticalPartialMedian.spec.js +13 -0
  75. package/src/core/math/vector_nd_dot.js +16 -0
  76. package/src/core/math/{normalizeArrayVector.js → vector_nd_normalize.js} +3 -3
  77. package/src/core/math/vector_nd_normalize.spec.js +15 -0
  78. package/src/core/process/PromiseWatcher.spec.js +1 -1
  79. package/src/engine/achievements/Achievement.spec.js +21 -0
  80. package/src/engine/animation/curve/compression/downsample_float_array_curve_by_error.js +1 -1
  81. package/src/engine/animation/curve/compression/prototypeCurveCompression.js +2 -2
  82. package/src/engine/animation/curve/compression/{animation_curve_to_float_array.js → sample_animation_curve_to_float_array.js} +10 -3
  83. package/src/engine/animation/curve/compression/sample_animation_curve_to_float_array.spec.js +29 -0
  84. package/src/engine/animation/curve/draw/build_curve_editor.js +3 -3
  85. package/src/engine/development/performance/RingBufferMetric.js +1 -1
  86. package/src/engine/ecs/EntityManager.js +1 -205
  87. package/src/engine/ecs/animation/Animation.js +2 -180
  88. package/src/engine/ecs/animation/AnimationClip.js +132 -0
  89. package/src/engine/ecs/animation/AnimationClip.spec.js +5 -0
  90. package/src/engine/ecs/animation/AnimationClipFlag.js +7 -0
  91. package/src/engine/ecs/animation/AnimationFlags.js +8 -0
  92. package/src/engine/ecs/animation/AnimationSerializationAdapter.js +32 -0
  93. package/src/engine/ecs/fow/FogOfWar.js +1 -1
  94. package/src/engine/ecs/guid/GUID.js +1 -1
  95. package/src/engine/ecs/systems/AnimationSystem.js +3 -1
  96. package/src/engine/ecs/terrain/ecs/splat/SplatMapping.js +1 -1
  97. package/src/engine/ecs/terrain/overlay/TerrainOverlay.js +1 -1
  98. package/src/engine/ecs/terrain/tiles/TerrainTile.js +1 -1
  99. package/src/engine/ecs/transform/Transform.d.ts +2 -0
  100. package/src/engine/ecs/transform/Transform.spec.js +63 -0
  101. package/src/engine/ecs/transform-attachment/TransformAttachment.d.ts +17 -1
  102. package/src/engine/ecs/transform-attachment/TransformAttachment.js +12 -2
  103. package/src/engine/ecs/transform-attachment/TransformAttachment.spec.js +103 -0
  104. package/src/engine/graphics/camera/testClippingPlaneComputation.js +1 -1
  105. package/src/engine/graphics/ecs/animation/AnimationControllerSystem.js +2 -1
  106. package/src/engine/graphics/ecs/path/testPathDisplaySystem.js +1 -1
  107. package/src/engine/graphics/ecs/path/tube/build/computeFrenetFrames.js +1 -1
  108. package/src/engine/graphics/ecs/path/tube/prototypeAnimatedPathMask.js +1 -1
  109. package/src/engine/graphics/geometry/MikkT/GenerateTSpaces.js +1 -1
  110. package/src/engine/graphics/geometry/MikkT/m_getNormal.js +1 -1
  111. package/src/engine/graphics/geometry/MikkT/m_getTexCoord.js +1 -1
  112. package/src/engine/graphics/geometry/bvh/buffered/BVHGeometryRaycaster.js +1 -1
  113. package/src/engine/graphics/geometry/instancing/InstancedMeshGroup.js +1 -1
  114. package/src/engine/graphics/geometry/optimization/merge/merge_geometry_hierarchy.js +1 -1
  115. package/src/engine/graphics/impostors/octahedral/util/build_cutout_from_atlas_by_alpha.js +1 -1
  116. package/src/engine/graphics/load_and_set_cubemap_v0.js +1 -1
  117. package/src/engine/graphics/particles/particular/engine/utils/volume/AttributeValue.js +1 -1
  118. package/src/engine/graphics/render/Lines.js +1 -1
  119. package/src/engine/graphics/render/buffer/buffers/prototypeNormalFrameBuffer.js +1 -1
  120. package/src/engine/graphics/render/buffer/simple-fx/taa/TemporalSupersamplingRenderPlugin.js +1 -1
  121. package/src/engine/graphics/render/forward_plus/LightManager.js +1 -1
  122. package/src/engine/graphics/render/forward_plus/model/Decal.js +1 -1
  123. package/src/engine/graphics/render/forward_plus/plugin/ptototypeFPPlugin.js +1 -1
  124. package/src/engine/graphics/render/forward_plus/prototype/prototypeLightManager.js +1 -1
  125. package/src/engine/graphics/render/gizmo/GizmoShapeRenderingInterface.js +1 -1
  126. package/src/engine/graphics/render/view/CameraView.js +1 -1
  127. package/src/engine/graphics/render/visibility/hiz/prototypeHiZ.js +1 -1
  128. package/src/engine/graphics/render/visibility/hiz/query/BatchOcclusionQuery.js +1 -1
  129. package/src/engine/graphics/render/webgpu/sample/MeshInstance.js +1 -1
  130. package/src/engine/graphics/sh3/LightProbeVolume.js +1 -1
  131. package/src/engine/graphics/sh3/path_tracer/PathTracedMesh.js +1 -1
  132. package/src/engine/graphics/sh3/path_tracer/PathTracer.js +1 -1
  133. package/src/engine/graphics/sh3/path_tracer/make_sky_hosek.js +1 -1
  134. package/src/engine/graphics/sh3/prototypeSH3Probe.js +1 -1
  135. package/src/engine/graphics/texture/3d/scs3d_read_2d_slice.js +1 -1
  136. package/src/engine/graphics/texture/CanvasClone.js +5 -1
  137. package/src/engine/graphics/texture/sampler/Sampler2D.js +14 -75
  138. package/src/engine/graphics/texture/sampler/bicubic.js +19 -19
  139. package/src/engine/graphics/texture/sampler/convertSampler2D2DataURL.spec.js +10 -0
  140. package/src/engine/graphics/texture/sampler/copy_Sampler2D_channel_data.spec.js +90 -0
  141. package/src/engine/graphics/texture/sampler/differenceSampler.js +13 -8
  142. package/src/engine/graphics/texture/sampler/distance/computeSignedDistanceField_Chamfer.js +140 -0
  143. package/src/engine/graphics/texture/sampler/distance/computeSignedDistanceField_NaiveFlood.js +130 -0
  144. package/src/engine/graphics/texture/sampler/distance/computeUnsignedDistanceField.js +10 -0
  145. package/src/engine/graphics/texture/sampler/distance/computeUnsignedDistanceField.spec.js +183 -0
  146. package/src/engine/graphics/texture/sampler/distance/computeUnsignedDistanceField_Chamfer.js +133 -0
  147. package/src/engine/graphics/texture/sampler/filter/kaiser_1.js +8 -4
  148. package/src/engine/graphics/texture/sampler/filter/kaiser_bessel_window.js +2 -0
  149. package/src/engine/graphics/texture/sampler/filter/mitchell.js +4 -0
  150. package/src/engine/graphics/texture/sampler/loadSampler2D.js +5 -2
  151. package/src/engine/graphics/texture/sampler/resize/sampler2d_downsample_mipmap.js +8 -3
  152. package/src/engine/graphics/texture/sampler/resize/sampler2d_downsample_mipmap.spec.js +13 -0
  153. package/src/engine/graphics/texture/sampler/sampler2d_channel_compute_min_indices.js +58 -0
  154. package/src/engine/graphics/trail/TemporalPath.js +0 -36
  155. package/src/engine/intelligence/behavior/composite/ParallelBehavior.spec.js +12 -12
  156. package/src/engine/intelligence/behavior/composite/SequenceBehavior.spec.js +17 -0
  157. package/src/engine/intelligence/behavior/primitive/SucceedingBehavior.js +2 -0
  158. package/src/engine/knowledge/database/StaticKnowledgeDataTable.d.ts +7 -1
  159. package/src/engine/knowledge/database/StaticKnowledgeDataTable.spec.js +21 -0
  160. package/src/engine/knowledge/database/StaticKnowledgeDataTableDescriptor.d.ts +2 -2
  161. package/src/engine/logging/ConsoleLoggerBackend.js +4 -0
  162. package/src/engine/logging/VoidLoggerBackend.js +12 -0
  163. package/src/engine/navigation/ecs/components/computeCatmullRomSpline.js +1 -1
  164. package/src/engine/navigation/ecs/components/computeCatmullRomSplineUniformDistance.js +1 -1
  165. package/src/engine/physics/cannon/CannonJSPhysicsSystem.js +1 -1
  166. package/src/engine/save/GameStateLoader.js +1 -1
  167. package/src/engine/scene/Scene.d.ts +2 -0
  168. package/src/engine/scene/Scene.js +2 -2
  169. package/src/engine/scene/Scene.spec.js +20 -0
  170. package/src/engine/scene/SceneManager.d.ts +4 -0
  171. package/src/engine/scene/SceneManager.js +46 -23
  172. package/src/engine/scene/SceneManager.spec.js +107 -0
  173. package/src/engine/sound/material/detector/terrain/TerrainSoundMaterialSurfaceDetector.js +2 -2
  174. package/src/engine/ui/GUIEngine.js +1 -1
  175. package/src/generation/filtering/numeric/complex/CellFilterAngleToNormal.js +11 -4
  176. package/src/generation/filtering/numeric/complex/CellFilterAngleToNormal.spec.js +30 -0
  177. package/src/generation/filtering/numeric/complex/CellFilterGaussianBlur.js +18 -2
  178. package/src/generation/filtering/numeric/complex/CellFilterGaussianBlur.spec.js +17 -0
  179. package/src/generation/filtering/numeric/complex/CellFilterSimplexNoise.js +2 -2
  180. package/src/generation/grid/GridData.js +0 -60
  181. package/src/generation/grid/generation/util/buildUnsignedDistanceField.js +3 -1
  182. package/src/generation/markers/MarkerNode.js +2 -2
  183. package/src/generation/theme/AreaMask.js +3 -1
  184. package/src/view/elements/progress/RectangularPieProgressView.js +8 -6
  185. package/src/core/geom/2d/LineSegment2.js +0 -175
  186. package/src/core/geom/Matrix4.js +0 -275
  187. package/src/engine/graphics/texture/sampler/distanceField.js +0 -411
  188. package/src/engine/graphics/texture/sampler/distanceField.spec.js +0 -184
  189. package/src/engine/physics/cannon/cannon.min.js +0 -27
  190. /package/src/engine/ecs/{animation → ik}/IKMath.js +0 -0
  191. /package/src/engine/ecs/{animation → ik}/IKProblem.js +0 -0
  192. /package/src/engine/ecs/{animation → ik}/IKSolver.js +0 -0
  193. /package/src/engine/ecs/{animation → ik}/InverseKinematics.js +0 -0
  194. /package/src/engine/ecs/{animation → ik}/InverseKinematicsSystem.js +0 -0
  195. /package/src/engine/ecs/{animation → ik}/OneBoneSurfaceAlignmentSolver.js +0 -0
  196. /package/src/engine/ecs/{animation → ik}/TwoBoneInverseKinematicsSolver.js +0 -0
  197. /package/src/engine/physics/spring/{Spring.js → computeHookeForce.js} +0 -0
@@ -8,10 +8,12 @@ import { assert } from "../../../assert.js";
8
8
  import { clamp } from "../../../math/clamp.js";
9
9
  import { max2 } from "../../../math/max2.js";
10
10
  import { min2 } from "../../../math/min2.js";
11
- import LineSegment2 from "../LineSegment2.js";
12
11
  import Vector2 from "../../Vector2.js";
13
12
  import { aabb2_compute_overlap } from "./aabb2_compute_overlap.js";
14
13
  import { aabb2_overlap_exists } from "./aabb2_overlap_exists.js";
14
+ import {
15
+ line_segment_compute_line_segment_intersection_2d
16
+ } from "../line/line_segment_compute_line_segment_intersection_2d.js";
15
17
 
16
18
  /**
17
19
  *
@@ -215,7 +217,7 @@ class AABB2 {
215
217
  }
216
218
 
217
219
  /**
218
- *
220
+ * NOTE: only 1 intersection point is produced
219
221
  * @param {Vector2} p0
220
222
  * @param {Vector2} p1
221
223
  * @param {Vector2} result
@@ -227,19 +229,19 @@ class AABB2 {
227
229
  const x1 = this.x1;
228
230
  const y1 = this.y1;
229
231
 
230
- if (LineSegment2.intersectionPointRaw(p0.x, p0.y, p1.x, p1.y, x0, y0, x1, y0, result)) {
232
+ if (line_segment_compute_line_segment_intersection_2d(p0.x, p0.y, p1.x, p1.y, x0, y0, x1, y0, result)) {
231
233
  //top
232
234
  return true;
233
235
  }
234
- if (LineSegment2.intersectionPointRaw(p0.x, p0.y, p1.x, p1.y, x0, y1, x1, y1, result)) {
236
+ if (line_segment_compute_line_segment_intersection_2d(p0.x, p0.y, p1.x, p1.y, x0, y1, x1, y1, result)) {
235
237
  //bottom
236
238
  return true;
237
239
  }
238
- if (LineSegment2.intersectionPointRaw(p0.x, p0.y, p1.x, p1.y, x0, y0, x0, y1, result)) {
240
+ if (line_segment_compute_line_segment_intersection_2d(p0.x, p0.y, p1.x, p1.y, x0, y0, x0, y1, result)) {
239
241
  //left
240
242
  return true;
241
243
  }
242
- if (LineSegment2.intersectionPointRaw(p0.x, p0.y, p1.x, p1.y, x1, y0, x1, y1, result)) {
244
+ if (line_segment_compute_line_segment_intersection_2d(p0.x, p0.y, p1.x, p1.y, x1, y0, x1, y1, result)) {
243
245
  //right
244
246
  return true;
245
247
  }
@@ -486,7 +488,7 @@ class AABB2 {
486
488
  }
487
489
 
488
490
  /**
489
- *
491
+ * Set bounds without having to maintain constraint that x0 >= x1 and y0 >= y1
490
492
  * @param {number} x0
491
493
  * @param {number} y0
492
494
  * @param {number} x1
@@ -1,4 +1,5 @@
1
1
  import AABB2 from "./AABB2.js";
2
+ import Vector2 from "../../Vector2.js";
2
3
 
3
4
  test('copy', () => {
4
5
  const a = new AABB2(1, 2, 5, 11);
@@ -51,3 +52,102 @@ test('equals', () => {
51
52
  expect(a.equals(e)).toBe(false);
52
53
  expect(a.equals(f)).toBe(false);
53
54
  });
55
+
56
+ test("lineIntersectionPoint", () => {
57
+ const aabb = new AABB2(1, 1, 2, 2);
58
+
59
+ const result = new Vector2();
60
+
61
+ expect(aabb.lineIntersectionPoint(new Vector2(0, 0), new Vector2(-1, -1), result)).toBe(false);
62
+
63
+ expect(aabb.lineIntersectionPoint(new Vector2(0, 1.5), new Vector2(3, 1.5), result)).toBe(true);
64
+ });
65
+
66
+ /**
67
+ *
68
+ * @param {AABB2} aabb
69
+ * @param {number} x0
70
+ * @param {number} y0
71
+ * @param {number} x1
72
+ * @param {number} y1
73
+ */
74
+ function expect_aabb_equals(aabb, x0, y0, x1, y1) {
75
+ expect(aabb.x0).toEqual(x0);
76
+ expect(aabb.y0).toEqual(y0);
77
+ expect(aabb.x1).toEqual(x1);
78
+ expect(aabb.y1).toEqual(y1);
79
+ }
80
+
81
+ test("setBoundsUnordered", () => {
82
+
83
+ const aabb = new AABB2();
84
+
85
+ aabb.setBoundsUnordered(2, 3, -5, -7);
86
+
87
+ expect_aabb_equals(aabb, -5, -7, 2, 3);
88
+
89
+ aabb.setBoundsUnordered(-5, -7, 2, 3);
90
+
91
+ expect_aabb_equals(aabb, -5, -7, 2, 3);
92
+
93
+ aabb.setBoundsUnordered(-5, 3, 2, -7);
94
+
95
+ expect_aabb_equals(aabb, -5, -7, 2, 3);
96
+
97
+ aabb.setBoundsUnordered(2, -7, -5, 3);
98
+
99
+ expect_aabb_equals(aabb, -5, -7, 2, 3);
100
+ });
101
+
102
+ test("toJSON", () => {
103
+
104
+ const aabb = new AABB2(1, 3, 5, 7);
105
+
106
+ expect(aabb.toJSON()).toEqual({
107
+ x0: 1,
108
+ y0: 3,
109
+ x1: 5,
110
+ y1: 7
111
+ });
112
+
113
+ });
114
+
115
+ test("fromJSON", () => {
116
+
117
+ const aabb = new AABB2();
118
+
119
+ aabb.fromJSON({
120
+ x0: 1,
121
+ y0: 3,
122
+ x1: 5,
123
+ y1: 7
124
+ });
125
+
126
+ expect_aabb_equals(aabb, 1, 3, 5, 7);
127
+ });
128
+
129
+ test("_expandToFitPoint", () => {
130
+
131
+ const aabb = new AABB2();
132
+
133
+ aabb._expandToFitPoint(0, 0);
134
+
135
+ expect_aabb_equals(aabb, 0, 0, 0, 0);
136
+
137
+ aabb._expandToFitPoint(-1, 0);
138
+
139
+ expect_aabb_equals(aabb, -1, 0, 0, 0);
140
+
141
+ aabb._expandToFitPoint(0, -1);
142
+
143
+ expect_aabb_equals(aabb, -1, -1, 0, 0);
144
+
145
+ aabb._expandToFitPoint(3, 5);
146
+
147
+ expect_aabb_equals(aabb, -1, -1, 3, 5);
148
+
149
+ aabb._expandToFitPoint(7, 0);
150
+
151
+ expect_aabb_equals(aabb, -1, -1, 7, 5);
152
+
153
+ });
@@ -0,0 +1,11 @@
1
+ import { aabb2_compute_center_from_multiple } from "./aabb2_compute_center_from_multiple.js";
2
+ import AABB2 from "./AABB2.js";
3
+ import Vector2 from "../../Vector2.js";
4
+
5
+ test("single box", () => {
6
+ const center = aabb2_compute_center_from_multiple([
7
+ new AABB2(-1, -3, 0, -2)
8
+ ]);
9
+
10
+ expect(center.roughlyEquals(new Vector2(-0.5, -2.5))).toBe(true);
11
+ });
@@ -0,0 +1,56 @@
1
+ import { aabb2_compute_overlap } from "./aabb2_compute_overlap.js";
2
+ import AABB2 from "./AABB2.js";
3
+
4
+ test("no overlap", () => {
5
+
6
+ const aabb = new AABB2();
7
+
8
+ expect(aabb2_compute_overlap(
9
+ -1, -1, -1, -1,
10
+ 1, 1, 1, 1,
11
+ aabb
12
+ )).toBe(false);
13
+
14
+ expect(aabb2_compute_overlap(
15
+ 0, 0, 0, 0,
16
+ -1, 1, 1, 1,
17
+ aabb
18
+ )).toBe(false);
19
+
20
+ expect(aabb2_compute_overlap(
21
+ 0, 0, 0, 0,
22
+ 1, -1, 1, 1,
23
+ aabb
24
+ )).toBe(false);
25
+
26
+ expect(aabb2_compute_overlap(
27
+ -1, 1, 1, 1,
28
+ 0, 0, 0, 0,
29
+ aabb
30
+ )).toBe(false);
31
+
32
+ expect(aabb2_compute_overlap(
33
+ 1, -1, 1, 1,
34
+ 0, 0, 0, 0,
35
+ aabb
36
+ )).toBe(false);
37
+
38
+ });
39
+
40
+ test("partial complex overlap", () => {
41
+
42
+ const aabb = new AABB2();
43
+
44
+ expect(aabb2_compute_overlap(
45
+ 0, 0, 7, 3,
46
+ 5, 1, 11, 2,
47
+ aabb
48
+ )).toBe(true);
49
+
50
+ expect(aabb.toJSON()).toEqual({
51
+ x0: 5,
52
+ y0: 1,
53
+ x1: 7,
54
+ y1: 2
55
+ });
56
+ });
@@ -0,0 +1,40 @@
1
+ import { aabb2_contains } from "./aabb2_contains.js";
2
+
3
+ test("test", () => {
4
+
5
+ expect(aabb2_contains(
6
+ 0, 0, 0, 0,
7
+ -1, -1, 1, 1
8
+ )).toBe(false);
9
+
10
+ expect(aabb2_contains(
11
+ 0, 0, 0, 0,
12
+ 0, 0, 0, 0
13
+ )).toBe(true);
14
+
15
+ expect(aabb2_contains(
16
+ -1, -1, 1, 1,
17
+ 0, 0, 0, 0
18
+ )).toBe(true);
19
+
20
+ expect(aabb2_contains(
21
+ -1, -1, 1, 1,
22
+ -2, 0, 0, 0
23
+ )).toBe(false);
24
+
25
+ expect(aabb2_contains(
26
+ -1, -1, 1, 1,
27
+ 0, -2, 0, 0
28
+ )).toBe(false);
29
+
30
+ expect(aabb2_contains(
31
+ -1, -1, 1, 1,
32
+ 0, 0, 2, 0
33
+ )).toBe(false);
34
+
35
+ expect(aabb2_contains(
36
+ -1, -1, 1, 1,
37
+ 0, 0, 0, 2
38
+ )).toBe(false);
39
+
40
+ });
@@ -1,4 +1,4 @@
1
- import AABB2 from "../../AABB2.js";
1
+ import AABB2 from "../aabb/AABB2.js";
2
2
 
3
3
  export class Node2 extends AABB2 {
4
4
  constructor(x0, y0, x1, y1) {
@@ -1,6 +1,6 @@
1
1
  //
2
2
 
3
- import { array_copy } from "../../../collection/array/copyArray.js";
3
+ import { array_copy } from "../../../collection/array/array_copy.js";
4
4
  import { compute_polygon_area_2d } from "../compute_polygon_area_2d.js";
5
5
  import { intersect_ray_2d } from "../intersect_ray_2d.js";
6
6
  import { UintArrayForCount } from "../../../collection/array/typed/uint_array_for_count.js";
@@ -1,4 +1,4 @@
1
- import { array_copy } from "../../../collection/array/copyArray.js";
1
+ import { array_copy } from "../../../collection/array/array_copy.js";
2
2
  import { Uint32Heap } from "../../../collection/heap/Uint32Heap.js";
3
3
  import { intersect_ray_2d } from "../intersect_ray_2d.js";
4
4
  import { compute_triangle_area_2d } from "../compute_triangle_area_2d.js";
@@ -0,0 +1,35 @@
1
+ import {
2
+ line_segment_compute_line_segment_intersection_array_2d
3
+ } from "./line_segment_compute_line_segment_intersection_array_2d.js";
4
+
5
+ const scratch_array = new Float32Array(2);
6
+
7
+ /**
8
+ * @param {number} a0_x
9
+ * @param {number} a0_y
10
+ * @param {number} a1_x
11
+ * @param {number} a1_y
12
+ * @param {number} b0_x
13
+ * @param {number} b0_y
14
+ * @param {number} b1_x
15
+ * @param {number} b1_y
16
+ * @param {Vector2} result resulting intersection point will be stored here if intersection exists
17
+ * @returns {boolean} True if segments intersect, False otherwise
18
+ */
19
+ export function line_segment_compute_line_segment_intersection_2d(
20
+ a0_x, a0_y, a1_x, a1_y,
21
+ b0_x, b0_y, b1_x, b1_y,
22
+ result
23
+ ) {
24
+ const collision = line_segment_compute_line_segment_intersection_array_2d(
25
+ scratch_array, 0,
26
+ a0_x, a0_y, a1_x, a1_y,
27
+ b0_x, b0_y, b1_x, b1_y,
28
+ );
29
+
30
+ if (collision) {
31
+ result.readFromArray(scratch_array);
32
+ }
33
+
34
+ return collision;
35
+ }
@@ -0,0 +1,51 @@
1
+ /**
2
+ *
3
+ * Find intersection point between two line segments if they intersect at all
4
+ * Adapted from answer by iMalc from stackoverflow.com "how do you detect where two line segments intersect"
5
+ * @link https://stackoverflow.com/questions/563198/how-do-you-detect-where-two-line-segments-intersect
6
+ *
7
+ * @param {number[]|Float32Array|Float64Array} result resulting intersection point will be stored here if intersection exists
8
+ * @param {number} result_offset
9
+ * @param {number} a0_x
10
+ * @param {number} a0_y
11
+ * @param {number} a1_x
12
+ * @param {number} a1_y
13
+ * @param {number} b0_x
14
+ * @param {number} b0_y
15
+ * @param {number} b1_x
16
+ * @param {number} b1_y
17
+ * @return {boolean} True if segments intersect, False otherwise
18
+ */
19
+ export function line_segment_compute_line_segment_intersection_array_2d(
20
+ result, result_offset,
21
+ a0_x, a0_y, a1_x, a1_y,
22
+ b0_x, b0_y, b1_x, b1_y
23
+ ) {
24
+
25
+ const s1_x = a1_x - a0_x;
26
+ const s1_y = a1_y - a0_y;
27
+ const s2_x = b1_x - b0_x;
28
+ const s2_y = b1_y - b0_y;
29
+
30
+ const dy_02 = a0_y - b0_y;
31
+ const dx_02 = a0_x - b0_x;
32
+
33
+ const inv_denom = 1 / (-s2_x * s1_y + s1_x * s2_y);
34
+
35
+ const s = (-s1_y * dx_02 + s1_x * dy_02) * inv_denom;
36
+ const t = (s2_x * dy_02 - s2_y * dx_02) * inv_denom;
37
+
38
+ if (s >= 0 && s <= 1 && t >= 0 && t <= 1) {
39
+ // Collision detected
40
+
41
+ const intercept_x = a0_x + (t * s1_x);
42
+ const intercept_y = a0_y + (t * s1_y);
43
+
44
+ result[result_offset] = intercept_x;
45
+ result[result_offset + 1] = intercept_y;
46
+
47
+ return true;
48
+ }
49
+
50
+ return false; // No collision
51
+ }
@@ -0,0 +1,15 @@
1
+ import {
2
+ line_segment_compute_line_segment_intersection_2d
3
+ } from "./line_segment_compute_line_segment_intersection_2d.js";
4
+
5
+ /**
6
+ * @param {Vector2} a0 start of first segment
7
+ * @param {Vector2} a1 end of first segment
8
+ * @param {Vector2} b0 start of second segment
9
+ * @param {Vector2} b1 end of second segment
10
+ * @param {Vector2} result resulting intersection point will be stored here if intersection exists
11
+ * @returns {boolean} True if segments intersect, False otherwise
12
+ */
13
+ export function line_segment_compute_line_segment_intersection_vectors_2d(a0, a1, b0, b1, result) {
14
+ return line_segment_compute_line_segment_intersection_2d(a0.x, a0.y, a1.x, a1.y, b0.x, b0.y, b1.x, b1.y, result);
15
+ }
@@ -0,0 +1,30 @@
1
+ import {
2
+ line_segment_compute_line_segment_intersection_array_2d
3
+ } from "./line_segment_compute_line_segment_intersection_array_2d.js";
4
+
5
+ /**
6
+ * @param {Vector2} p0
7
+ * @param {Vector2} p1
8
+ * @param {Vector2} p2
9
+ * @param {Vector2} p3
10
+ * @returns {[number,number]}
11
+ */
12
+ export function line_segment_compute_line_segment_intersection_vectors_array_2d(p0, p1, p2, p3) {
13
+ const p0_x = p0.x;
14
+ const p0_y = p0.y;
15
+ const p1_x = p1.x;
16
+ const p1_y = p1.y;
17
+ const p2_x = p2.x;
18
+ const p2_y = p2.y;
19
+ const p3_x = p3.x;
20
+ const p3_y = p3.y;
21
+
22
+ const result = [];
23
+
24
+ if (line_segment_compute_line_segment_intersection_array_2d(result, 0, p0_x, p0_y, p1_x, p1_y, p2_x, p2_y, p3_x, p3_y)) {
25
+ return result;
26
+ } else {
27
+ return null; // No collision
28
+ }
29
+
30
+ }
@@ -0,0 +1,29 @@
1
+ /**
2
+ *
3
+ * @param {number} a0_x
4
+ * @param {number} a0_y
5
+ * @param {number} a1_x
6
+ * @param {number} a1_y
7
+ * @param {number} b0_x
8
+ * @param {number} b0_y
9
+ * @param {number} b1_x
10
+ * @param {number} b1_y
11
+ * @returns {boolean} True if segments intersect, False otherwise
12
+ * @public
13
+ */
14
+ export function line_segment_line_segment_intersection_exists_2d(a0_x, a0_y, a1_x, a1_y, b0_x, b0_y, b1_x, b1_y) {
15
+ const s1_x = a1_x - a0_x;
16
+ const s1_y = a1_y - a0_y;
17
+ const s2_x = b1_x - b0_x;
18
+ const s2_y = b1_y - b0_y;
19
+
20
+ const dy_02 = a0_y - b0_y;
21
+ const dx_02 = a0_x - b0_x;
22
+
23
+ const inv_denom = 1 / (-s2_x * s1_y + s1_x * s2_y);
24
+
25
+ const s = (-s1_y * dx_02 + s1_x * dy_02) * inv_denom;
26
+ const t = (s2_x * dy_02 - s2_y * dx_02) * inv_denom;
27
+
28
+ return s >= 0 && s <= 1 && t >= 0 && t <= 1;
29
+ }
@@ -12,6 +12,8 @@ export class AABB3 {
12
12
 
13
13
  setBounds(x0: number, y0: number, z0: number, x1: number, y1: number, z1: number): void
14
14
 
15
+ setBoundsUnordered(x0: number, y0: number, z0: number, x1: number, y1: number, z1: number): void
16
+
15
17
  getCenter(target: Vector3): void
16
18
 
17
19
  getCenterX(): number
@@ -43,4 +45,6 @@ export class AABB3 {
43
45
  equals(other: AABB3): boolean
44
46
 
45
47
  copy(other: AABB3): void
48
+
49
+ _isBelowPlane(nx: number, ny: number, nz: number, constant: number): boolean
46
50
  }
@@ -6,6 +6,12 @@ import { serializeAABB3 } from "./serializeAABB3.js";
6
6
  import { deserializeAABB3 } from "./deserializeAABB3.js";
7
7
 
8
8
 
9
+ /**
10
+ *
11
+ * @param {AABB3} expected
12
+ * @param {AABB3} actual
13
+ * @param {number} [numDigits]
14
+ */
9
15
  function compareBounds(expected, actual, numDigits = 10) {
10
16
  expect(actual.x0).toBeCloseTo(expected.x0, numDigits);
11
17
  expect(actual.y0).toBeCloseTo(expected.y0, numDigits);
@@ -225,3 +231,27 @@ test("getExtentsZ", () => {
225
231
  expect(new AABB3(0, 0, 0, 0, 0, 1).getExtentsZ()).toBeCloseTo(1);
226
232
  expect(new AABB3(0, 0, -1, 0, 0, 1).getExtentsZ()).toBeCloseTo(2);
227
233
  });
234
+
235
+ test("setBoundsUnordered", () => {
236
+ const aabb = new AABB3();
237
+
238
+ aabb.setBoundsUnordered(1, 2, 3, -5, -7, -11);
239
+
240
+ compareBounds(aabb, new AABB3(-5, -7, -11, 1,2,3));
241
+
242
+ aabb.setBoundsUnordered(-5, -7, -11, 1, 2, 3);
243
+
244
+ compareBounds(aabb, new AABB3(-5, -7, -11, 1,2,3));
245
+
246
+ aabb.setBoundsUnordered(1, -7, -11, -5, 2, 3);
247
+
248
+ compareBounds(aabb, new AABB3(-5, -7, -11, 1,2,3));
249
+
250
+ aabb.setBoundsUnordered(-5, 2, -11, 1, -7, 3);
251
+
252
+ compareBounds(aabb, new AABB3(-5, -7, -11, 1,2,3));
253
+
254
+ aabb.setBoundsUnordered(-5, -7, 3, 1, 2, -11);
255
+
256
+ compareBounds(aabb, new AABB3(-5, -7, -11, 1,2,3));
257
+ });
@@ -1,4 +1,4 @@
1
- import { array_copy } from "../../../collection/array/copyArray.js";
1
+ import { array_copy } from "../../../collection/array/array_copy.js";
2
2
  import { MATRIX_4_IDENTITY } from "./MATRIX_4_IDENTITY.js";
3
3
 
4
4
  /**
@@ -1,6 +1,6 @@
1
1
  import { max2 } from "../../../../math/max2.js";
2
2
  import { mat3, vec3 } from "gl-matrix";
3
- import { array_copy } from "../../../../collection/array/copyArray.js";
3
+ import { array_copy } from "../../../../collection/array/array_copy.js";
4
4
  import { min2 } from "../../../../math/min2.js";
5
5
  import { assert } from "../../../../assert.js";
6
6
 
@@ -2,7 +2,7 @@ import { tetrahedron_contains_point } from "./tetrahedron_contains_point.js";
2
2
  import { typed_array_copy } from "../../../collection/array/typed/typed_array_copy.js";
3
3
  import { max3 } from "../../../math/max3.js";
4
4
  import { assert } from "../../../assert.js";
5
- import { array_copy } from "../../../collection/array/copyArray.js";
5
+ import { array_copy } from "../../../collection/array/array_copy.js";
6
6
  import { array_quick_sort_by_comparator } from "../../../collection/array/arrayQuickSort.js";
7
7
  import { compareNumbersDescending } from "../../../function/Functions.js";
8
8
  import { BinaryBuffer } from "../../../binary/BinaryBuffer.js";
@@ -1,4 +1,4 @@
1
- import { array_copy } from "../../../collection/array/copyArray.js";
1
+ import { array_copy } from "../../../collection/array/array_copy.js";
2
2
  import { v3_dot } from "../../v3_dot.js";
3
3
 
4
4
  const MAX_FLOAT32 = 3.4028234663852886e+38;
@@ -1,5 +1,5 @@
1
1
  import { assert } from "../../../../assert.js";
2
- import { array_copy } from "../../../../collection/array/copyArray.js";
2
+ import { array_copy } from "../../../../collection/array/array_copy.js";
3
3
  import { INVALID_NEIGHBOUR } from "../TetrahedralMesh.js";
4
4
  import { validate_neighbour } from "../validate_tetrahedral_mesh.js";
5
5
 
@@ -1,7 +1,7 @@
1
1
  import { Miniball } from "../../../packing/miniball/Miniball.js";
2
2
  import { PointSet } from "../../../packing/miniball/PointSet.js";
3
3
  import { ConicRay } from "../../../ConicRay.js";
4
- import { array_copy } from "../../../../collection/array/copyArray.js";
4
+ import { array_copy } from "../../../../collection/array/array_copy.js";
5
5
  import { min2 } from "../../../../math/min2.js";
6
6
  import { v3_angle_between } from "../../../v3_angle_between.js";
7
7
 
@@ -1,4 +1,4 @@
1
- import { array_copy } from "../../../collection/array/copyArray.js";
1
+ import { array_copy } from "../../../collection/array/array_copy.js";
2
2
  import { computeTopoMeshVertexDuplicates } from "./computeTopoMeshVertexDuplicates.js";
3
3
  import { arraySetSortingDiff } from "../../../collection/array/arraySetSortingDiff.js";
4
4
  import { compareFaces } from "./compareFaces.js";
@@ -1,5 +1,5 @@
1
1
  import { BinaryElementPool } from "./BinaryElementPool.js";
2
- import { array_copy } from "../../../../../collection/array/copyArray.js";
2
+ import { array_copy } from "../../../../../collection/array/array_copy.js";
3
3
  import { assert } from "../../../../../assert.js";
4
4
 
5
5
  /**
@@ -1,5 +1,6 @@
1
1
  import Signal from "../events/signal/Signal";
2
2
  import {Matrix4, Quaternion as ThreeQuaternion} from "three";
3
+ import Vector3 from "./Vector3";
3
4
 
4
5
  interface Vector3Like {
5
6
  x: number,
@@ -28,12 +29,18 @@ export default class Quaternion {
28
29
 
29
30
  clone(): Quaternion
30
31
 
32
+ random(random?:()=>number):void
33
+
31
34
  equals(other: { x: number, y: number, z: number, w: number }): boolean
32
35
 
36
+ roughlyEquals(other: { x: number, y: number, z: number, w: number }, tolerance?: number): boolean
37
+
33
38
  slerp(other: Quaternion, t: number): void
34
39
 
35
40
  normalize(): void
36
41
 
42
+ length():number
43
+
37
44
  __setFromEuler(x: number, y: number, z: number, order?: string): void
38
45
 
39
46
  setFromRotationMatrix(m: Matrix4): void
@@ -54,6 +61,8 @@ export default class Quaternion {
54
61
 
55
62
  fromAxisAngle(axis: Vector3Like, angle: number): void
56
63
 
64
+ toAxisAngle(axis: Vector3):number
65
+
57
66
  computeTwistAngle(axis: Vector3Like): number
58
67
 
59
68
  multiplyQuaternions(a: Quaternion, b: Quaternion): void
@@ -69,4 +78,6 @@ export default class Quaternion {
69
78
  writeToArray(array: ArrayLike<number>, offset?: number): void
70
79
 
71
80
  asArray(): number[]
81
+
82
+ static readonly identity:Quaternion
72
83
  }