@woosh/meep-engine 2.91.7 → 2.91.8
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/math/euclidean_modulo.d.ts +9 -0
- package/src/core/math/euclidean_modulo.d.ts.map +1 -0
- package/src/core/math/euclidean_modulo.js +12 -0
- package/src/core/math/newton_solver_1d.js +1 -1
- package/src/core/math/pingpong.d.ts.map +1 -1
- package/src/core/math/pingpong.js +2 -8
- package/src/core/math/separation1D.d.ts +4 -4
- package/src/core/math/separation1D.d.ts.map +1 -1
- package/src/core/math/separation1D.js +5 -5
- package/src/core/math/smoothStep.d.ts +2 -0
- package/src/core/math/smoothStep.d.ts.map +1 -1
- package/src/core/math/smoothStep.js +2 -0
- package/src/core/math/smootherStep.d.ts +11 -0
- package/src/core/math/smootherStep.d.ts.map +1 -0
- package/src/core/math/smootherStep.js +19 -0
- package/src/core/math/smootherStep.spec.d.ts +2 -0
- package/src/core/math/smootherStep.spec.d.ts.map +1 -0
- package/src/core/math/smootherStep.spec.js +16 -0
package/package.json
CHANGED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* compute euclidian modulo of n % m
|
|
3
|
+
* https://en.wikipedia.org/wiki/Modulo_operation
|
|
4
|
+
* @param {number} x
|
|
5
|
+
* @param {number} m divisor
|
|
6
|
+
* @returns {number}
|
|
7
|
+
*/
|
|
8
|
+
export function euclidean_modulo(x: number, m: number): number;
|
|
9
|
+
//# sourceMappingURL=euclidean_modulo.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"euclidean_modulo.d.ts","sourceRoot":"","sources":["../../../../src/core/math/euclidean_modulo.js"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,oCAJW,MAAM,KACN,MAAM,GACJ,MAAM,CAMlB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pingpong.d.ts","sourceRoot":"","sources":["../../../../src/core/math/pingpong.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pingpong.d.ts","sourceRoot":"","sources":["../../../../src/core/math/pingpong.js"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,4BAJW,MAAM,WACN,MAAM,GACL,MAAM,CAIjB"}
|
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
// https://en.wikipedia.org/wiki/Modulo_operation
|
|
3
|
-
function euclideanModulo(n, m) {
|
|
4
|
-
|
|
5
|
-
return ((n % m) + m) % m;
|
|
6
|
-
|
|
7
|
-
}
|
|
1
|
+
import { euclidean_modulo } from "./euclidean_modulo.js";
|
|
8
2
|
|
|
9
3
|
/**
|
|
10
4
|
*
|
|
@@ -13,5 +7,5 @@ function euclideanModulo(n, m) {
|
|
|
13
7
|
* @return {number}
|
|
14
8
|
*/
|
|
15
9
|
export function pingpong(x, length = 1) {
|
|
16
|
-
return length - Math.abs(
|
|
10
|
+
return length - Math.abs(euclidean_modulo(x, length * 2) - length);
|
|
17
11
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Returns a number representing overlap distance between two 1D line segments.
|
|
3
3
|
* Positive number indicates overlap, negative number indicates that segments do not overlap; 0 indicates that segments are touching.
|
|
4
|
-
* @param {
|
|
5
|
-
* @param {
|
|
6
|
-
* @param {
|
|
7
|
-
* @param {
|
|
4
|
+
* @param {number} a0
|
|
5
|
+
* @param {number} a1
|
|
6
|
+
* @param {number} b0
|
|
7
|
+
* @param {number} b1
|
|
8
8
|
* @returns {number}
|
|
9
9
|
*/
|
|
10
10
|
export function separation1D(a0: number, a1: number, b0: number, b1: number): number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"separation1D.d.ts","sourceRoot":"","sources":["../../../../src/core/math/separation1D.js"],"names":[],"mappings":"AAIA;;;;;;;;GAQG;AACH,
|
|
1
|
+
{"version":3,"file":"separation1D.d.ts","sourceRoot":"","sources":["../../../../src/core/math/separation1D.js"],"names":[],"mappings":"AAIA;;;;;;;;GAQG;AACH,iCANW,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,GACJ,MAAM,CASlB"}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { assert } from "../assert.js";
|
|
2
|
-
import { min2 } from "./min2.js";
|
|
3
2
|
import { max2 } from "./max2.js";
|
|
3
|
+
import { min2 } from "./min2.js";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Returns a number representing overlap distance between two 1D line segments.
|
|
7
7
|
* Positive number indicates overlap, negative number indicates that segments do not overlap; 0 indicates that segments are touching.
|
|
8
|
-
* @param {
|
|
9
|
-
* @param {
|
|
10
|
-
* @param {
|
|
11
|
-
* @param {
|
|
8
|
+
* @param {number} a0
|
|
9
|
+
* @param {number} a1
|
|
10
|
+
* @param {number} b0
|
|
11
|
+
* @param {number} b1
|
|
12
12
|
* @returns {number}
|
|
13
13
|
*/
|
|
14
14
|
export function separation1D(a0, a1, b0, b1) {
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Adapted from OpenGL spec
|
|
3
3
|
* smoothstep performs smooth Hermite interpolation between 0 and 1 when edge0 < x < edge1. This is useful in cases where a threshold function with a smooth transition is desired.
|
|
4
|
+
* @see https://en.wikipedia.org/wiki/Smoothstep
|
|
4
5
|
* @param {number} edge0
|
|
5
6
|
* @param {number} edge1
|
|
6
7
|
* @param {number} x
|
|
8
|
+
* @returns {number}
|
|
7
9
|
*/
|
|
8
10
|
export function smoothStep(edge0: number, edge1: number, x: number): number;
|
|
9
11
|
//# sourceMappingURL=smoothStep.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"smoothStep.d.ts","sourceRoot":"","sources":["../../../../src/core/math/smoothStep.js"],"names":[],"mappings":"AAEA
|
|
1
|
+
{"version":3,"file":"smoothStep.d.ts","sourceRoot":"","sources":["../../../../src/core/math/smoothStep.js"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,kCALW,MAAM,SACN,MAAM,KACN,MAAM,GACJ,MAAM,CASlB"}
|
|
@@ -3,9 +3,11 @@ import { clamp01 } from "./clamp01.js";
|
|
|
3
3
|
/**
|
|
4
4
|
* Adapted from OpenGL spec
|
|
5
5
|
* smoothstep performs smooth Hermite interpolation between 0 and 1 when edge0 < x < edge1. This is useful in cases where a threshold function with a smooth transition is desired.
|
|
6
|
+
* @see https://en.wikipedia.org/wiki/Smoothstep
|
|
6
7
|
* @param {number} edge0
|
|
7
8
|
* @param {number} edge1
|
|
8
9
|
* @param {number} x
|
|
10
|
+
* @returns {number}
|
|
9
11
|
*/
|
|
10
12
|
export function smoothStep(edge0, edge1, x) {
|
|
11
13
|
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ken Perlin's suggested improvement on `smoothStep` function
|
|
3
|
+
* has gentler entry and exit slope
|
|
4
|
+
* @see https://en.wikipedia.org/wiki/Smoothstep
|
|
5
|
+
* @param {number} edge0
|
|
6
|
+
* @param {number} edge1
|
|
7
|
+
* @param {number} x
|
|
8
|
+
* @returns {number}
|
|
9
|
+
*/
|
|
10
|
+
export function smootherStep(edge0: number, edge1: number, x: number): number;
|
|
11
|
+
//# sourceMappingURL=smootherStep.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"smootherStep.d.ts","sourceRoot":"","sources":["../../../../src/core/math/smootherStep.js"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,oCALW,MAAM,SACN,MAAM,KACN,MAAM,GACJ,MAAM,CASlB"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { clamp01 } from "./clamp01.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Ken Perlin's suggested improvement on `smoothStep` function
|
|
5
|
+
* has gentler entry and exit slope
|
|
6
|
+
* @see https://en.wikipedia.org/wiki/Smoothstep
|
|
7
|
+
* @param {number} edge0
|
|
8
|
+
* @param {number} edge1
|
|
9
|
+
* @param {number} x
|
|
10
|
+
* @returns {number}
|
|
11
|
+
*/
|
|
12
|
+
export function smootherStep(edge0, edge1, x) {
|
|
13
|
+
// Scale, and clamp x to 0..1 range
|
|
14
|
+
const span = edge1 - edge0;
|
|
15
|
+
|
|
16
|
+
const t = clamp01((x - edge0) / span);
|
|
17
|
+
|
|
18
|
+
return t * t * t * (t * (6.0 * t - 15.0) + 10.0);
|
|
19
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"smootherStep.spec.d.ts","sourceRoot":"","sources":["../../../../src/core/math/smootherStep.spec.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { smootherStep } from "./smootherStep.js";
|
|
2
|
+
|
|
3
|
+
test("basics", () => {
|
|
4
|
+
expect(smootherStep(0, 1, 1)).toEqual(1);
|
|
5
|
+
expect(smootherStep(1, 2, 2)).toEqual(1);
|
|
6
|
+
|
|
7
|
+
expect(smootherStep(0, 1, 0)).toEqual(0);
|
|
8
|
+
expect(smootherStep(1, 2, 1)).toEqual(0);
|
|
9
|
+
|
|
10
|
+
expect(smootherStep(0, 1, 0.5)).toBeCloseTo(0.5);
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
test("clamping", () => {
|
|
14
|
+
expect(smootherStep(1, 2, 0)).toEqual(0);
|
|
15
|
+
expect(smootherStep(1, 2, 3)).toEqual(1);
|
|
16
|
+
});
|