@woosh/meep-engine 2.49.9 → 2.50.1
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/aabb/aabb3_detailed_volume_intersection.js +4 -4
- package/src/core/geom/3d/frustum/frustum3_computeNearestPointToPoint.js +5 -5
- package/src/core/geom/3d/matrix/m4_make_translation.js +1 -1
- package/src/core/geom/3d/plane/is_point_within_planes.js +1 -1
- package/src/core/geom/3d/plane/lerp_planes_to_array.js +2 -0
- package/src/core/geom/3d/plane/{plane_computeConvex3PlaneIntersection.js → plane3_compute_convex_3_plane_intersection.js} +1 -1
- package/src/core/geom/3d/plane/{plane3_computeLineSegmentIntersection.js → plane3_compute_line_segment_intersection.js} +1 -1
- package/src/core/geom/3d/plane/{computePlanePlaneIntersection.js → plane3_compute_plane_intersection.js} +15 -11
- package/src/core/geom/3d/plane/{computePlaneLineIntersection.js → plane3_compute_ray_intersection.js} +5 -1
- package/src/core/geom/3d/plane/plane3_intersect_plane.js +14 -0
- package/src/core/geom/3d/plane/{plane_three_compute_convex3_plane_intersection.js → plane3_three_compute_convex_3_plane_intersection.js} +7 -4
- package/src/core/geom/3d/plane/planeRayIntersection.js +2 -2
- 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_bounding_simplex_3d.js +5 -5
- 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 +6 -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/EntityBlueprint.d.ts +14 -0
- package/src/engine/ecs/EntityBlueprint.js +2 -2
- package/src/engine/ecs/EntityBlueprint.spec.js +52 -0
- package/src/engine/ecs/EntityBuilder.js +8 -0
- package/src/engine/ecs/EntityManager.d.ts +1 -0
- package/src/engine/ecs/EntityManager.js +17 -213
- package/src/engine/ecs/EntityManager.spec.js +62 -1
- package/src/engine/ecs/System.js +8 -2
- 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/camera/Camera.js +2 -2
- package/src/engine/graphics/ecs/path/entity/EntityPath.js +1 -1
- 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/computeFrustumCorners.js +10 -10
- 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/layers/RenderLayerUtils.js +3 -3
- 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 +3 -1
- 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 +131 -0
- package/src/engine/sound/material/detector/terrain/TerrainSoundMaterialSurfaceDetector.js +2 -2
- package/src/engine/ui/GUIEngine.js +1 -1
- package/src/generation/grid/GridData.js +8 -2
- package/src/generation/grid/GridData.spec.js +5 -0
- package/src/generation/grid/generation/util/buildUnsignedDistanceField.js +3 -1
- package/src/generation/markers/MarkerNode.js +2 -2
- package/src/generation/markers/actions/MarkerNodeActionEntityPlacement.js +1 -1
- package/src/generation/theme/AreaMask.js +3 -1
- package/src/view/elements/progress/RectangularPieProgressView.js +8 -6
- package/src/view/minimap/dom/MinimapCameraView.js +3 -3
- package/src/core/geom/2d/LineSegment2.js +0 -175
- package/src/core/geom/3d/plane/computePlaneRayIntersection.js +0 -55
- 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/generation/grid/MarkerMatchCounter.js +0 -25
- /package/src/engine/physics/spring/{Spring.js → computeHookeForce.js} +0 -0
|
@@ -3,21 +3,25 @@
|
|
|
3
3
|
Algorithm taken from http://geomalgorithms.com/a05-_intersect-1.html. See the
|
|
4
4
|
section 'Intersection of 2 Planes' and specifically the subsection
|
|
5
5
|
(A) Direct Linear Equation
|
|
6
|
+
TODO consolidate with {@link plane3_intersect_plane} as they seem to do the same thing
|
|
6
7
|
@param {Plane} p1
|
|
7
8
|
@param {Plane} p2
|
|
8
|
-
@param {Vector3}
|
|
9
|
-
@param {Vector3}
|
|
9
|
+
@param {Vector3} out_point
|
|
10
|
+
@param {Vector3} out_direction
|
|
10
11
|
@returns {boolean}
|
|
11
12
|
*/
|
|
12
|
-
export function
|
|
13
|
+
export function plane3_compute_plane_intersection(
|
|
14
|
+
p1, p2,
|
|
15
|
+
out_point, out_direction
|
|
16
|
+
) {
|
|
13
17
|
|
|
14
18
|
// the cross product gives us the direction of the line at the intersection
|
|
15
19
|
// of the two planes, and gives us an easy way to check if the two planes
|
|
16
20
|
// are parallel - the cross product will have zero magnitude
|
|
17
21
|
|
|
18
|
-
|
|
22
|
+
out_direction.crossVectors(p1.normal, p2.normal);
|
|
19
23
|
|
|
20
|
-
const magnitude =
|
|
24
|
+
const magnitude = out_direction.lengthSqr();
|
|
21
25
|
|
|
22
26
|
if (magnitude === 0) {
|
|
23
27
|
return false;
|
|
@@ -28,16 +32,16 @@ export function computePlanePlaneIntersection(p1, p2, point, direction) {
|
|
|
28
32
|
// to set as zero by seeing which has the largest absolute value in the
|
|
29
33
|
// directional vector
|
|
30
34
|
|
|
31
|
-
const X = Math.abs(
|
|
32
|
-
const Y = Math.abs(
|
|
33
|
-
const Z = Math.abs(
|
|
35
|
+
const X = Math.abs(out_direction.x);
|
|
36
|
+
const Y = Math.abs(out_direction.y);
|
|
37
|
+
const Z = Math.abs(out_direction.z);
|
|
34
38
|
|
|
35
39
|
if (Z >= X && Z >= Y) {
|
|
36
|
-
solveIntersectingPoint('z', 'x', 'y', p1, p2,
|
|
40
|
+
solveIntersectingPoint('z', 'x', 'y', p1, p2, out_point);
|
|
37
41
|
} else if (Y >= Z && Y >= X) {
|
|
38
|
-
solveIntersectingPoint('y', 'z', 'x', p1, p2,
|
|
42
|
+
solveIntersectingPoint('y', 'z', 'x', p1, p2, out_point);
|
|
39
43
|
} else {
|
|
40
|
-
solveIntersectingPoint('x', 'y', 'z', p1, p2,
|
|
44
|
+
solveIntersectingPoint('x', 'y', 'z', p1, p2, out_point);
|
|
41
45
|
}
|
|
42
46
|
|
|
43
47
|
return true;
|
|
@@ -15,7 +15,7 @@ import { v3_dot } from "../../v3_dot.js";
|
|
|
15
15
|
* @param {number} dist Plane distance
|
|
16
16
|
* @returns {boolean} true if intersection is found, false otherwise
|
|
17
17
|
*/
|
|
18
|
-
export function
|
|
18
|
+
export function plane3_compute_ray_intersection(
|
|
19
19
|
out,
|
|
20
20
|
originX, originY, originZ,
|
|
21
21
|
directionX, directionY, directionZ,
|
|
@@ -29,6 +29,10 @@ export function computePlaneLineIntersection(
|
|
|
29
29
|
|
|
30
30
|
const t = -p / denom;
|
|
31
31
|
|
|
32
|
+
if (t < 0) {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
|
|
32
36
|
out.set(
|
|
33
37
|
directionX * t + originX,
|
|
34
38
|
directionY * t + originY,
|
|
@@ -3,6 +3,20 @@ import Vector3 from "../../Vector3.js";
|
|
|
3
3
|
const v0 = new Vector3();
|
|
4
4
|
const v1 = new Vector3();
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
*
|
|
8
|
+
* @param {Vector3} result_point
|
|
9
|
+
* @param {Vector3} result_direction
|
|
10
|
+
* @param {number} a_normal_x
|
|
11
|
+
* @param {number} a_normal_y
|
|
12
|
+
* @param {number} a_normal_z
|
|
13
|
+
* @param {number} a_constant
|
|
14
|
+
* @param {number} b_normal_x
|
|
15
|
+
* @param {number} b_normal_y
|
|
16
|
+
* @param {number} b_normal_z
|
|
17
|
+
* @param {number} b_constant
|
|
18
|
+
* @return {boolean}
|
|
19
|
+
*/
|
|
6
20
|
export function plane3_intersect_plane(
|
|
7
21
|
result_point,
|
|
8
22
|
result_direction,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { plane3_compute_convex_3_plane_intersection } from "./plane3_compute_convex_3_plane_intersection.js";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Works with THREE.js Plane representations as inputs
|
|
5
5
|
* @param {number[]} result
|
|
6
6
|
* @param {number} result_offset
|
|
7
7
|
* @param {Plane} a
|
|
@@ -9,12 +9,15 @@ import { plane_computeConvex3PlaneIntersection } from "./plane_computeConvex3Pla
|
|
|
9
9
|
* @param {Plane} c
|
|
10
10
|
* @returns {boolean}
|
|
11
11
|
*/
|
|
12
|
-
export function
|
|
12
|
+
export function plane3_three_compute_convex_3_plane_intersection(
|
|
13
|
+
result, result_offset,
|
|
14
|
+
a, b, c
|
|
15
|
+
) {
|
|
13
16
|
const a_normal = a.normal;
|
|
14
17
|
const b_normal = b.normal;
|
|
15
18
|
const c_normal = c.normal;
|
|
16
19
|
|
|
17
|
-
return
|
|
20
|
+
return plane3_compute_convex_3_plane_intersection(
|
|
18
21
|
result,
|
|
19
22
|
result_offset,
|
|
20
23
|
a_normal.x, a_normal.y, a_normal.z, a.constant,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { plane3_compute_ray_intersection } from "./plane3_compute_ray_intersection.js";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
*
|
|
@@ -10,5 +10,5 @@ import { computePlaneRayIntersection } from "./computePlaneRayIntersection.js";
|
|
|
10
10
|
* @returns {boolean} true if intersection is found, false otherwise
|
|
11
11
|
*/
|
|
12
12
|
export function planeRayIntersection(out, origin, direction, normal, dist) {
|
|
13
|
-
return
|
|
13
|
+
return plane3_compute_ray_intersection(out, origin.x, origin.y, origin.z, direction.x, direction.y, direction.z, normal.x, normal.y, normal.z, dist)
|
|
14
14
|
}
|
|
@@ -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,7 +1,7 @@
|
|
|
1
1
|
import { v3_dot } from "../../v3_dot.js";
|
|
2
2
|
import { min2 } from "../../../math/min2.js";
|
|
3
3
|
import { max2 } from "../../../math/max2.js";
|
|
4
|
-
import {
|
|
4
|
+
import { plane3_compute_convex_3_plane_intersection } from "../plane/plane3_compute_convex_3_plane_intersection.js";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Planes used to bound the simplex
|
|
@@ -152,25 +152,25 @@ export function compute_bounding_simplex_3d(
|
|
|
152
152
|
min_d -= padding;
|
|
153
153
|
|
|
154
154
|
// let's compute intersection points for each tri-plane combination to find simplex corners
|
|
155
|
-
|
|
155
|
+
plane3_compute_convex_3_plane_intersection(
|
|
156
156
|
result, result_offset,
|
|
157
157
|
SIMPLEX_PROJECTION_AXES[0], SIMPLEX_PROJECTION_AXES[1], SIMPLEX_PROJECTION_AXES[2], -min_a,
|
|
158
158
|
SIMPLEX_PROJECTION_AXES[3], SIMPLEX_PROJECTION_AXES[4], SIMPLEX_PROJECTION_AXES[5], -min_b,
|
|
159
159
|
SIMPLEX_PROJECTION_AXES[9], SIMPLEX_PROJECTION_AXES[10], SIMPLEX_PROJECTION_AXES[11], -min_d
|
|
160
160
|
);
|
|
161
|
-
|
|
161
|
+
plane3_compute_convex_3_plane_intersection(
|
|
162
162
|
result, result_offset + 3,
|
|
163
163
|
SIMPLEX_PROJECTION_AXES[3], SIMPLEX_PROJECTION_AXES[4], SIMPLEX_PROJECTION_AXES[5], -min_b,
|
|
164
164
|
SIMPLEX_PROJECTION_AXES[6], SIMPLEX_PROJECTION_AXES[7], SIMPLEX_PROJECTION_AXES[8], -min_c,
|
|
165
165
|
SIMPLEX_PROJECTION_AXES[9], SIMPLEX_PROJECTION_AXES[10], SIMPLEX_PROJECTION_AXES[11], -min_d
|
|
166
166
|
);
|
|
167
|
-
|
|
167
|
+
plane3_compute_convex_3_plane_intersection(
|
|
168
168
|
result, result_offset + 6,
|
|
169
169
|
SIMPLEX_PROJECTION_AXES[0], SIMPLEX_PROJECTION_AXES[1], SIMPLEX_PROJECTION_AXES[2], -min_a,
|
|
170
170
|
SIMPLEX_PROJECTION_AXES[3], SIMPLEX_PROJECTION_AXES[4], SIMPLEX_PROJECTION_AXES[5], -min_b,
|
|
171
171
|
SIMPLEX_PROJECTION_AXES[6], SIMPLEX_PROJECTION_AXES[7], SIMPLEX_PROJECTION_AXES[8], -min_c
|
|
172
172
|
);
|
|
173
|
-
|
|
173
|
+
plane3_compute_convex_3_plane_intersection(
|
|
174
174
|
result, result_offset + 9,
|
|
175
175
|
SIMPLEX_PROJECTION_AXES[6], SIMPLEX_PROJECTION_AXES[7], SIMPLEX_PROJECTION_AXES[8], -min_c,
|
|
176
176
|
SIMPLEX_PROJECTION_AXES[0], SIMPLEX_PROJECTION_AXES[1], SIMPLEX_PROJECTION_AXES[2], -min_a,
|
|
@@ -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
|
}
|
|
@@ -136,15 +136,16 @@ class Quaternion {
|
|
|
136
136
|
|
|
137
137
|
up.crossVectors(forward, right);
|
|
138
138
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
139
|
+
// construct partial transform matrix
|
|
140
|
+
const m00 = right.x;
|
|
141
|
+
const m01 = right.y;
|
|
142
|
+
const m02 = right.z;
|
|
143
|
+
const m10 = up.x;
|
|
144
|
+
const m11 = up.y;
|
|
145
|
+
const m12 = up.z;
|
|
146
|
+
const m20 = forward.x;
|
|
147
|
+
const m21 = forward.y;
|
|
148
|
+
const m22 = forward.z;
|
|
148
149
|
|
|
149
150
|
|
|
150
151
|
const num8 = (m00 + m11) + m22;
|
|
@@ -159,22 +160,29 @@ class Quaternion {
|
|
|
159
160
|
_y = (m20 - m02) * num;
|
|
160
161
|
_z = (m01 - m10) * num;
|
|
161
162
|
} else if ((m00 >= m11) && (m00 >= m22)) {
|
|
162
|
-
|
|
163
|
-
|
|
163
|
+
|
|
164
|
+
const num7 = Math.sqrt(((1 + m00) - m11) - m22);
|
|
165
|
+
const num4 = 0.5 / num7;
|
|
166
|
+
|
|
164
167
|
_x = 0.5 * num7;
|
|
165
168
|
_y = (m01 + m10) * num4;
|
|
166
169
|
_z = (m02 + m20) * num4;
|
|
167
170
|
_w = (m12 - m21) * num4;
|
|
171
|
+
|
|
168
172
|
} else if (m11 > m22) {
|
|
169
|
-
|
|
170
|
-
|
|
173
|
+
|
|
174
|
+
const num6 = Math.sqrt(((1 + m11) - m00) - m22);
|
|
175
|
+
const num3 = 0.5 / num6;
|
|
176
|
+
|
|
171
177
|
_x = (m10 + m01) * num3;
|
|
172
178
|
_y = 0.5 * num6;
|
|
173
179
|
_z = (m21 + m12) * num3;
|
|
174
180
|
_w = (m20 - m02) * num3;
|
|
175
181
|
} else {
|
|
176
|
-
|
|
177
|
-
|
|
182
|
+
|
|
183
|
+
const num5 = Math.sqrt(((1 + m22) - m00) - m11);
|
|
184
|
+
const num2 = 0.5 / num5;
|
|
185
|
+
|
|
178
186
|
_x = (m20 + m02) * num2;
|
|
179
187
|
_y = (m21 + m12) * num2;
|
|
180
188
|
_z = 0.5 * num5;
|
|
@@ -359,9 +367,9 @@ class Quaternion {
|
|
|
359
367
|
toAxisAngle(axis) {
|
|
360
368
|
const rad = Math.acos(this.w) * 2.0;
|
|
361
369
|
|
|
362
|
-
const s = Math.sin(rad
|
|
370
|
+
const s = Math.sin(rad * 0.5);
|
|
363
371
|
|
|
364
|
-
if (s > EPSILON) {
|
|
372
|
+
if (Math.abs(s) > EPSILON) {
|
|
365
373
|
axis.set(
|
|
366
374
|
this.x / s,
|
|
367
375
|
this.y / s,
|
|
@@ -378,7 +386,8 @@ class Quaternion {
|
|
|
378
386
|
let l = this.length();
|
|
379
387
|
|
|
380
388
|
if (l < EPSILON) {
|
|
381
|
-
//
|
|
389
|
+
// Quaternion has close to 0 length
|
|
390
|
+
// use identity, avoid division by 0
|
|
382
391
|
this.set(0, 0, 0, 1);
|
|
383
392
|
} else {
|
|
384
393
|
const m = 1 / l;
|
|
@@ -1131,17 +1140,17 @@ class Quaternion {
|
|
|
1131
1140
|
m31, m32, m33
|
|
1132
1141
|
) {
|
|
1133
1142
|
|
|
1134
|
-
assert.notNaN(m11,'m11');
|
|
1135
|
-
assert.notNaN(m12,'m12');
|
|
1136
|
-
assert.notNaN(m13,'m13');
|
|
1143
|
+
assert.notNaN(m11, 'm11');
|
|
1144
|
+
assert.notNaN(m12, 'm12');
|
|
1145
|
+
assert.notNaN(m13, 'm13');
|
|
1137
1146
|
|
|
1138
|
-
assert.notNaN(m21,'m21');
|
|
1139
|
-
assert.notNaN(m22,'m22');
|
|
1140
|
-
assert.notNaN(m23,'m23');
|
|
1147
|
+
assert.notNaN(m21, 'm21');
|
|
1148
|
+
assert.notNaN(m22, 'm22');
|
|
1149
|
+
assert.notNaN(m23, 'm23');
|
|
1141
1150
|
|
|
1142
|
-
assert.notNaN(m31,'m31');
|
|
1143
|
-
assert.notNaN(m32,'m32');
|
|
1144
|
-
assert.notNaN(m33,'m33');
|
|
1151
|
+
assert.notNaN(m31, 'm31');
|
|
1152
|
+
assert.notNaN(m32, 'm32');
|
|
1153
|
+
assert.notNaN(m33, 'm33');
|
|
1145
1154
|
|
|
1146
1155
|
|
|
1147
1156
|
const trace = m11 + m22 + m33;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import Quaternion from "./Quaternion.js";
|
|
2
2
|
import Vector3 from "./Vector3.js";
|
|
3
|
+
import { decode_octahedron_to_unit } from "./3d/normal/octahedron/decode_octahedron_to_unit.js";
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
*
|
|
@@ -260,3 +261,143 @@ test('computeTwistAngle', () => {
|
|
|
260
261
|
expect(q.computeTwistAngle(Vector3.up)).toBeCloseTo(hp * 3);
|
|
261
262
|
|
|
262
263
|
});
|
|
264
|
+
|
|
265
|
+
test("numeric(array) accessors", () => {
|
|
266
|
+
|
|
267
|
+
const q = new Quaternion();
|
|
268
|
+
|
|
269
|
+
q[0] = 3;
|
|
270
|
+
q[1] = -7;
|
|
271
|
+
q[2] = 11;
|
|
272
|
+
q[3] = -13;
|
|
273
|
+
|
|
274
|
+
expect(q[0]).toEqual(3);
|
|
275
|
+
expect(q.x).toEqual(3);
|
|
276
|
+
|
|
277
|
+
expect(q[1]).toEqual(-7);
|
|
278
|
+
expect(q.y).toEqual(-7);
|
|
279
|
+
|
|
280
|
+
expect(q[2]).toEqual(11);
|
|
281
|
+
expect(q.z).toEqual(11);
|
|
282
|
+
|
|
283
|
+
expect(q[3]).toEqual(-13);
|
|
284
|
+
expect(q.w).toEqual(-13);
|
|
285
|
+
});
|
|
286
|
+
|
|
287
|
+
test("forward lookRotation produces identity quaternion ", () => {
|
|
288
|
+
|
|
289
|
+
const q = new Quaternion(1, 3, 4, -7);
|
|
290
|
+
|
|
291
|
+
q.lookRotation(Vector3.forward, Vector3.up);
|
|
292
|
+
|
|
293
|
+
expect(q.roughlyEquals(Quaternion.identity)).toBe(true);
|
|
294
|
+
|
|
295
|
+
});
|
|
296
|
+
|
|
297
|
+
test("lookRotation when FORWARD and UP are the same vectors ", () => {
|
|
298
|
+
|
|
299
|
+
const q = new Quaternion(1, 3, 4, -7);
|
|
300
|
+
|
|
301
|
+
q.lookRotation(Vector3.forward, Vector3.forward);
|
|
302
|
+
|
|
303
|
+
const vec = Vector3.forward.clone();
|
|
304
|
+
|
|
305
|
+
vec.applyQuaternion(q);
|
|
306
|
+
|
|
307
|
+
expect(vec.roughlyEquals(Vector3.forward, 0.001)).toBe(true);
|
|
308
|
+
});
|
|
309
|
+
|
|
310
|
+
test("check lookRotation rotations on octahedron points", () => {
|
|
311
|
+
|
|
312
|
+
const q = new Quaternion(1, 3, 4, -7);
|
|
313
|
+
|
|
314
|
+
const direction_vector_forward_array = [];
|
|
315
|
+
|
|
316
|
+
const direction_vector_forward = new Vector3();
|
|
317
|
+
|
|
318
|
+
const direction_vector_up_array = [];
|
|
319
|
+
|
|
320
|
+
const direction_vector_up = new Vector3();
|
|
321
|
+
|
|
322
|
+
const rotation_vector = new Vector3();
|
|
323
|
+
|
|
324
|
+
const GRID_SIZE = 9;
|
|
325
|
+
|
|
326
|
+
for (let i0 = 0; i0 < GRID_SIZE; i0++) {
|
|
327
|
+
for (let j0 = 0; j0 < GRID_SIZE; j0++) {
|
|
328
|
+
|
|
329
|
+
const u0 = i0 / (GRID_SIZE - 1);
|
|
330
|
+
const v0 = j0 / (GRID_SIZE - 1);
|
|
331
|
+
|
|
332
|
+
// sample direction for FORWARD vector
|
|
333
|
+
decode_octahedron_to_unit(direction_vector_forward_array, 0, u0, v0);
|
|
334
|
+
direction_vector_forward.readFromArray(direction_vector_forward_array);
|
|
335
|
+
|
|
336
|
+
|
|
337
|
+
for (let i1 = 0; i1 < GRID_SIZE; i1++) {
|
|
338
|
+
for (let j1 = 0; j1 < GRID_SIZE; j1++) {
|
|
339
|
+
|
|
340
|
+
const u1 = i1 / (GRID_SIZE - 1);
|
|
341
|
+
const v1 = j1 / (GRID_SIZE - 1);
|
|
342
|
+
|
|
343
|
+
// sample direction for UP vector
|
|
344
|
+
decode_octahedron_to_unit(direction_vector_up_array, 0, u1, v1);
|
|
345
|
+
direction_vector_up.readFromArray(direction_vector_up_array);
|
|
346
|
+
|
|
347
|
+
// obtain quaternion
|
|
348
|
+
q.lookRotation(direction_vector_forward, direction_vector_up);
|
|
349
|
+
|
|
350
|
+
// verify that a vector transformed via this quaternion would produce the same direction as the look direciton
|
|
351
|
+
rotation_vector.copy(Vector3.forward);
|
|
352
|
+
|
|
353
|
+
rotation_vector.applyQuaternion(q);
|
|
354
|
+
|
|
355
|
+
expect(rotation_vector.roughlyEquals(direction_vector_forward, 0.001)).toBe(true);
|
|
356
|
+
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
});
|
|
363
|
+
|
|
364
|
+
test("random produces valid normalized quaternion", () => {
|
|
365
|
+
|
|
366
|
+
const q = new Quaternion();
|
|
367
|
+
|
|
368
|
+
q.random(() => 0);
|
|
369
|
+
|
|
370
|
+
expect(q.length()).toBeCloseTo(1);
|
|
371
|
+
|
|
372
|
+
});
|
|
373
|
+
|
|
374
|
+
test("toAxisAngle on identity", () => {
|
|
375
|
+
const q = new Quaternion();
|
|
376
|
+
|
|
377
|
+
const axis = new Vector3();
|
|
378
|
+
|
|
379
|
+
const angle = q.toAxisAngle(axis);
|
|
380
|
+
|
|
381
|
+
expect(angle).toBeCloseTo(0)
|
|
382
|
+
});
|
|
383
|
+
|
|
384
|
+
test("normalizing quaternion of 0 length produces non-NaN result", () => {
|
|
385
|
+
const q = new Quaternion(0, 0, 0, 0);
|
|
386
|
+
|
|
387
|
+
q.normalize();
|
|
388
|
+
|
|
389
|
+
expect(q.x).not.toBeNaN();
|
|
390
|
+
expect(q.y).not.toBeNaN();
|
|
391
|
+
expect(q.z).not.toBeNaN();
|
|
392
|
+
expect(q.w).not.toBeNaN();
|
|
393
|
+
|
|
394
|
+
expect(q.length()).toBeCloseTo(1);
|
|
395
|
+
});
|
|
396
|
+
|
|
397
|
+
test("angleTo between identical quaternions should be 0", () => {
|
|
398
|
+
|
|
399
|
+
const a = new Quaternion();
|
|
400
|
+
const b = new Quaternion();
|
|
401
|
+
|
|
402
|
+
expect(a.angleTo(b)).toBeCloseTo(0);
|
|
403
|
+
});
|
|
@@ -35,6 +35,10 @@ export default class Vector2 {
|
|
|
35
35
|
|
|
36
36
|
clone(): Vector2
|
|
37
37
|
|
|
38
|
+
equals(other: Vector2): boolean
|
|
39
|
+
|
|
40
|
+
roughlyEquals(other: Vector2, tolerance?: number): boolean
|
|
41
|
+
|
|
38
42
|
distanceTo(other: Vector2): number
|
|
39
43
|
|
|
40
44
|
isZero(): boolean
|
|
@@ -43,5 +47,5 @@ export default class Vector2 {
|
|
|
43
47
|
|
|
44
48
|
writeToArray(array: ArrayLike<number>, offset?: number): void
|
|
45
49
|
|
|
46
|
-
asArray():number[]
|
|
50
|
+
asArray(): number[]
|
|
47
51
|
}
|
package/src/core/geom/Vector2.js
CHANGED
|
@@ -9,6 +9,8 @@ import { clamp } from "../math/clamp.js";
|
|
|
9
9
|
import { lerp } from "../math/lerp.js";
|
|
10
10
|
import { max2 } from "../math/max2.js";
|
|
11
11
|
import { min2 } from "../math/min2.js";
|
|
12
|
+
import { EPSILON } from "../math/EPSILON.js";
|
|
13
|
+
import { epsilonEquals } from "../math/epsilonEquals.js";
|
|
12
14
|
|
|
13
15
|
class Vector2 {
|
|
14
16
|
/**
|
|
@@ -588,6 +590,28 @@ class Vector2 {
|
|
|
588
590
|
return this.x === other.x && this.y === other.y;
|
|
589
591
|
}
|
|
590
592
|
|
|
593
|
+
/**
|
|
594
|
+
*
|
|
595
|
+
* @param {Vector2} other
|
|
596
|
+
* @param {number} [tolerance]
|
|
597
|
+
* @return {boolean}
|
|
598
|
+
*/
|
|
599
|
+
roughlyEquals(other, tolerance) {
|
|
600
|
+
return this._roughlyEquals(other.x, other.y, tolerance);
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
/**
|
|
604
|
+
*
|
|
605
|
+
* @param {number} x
|
|
606
|
+
* @param {number} y
|
|
607
|
+
* @param {number} [tolerance] acceptable deviation
|
|
608
|
+
* @return {boolean}
|
|
609
|
+
*/
|
|
610
|
+
_roughlyEquals(x, y, tolerance = EPSILON) {
|
|
611
|
+
return epsilonEquals(this.x, x, tolerance)
|
|
612
|
+
&& epsilonEquals(this.y, y, tolerance);
|
|
613
|
+
}
|
|
614
|
+
|
|
591
615
|
get 0() {
|
|
592
616
|
return this.x;
|
|
593
617
|
}
|
|
@@ -69,10 +69,16 @@ export default class Vector3 implements Vector3Like {
|
|
|
69
69
|
|
|
70
70
|
clone(): Vector3
|
|
71
71
|
|
|
72
|
+
equals(other: Vector3Like): boolean
|
|
73
|
+
|
|
74
|
+
roughlyEquals(other: Vector3Like, tolerance?: number): boolean
|
|
75
|
+
|
|
72
76
|
normalize(): void
|
|
73
77
|
|
|
74
78
|
length(): number
|
|
75
79
|
|
|
80
|
+
lengthSqr(): number
|
|
81
|
+
|
|
76
82
|
lerpVectors(a: Vector3Like, b: Vector3Like, fraction: number): void
|
|
77
83
|
|
|
78
84
|
distanceTo(other: Vector3Like): number
|