@woosh/meep-engine 2.84.1 → 2.84.3
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/build/meep.cjs +20 -20
- package/build/meep.module.js +20 -20
- package/package.json +1 -1
- package/src/core/geom/3d/line/line3_compute_nearest_point_to_point.d.ts +6 -0
- package/src/core/geom/packing/miniball/Miniball.d.ts +2 -0
- package/src/core/geom/vec3/v3_angle_atan2_between.js +27 -0
- package/src/core/geom/vec3/v3_angle_between.js +1 -58
- package/src/core/geom/vec3/v3_angle_cos_between.js +35 -0
- package/src/core/geom/vec3/v3_distance_above_plane.d.ts +4 -0
- package/src/core/math/clamp.d.ts +1 -0
- package/src/core/math/noise/create_simplex_noise_2d.d.ts +1 -0
- package/src/core/math/random/seededRandom.d.ts +1 -0
- package/src/core/math/remap.d.ts +5 -0
- package/src/engine/graphics/camera/camera_compute_distance_to_fit_length.d.ts +1 -1
- package/src/engine/graphics/ecs/path/tube/build/makeTubeGeometry.js +5 -5
- package/src/core/geom/vec3/v3_angle_between_atan2.js +0 -0
package/build/meep.cjs
CHANGED
|
@@ -1978,19 +1978,30 @@ function v3_length(x, y, z) {
|
|
|
1978
1978
|
* @param {number} x1
|
|
1979
1979
|
* @param {number} y1
|
|
1980
1980
|
* @param {number} z1
|
|
1981
|
-
* @returns {number}
|
|
1981
|
+
* @returns {number} value between -1 and 1, cosine of the angle between vectors
|
|
1982
1982
|
*/
|
|
1983
|
-
function
|
|
1983
|
+
function v3_angle_cos_between(
|
|
1984
1984
|
x0, y0, z0,
|
|
1985
1985
|
x1, y1, z1
|
|
1986
1986
|
) {
|
|
1987
1987
|
|
|
1988
|
-
const
|
|
1988
|
+
const d = v3_dot(x0, y0, z0, x1, y1, z1);
|
|
1989
1989
|
|
|
1990
|
-
|
|
1990
|
+
const magnitude_0 = v3_length(x0, y0, z0);
|
|
1991
|
+
const magnitude_1 = v3_length(x1, y1, z1);
|
|
1991
1992
|
|
|
1992
|
-
|
|
1993
|
+
const l = magnitude_0 * magnitude_1;
|
|
1994
|
+
|
|
1995
|
+
if (l === 0) {
|
|
1996
|
+
// collective magnitude is 0, provide arbitrary angle
|
|
1997
|
+
// avoid division by 0
|
|
1998
|
+
return 0;
|
|
1999
|
+
}
|
|
1993
2000
|
|
|
2001
|
+
return clamp$1(d / l, -1, 1);
|
|
2002
|
+
|
|
2003
|
+
}
|
|
2004
|
+
|
|
1994
2005
|
/**
|
|
1995
2006
|
*
|
|
1996
2007
|
* @param {number} x0
|
|
@@ -1999,27 +2010,16 @@ function v3_angle_between(
|
|
|
1999
2010
|
* @param {number} x1
|
|
2000
2011
|
* @param {number} y1
|
|
2001
2012
|
* @param {number} z1
|
|
2002
|
-
* @returns {number}
|
|
2013
|
+
* @returns {number}
|
|
2003
2014
|
*/
|
|
2004
|
-
function
|
|
2015
|
+
function v3_angle_between(
|
|
2005
2016
|
x0, y0, z0,
|
|
2006
2017
|
x1, y1, z1
|
|
2007
2018
|
) {
|
|
2008
2019
|
|
|
2009
|
-
const
|
|
2010
|
-
|
|
2011
|
-
const magnitude_0 = v3_length(x0, y0, z0);
|
|
2012
|
-
const magnitude_1 = v3_length(x1, y1, z1);
|
|
2013
|
-
|
|
2014
|
-
const l = magnitude_0 * magnitude_1;
|
|
2015
|
-
|
|
2016
|
-
if (l === 0) {
|
|
2017
|
-
// collective magnitude is 0, provide arbitrary angle
|
|
2018
|
-
// avoid division by 0
|
|
2019
|
-
return 0;
|
|
2020
|
-
}
|
|
2020
|
+
const theta = v3_angle_cos_between(x0, y0, z0, x1, y1, z1);
|
|
2021
2021
|
|
|
2022
|
-
return
|
|
2022
|
+
return Math.acos(theta);
|
|
2023
2023
|
|
|
2024
2024
|
}
|
|
2025
2025
|
|
package/build/meep.module.js
CHANGED
|
@@ -1976,19 +1976,30 @@ function v3_length(x, y, z) {
|
|
|
1976
1976
|
* @param {number} x1
|
|
1977
1977
|
* @param {number} y1
|
|
1978
1978
|
* @param {number} z1
|
|
1979
|
-
* @returns {number}
|
|
1979
|
+
* @returns {number} value between -1 and 1, cosine of the angle between vectors
|
|
1980
1980
|
*/
|
|
1981
|
-
function
|
|
1981
|
+
function v3_angle_cos_between(
|
|
1982
1982
|
x0, y0, z0,
|
|
1983
1983
|
x1, y1, z1
|
|
1984
1984
|
) {
|
|
1985
1985
|
|
|
1986
|
-
const
|
|
1986
|
+
const d = v3_dot(x0, y0, z0, x1, y1, z1);
|
|
1987
1987
|
|
|
1988
|
-
|
|
1988
|
+
const magnitude_0 = v3_length(x0, y0, z0);
|
|
1989
|
+
const magnitude_1 = v3_length(x1, y1, z1);
|
|
1989
1990
|
|
|
1990
|
-
|
|
1991
|
+
const l = magnitude_0 * magnitude_1;
|
|
1992
|
+
|
|
1993
|
+
if (l === 0) {
|
|
1994
|
+
// collective magnitude is 0, provide arbitrary angle
|
|
1995
|
+
// avoid division by 0
|
|
1996
|
+
return 0;
|
|
1997
|
+
}
|
|
1991
1998
|
|
|
1999
|
+
return clamp$1(d / l, -1, 1);
|
|
2000
|
+
|
|
2001
|
+
}
|
|
2002
|
+
|
|
1992
2003
|
/**
|
|
1993
2004
|
*
|
|
1994
2005
|
* @param {number} x0
|
|
@@ -1997,27 +2008,16 @@ function v3_angle_between(
|
|
|
1997
2008
|
* @param {number} x1
|
|
1998
2009
|
* @param {number} y1
|
|
1999
2010
|
* @param {number} z1
|
|
2000
|
-
* @returns {number}
|
|
2011
|
+
* @returns {number}
|
|
2001
2012
|
*/
|
|
2002
|
-
function
|
|
2013
|
+
function v3_angle_between(
|
|
2003
2014
|
x0, y0, z0,
|
|
2004
2015
|
x1, y1, z1
|
|
2005
2016
|
) {
|
|
2006
2017
|
|
|
2007
|
-
const
|
|
2008
|
-
|
|
2009
|
-
const magnitude_0 = v3_length(x0, y0, z0);
|
|
2010
|
-
const magnitude_1 = v3_length(x1, y1, z1);
|
|
2011
|
-
|
|
2012
|
-
const l = magnitude_0 * magnitude_1;
|
|
2013
|
-
|
|
2014
|
-
if (l === 0) {
|
|
2015
|
-
// collective magnitude is 0, provide arbitrary angle
|
|
2016
|
-
// avoid division by 0
|
|
2017
|
-
return 0;
|
|
2018
|
-
}
|
|
2018
|
+
const theta = v3_angle_cos_between(x0, y0, z0, x1, y1, z1);
|
|
2019
2019
|
|
|
2020
|
-
return
|
|
2020
|
+
return Math.acos(theta);
|
|
2021
2021
|
|
|
2022
2022
|
}
|
|
2023
2023
|
|
package/package.json
CHANGED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { v3_dot } from "./v3_dot.js";
|
|
2
|
+
import { v3_length } from "./v3_length.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @see https://stackoverflow.com/questions/21483999/using-atan2-to-find-angle-between-two-vectors
|
|
6
|
+
* @param {number} x0
|
|
7
|
+
* @param {number} y0
|
|
8
|
+
* @param {number} z0
|
|
9
|
+
* @param {number} x1
|
|
10
|
+
* @param {number} y1
|
|
11
|
+
* @param {number} z1
|
|
12
|
+
* @returns {number}
|
|
13
|
+
*/
|
|
14
|
+
export function v3_angle_atan2_between(
|
|
15
|
+
x0, y0, z0,
|
|
16
|
+
x1, y1, z1
|
|
17
|
+
) {
|
|
18
|
+
const cx = y0 * z1 - z0 * y1;
|
|
19
|
+
const cy = z0 * x1 - x0 * z1;
|
|
20
|
+
const cz = x0 * y1 - y0 * x1;
|
|
21
|
+
|
|
22
|
+
const cross_length = v3_length(cx, cy, cz);
|
|
23
|
+
|
|
24
|
+
const d = v3_dot(x0, y0, z0, x1, y1, z1);
|
|
25
|
+
|
|
26
|
+
return Math.atan2(cross_length, d);
|
|
27
|
+
}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { v3_dot } from "./v3_dot.js";
|
|
3
|
-
import { v3_length } from "./v3_length.js";
|
|
1
|
+
import { v3_angle_cos_between } from "./v3_angle_cos_between.js";
|
|
4
2
|
|
|
5
3
|
/**
|
|
6
4
|
*
|
|
@@ -23,58 +21,3 @@ export function v3_angle_between(
|
|
|
23
21
|
|
|
24
22
|
}
|
|
25
23
|
|
|
26
|
-
/**
|
|
27
|
-
*
|
|
28
|
-
* @param {number} x0
|
|
29
|
-
* @param {number} y0
|
|
30
|
-
* @param {number} z0
|
|
31
|
-
* @param {number} x1
|
|
32
|
-
* @param {number} y1
|
|
33
|
-
* @param {number} z1
|
|
34
|
-
* @returns {number} value between -1 and 1, cosine of the angle between vectors
|
|
35
|
-
*/
|
|
36
|
-
export function v3_angle_cos_between(
|
|
37
|
-
x0, y0, z0,
|
|
38
|
-
x1, y1, z1
|
|
39
|
-
) {
|
|
40
|
-
|
|
41
|
-
const d = v3_dot(x0, y0, z0, x1, y1, z1);
|
|
42
|
-
|
|
43
|
-
const magnitude_0 = v3_length(x0, y0, z0);
|
|
44
|
-
const magnitude_1 = v3_length(x1, y1, z1);
|
|
45
|
-
|
|
46
|
-
const l = magnitude_0 * magnitude_1;
|
|
47
|
-
|
|
48
|
-
if (l === 0) {
|
|
49
|
-
// collective magnitude is 0, provide arbitrary angle
|
|
50
|
-
// avoid division by 0
|
|
51
|
-
return 0;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
return clamp(d / l, -1, 1);
|
|
55
|
-
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* @see https://stackoverflow.com/questions/21483999/using-atan2-to-find-angle-between-two-vectors
|
|
60
|
-
* @param {number} x0
|
|
61
|
-
* @param {number} y0
|
|
62
|
-
* @param {number} z0
|
|
63
|
-
* @param {number} x1
|
|
64
|
-
* @param {number} y1
|
|
65
|
-
* @param {number} z1
|
|
66
|
-
* @returns {number}
|
|
67
|
-
*/
|
|
68
|
-
export function v3_angle_between_atan2(x0, y0, z0, x1, y1, z1) {
|
|
69
|
-
// angle = atan2(norm(cross(a,b)), dot(a,b))
|
|
70
|
-
|
|
71
|
-
const cx = y0 * z1 - z0 * y1;
|
|
72
|
-
const cy = z0 * x1 - x0 * z1;
|
|
73
|
-
const cz = x0 * y1 - y0 * x1;
|
|
74
|
-
|
|
75
|
-
const cross_length = v3_length(cx, cy, cz);
|
|
76
|
-
|
|
77
|
-
const d = v3_dot(x0, y0, z0, x1, y1, z1);
|
|
78
|
-
|
|
79
|
-
return Math.atan2(cross_length, d);
|
|
80
|
-
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { clamp } from "../../math/clamp.js";
|
|
2
|
+
import { v3_dot } from "./v3_dot.js";
|
|
3
|
+
import { v3_length } from "./v3_length.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
* @param {number} x0
|
|
8
|
+
* @param {number} y0
|
|
9
|
+
* @param {number} z0
|
|
10
|
+
* @param {number} x1
|
|
11
|
+
* @param {number} y1
|
|
12
|
+
* @param {number} z1
|
|
13
|
+
* @returns {number} value between -1 and 1, cosine of the angle between vectors
|
|
14
|
+
*/
|
|
15
|
+
export function v3_angle_cos_between(
|
|
16
|
+
x0, y0, z0,
|
|
17
|
+
x1, y1, z1
|
|
18
|
+
) {
|
|
19
|
+
|
|
20
|
+
const d = v3_dot(x0, y0, z0, x1, y1, z1);
|
|
21
|
+
|
|
22
|
+
const magnitude_0 = v3_length(x0, y0, z0);
|
|
23
|
+
const magnitude_1 = v3_length(x1, y1, z1);
|
|
24
|
+
|
|
25
|
+
const l = magnitude_0 * magnitude_1;
|
|
26
|
+
|
|
27
|
+
if (l === 0) {
|
|
28
|
+
// collective magnitude is 0, provide arbitrary angle
|
|
29
|
+
// avoid division by 0
|
|
30
|
+
return 0;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return clamp(d / l, -1, 1);
|
|
34
|
+
|
|
35
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function clamp(value: number, min: number, max: number): number
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function create_simplex_noise_2d(random?: () => number): (x: number, y: number) => number
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function seededRandom(seed?: number): () => number
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export function camera_compute_distance_to_fit_length(length: number, fov: number);
|
|
1
|
+
export declare function camera_compute_distance_to_fit_length(length: number, fov: number): number;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { BufferGeometry, Vector3 } from "three";
|
|
2
|
-
import { StreamGeometryBuilder } from "./StreamGeometryBuilder.js";
|
|
3
|
-
import { CapType } from "../CapType.js";
|
|
4
|
-
import { make_ring_vertices } from "./make_ring_vertices.js";
|
|
5
2
|
import { assert } from "../../../../../../core/assert.js";
|
|
6
|
-
import {
|
|
3
|
+
import { v3_angle_cos_between } from "../../../../../../core/geom/vec3/v3_angle_cos_between.js";
|
|
4
|
+
import { CapType } from "../CapType.js";
|
|
7
5
|
import { append_compute_cap_geometry_size, make_cap } from "./make_cap.js";
|
|
8
|
-
import {
|
|
6
|
+
import { make_ring_faces } from "./make_ring_faces.js";
|
|
7
|
+
import { make_ring_vertices } from "./make_ring_vertices.js";
|
|
8
|
+
import { StreamGeometryBuilder } from "./StreamGeometryBuilder.js";
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
const v4_array = new Float32Array(4);
|
|
File without changes
|