@woosh/meep-engine 2.49.9 → 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.
- package/editor/actions/concrete/ArrayCopyAction.js +1 -1
- package/package.json +1 -1
- package/src/core/binary/BinaryBuffer.js +1 -1
- package/src/core/binary/BinaryBuffer.spec.js +128 -0
- package/src/core/binary/int32_to_binary_string.js +4 -1
- package/src/core/binary/int32_to_binary_string.spec.js +9 -0
- package/src/core/bvh2/BinaryNode.js +0 -30
- package/src/core/bvh2/binary/2/BinaryUint32BVH.js +1 -1
- package/src/core/bvh2/binary/IndexedBinaryBVH.js +1 -1
- package/src/core/bvh2/bvh3/ExplicitBinaryBoundingVolumeHierarchy.js +1 -1
- package/src/core/bvh2/bvh3/query/compute_tight_near_far_clipping_planes.js +1 -1
- package/src/core/cache/Cache.js +31 -29
- package/src/core/cache/Cache.spec.js +4 -1
- package/src/core/collection/HashMap.js +1 -1
- package/src/core/collection/array/{copyArray.js → array_copy.js} +1 -24
- package/src/core/collection/array/array_copy_entire.js +21 -0
- package/src/core/collection/array/typed/typed_array_copy.js +1 -1
- package/src/core/collection/queue/Deque.d.ts +4 -0
- package/src/core/collection/queue/Deque.js +5 -7
- package/src/core/collection/queue/Deque.spec.js +107 -0
- package/src/core/collection/table/RowFirstTable.js +1 -1
- package/src/core/geom/2d/aabb/AABB2.d.ts +14 -0
- package/src/core/geom/2d/aabb/AABB2.js +9 -7
- package/src/core/geom/2d/aabb/AABB2.spec.js +100 -0
- package/src/core/geom/2d/aabb/aabb2_compute_center_from_multiple.spec.js +11 -0
- package/src/core/geom/2d/aabb/aabb2_compute_overlap.spec.js +56 -0
- package/src/core/geom/2d/aabb/aabb2_contains.spec.js +40 -0
- package/src/core/geom/2d/bvh/Node2.js +1 -1
- package/src/core/geom/2d/convex-hull/fixed_convex_hull_humus.js +1 -1
- package/src/core/geom/2d/convex-hull/fixed_convex_hull_relaxation.js +1 -1
- package/src/core/geom/2d/line/line_segment_compute_line_segment_intersection_2d.js +35 -0
- package/src/core/geom/2d/line/line_segment_compute_line_segment_intersection_array_2d.js +51 -0
- package/src/core/geom/2d/line/line_segment_compute_line_segment_intersection_vectors_2d.js +15 -0
- package/src/core/geom/2d/line/line_segment_compute_line_segment_intersection_vectors_array_2d.js +30 -0
- package/src/core/geom/2d/line/line_segment_line_segment_intersection_exists_2d.js +29 -0
- package/src/core/geom/3d/aabb/AABB3.d.ts +4 -0
- package/src/core/geom/3d/aabb/AABB3.spec.js +30 -0
- package/src/core/geom/3d/matrix/m4_make_translation.js +1 -1
- package/src/core/geom/3d/sphere/harmonics/sh3_dering_optimize_positive.js +1 -1
- package/src/core/geom/3d/tetrahedra/TetrahedralMesh.js +1 -1
- package/src/core/geom/3d/tetrahedra/compute_circumsphere.js +1 -1
- package/src/core/geom/3d/tetrahedra/delaunay/fill_in_a_cavity.js +1 -1
- package/src/core/geom/3d/topology/bounds/computeTriangleClusterNormalBoundingCone.js +1 -1
- package/src/core/geom/3d/topology/expandConnectivityByLocality.js +1 -1
- package/src/core/geom/3d/topology/struct/binary/BinaryTopology.js +1 -1
- package/src/core/geom/Quaternion.d.ts +11 -0
- package/src/core/geom/Quaternion.js +36 -27
- package/src/core/geom/Quaternion.spec.js +141 -0
- package/src/core/geom/Vector2.d.ts +5 -1
- package/src/core/geom/Vector2.js +24 -0
- package/src/core/geom/Vector3.d.ts +4 -0
- package/src/core/geom/Vector3.spec.js +60 -0
- package/src/core/graph/GraphUtils.js +4 -2
- package/src/core/graph/layout/CircleLayout.js +4 -2
- package/src/core/math/vector_nd_dot.js +16 -0
- package/src/core/math/{normalizeArrayVector.js → vector_nd_normalize.js} +3 -3
- package/src/core/math/{normalizeArrayVector.spec.js → vector_nd_normalize.spec.js} +3 -3
- package/src/core/process/PromiseWatcher.spec.js +1 -1
- package/src/engine/animation/curve/compression/downsample_float_array_curve_by_error.js +1 -1
- package/src/engine/ecs/EntityManager.js +1 -205
- package/src/engine/ecs/fow/FogOfWar.js +1 -1
- package/src/engine/ecs/guid/GUID.js +1 -1
- package/src/engine/ecs/terrain/ecs/splat/SplatMapping.js +1 -1
- package/src/engine/ecs/terrain/overlay/TerrainOverlay.js +1 -1
- package/src/engine/ecs/terrain/tiles/TerrainTile.js +1 -1
- package/src/engine/ecs/transform/Transform.d.ts +2 -0
- package/src/engine/ecs/transform/Transform.spec.js +63 -0
- package/src/engine/ecs/transform-attachment/TransformAttachment.d.ts +17 -1
- package/src/engine/ecs/transform-attachment/TransformAttachment.js +12 -2
- package/src/engine/ecs/transform-attachment/TransformAttachment.spec.js +103 -0
- package/src/engine/graphics/ecs/path/tube/build/computeFrenetFrames.js +1 -1
- package/src/engine/graphics/geometry/MikkT/GenerateTSpaces.js +1 -1
- package/src/engine/graphics/geometry/MikkT/m_getNormal.js +1 -1
- package/src/engine/graphics/geometry/MikkT/m_getTexCoord.js +1 -1
- package/src/engine/graphics/geometry/bvh/buffered/BVHGeometryRaycaster.js +1 -1
- package/src/engine/graphics/geometry/instancing/InstancedMeshGroup.js +1 -1
- package/src/engine/graphics/geometry/optimization/merge/merge_geometry_hierarchy.js +1 -1
- package/src/engine/graphics/impostors/octahedral/util/build_cutout_from_atlas_by_alpha.js +1 -1
- package/src/engine/graphics/particles/particular/engine/utils/volume/AttributeValue.js +1 -1
- package/src/engine/graphics/render/Lines.js +1 -1
- package/src/engine/graphics/render/buffer/simple-fx/taa/TemporalSupersamplingRenderPlugin.js +1 -1
- package/src/engine/graphics/render/forward_plus/LightManager.js +1 -1
- package/src/engine/graphics/render/forward_plus/model/Decal.js +1 -1
- package/src/engine/graphics/render/forward_plus/prototype/prototypeLightManager.js +1 -1
- package/src/engine/graphics/render/gizmo/GizmoShapeRenderingInterface.js +1 -1
- package/src/engine/graphics/render/view/CameraView.js +1 -1
- package/src/engine/graphics/render/visibility/hiz/query/BatchOcclusionQuery.js +1 -1
- package/src/engine/graphics/render/webgpu/sample/MeshInstance.js +1 -1
- package/src/engine/graphics/sh3/LightProbeVolume.js +1 -1
- package/src/engine/graphics/sh3/path_tracer/PathTracedMesh.js +1 -1
- package/src/engine/graphics/sh3/path_tracer/PathTracer.js +1 -1
- package/src/engine/graphics/sh3/path_tracer/make_sky_hosek.js +1 -1
- package/src/engine/graphics/sh3/prototypeSH3Probe.js +1 -1
- package/src/engine/graphics/texture/3d/scs3d_read_2d_slice.js +1 -1
- package/src/engine/graphics/texture/CanvasClone.js +5 -1
- package/src/engine/graphics/texture/sampler/Sampler2D.js +14 -75
- package/src/engine/graphics/texture/sampler/bicubic.js +19 -19
- package/src/engine/graphics/texture/sampler/convertSampler2D2DataURL.spec.js +10 -0
- package/src/engine/graphics/texture/sampler/copy_Sampler2D_channel_data.spec.js +90 -0
- package/src/engine/graphics/texture/sampler/differenceSampler.js +13 -8
- package/src/engine/graphics/texture/sampler/distance/computeSignedDistanceField_Chamfer.js +140 -0
- package/src/engine/graphics/texture/sampler/distance/computeSignedDistanceField_NaiveFlood.js +130 -0
- package/src/engine/graphics/texture/sampler/distance/computeUnsignedDistanceField.js +10 -0
- package/src/engine/graphics/texture/sampler/distance/computeUnsignedDistanceField.spec.js +183 -0
- package/src/engine/graphics/texture/sampler/distance/computeUnsignedDistanceField_Chamfer.js +133 -0
- package/src/engine/graphics/texture/sampler/filter/mitchell.js +4 -0
- package/src/engine/graphics/texture/sampler/loadSampler2D.js +5 -2
- package/src/engine/graphics/texture/sampler/resize/sampler2d_downsample_mipmap.js +8 -3
- package/src/engine/graphics/texture/sampler/resize/sampler2d_downsample_mipmap.spec.js +13 -0
- package/src/engine/graphics/texture/sampler/sampler2d_channel_compute_min_indices.js +58 -0
- package/src/engine/graphics/trail/TemporalPath.js +0 -36
- package/src/engine/intelligence/behavior/composite/ParallelBehavior.spec.js +12 -12
- package/src/engine/intelligence/behavior/composite/SequenceBehavior.spec.js +17 -0
- package/src/engine/intelligence/behavior/primitive/SucceedingBehavior.js +2 -0
- package/src/engine/knowledge/database/StaticKnowledgeDataTable.d.ts +7 -1
- package/src/engine/knowledge/database/StaticKnowledgeDataTable.spec.js +21 -0
- package/src/engine/knowledge/database/StaticKnowledgeDataTableDescriptor.d.ts +2 -2
- package/src/engine/logging/ConsoleLoggerBackend.js +4 -0
- package/src/engine/logging/VoidLoggerBackend.js +12 -0
- package/src/engine/navigation/ecs/components/computeCatmullRomSpline.js +1 -1
- package/src/engine/navigation/ecs/components/computeCatmullRomSplineUniformDistance.js +1 -1
- package/src/engine/physics/cannon/CannonJSPhysicsSystem.js +1 -1
- package/src/engine/save/GameStateLoader.js +1 -1
- package/src/engine/scene/Scene.d.ts +2 -0
- package/src/engine/scene/Scene.js +2 -2
- package/src/engine/scene/Scene.spec.js +20 -0
- package/src/engine/scene/SceneManager.d.ts +4 -0
- package/src/engine/scene/SceneManager.js +46 -23
- package/src/engine/scene/SceneManager.spec.js +107 -0
- package/src/engine/sound/material/detector/terrain/TerrainSoundMaterialSurfaceDetector.js +2 -2
- package/src/engine/ui/GUIEngine.js +1 -1
- package/src/generation/grid/generation/util/buildUnsignedDistanceField.js +3 -1
- package/src/generation/markers/MarkerNode.js +2 -2
- package/src/generation/theme/AreaMask.js +3 -1
- package/src/view/elements/progress/RectangularPieProgressView.js +8 -6
- package/src/core/geom/2d/LineSegment2.js +0 -175
- package/src/core/geom/Matrix4.js +0 -275
- package/src/engine/graphics/texture/sampler/distanceField.js +0 -411
- package/src/engine/graphics/texture/sampler/distanceField.spec.js +0 -184
- package/src/engine/physics/cannon/cannon.min.js +0 -27
- /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 (
|
|
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 (
|
|
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 (
|
|
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 (
|
|
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,6 +1,6 @@
|
|
|
1
1
|
//
|
|
2
2
|
|
|
3
|
-
import { array_copy } from "../../../collection/array/
|
|
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/
|
|
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
|
+
}
|
package/src/core/geom/2d/line/line_segment_compute_line_segment_intersection_vectors_array_2d.js
ADDED
|
@@ -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,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/
|
|
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/
|
|
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,5 +1,5 @@
|
|
|
1
1
|
import { assert } from "../../../../assert.js";
|
|
2
|
-
import { array_copy } from "../../../../collection/array/
|
|
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/
|
|
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/
|
|
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/
|
|
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
|
}
|