@woosh/meep-engine 2.126.28 → 2.126.30
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/package.json +1 -1
- package/src/core/events/signal/Signal.d.ts.map +1 -1
- package/src/core/events/signal/Signal.js +4 -2
- package/src/core/events/signal/SignalHandler.d.ts +9 -1
- package/src/core/events/signal/SignalHandler.d.ts.map +1 -1
- package/src/core/events/signal/SignalHandler.js +10 -2
- package/src/core/fsm/simple/SimpleStateMachine.js +1 -1
- package/src/core/geom/2d/spline_bezier2_2d.js +3 -3
- package/src/core/geom/3d/tetrahedra/visualize_tetrahedral_mesh.d.ts +2 -2
- package/src/core/geom/3d/tetrahedra/visualize_tetrahedral_mesh.d.ts.map +1 -1
- package/src/core/geom/3d/tetrahedra/visualize_tetrahedral_mesh.js +7 -3
- package/src/core/geom/vec3/serialization/v3_binary_equality_decode.d.ts.map +1 -1
- package/src/core/geom/vec3/serialization/v3_binary_equality_decode.js +16 -1
- package/src/core/geom/vec3/serialization/v3_binary_equality_encode.d.ts.map +1 -1
- package/src/core/geom/vec3/serialization/v3_binary_equality_encode.js +15 -0
- package/src/core/math/spline/cubicCurve.d.ts +3 -3
- package/src/core/math/spline/cubicCurve.js +3 -3
- package/src/core/math/spline/makeCubicCurve.js +2 -2
- package/src/core/math/spline/spline2_bezier.d.ts +10 -0
- package/src/core/math/spline/spline2_bezier.d.ts.map +1 -0
- package/src/core/math/spline/spline2_bezier.js +13 -0
- package/src/core/math/spline/spline3_bezier.d.ts +13 -0
- package/src/core/math/spline/spline3_bezier.d.ts.map +1 -0
- package/src/core/math/spline/spline3_bezier.js +26 -0
- package/src/core/math/spline/spline3_bezier_bounds.d.ts +15 -0
- package/src/core/math/spline/spline3_bezier_bounds.d.ts.map +1 -0
- package/src/core/math/spline/spline3_bezier_bounds.js +89 -0
- package/src/core/math/spline/spline3_bezier_to_hermite.d.ts +15 -0
- package/src/core/math/spline/spline3_bezier_to_hermite.d.ts.map +1 -0
- package/src/core/math/spline/spline3_bezier_to_hermite.js +33 -0
- package/src/core/math/spline/spline3_hermite.d.ts +15 -0
- package/src/core/math/spline/spline3_hermite.d.ts.map +1 -0
- package/src/core/math/spline/spline3_hermite.js +26 -0
- package/src/core/math/spline/spline3_hermite_bounds.d.ts +17 -0
- package/src/core/math/spline/spline3_hermite_bounds.d.ts.map +1 -0
- package/src/core/math/spline/spline3_hermite_bounds.js +102 -0
- package/src/core/math/spline/spline3_hermite_to_bezier.d.ts +13 -0
- package/src/core/math/spline/spline3_hermite_to_bezier.d.ts.map +1 -0
- package/src/core/math/spline/spline3_hermite_to_bezier.js +32 -0
- package/src/core/math/spline/spline_bezier2.d.ts +3 -7
- package/src/core/math/spline/spline_bezier2.d.ts.map +1 -1
- package/src/core/math/spline/spline_bezier2.js +4 -11
- package/src/core/math/spline/spline_bezier3.d.ts +3 -10
- package/src/core/math/spline/spline_bezier3.d.ts.map +1 -1
- package/src/core/math/spline/spline_bezier3.js +4 -24
- package/src/core/math/spline/spline_bezier3_bounds.d.ts +3 -12
- package/src/core/math/spline/spline_bezier3_bounds.d.ts.map +1 -1
- package/src/core/math/spline/spline_bezier3_bounds.js +3 -85
- package/src/core/math/spline/spline_hermite3.d.ts +3 -12
- package/src/core/math/spline/spline_hermite3.d.ts.map +1 -1
- package/src/core/math/spline/spline_hermite3.js +4 -24
- package/src/core/math/spline/spline_hermite3_bounds.d.ts +3 -14
- package/src/core/math/spline/spline_hermite3_bounds.d.ts.map +1 -1
- package/src/core/math/spline/spline_hermite3_bounds.js +3 -98
- package/src/core/math/spline/spline_hermite3_to_bezier.d.ts +1 -12
- package/src/core/math/spline/spline_hermite3_to_bezier.d.ts.map +1 -1
- package/src/core/math/spline/spline_hermite3_to_bezier.js +4 -26
- package/src/engine/animation/curve/animation_curve_compute_aabb.js +2 -2
- package/src/engine/animation/curve/evaluate_two_key_curve.js +2 -2
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { assert } from "../../assert.js";
|
|
2
|
+
import { max2 } from "../max2.js";
|
|
3
|
+
import { min2 } from "../min2.js";
|
|
4
|
+
import { spline3_hermite } from "./spline3_hermite.js";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Compute `y0,y1` bounds of a cubic hermite spline.
|
|
8
|
+
* Lower bound will be written into result[offset], upper bounds will be written into result[offset+result_stride]
|
|
9
|
+
*
|
|
10
|
+
* @param {number[]|Float32Array} result output will be written here, only y0 and y1
|
|
11
|
+
* @param {number} result_offset offset into the result array
|
|
12
|
+
* @param {number} result_stride useful for mixing multidimensional results
|
|
13
|
+
* @param {number} p0
|
|
14
|
+
* @param {number} p1
|
|
15
|
+
* @param {number} m0
|
|
16
|
+
* @param {number} m1
|
|
17
|
+
*
|
|
18
|
+
* @author Alex Goldring
|
|
19
|
+
* @copyright Company Named Limited (c) 2025
|
|
20
|
+
*/
|
|
21
|
+
export function spline3_hermite_bounds(
|
|
22
|
+
result,
|
|
23
|
+
result_offset,
|
|
24
|
+
result_stride,
|
|
25
|
+
p0, p1, m0, m1) {
|
|
26
|
+
|
|
27
|
+
/*
|
|
28
|
+
Solution is based on https://stackoverflow.com/questions/24809978/calculating-the-bounding-box-of-cubic-bezier-curve
|
|
29
|
+
Differentiation of hermite polynomial is done in WolframAlpha:
|
|
30
|
+
0 = 3 t^2 (m0 + m1 + 2 p0 - 2 p1) - 2 t (2 m0 + m1 + 3 p0 - 3 p1) + m0
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
assert.greaterThan(result_stride, 0, 'result_stride must be greater than 0');
|
|
34
|
+
assert.isInteger(result_stride, 'result_stride');
|
|
35
|
+
|
|
36
|
+
const a = 3 * (m0 + m1 + 2 * p0 - 2 * p1);
|
|
37
|
+
const b = -2 * (2 * m0 + m1 + 3 * p0 - 3 * p1);
|
|
38
|
+
const c = m0;
|
|
39
|
+
|
|
40
|
+
let min = min2(p0, p1);
|
|
41
|
+
let max = max2(p0, p1);
|
|
42
|
+
|
|
43
|
+
if (Math.abs(a) < 1e-12) {
|
|
44
|
+
|
|
45
|
+
if (Math.abs(b) >= 1e-12) {
|
|
46
|
+
const t = -c / b;
|
|
47
|
+
|
|
48
|
+
if (0 < t && t < 1) {
|
|
49
|
+
const value = spline3_hermite(t, p0, p1, m0, m1);
|
|
50
|
+
|
|
51
|
+
if (value < min) {
|
|
52
|
+
min = value;
|
|
53
|
+
}
|
|
54
|
+
if (value > max) {
|
|
55
|
+
max = value;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
} else {
|
|
63
|
+
|
|
64
|
+
const b2ac = b * b - 4 * c * a;
|
|
65
|
+
const sqrtb2ac = Math.sqrt(b2ac);
|
|
66
|
+
|
|
67
|
+
if (b2ac >= 0) {
|
|
68
|
+
|
|
69
|
+
const t1 = (-b + sqrtb2ac) / (2 * a);
|
|
70
|
+
|
|
71
|
+
if (0 < t1 && t1 < 1) {
|
|
72
|
+
const value = spline3_hermite(t1, p0, p1, m0, m1);
|
|
73
|
+
|
|
74
|
+
if (value < min) {
|
|
75
|
+
min = value;
|
|
76
|
+
}
|
|
77
|
+
if (value > max) {
|
|
78
|
+
max = value;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const t2 = (-b - sqrtb2ac) / (2 * a);
|
|
83
|
+
|
|
84
|
+
if (0 < t2 && t2 < 1) {
|
|
85
|
+
const value = spline3_hermite(t2, p0, p1, m0, m1);
|
|
86
|
+
|
|
87
|
+
if (value < min) {
|
|
88
|
+
min = value;
|
|
89
|
+
}
|
|
90
|
+
if (value > max) {
|
|
91
|
+
max = value;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
result[result_offset] = min;
|
|
100
|
+
result[result_offset + result_stride] = max;
|
|
101
|
+
}
|
|
102
|
+
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One-dimensional cubic curve conversion from Hermite to bezier
|
|
3
|
+
* @param {Float32Array|number[]} result where to put results
|
|
4
|
+
* @param {number} result_offset offset to start writing at in result array
|
|
5
|
+
* @param {number} result_stride how far to step between each written value. Necessary for N-dimensional curves where we want to interleave multiple curves together, such as for color or quaternions
|
|
6
|
+
* @param {number} p0
|
|
7
|
+
* @param {number} p1
|
|
8
|
+
* @param {number} m0 tangent at p0
|
|
9
|
+
* @param {number} m1 tangent at p1
|
|
10
|
+
* @see spline3_bezier_to_hermite
|
|
11
|
+
*/
|
|
12
|
+
export function spline3_hermite_to_bezier(result: Float32Array | number[], result_offset: number, result_stride: number, p0: number, p1: number, m0: number, m1: number): void;
|
|
13
|
+
//# sourceMappingURL=spline3_hermite_to_bezier.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spline3_hermite_to_bezier.d.ts","sourceRoot":"","sources":["../../../../../src/core/math/spline/spline3_hermite_to_bezier.js"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,kDATW,YAAY,GAAC,MAAM,EAAE,iBACrB,MAAM,iBACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,QAsBhB"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One-dimensional cubic curve conversion from Hermite to bezier
|
|
3
|
+
* @param {Float32Array|number[]} result where to put results
|
|
4
|
+
* @param {number} result_offset offset to start writing at in result array
|
|
5
|
+
* @param {number} result_stride how far to step between each written value. Necessary for N-dimensional curves where we want to interleave multiple curves together, such as for color or quaternions
|
|
6
|
+
* @param {number} p0
|
|
7
|
+
* @param {number} p1
|
|
8
|
+
* @param {number} m0 tangent at p0
|
|
9
|
+
* @param {number} m1 tangent at p1
|
|
10
|
+
* @see spline3_bezier_to_hermite
|
|
11
|
+
*/
|
|
12
|
+
export function spline3_hermite_to_bezier(
|
|
13
|
+
result,
|
|
14
|
+
result_offset,
|
|
15
|
+
result_stride,
|
|
16
|
+
p0, p1,
|
|
17
|
+
m0, m1
|
|
18
|
+
) {
|
|
19
|
+
|
|
20
|
+
// see https://stackoverflow.com/questions/42574940/draw-hermite-curve-on-browser-canvas-javascript
|
|
21
|
+
// see https://pomax.github.io/bezierinfo/#catmullconv
|
|
22
|
+
// see https://github.com/haiku/haiku/blob/eb5f74847eb9d7e1cbfa484064b35f833102f9c5/headers/libs/agg/agg_curves.h#L340
|
|
23
|
+
|
|
24
|
+
const TENSION_FACTOR = 3;
|
|
25
|
+
|
|
26
|
+
result[result_offset + 0 * result_stride] = p0;
|
|
27
|
+
result[result_offset + 1 * result_stride] = p0 + m0 / TENSION_FACTOR;
|
|
28
|
+
result[result_offset + 2 * result_stride] = p1 - m1 / TENSION_FACTOR;
|
|
29
|
+
result[result_offset + 3 * result_stride] = p1;
|
|
30
|
+
|
|
31
|
+
}
|
|
32
|
+
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* @param {number} t
|
|
4
|
-
* @param {number} p0
|
|
5
|
-
* @param {number} p1
|
|
6
|
-
* @param {number} p2
|
|
7
|
-
* @return {number}
|
|
2
|
+
* @deprecated use {@link spline2_bezier}
|
|
8
3
|
*/
|
|
9
|
-
export
|
|
4
|
+
export const spline_bezier2: typeof spline2_bezier;
|
|
5
|
+
import { spline2_bezier } from "./spline2_bezier.js";
|
|
10
6
|
//# sourceMappingURL=spline_bezier2.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spline_bezier2.d.ts","sourceRoot":"","sources":["../../../../../src/core/math/spline/spline_bezier2.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"spline_bezier2.d.ts","sourceRoot":"","sources":["../../../../../src/core/math/spline/spline_bezier2.js"],"names":[],"mappings":"AAEA;;GAEG;AACH,mDAA6C;+BALd,qBAAqB"}
|
|
@@ -1,13 +1,6 @@
|
|
|
1
|
+
import { spline2_bezier } from "./spline2_bezier.js";
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
|
-
*
|
|
3
|
-
* @param {number} t
|
|
4
|
-
* @param {number} p0
|
|
5
|
-
* @param {number} p1
|
|
6
|
-
* @param {number} p2
|
|
7
|
-
* @return {number}
|
|
4
|
+
* @deprecated use {@link spline2_bezier}
|
|
8
5
|
*/
|
|
9
|
-
export
|
|
10
|
-
const inv_t = 1 - t;
|
|
11
|
-
|
|
12
|
-
return inv_t * inv_t * p0 + 2 * inv_t * t * p1 + t * t * p2;
|
|
13
|
-
}
|
|
6
|
+
export const spline_bezier2 = spline2_bezier;
|
|
@@ -1,13 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* @see https://www.youtube.com/watch?v=jvPPXbo87ds&t=234s
|
|
4
|
-
* @see https://en.wikipedia.org/wiki/B%C3%A9zier_curve
|
|
5
|
-
* @param {number} t factor value between 0..1
|
|
6
|
-
* @param {number} p0 start point
|
|
7
|
-
* @param {number} p1 control point
|
|
8
|
-
* @param {number} p2 control point
|
|
9
|
-
* @param {number} p3 end point
|
|
10
|
-
* @returns {number}
|
|
2
|
+
* @deprecated use {@link spline3_bezier}
|
|
11
3
|
*/
|
|
12
|
-
export
|
|
4
|
+
export const spline_bezier3: typeof spline3_bezier;
|
|
5
|
+
import { spline3_bezier } from "./spline3_bezier.js";
|
|
13
6
|
//# sourceMappingURL=spline_bezier3.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spline_bezier3.d.ts","sourceRoot":"","sources":["../../../../../src/core/math/spline/spline_bezier3.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"spline_bezier3.d.ts","sourceRoot":"","sources":["../../../../../src/core/math/spline/spline_bezier3.js"],"names":[],"mappings":"AAEA;;GAEG;AACH,mDAA6C;+BALd,qBAAqB"}
|
|
@@ -1,26 +1,6 @@
|
|
|
1
|
+
import { spline3_bezier } from "./spline3_bezier.js";
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
|
-
*
|
|
3
|
-
* @see https://www.youtube.com/watch?v=jvPPXbo87ds&t=234s
|
|
4
|
-
* @see https://en.wikipedia.org/wiki/B%C3%A9zier_curve
|
|
5
|
-
* @param {number} t factor value between 0..1
|
|
6
|
-
* @param {number} p0 start point
|
|
7
|
-
* @param {number} p1 control point
|
|
8
|
-
* @param {number} p2 control point
|
|
9
|
-
* @param {number} p3 end point
|
|
10
|
-
* @returns {number}
|
|
4
|
+
* @deprecated use {@link spline3_bezier}
|
|
11
5
|
*/
|
|
12
|
-
export
|
|
13
|
-
// first we compute necessary factors for each point
|
|
14
|
-
const nt = 1 - t;
|
|
15
|
-
|
|
16
|
-
const nt_2 = nt * nt;
|
|
17
|
-
|
|
18
|
-
const nt_3 = nt_2 * nt;
|
|
19
|
-
|
|
20
|
-
const t_2 = t * t;
|
|
21
|
-
|
|
22
|
-
const t_3 = t_2 * t;
|
|
23
|
-
|
|
24
|
-
// combine factors with point values to produce final result
|
|
25
|
-
return nt_3 * p0 + 3 * nt_2 * t * p1 + 3 * nt * t_2 * p2 + t_3 * p3;
|
|
26
|
-
}
|
|
6
|
+
export const spline_bezier3 = spline3_bezier;
|
|
@@ -1,15 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* Note that this is a 1d case solver
|
|
4
|
-
* Lower bound will be written into result[offset], upper bounds will be written into result[offset+result_stride]
|
|
5
|
-
* @see https://github.com/adobe-webplatform/Snap.svg/blob/c8e483c9694517e24b282f8f59f985629f4994ce/src/path.js#L856
|
|
6
|
-
* @param {number[]|Float32Array} result
|
|
7
|
-
* @param {number} result_offset offset into the result array
|
|
8
|
-
* @param {number} result_stride
|
|
9
|
-
* @param {number} p0
|
|
10
|
-
* @param {number} p1
|
|
11
|
-
* @param {number} p2
|
|
12
|
-
* @param {number} p3
|
|
2
|
+
* @deprecated use {@link spline3_bezier_bounds}
|
|
13
3
|
*/
|
|
14
|
-
export
|
|
4
|
+
export const spline_bezier3_bounds: typeof spline3_bezier_bounds;
|
|
5
|
+
import { spline3_bezier_bounds } from "./spline3_bezier_bounds.js";
|
|
15
6
|
//# sourceMappingURL=spline_bezier3_bounds.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spline_bezier3_bounds.d.ts","sourceRoot":"","sources":["../../../../../src/core/math/spline/spline_bezier3_bounds.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"spline_bezier3_bounds.d.ts","sourceRoot":"","sources":["../../../../../src/core/math/spline/spline_bezier3_bounds.js"],"names":[],"mappings":"AAEA;;GAEG;AACH,iEAA2D;sCALrB,4BAA4B"}
|
|
@@ -1,88 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { max2 } from "../max2.js";
|
|
3
|
-
import { min2 } from "../min2.js";
|
|
4
|
-
import { spline_bezier3 } from './spline_bezier3.js'
|
|
1
|
+
import { spline3_bezier_bounds } from "./spline3_bezier_bounds.js";
|
|
5
2
|
|
|
6
3
|
/**
|
|
7
|
-
*
|
|
8
|
-
* Note that this is a 1d case solver
|
|
9
|
-
* Lower bound will be written into result[offset], upper bounds will be written into result[offset+result_stride]
|
|
10
|
-
* @see https://github.com/adobe-webplatform/Snap.svg/blob/c8e483c9694517e24b282f8f59f985629f4994ce/src/path.js#L856
|
|
11
|
-
* @param {number[]|Float32Array} result
|
|
12
|
-
* @param {number} result_offset offset into the result array
|
|
13
|
-
* @param {number} result_stride
|
|
14
|
-
* @param {number} p0
|
|
15
|
-
* @param {number} p1
|
|
16
|
-
* @param {number} p2
|
|
17
|
-
* @param {number} p3
|
|
4
|
+
* @deprecated use {@link spline3_bezier_bounds}
|
|
18
5
|
*/
|
|
19
|
-
export
|
|
20
|
-
assert.greaterThan(result_stride, 0, 'result_stride must be greater than 0');
|
|
21
|
-
assert.isInteger(result_stride, 'result_stride');
|
|
22
|
-
|
|
23
|
-
const b = 6 * p0 - 12 * p1 + 6 * p2;
|
|
24
|
-
const a = -3 * p0 + 9 * p1 - 9 * p2 + 3 * p3;
|
|
25
|
-
const c = 3 * p1 - 3 * p0;
|
|
26
|
-
|
|
27
|
-
let min = min2(p0, p3);
|
|
28
|
-
let max = max2(p0, p3);
|
|
29
|
-
|
|
30
|
-
if (Math.abs(a) < 1e-12) {
|
|
31
|
-
|
|
32
|
-
if (Math.abs(b) >= 1e-12) {
|
|
33
|
-
const t = -c / b;
|
|
34
|
-
|
|
35
|
-
if (0 < t && t < 1) {
|
|
36
|
-
const value = spline_bezier3(t, p0, p1, p2, p3);
|
|
37
|
-
|
|
38
|
-
if (value < min) {
|
|
39
|
-
min = value;
|
|
40
|
-
}
|
|
41
|
-
if (value > max) {
|
|
42
|
-
max = value;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
} else {
|
|
50
|
-
|
|
51
|
-
const b2ac = b * b - 4 * c * a;
|
|
52
|
-
const sqrtb2ac = Math.sqrt(b2ac);
|
|
53
|
-
|
|
54
|
-
if (b2ac >= 0) {
|
|
55
|
-
|
|
56
|
-
const t1 = (-b + sqrtb2ac) / (2 * a);
|
|
57
|
-
|
|
58
|
-
if (0 < t1 && t1 < 1) {
|
|
59
|
-
const value = spline_bezier3(t1, p0, p1, p2, p3);
|
|
60
|
-
|
|
61
|
-
if (value < min) {
|
|
62
|
-
min = value;
|
|
63
|
-
}
|
|
64
|
-
if (value > max) {
|
|
65
|
-
max = value;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
const t2 = (-b - sqrtb2ac) / (2 * a);
|
|
70
|
-
|
|
71
|
-
if (0 < t2 && t2 < 1) {
|
|
72
|
-
const value = spline_bezier3(t2, p0, p1, p2, p3);
|
|
73
|
-
|
|
74
|
-
if (value < min) {
|
|
75
|
-
min = value;
|
|
76
|
-
}
|
|
77
|
-
if (value > max) {
|
|
78
|
-
max = value;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
result[result_offset] = min;
|
|
87
|
-
result[result_offset + result_stride] = max;
|
|
88
|
-
}
|
|
6
|
+
export const spline_bezier3_bounds = spline3_bezier_bounds;
|
|
@@ -1,15 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* @see https://en.wikipedia.org/wiki/Cubic_Hermite_spline
|
|
4
|
-
* @param {number} t normalized interpolation position in interval [0,1]
|
|
5
|
-
* @param {number} p0 first value
|
|
6
|
-
* @param {number} p1 second value
|
|
7
|
-
* @param {number} m0 first tangent (tangent exiting from first value)
|
|
8
|
-
* @param {number} m1 second tangent (tangent entering into second value)
|
|
9
|
-
* @return {number}
|
|
10
|
-
*
|
|
11
|
-
* @author Alex Goldring
|
|
12
|
-
* @copyright Company Named Limited (c) 2025
|
|
2
|
+
* @deprecated use {@link spline3_hermite}
|
|
13
3
|
*/
|
|
14
|
-
export
|
|
4
|
+
export const spline_hermite3: typeof spline3_hermite;
|
|
5
|
+
import { spline3_hermite } from "./spline3_hermite.js";
|
|
15
6
|
//# sourceMappingURL=spline_hermite3.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spline_hermite3.d.ts","sourceRoot":"","sources":["../../../../../src/core/math/spline/spline_hermite3.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"spline_hermite3.d.ts","sourceRoot":"","sources":["../../../../../src/core/math/spline/spline_hermite3.js"],"names":[],"mappings":"AAEA;;GAEG;AACH,qDAA+C;gCALf,sBAAsB"}
|
|
@@ -1,26 +1,6 @@
|
|
|
1
|
+
import { spline3_hermite } from "./spline3_hermite.js";
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
|
-
*
|
|
3
|
-
* @see https://en.wikipedia.org/wiki/Cubic_Hermite_spline
|
|
4
|
-
* @param {number} t normalized interpolation position in interval [0,1]
|
|
5
|
-
* @param {number} p0 first value
|
|
6
|
-
* @param {number} p1 second value
|
|
7
|
-
* @param {number} m0 first tangent (tangent exiting from first value)
|
|
8
|
-
* @param {number} m1 second tangent (tangent entering into second value)
|
|
9
|
-
* @return {number}
|
|
10
|
-
*
|
|
11
|
-
* @author Alex Goldring
|
|
12
|
-
* @copyright Company Named Limited (c) 2025
|
|
4
|
+
* @deprecated use {@link spline3_hermite}
|
|
13
5
|
*/
|
|
14
|
-
export
|
|
15
|
-
|
|
16
|
-
const t2 = t * t;
|
|
17
|
-
const t3 = t2 * t;
|
|
18
|
-
|
|
19
|
-
const a = 2 * t3 - 3 * t2 + 1;
|
|
20
|
-
const b = t3 - 2 * t2 + t;
|
|
21
|
-
const c = t3 - t2;
|
|
22
|
-
const d = -2 * t3 + 3 * t2;
|
|
23
|
-
|
|
24
|
-
return a * p0 + b * m0 + c * m1 + d * p1;
|
|
25
|
-
}
|
|
26
|
-
|
|
6
|
+
export const spline_hermite3 = spline3_hermite;
|
|
@@ -1,17 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* Lower bound will be written into result[offset], upper bounds will be written into result[offset+result_stride]
|
|
4
|
-
*
|
|
5
|
-
* @param {number[]|Float32Array} result output will be written here, only y0 and y1
|
|
6
|
-
* @param {number} result_offset offset into the result array
|
|
7
|
-
* @param {number} result_stride useful for mixing multidimensional results
|
|
8
|
-
* @param {number} p0
|
|
9
|
-
* @param {number} p1
|
|
10
|
-
* @param {number} m0
|
|
11
|
-
* @param {number} m1
|
|
12
|
-
*
|
|
13
|
-
* @author Alex Goldring
|
|
14
|
-
* @copyright Company Named Limited (c) 2025
|
|
2
|
+
* @deprecated use {@link spline3_hermite_bounds}
|
|
15
3
|
*/
|
|
16
|
-
export
|
|
4
|
+
export const spline_hermite3_bounds: typeof spline3_hermite_bounds;
|
|
5
|
+
import { spline3_hermite_bounds } from "./spline3_hermite_bounds.js";
|
|
17
6
|
//# sourceMappingURL=spline_hermite3_bounds.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spline_hermite3_bounds.d.ts","sourceRoot":"","sources":["../../../../../src/core/math/spline/spline_hermite3_bounds.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"spline_hermite3_bounds.d.ts","sourceRoot":"","sources":["../../../../../src/core/math/spline/spline_hermite3_bounds.js"],"names":[],"mappings":"AAEA;;GAEG;AACH,mEAA6D;uCALtB,6BAA6B"}
|
|
@@ -1,101 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { max2 } from "../max2.js";
|
|
3
|
-
import { min2 } from "../min2.js";
|
|
4
|
-
import { spline_hermite3 } from "./spline_hermite3.js";
|
|
1
|
+
import { spline3_hermite_bounds } from "./spline3_hermite_bounds.js";
|
|
5
2
|
|
|
6
3
|
/**
|
|
7
|
-
*
|
|
8
|
-
* Lower bound will be written into result[offset], upper bounds will be written into result[offset+result_stride]
|
|
9
|
-
*
|
|
10
|
-
* @param {number[]|Float32Array} result output will be written here, only y0 and y1
|
|
11
|
-
* @param {number} result_offset offset into the result array
|
|
12
|
-
* @param {number} result_stride useful for mixing multidimensional results
|
|
13
|
-
* @param {number} p0
|
|
14
|
-
* @param {number} p1
|
|
15
|
-
* @param {number} m0
|
|
16
|
-
* @param {number} m1
|
|
17
|
-
*
|
|
18
|
-
* @author Alex Goldring
|
|
19
|
-
* @copyright Company Named Limited (c) 2025
|
|
4
|
+
* @deprecated use {@link spline3_hermite_bounds}
|
|
20
5
|
*/
|
|
21
|
-
export
|
|
22
|
-
result,
|
|
23
|
-
result_offset,
|
|
24
|
-
result_stride,
|
|
25
|
-
p0, p1, m0, m1) {
|
|
26
|
-
|
|
27
|
-
/*
|
|
28
|
-
Solution is based on https://stackoverflow.com/questions/24809978/calculating-the-bounding-box-of-cubic-bezier-curve
|
|
29
|
-
Differentiation of hermite polynomial is done in WolframAlpha:
|
|
30
|
-
0 = 3 t^2 (m0 + m1 + 2 p0 - 2 p1) - 2 t (2 m0 + m1 + 3 p0 - 3 p1) + m0
|
|
31
|
-
*/
|
|
32
|
-
|
|
33
|
-
assert.greaterThan(result_stride, 0, 'result_stride must be greater than 0');
|
|
34
|
-
assert.isInteger(result_stride, 'result_stride');
|
|
35
|
-
|
|
36
|
-
const a = 3 * (m0 + m1 + 2 * p0 - 2 * p1);
|
|
37
|
-
const b = -2 * (2 * m0 + m1 + 3 * p0 - 3 * p1);
|
|
38
|
-
const c = m0;
|
|
39
|
-
|
|
40
|
-
let min = min2(p0, p1);
|
|
41
|
-
let max = max2(p0, p1);
|
|
42
|
-
|
|
43
|
-
if (Math.abs(a) < 1e-12) {
|
|
44
|
-
|
|
45
|
-
if (Math.abs(b) >= 1e-12) {
|
|
46
|
-
const t = -c / b;
|
|
47
|
-
|
|
48
|
-
if (0 < t && t < 1) {
|
|
49
|
-
const value = spline_hermite3(t, p0, p1, m0, m1);
|
|
50
|
-
|
|
51
|
-
if (value < min) {
|
|
52
|
-
min = value;
|
|
53
|
-
}
|
|
54
|
-
if (value > max) {
|
|
55
|
-
max = value;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
} else {
|
|
63
|
-
|
|
64
|
-
const b2ac = b * b - 4 * c * a;
|
|
65
|
-
const sqrtb2ac = Math.sqrt(b2ac);
|
|
66
|
-
|
|
67
|
-
if (b2ac >= 0) {
|
|
68
|
-
|
|
69
|
-
const t1 = (-b + sqrtb2ac) / (2 * a);
|
|
70
|
-
|
|
71
|
-
if (0 < t1 && t1 < 1) {
|
|
72
|
-
const value = spline_hermite3(t1, p0, p1, m0, m1);
|
|
73
|
-
|
|
74
|
-
if (value < min) {
|
|
75
|
-
min = value;
|
|
76
|
-
}
|
|
77
|
-
if (value > max) {
|
|
78
|
-
max = value;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
const t2 = (-b - sqrtb2ac) / (2 * a);
|
|
83
|
-
|
|
84
|
-
if (0 < t2 && t2 < 1) {
|
|
85
|
-
const value = spline_hermite3(t2, p0, p1, m0, m1);
|
|
86
|
-
|
|
87
|
-
if (value < min) {
|
|
88
|
-
min = value;
|
|
89
|
-
}
|
|
90
|
-
if (value > max) {
|
|
91
|
-
max = value;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
result[result_offset] = min;
|
|
100
|
-
result[result_offset + result_stride] = max;
|
|
101
|
-
}
|
|
6
|
+
export const spline_hermite3_bounds = spline3_hermite_bounds;
|
|
@@ -1,13 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
* One-dimensional curve conversion from cubic Hermite to bezier
|
|
3
|
-
* TODO: not tested
|
|
4
|
-
* @param {Float32Array|number[]} result where to put results
|
|
5
|
-
* @param {number} result_offset offset to start writing at in result array
|
|
6
|
-
* @param {number} result_stride how far to step between each written value. Necessary for N-dimensional curves where we want to interleave multiple curves together, such as for color or quaternions
|
|
7
|
-
* @param {number} p0
|
|
8
|
-
* @param {number} p1
|
|
9
|
-
* @param {number} m0 tangent at p0
|
|
10
|
-
* @param {number} m1 tangent at p1
|
|
11
|
-
*/
|
|
12
|
-
export function spline_hermite3_to_bezier(result: Float32Array | number[], result_offset: number, result_stride: number, p0: number, p1: number, m0: number, m1: number): void;
|
|
1
|
+
export {};
|
|
13
2
|
//# sourceMappingURL=spline_hermite3_to_bezier.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spline_hermite3_to_bezier.d.ts","sourceRoot":"","sources":["../../../../../src/core/math/spline/spline_hermite3_to_bezier.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"spline_hermite3_to_bezier.d.ts","sourceRoot":"","sources":["../../../../../src/core/math/spline/spline_hermite3_to_bezier.js"],"names":[],"mappings":""}
|
|
@@ -1,28 +1,6 @@
|
|
|
1
|
+
import { spline3_hermite_to_bezier } from "./spline3_hermite_to_bezier.js";
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
|
-
*
|
|
3
|
-
* TODO: not tested
|
|
4
|
-
* @param {Float32Array|number[]} result where to put results
|
|
5
|
-
* @param {number} result_offset offset to start writing at in result array
|
|
6
|
-
* @param {number} result_stride how far to step between each written value. Necessary for N-dimensional curves where we want to interleave multiple curves together, such as for color or quaternions
|
|
7
|
-
* @param {number} p0
|
|
8
|
-
* @param {number} p1
|
|
9
|
-
* @param {number} m0 tangent at p0
|
|
10
|
-
* @param {number} m1 tangent at p1
|
|
4
|
+
* @deprecated use {@link spline3_hermite_to_bezier}
|
|
11
5
|
*/
|
|
12
|
-
|
|
13
|
-
result,
|
|
14
|
-
result_offset,
|
|
15
|
-
result_stride,
|
|
16
|
-
p0, p1,
|
|
17
|
-
m0, m1
|
|
18
|
-
) {
|
|
19
|
-
|
|
20
|
-
// see https://stackoverflow.com/questions/42574940/draw-hermite-curve-on-browser-canvas-javascript
|
|
21
|
-
// see https://pomax.github.io/bezierinfo/#catmullconv
|
|
22
|
-
|
|
23
|
-
result[result_offset + 0 * result_stride] = p0;
|
|
24
|
-
result[result_offset + 1 * result_stride] = p0 + m0 / 3;
|
|
25
|
-
result[result_offset + 2 * result_stride] = p1 - m1 / 3;
|
|
26
|
-
result[result_offset + 3 * result_stride] = p1;
|
|
27
|
-
|
|
28
|
-
}
|
|
6
|
+
const spline_hermite3_to_bezier = spline3_hermite_to_bezier;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { max2 } from "../../../core/math/max2.js";
|
|
2
2
|
import { min2 } from "../../../core/math/min2.js";
|
|
3
|
-
import {
|
|
3
|
+
import { spline3_hermite_bounds } from "../../../core/math/spline/spline3_hermite_bounds.js";
|
|
4
4
|
|
|
5
5
|
const temp_bounds = new Float32Array(2);
|
|
6
6
|
|
|
@@ -33,7 +33,7 @@ export function animation_curve_compute_aabb(out, curve) {
|
|
|
33
33
|
|
|
34
34
|
const time_delta = keyframe.time - previous.time;
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
spline3_hermite_bounds(temp_bounds, 0, 1,
|
|
37
37
|
previous.value, keyframe.value,
|
|
38
38
|
previous.outTangent * time_delta,
|
|
39
39
|
keyframe.inTangent * time_delta
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { inverseLerp } from "../../../core/math/inverseLerp.js";
|
|
2
|
-
import {
|
|
2
|
+
import { spline3_hermite } from "../../../core/math/spline/spline3_hermite.js";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
*
|
|
@@ -14,7 +14,7 @@ export function evaluate_two_key_curve(time, keyframe0, keyframe1) {
|
|
|
14
14
|
|
|
15
15
|
const time_distance = keyframe1.time - keyframe0.time;
|
|
16
16
|
|
|
17
|
-
return
|
|
17
|
+
return spline3_hermite(
|
|
18
18
|
normalized_time,
|
|
19
19
|
keyframe0.value, keyframe1.value,
|
|
20
20
|
keyframe0.outTangent * time_distance,
|