@forgeax/engine-math 0.0.0-dev.8d955ade1c79
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/LICENSE +202 -0
- package/README.md +294 -0
- package/dist/.tsbuildinfo +1 -0
- package/dist/__tests__/_arbs.d.ts +36 -0
- package/dist/__tests__/_arbs.d.ts.map +1 -0
- package/dist/__tests__/_fixtures.d.ts +61 -0
- package/dist/__tests__/_fixtures.d.ts.map +1 -0
- package/dist/__tests__/bounds2.test.d.ts +2 -0
- package/dist/__tests__/bounds2.test.d.ts.map +1 -0
- package/dist/__tests__/box3.test.d.ts +2 -0
- package/dist/__tests__/box3.test.d.ts.map +1 -0
- package/dist/__tests__/easing.test.d.ts +2 -0
- package/dist/__tests__/easing.test.d.ts.map +1 -0
- package/dist/__tests__/euler.test-d.d.ts +2 -0
- package/dist/__tests__/euler.test-d.d.ts.map +1 -0
- package/dist/__tests__/mat3.test-d.d.ts +2 -0
- package/dist/__tests__/mat3.test-d.d.ts.map +1 -0
- package/dist/__tests__/mat4.property.test.d.ts +2 -0
- package/dist/__tests__/mat4.property.test.d.ts.map +1 -0
- package/dist/__tests__/mat4.test-d.d.ts +2 -0
- package/dist/__tests__/mat4.test-d.d.ts.map +1 -0
- package/dist/__tests__/mat4.test.d.ts +2 -0
- package/dist/__tests__/mat4.test.d.ts.map +1 -0
- package/dist/__tests__/noise.test.d.ts +2 -0
- package/dist/__tests__/noise.test.d.ts.map +1 -0
- package/dist/__tests__/quat.basis.test.d.ts +2 -0
- package/dist/__tests__/quat.basis.test.d.ts.map +1 -0
- package/dist/__tests__/quat.interpolation.test.d.ts +2 -0
- package/dist/__tests__/quat.interpolation.test.d.ts.map +1 -0
- package/dist/__tests__/quat.lookat.test.d.ts +2 -0
- package/dist/__tests__/quat.lookat.test.d.ts.map +1 -0
- package/dist/__tests__/quat.property.test.d.ts +2 -0
- package/dist/__tests__/quat.property.test.d.ts.map +1 -0
- package/dist/__tests__/quat.rotateaxis.test.d.ts +2 -0
- package/dist/__tests__/quat.rotateaxis.test.d.ts.map +1 -0
- package/dist/__tests__/quat.test-d.d.ts +2 -0
- package/dist/__tests__/quat.test-d.d.ts.map +1 -0
- package/dist/__tests__/ray.property.test.d.ts +2 -0
- package/dist/__tests__/ray.property.test.d.ts.map +1 -0
- package/dist/__tests__/ray.test.d.ts +2 -0
- package/dist/__tests__/ray.test.d.ts.map +1 -0
- package/dist/__tests__/types.test-d.d.ts +2 -0
- package/dist/__tests__/types.test-d.d.ts.map +1 -0
- package/dist/__tests__/vec-catmull-rom.test.d.ts +2 -0
- package/dist/__tests__/vec-catmull-rom.test.d.ts.map +1 -0
- package/dist/__tests__/vec-smooth-damp.test.d.ts +2 -0
- package/dist/__tests__/vec-smooth-damp.test.d.ts.map +1 -0
- package/dist/__tests__/vec2.test-d.d.ts +2 -0
- package/dist/__tests__/vec2.test-d.d.ts.map +1 -0
- package/dist/__tests__/vec3.property.test.d.ts +2 -0
- package/dist/__tests__/vec3.property.test.d.ts.map +1 -0
- package/dist/__tests__/vec3.test-d.d.ts +2 -0
- package/dist/__tests__/vec3.test-d.d.ts.map +1 -0
- package/dist/__tests__/vec4.test-d.d.ts +2 -0
- package/dist/__tests__/vec4.test-d.d.ts.map +1 -0
- package/dist/_internal/epsilon.d.ts +9 -0
- package/dist/_internal/epsilon.d.ts.map +1 -0
- package/dist/_internal/scalar.d.ts +40 -0
- package/dist/_internal/scalar.d.ts.map +1 -0
- package/dist/box2.d.ts +35 -0
- package/dist/box2.d.ts.map +1 -0
- package/dist/box3.d.ts +76 -0
- package/dist/box3.d.ts.map +1 -0
- package/dist/circle2.d.ts +29 -0
- package/dist/circle2.d.ts.map +1 -0
- package/dist/color.d.ts +64 -0
- package/dist/color.d.ts.map +1 -0
- package/dist/easing.d.ts +18 -0
- package/dist/easing.d.ts.map +1 -0
- package/dist/euler.d.ts +51 -0
- package/dist/euler.d.ts.map +1 -0
- package/dist/f32-to-f16-bytes.d.ts +10 -0
- package/dist/f32-to-f16-bytes.d.ts.map +1 -0
- package/dist/frustum.d.ts +49 -0
- package/dist/frustum.d.ts.map +1 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.mjs +3688 -0
- package/dist/index.mjs.map +1 -0
- package/dist/mat3.d.ts +70 -0
- package/dist/mat3.d.ts.map +1 -0
- package/dist/mat4.d.ts +329 -0
- package/dist/mat4.d.ts.map +1 -0
- package/dist/noise.d.ts +12 -0
- package/dist/noise.d.ts.map +1 -0
- package/dist/quat.d.ts +312 -0
- package/dist/quat.d.ts.map +1 -0
- package/dist/ray.d.ts +144 -0
- package/dist/ray.d.ts.map +1 -0
- package/dist/ray2.d.ts +38 -0
- package/dist/ray2.d.ts.map +1 -0
- package/dist/sphere.d.ts +41 -0
- package/dist/sphere.d.ts.map +1 -0
- package/dist/types.d.ts +57 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/vec2.d.ts +76 -0
- package/dist/vec2.d.ts.map +1 -0
- package/dist/vec3.d.ts +82 -0
- package/dist/vec3.d.ts.map +1 -0
- package/dist/vec4.d.ts +61 -0
- package/dist/vec4.d.ts.map +1 -0
- package/package.json +57 -0
- package/src/__tests__/_arbs.ts +149 -0
- package/src/__tests__/_fixtures.ts +118 -0
- package/src/__tests__/bounds2.test.ts +146 -0
- package/src/__tests__/box3.test.ts +277 -0
- package/src/__tests__/easing.test.ts +109 -0
- package/src/__tests__/euler.test-d.ts +63 -0
- package/src/__tests__/mat3.test-d.ts +47 -0
- package/src/__tests__/mat4.property.test.ts +256 -0
- package/src/__tests__/mat4.test-d.ts +130 -0
- package/src/__tests__/mat4.test.ts +162 -0
- package/src/__tests__/noise.test.ts +75 -0
- package/src/__tests__/quat.basis.test.ts +134 -0
- package/src/__tests__/quat.interpolation.test.ts +45 -0
- package/src/__tests__/quat.lookat.test.ts +103 -0
- package/src/__tests__/quat.property.test.ts +150 -0
- package/src/__tests__/quat.rotateaxis.test.ts +149 -0
- package/src/__tests__/quat.test-d.ts +138 -0
- package/src/__tests__/ray.property.test.ts +105 -0
- package/src/__tests__/ray.test.ts +539 -0
- package/src/__tests__/types.test-d.ts +64 -0
- package/src/__tests__/vec-catmull-rom.test.ts +125 -0
- package/src/__tests__/vec-smooth-damp.test.ts +167 -0
- package/src/__tests__/vec2.test-d.ts +59 -0
- package/src/__tests__/vec3.property.test.ts +72 -0
- package/src/__tests__/vec3.test-d.ts +65 -0
- package/src/__tests__/vec4.test-d.ts +61 -0
- package/src/_internal/epsilon.ts +29 -0
- package/src/_internal/scalar.ts +90 -0
- package/src/box2.ts +168 -0
- package/src/box3.ts +372 -0
- package/src/circle2.ts +134 -0
- package/src/color.ts +177 -0
- package/src/easing.ts +49 -0
- package/src/euler.ts +239 -0
- package/src/f32-to-f16-bytes.ts +71 -0
- package/src/frustum.ts +240 -0
- package/src/index.ts +65 -0
- package/src/mat3.ts +286 -0
- package/src/mat4.ts +1334 -0
- package/src/noise.ts +78 -0
- package/src/quat.ts +847 -0
- package/src/ray.ts +575 -0
- package/src/ray2.ts +198 -0
- package/src/sphere.ts +138 -0
- package/src/types.ts +78 -0
- package/src/vec2.ts +229 -0
- package/src/vec3.ts +294 -0
- package/src/vec4.ts +235 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { fc } from '@fast-check/vitest';
|
|
2
|
+
import type { Mat4, Quat, Vec3, Vec4 } from '../types';
|
|
3
|
+
/** Float32 single add/sub; ULP ≈ 1.19e-7, leaves an 8× margin. */
|
|
4
|
+
export declare const EPS_F32 = 0.00001;
|
|
5
|
+
/** Float32 mat4 × mat4: chained accumulation of 16 muls + 12 adds. */
|
|
6
|
+
export declare const EPS_MAT4_MUL = 0.0001;
|
|
7
|
+
/** Float32 mat4 × mat4 × mat4: associativity test accumulates 3 multiplications on each side. */
|
|
8
|
+
export declare const EPS_MAT4_MUL3 = 0.001;
|
|
9
|
+
/** Quat slerp endpoint / single-step numeric path. */
|
|
10
|
+
export declare const EPS_QUAT = 0.00001;
|
|
11
|
+
/** General 32-bit safe scalar: noNaN + noDefaultInfinity, lies in [-1e3, 1e3]. */
|
|
12
|
+
export declare const safeFloat: (min?: number, max?: number) => fc.Arbitrary<number>;
|
|
13
|
+
/** Safe scalar for matrix elements: [-10, 10], prevents mat4×mat4 element values from inflating ε. */
|
|
14
|
+
export declare const matFloat: () => fc.Arbitrary<number>;
|
|
15
|
+
/** Scale component: keeps away from 0 to avoid singularities ([1e-2, 10] ∪ [-10, -1e-2]). */
|
|
16
|
+
export declare const nonZeroScale: () => fc.Arbitrary<number>;
|
|
17
|
+
/** Generic vec3: three independent safeFloat components. */
|
|
18
|
+
export declare const vec3Arb: () => fc.Arbitrary<Vec3>;
|
|
19
|
+
/** Generic vec4. */
|
|
20
|
+
export declare const vec4Arb: () => fc.Arbitrary<Vec4>;
|
|
21
|
+
/** Non-zero vec3 (len² > 1e-6 to avoid normalize fall-back). */
|
|
22
|
+
export declare const nonZeroVec3Arb: () => fc.Arbitrary<Vec3>;
|
|
23
|
+
/** Scale vector: each component nonZeroScale, used by TRS compose. */
|
|
24
|
+
export declare const scaleVec3Arb: () => fc.Arbitrary<Vec3>;
|
|
25
|
+
/** Unit vec3: normalized non-zero vec3. */
|
|
26
|
+
export declare const unitVec3Arb: () => fc.Arbitrary<Vec3>;
|
|
27
|
+
/** Unit quaternion: 4D-sphere sampling (filter hit rate ≈ 1 since random 4D points have len² > 1e-12). */
|
|
28
|
+
export declare const unitQuatArb: () => fc.Arbitrary<Quat>;
|
|
29
|
+
/** Generic mat4: 16 independent elements ∈ [-10, 10], associativity / identity friendly. */
|
|
30
|
+
export declare const mat4Arb: () => fc.Arbitrary<Mat4>;
|
|
31
|
+
/**
|
|
32
|
+
* Invertible mat4: composed from TRS (translation × rotation × scale) so det ≠ 0 is guaranteed.
|
|
33
|
+
* Random 16 elements are almost always singular, invert returns identity → invertibility test always fails.
|
|
34
|
+
*/
|
|
35
|
+
export declare const invertibleMat4Arb: () => fc.Arbitrary<Mat4>;
|
|
36
|
+
//# sourceMappingURL=_arbs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_arbs.d.ts","sourceRoot":"","sources":["../../src/__tests__/_arbs.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAE,EAAE,EAAE,MAAM,oBAAoB,CAAC;AAExC,OAAO,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAIvD,kEAAkE;AAClE,eAAO,MAAM,OAAO,UAAO,CAAC;AAE5B,sEAAsE;AACtE,eAAO,MAAM,YAAY,SAAO,CAAC;AAEjC,iGAAiG;AACjG,eAAO,MAAM,aAAa,QAAO,CAAC;AAElC,sDAAsD;AACtD,eAAO,MAAM,QAAQ,UAAO,CAAC;AAI7B,kFAAkF;AAClF,eAAO,MAAM,SAAS,GAAI,YAAU,EAAE,YAAS,KAAG,EAAE,CAAC,SAAS,CAAC,MAAM,CAOjE,CAAC;AAEL,sGAAsG;AACtG,eAAO,MAAM,QAAQ,QAAO,EAAE,CAAC,SAAS,CAAC,MAAM,CAM3C,CAAC;AAEL,6FAA6F;AAC7F,eAAO,MAAM,YAAY,QAAO,EAAE,CAAC,SAAS,CAAC,MAAM,CAchD,CAAC;AAIJ,4DAA4D;AAC5D,eAAO,MAAM,OAAO,QAAO,EAAE,CAAC,SAAS,CAAC,IAAI,CAGa,CAAC;AAE1D,oBAAoB;AACpB,eAAO,MAAM,OAAO,QAAO,EAAE,CAAC,SAAS,CAAC,IAAI,CAGmB,CAAC;AAEhE,gEAAgE;AAChE,eAAO,MAAM,cAAc,QAAO,EAAE,CAAC,SAAS,CAAC,IAAI,CAO/C,CAAC;AAEL,sEAAsE;AACtE,eAAO,MAAM,YAAY,QAAO,EAAE,CAAC,SAAS,CAAC,IAAI,CAGQ,CAAC;AAE1D,2CAA2C;AAC3C,eAAO,MAAM,WAAW,QAAO,EAAE,CAAC,SAAS,CAAC,IAAI,CAO5C,CAAC;AAIL,0GAA0G;AAC1G,eAAO,MAAM,WAAW,QAAO,EAAE,CAAC,SAAS,CAAC,IAAI,CAQ1C,CAAC;AAIP,4FAA4F;AAC5F,eAAO,MAAM,OAAO,QAAO,EAAE,CAAC,SAAS,CAAC,IAAI,CAGK,CAAC;AAElD;;;GAGG;AACH,eAAO,MAAM,iBAAiB,QAAO,EAAE,CAAC,SAAS,CAAC,IAAI,CAIlD,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/** AC-05 fixed input: fovy=π/4, aspect=16/9, near=0.1, far=100. */
|
|
2
|
+
export declare const PERSPECTIVE_REVERSE_Z_FINITE_INPUT: {
|
|
3
|
+
readonly fovy: number;
|
|
4
|
+
readonly aspect: number;
|
|
5
|
+
readonly near: 0.1;
|
|
6
|
+
readonly far: 100;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Finite reversed-Z expected matrix (column-major 16 elements, double-precision reference).
|
|
10
|
+
*
|
|
11
|
+
* Numeric derivation:
|
|
12
|
+
* m[0] = (1 / tan(π/8)) / (16/9) = 1.357995128834866
|
|
13
|
+
* m[5] = 1 / tan(π/8) = 2.414213562373095
|
|
14
|
+
* m[10] = near / (far - near) = 0.1 / 99.9 = 0.001001001001001001
|
|
15
|
+
* m[11] = -1
|
|
16
|
+
* m[14] = near * far / (far - near) = 0.10010010010010009
|
|
17
|
+
* m[15] = 0
|
|
18
|
+
*/
|
|
19
|
+
export declare const PERSPECTIVE_REVERSE_Z_FINITE_EXPECTED: ReadonlyArray<number>;
|
|
20
|
+
/**
|
|
21
|
+
* Infinite reversed-Z expected matrix (fovy=π/4, aspect=16/9, near=0.1, far=Infinity).
|
|
22
|
+
*
|
|
23
|
+
* lim(f→∞) m[10] = 0; lim(f→∞) m[14] = near = 0.1.
|
|
24
|
+
*/
|
|
25
|
+
export declare const PERSPECTIVE_REVERSE_Z_INFINITE_EXPECTED: ReadonlyArray<number>;
|
|
26
|
+
/**
|
|
27
|
+
* Projection-correctness check (reversed-Z finite, near=0.1, far=100):
|
|
28
|
+
* feed z_eye into mat4.perspectiveReverseZ and the table below should produce ndc_z.
|
|
29
|
+
*
|
|
30
|
+
* Derivation: p_clip = M @ [0, 0, z_eye, 1]^T; ndc_z = p_clip[2] / p_clip[3].
|
|
31
|
+
*
|
|
32
|
+
* From wiki §7.4 table (n=0.1, f=100):
|
|
33
|
+
* z_eye=-0.1 (near) → ndc_z = 1.0
|
|
34
|
+
* z_eye=-1.0 → ndc_z = 0.09909909909909909
|
|
35
|
+
* z_eye=-10.0 → ndc_z = 0.009009009009009009
|
|
36
|
+
* z_eye=-100.0 (far) → ndc_z = 0.0
|
|
37
|
+
*/
|
|
38
|
+
export declare const REVERSE_Z_PROJECTION_PROBES_FINITE: ReadonlyArray<{
|
|
39
|
+
z_eye: number;
|
|
40
|
+
ndc_z: number;
|
|
41
|
+
}>;
|
|
42
|
+
/**
|
|
43
|
+
* Projection-correctness check (reversed-Z infinite, near=0.1, far=Infinity):
|
|
44
|
+
*
|
|
45
|
+
* From wiki §7.4 table: infinite-far yields ndc_z = -near / z_eye = n / |z_eye| for any z_eye < 0.
|
|
46
|
+
* z_eye=-0.1 (near) → ndc_z = 1.0
|
|
47
|
+
* z_eye=-1.0 → ndc_z = 0.1
|
|
48
|
+
* z_eye=-10.0 → ndc_z = 0.01
|
|
49
|
+
* z_eye=-100.0 → ndc_z = 0.001
|
|
50
|
+
* z_eye=-10000.0 (far frustum out) → ndc_z = 1e-5
|
|
51
|
+
*/
|
|
52
|
+
export declare const REVERSE_Z_PROJECTION_PROBES_INFINITE: ReadonlyArray<{
|
|
53
|
+
z_eye: number;
|
|
54
|
+
ndc_z: number;
|
|
55
|
+
}>;
|
|
56
|
+
/**
|
|
57
|
+
* AC-05 tolerance: vitest `toBeCloseTo(expected, decimals)` with 5 decimals → ≤ 0.5e-5;
|
|
58
|
+
* float32 arithmetic stays within this tolerance vs the float64 reference.
|
|
59
|
+
*/
|
|
60
|
+
export declare const REVERSE_Z_FIXTURE_TOLERANCE = 5;
|
|
61
|
+
//# sourceMappingURL=_fixtures.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_fixtures.d.ts","sourceRoot":"","sources":["../../src/__tests__/_fixtures.ts"],"names":[],"mappings":"AAUA,mEAAmE;AACnE,eAAO,MAAM,kCAAkC;;;;;CAKrC,CAAC;AAEX;;;;;;;;;;GAUG;AACH,eAAO,MAAM,qCAAqC,EAAE,aAAa,CAAC,MAAM,CAiBtE,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,uCAAuC,EAAE,aAAa,CAAC,MAAM,CAiBxE,CAAC;AAEH;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,kCAAkC,EAAE,aAAa,CAAC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAM3F,CAAC;AAEL;;;;;;;;;GASG;AACH,eAAO,MAAM,oCAAoC,EAAE,aAAa,CAAC;IAC/D,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf,CAMC,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,2BAA2B,IAAI,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bounds2.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/bounds2.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"box3.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/box3.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"easing.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/easing.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"euler.test-d.d.ts","sourceRoot":"","sources":["../../src/__tests__/euler.test-d.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mat3.test-d.d.ts","sourceRoot":"","sources":["../../src/__tests__/mat3.test-d.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mat4.property.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/mat4.property.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mat4.test-d.d.ts","sourceRoot":"","sources":["../../src/__tests__/mat4.test-d.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mat4.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/mat4.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"noise.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/noise.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quat.basis.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/quat.basis.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quat.interpolation.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/quat.interpolation.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quat.lookat.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/quat.lookat.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quat.property.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/quat.property.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quat.rotateaxis.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/quat.rotateaxis.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quat.test-d.d.ts","sourceRoot":"","sources":["../../src/__tests__/quat.test-d.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ray.property.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/ray.property.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ray.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/ray.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.test-d.d.ts","sourceRoot":"","sources":["../../src/__tests__/types.test-d.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vec-catmull-rom.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/vec-catmull-rom.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vec-smooth-damp.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/vec-smooth-damp.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vec2.test-d.d.ts","sourceRoot":"","sources":["../../src/__tests__/vec2.test-d.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vec3.property.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/vec3.property.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vec3.test-d.d.ts","sourceRoot":"","sources":["../../src/__tests__/vec3.test-d.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vec4.test-d.d.ts","sourceRoot":"","sources":["../../src/__tests__/vec4.test-d.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** Vector lengths below this value are treated as zero (normalize fall-back). */
|
|
2
|
+
export declare const EPS_NORMALIZE = 1e-12;
|
|
3
|
+
/** Matrix determinants below this value are treated as singular (invert falls back to identity, D-P1). */
|
|
4
|
+
export declare const EPS_DET = 1e-8;
|
|
5
|
+
/** Threshold for treating two unit vectors as nearly collinear / opposite (fromUnitVectors / slerp inputs). */
|
|
6
|
+
export declare const EPS_QUAT_PARALLEL = 0.000001;
|
|
7
|
+
/** In quat.slerp, |dot| above this value is treated as endpoint coincidence; falls back to nlerp (D-P6). */
|
|
8
|
+
export declare const EPS_SLERP_DOT_LIMIT = 0.000001;
|
|
9
|
+
//# sourceMappingURL=epsilon.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"epsilon.d.ts","sourceRoot":"","sources":["../../src/_internal/epsilon.ts"],"names":[],"mappings":"AAkBA,iFAAiF;AACjF,eAAO,MAAM,aAAa,QAAQ,CAAC;AAEnC,0GAA0G;AAC1G,eAAO,MAAM,OAAO,OAAO,CAAC;AAE5B,+GAA+G;AAC/G,eAAO,MAAM,iBAAiB,WAAO,CAAC;AAEtC,4GAA4G;AAC5G,eAAO,MAAM,mBAAmB,WAAO,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Scalar linear interpolation. t is not clamped (extrapolation semantics preserved,
|
|
3
|
+
* matches glam Vec3.lerp / wgpu-matrix).
|
|
4
|
+
*/
|
|
5
|
+
export declare function lerp(a: number, b: number, t: number): number;
|
|
6
|
+
/** Squared length of a four-component numeric value. */
|
|
7
|
+
export declare function lengthSq4(a: ArrayLike<number>): number;
|
|
8
|
+
/** Normalize a four-component numeric value into a typed-array output. */
|
|
9
|
+
export declare function normalize4(out: Float32Array, a: ArrayLike<number>, epsilon: number): void;
|
|
10
|
+
/**
|
|
11
|
+
* Exponential-decay smoothing factor for frame-rate-INDEPENDENT damping:
|
|
12
|
+
* `1 − exp(−decayRate · dt)`. The single value the vec `smoothDamp` helpers interpolate by.
|
|
13
|
+
*
|
|
14
|
+
* SSOT for the smooth-nudge semantics (Bevy `StableInterpolate::smooth_nudge`,
|
|
15
|
+
* three.js `MathUtils.damp`): the returned factor composes multiplicatively over dt —
|
|
16
|
+
* `exp(−k·(a+b)) = exp(−k·a)·exp(−k·b)` — so one step of dt equals two steps of dt/2, the
|
|
17
|
+
* property a naive `rate·dt` factor violates. `dt=0` → 0 (no move); `decayRate·dt → ∞` → 1
|
|
18
|
+
* (snap to target); `decayRate=0` → 0 (no effect). NaN propagates via Math.exp.
|
|
19
|
+
*/
|
|
20
|
+
export declare function smoothDecayFactor(decayRate: number, dt: number): number;
|
|
21
|
+
/**
|
|
22
|
+
* Scalar Catmull-Rom spline value on the segment between `b` and `c`, with `a` / `d` the
|
|
23
|
+
* neighbor control points that set the endpoint tangents. Tension 0.5 (the Catmull-Rom
|
|
24
|
+
* special case of a Cardinal spline, and the Bevy default). SSOT for the vec `catmullRom`
|
|
25
|
+
* helpers — the coefficient matrix lives here once (Bevy `CubicCardinalSpline::char_matrix`
|
|
26
|
+
* with s=0.5):
|
|
27
|
+
* c0 = b
|
|
28
|
+
* c1 = 0.5 (c − a)
|
|
29
|
+
* c2 = a − 2.5 b + 2 c − 0.5 d
|
|
30
|
+
* c3 = −0.5 a + 1.5 b − 1.5 c + 0.5 d
|
|
31
|
+
* value = c0 + c1 t + c2 t² + c3 t³
|
|
32
|
+
* Interpolates the control points: t=0 → b, t=1 → c. `t` is not clamped (extrapolation
|
|
33
|
+
* beyond the segment follows the same cubic, matching `lerp`'s unclamped semantics).
|
|
34
|
+
*/
|
|
35
|
+
export declare function catmullRomScalar(a: number, b: number, c: number, d: number, t: number): number;
|
|
36
|
+
/**
|
|
37
|
+
* Numeric clamp into the closed interval [min, max]. Returns NaN when v is NaN (NaN propagation).
|
|
38
|
+
*/
|
|
39
|
+
export declare function clamp(v: number, min: number, max: number): number;
|
|
40
|
+
//# sourceMappingURL=scalar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scalar.d.ts","sourceRoot":"","sources":["../../src/_internal/scalar.ts"],"names":[],"mappings":"AAUA;;;GAGG;AACH,wBAAgB,IAAI,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAE5D;AAED,wDAAwD;AACxD,wBAAgB,SAAS,CAAC,CAAC,EAAE,SAAS,CAAC,MAAM,CAAC,GAAG,MAAM,CAMtD;AAED,0EAA0E;AAC1E,wBAAgB,UAAU,CAAC,GAAG,EAAE,YAAY,EAAE,CAAC,EAAE,SAAS,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAczF;AAED;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAEvE;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAQ9F;AAED;;GAEG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAIjE"}
|
package/dist/box2.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { Circle2Like } from './circle2';
|
|
2
|
+
import type { Vec2, Vec2Like } from './types';
|
|
3
|
+
/** 2D AABB storage: [minX, minY, maxX, maxY]. */
|
|
4
|
+
export type Box2 = Float32Array & {
|
|
5
|
+
readonly __box2: void;
|
|
6
|
+
};
|
|
7
|
+
/** Readable 2D AABB input. */
|
|
8
|
+
export type Box2Like = ArrayLike<number>;
|
|
9
|
+
/** Create a 2D AABB. The default is the inverted-infinity empty box. */
|
|
10
|
+
export declare function create(minX?: number, minY?: number, maxX?: number, maxY?: number): Box2;
|
|
11
|
+
/** Create an AABB from its center and non-negative half-size. */
|
|
12
|
+
export declare function fromCenter(out: Box2, center: Vec2Like, halfSize: Vec2Like): Box2;
|
|
13
|
+
/** Build the tightest AABB containing the given points. */
|
|
14
|
+
export declare function fromPoints(out: Box2, points: readonly Vec2Like[]): Box2;
|
|
15
|
+
/** Write the box center to out. Empty boxes produce non-finite values. */
|
|
16
|
+
export declare function center(out: Vec2, box: Box2Like): Vec2;
|
|
17
|
+
/** Write the box half-size to out. */
|
|
18
|
+
export declare function halfSize(out: Vec2, box: Box2Like): Vec2;
|
|
19
|
+
/** Write the closest point in the box to point. */
|
|
20
|
+
export declare function closestPoint(out: Vec2, box: Box2Like, point: Vec2Like): Vec2;
|
|
21
|
+
/** True when point is inside the box, including its boundary. */
|
|
22
|
+
export declare function containsPoint(box: Box2Like, point: Vec2Like): boolean;
|
|
23
|
+
/** True when the box completely contains other, including touching edges. */
|
|
24
|
+
export declare function containsBox(box: Box2Like, other: Box2Like): boolean;
|
|
25
|
+
/** True when two boxes overlap, including touching edges. */
|
|
26
|
+
export declare function intersectsBox(a: Box2Like, b: Box2Like): boolean;
|
|
27
|
+
/** True when a box and a circle overlap, including tangent contact. */
|
|
28
|
+
export declare function intersectsCircle(box: Box2Like, circle: Circle2Like): boolean;
|
|
29
|
+
/** Return the smallest box containing a and b. */
|
|
30
|
+
export declare function merge(out: Box2, a: Box2Like, b: Box2Like): Box2;
|
|
31
|
+
/** Grow the box by a non-negative amount on each side. */
|
|
32
|
+
export declare function grow(out: Box2, box: Box2Like, amount: Vec2Like): Box2;
|
|
33
|
+
/** Shrink the box by a non-negative amount on each side. */
|
|
34
|
+
export declare function shrink(out: Box2, box: Box2Like, amount: Vec2Like): Box2;
|
|
35
|
+
//# sourceMappingURL=box2.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"box2.d.ts","sourceRoot":"","sources":["../src/box2.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAE9C,iDAAiD;AACjD,MAAM,MAAM,IAAI,GAAG,YAAY,GAAG;IAAE,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAA;CAAE,CAAC;AAE5D,8BAA8B;AAC9B,MAAM,MAAM,QAAQ,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC;AAEzC,wEAAwE;AACxE,wBAAgB,MAAM,CACpB,IAAI,SAA2B,EAC/B,IAAI,SAA2B,EAC/B,IAAI,SAA2B,EAC/B,IAAI,SAA2B,GAC9B,IAAI,CAEN;AAED,iEAAiE;AACjE,wBAAgB,UAAU,CAAC,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAUhF;AAED,2DAA2D;AAC3D,wBAAgB,UAAU,CAAC,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,QAAQ,EAAE,GAAG,IAAI,CAevE;AAED,0EAA0E;AAC1E,wBAAgB,MAAM,CAAC,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,QAAQ,GAAG,IAAI,CAIrD;AAED,sCAAsC;AACtC,wBAAgB,QAAQ,CAAC,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,QAAQ,GAAG,IAAI,CAIvD;AAED,mDAAmD;AACnD,wBAAgB,YAAY,CAAC,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,GAAG,IAAI,CAU5E;AAED,iEAAiE;AACjE,wBAAgB,aAAa,CAAC,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,GAAG,OAAO,CASrE;AAED,6EAA6E;AAC7E,wBAAgB,WAAW,CAAC,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,GAAG,OAAO,CAOnE;AAED,6DAA6D;AAC7D,wBAAgB,aAAa,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,QAAQ,GAAG,OAAO,CAO/D;AAED,uEAAuE;AACvE,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAoB5E;AAED,kDAAkD;AAClD,wBAAgB,KAAK,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,QAAQ,GAAG,IAAI,CAM/D;AAED,0DAA0D;AAC1D,wBAAgB,IAAI,CAAC,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,GAAG,IAAI,CAQrE;AAED,4DAA4D;AAC5D,wBAAgB,MAAM,CAAC,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,GAAG,IAAI,CAQvE"}
|
package/dist/box3.d.ts
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type { Mat4Like, Vec3Like } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Box3 storage: Float32Array length 6 [minX, minY, minZ, maxX, maxY, maxZ].
|
|
4
|
+
* Local brand (not part of the seven-piece SSOT because bounding volumes are
|
|
5
|
+
* neither linear-algebra primitives nor ECS POD carriers; types.ts SSOT is
|
|
6
|
+
* reserved for vec/mat/quat/color).
|
|
7
|
+
*/
|
|
8
|
+
export type Box3 = Float32Array & {
|
|
9
|
+
readonly __box3: void;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Box3 readable input: ArrayLike<number> of length 6 (ordering identical to Box3).
|
|
13
|
+
*/
|
|
14
|
+
export type Box3Like = ArrayLike<number>;
|
|
15
|
+
/**
|
|
16
|
+
* Create a Box3. Defaults to the "empty" box (min=+Inf, max=-Inf) so the first
|
|
17
|
+
* `expandByPoint` call collapses to a zero-volume box at the input point.
|
|
18
|
+
*/
|
|
19
|
+
export declare function create(minX?: number, minY?: number, minZ?: number, maxX?: number, maxY?: number, maxZ?: number): Box3;
|
|
20
|
+
/**
|
|
21
|
+
* out ∪= point: grow min / max so `point` lies inside (boundary inclusive). Returns out.
|
|
22
|
+
* Works correctly from the default empty box (inverted-infinity) — the first call
|
|
23
|
+
* collapses both min and max to `point`.
|
|
24
|
+
*/
|
|
25
|
+
export declare function expandByPoint(out: Box3, point: Vec3Like): Box3;
|
|
26
|
+
/**
|
|
27
|
+
* True when `point` is inside `box` (boundary inclusive). An empty box
|
|
28
|
+
* (min > max on any axis) contains no points.
|
|
29
|
+
*/
|
|
30
|
+
export declare function containsPoint(box: Box3Like, point: Vec3Like): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* True when `a` and `b` overlap on every axis (boundary inclusive — touching
|
|
33
|
+
* faces intersect). Two empty boxes do not intersect.
|
|
34
|
+
*/
|
|
35
|
+
export declare function intersectsBox(a: Box3Like, b: Box3Like): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Build the tightest AABB enclosing `points`. Writes to `out` in place and
|
|
38
|
+
* returns it. Empty `points` leaves `out` as the inverted-infinity empty box.
|
|
39
|
+
*/
|
|
40
|
+
export declare function fromPoints(out: Box3, points: readonly Vec3Like[]): Box3;
|
|
41
|
+
/**
|
|
42
|
+
* Build the tightest AABB enclosing flattened xyz `positions` (tight-packed,
|
|
43
|
+
* 3 floats per vertex). Writes to `out` in place and returns it.
|
|
44
|
+
*
|
|
45
|
+
* `positions` must have at least 3 elements to produce a non-empty box.
|
|
46
|
+
* Fewer than 3 elements leaves `out` as the inverted-infinity empty box
|
|
47
|
+
* (identical to `create()` default).
|
|
48
|
+
*
|
|
49
|
+
* Trailing elements beyond the last complete triplet are read verbatim
|
|
50
|
+
* (undefined → NaN), matching the legacy `aabbFromPositions` behaviour
|
|
51
|
+
* this function replaces.
|
|
52
|
+
*
|
|
53
|
+
* Related: `fromPoints` for `Vec3Like[]` input.
|
|
54
|
+
*/
|
|
55
|
+
export declare function fromPositions(out: Box3, positions: ArrayLike<number>): Box3;
|
|
56
|
+
/**
|
|
57
|
+
* Transform an AABB by a 4x4 matrix using the conservative 8-corner method.
|
|
58
|
+
*
|
|
59
|
+
* Each of the 8 corners (all min/max combinations) is transformed by `m` as a
|
|
60
|
+
* homogeneous point (w=1), then a new AABB is computed that tightly encloses
|
|
61
|
+
* all 8 transformed points. This is always conservative — the output AABB is
|
|
62
|
+
* guaranteed to contain the true transformed volume (no false culling).
|
|
63
|
+
*
|
|
64
|
+
* Returns `out`. Aliasing-safe: `box` and `out` may be the same reference.
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* ```ts
|
|
68
|
+
* import { box3, mat4 } from '@forgeax/engine-math';
|
|
69
|
+
* const box = box3.create(-1, -1, -1, 1, 1, 1);
|
|
70
|
+
* const xform = mat4.create();
|
|
71
|
+
* mat4.fromTranslation(xform, [5, 0, 0]);
|
|
72
|
+
* box3.transformBox3(box, box, xform);
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
export declare function transformBox3(out: Box3, box: Box3Like, m: Mat4Like): Box3;
|
|
76
|
+
//# sourceMappingURL=box3.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"box3.d.ts","sourceRoot":"","sources":["../src/box3.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAElD;;;;;GAKG;AACH,MAAM,MAAM,IAAI,GAAG,YAAY,GAAG;IAAE,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAA;CAAE,CAAC;AAE5D;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC;AAEzC;;;GAGG;AACH,wBAAgB,MAAM,CACpB,IAAI,GAAE,MAAiC,EACvC,IAAI,GAAE,MAAiC,EACvC,IAAI,GAAE,MAAiC,EACvC,IAAI,GAAE,MAAiC,EACvC,IAAI,GAAE,MAAiC,EACvC,IAAI,GAAE,MAAiC,GACtC,IAAI,CAEN;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,GAAG,IAAI,CAW9D;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,GAAG,OAAO,CAYrE;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,QAAQ,GAAG,OAAO,CAS/D;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,QAAQ,EAAE,GAAG,IAAI,CAoBvE;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,CAAC,MAAM,CAAC,GAAG,IAAI,CAgC3E;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAC,EAAE,QAAQ,GAAG,IAAI,CAgLzE"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import * as box2 from './box2';
|
|
2
|
+
import type { Vec2, Vec2Like } from './types';
|
|
3
|
+
/** 2D bounding circle storage: Float32Array [centerX, centerY, radius]. */
|
|
4
|
+
export type Circle2 = Float32Array & {
|
|
5
|
+
readonly __circle2: void;
|
|
6
|
+
};
|
|
7
|
+
/** Readable 2D bounding-circle input. */
|
|
8
|
+
export type Circle2Like = ArrayLike<number>;
|
|
9
|
+
/** Create a bounding circle. Negative radius is clamped to zero. */
|
|
10
|
+
export declare function create(cx?: number, cy?: number, radius?: number): Circle2;
|
|
11
|
+
/** Build a circle centered at the point-cloud AABB center and enclosing all points. */
|
|
12
|
+
export declare function fromPoints(out: Circle2, points: readonly Vec2Like[]): Circle2;
|
|
13
|
+
/** Build the smallest AABB containing the circle. */
|
|
14
|
+
export declare function toBox(out: box2.Box2, circle: Circle2Like): box2.Box2;
|
|
15
|
+
/** Write the circle center to out. */
|
|
16
|
+
export declare function center(out: Vec2, circle: Circle2Like): Vec2;
|
|
17
|
+
/** Return the circle radius. */
|
|
18
|
+
export declare function radius(circle: Circle2Like): number;
|
|
19
|
+
/** Write the closest point in the circle to point. */
|
|
20
|
+
export declare function closestPoint(out: Vec2, circle: Circle2Like, point: Vec2Like): Vec2;
|
|
21
|
+
/** True when point is inside the circle, including its boundary. */
|
|
22
|
+
export declare function containsPoint(circle: Circle2Like, point: Vec2Like): boolean;
|
|
23
|
+
/** True when two circles overlap, including tangent contact. */
|
|
24
|
+
export declare function intersectsCircle(a: Circle2Like, b: Circle2Like): boolean;
|
|
25
|
+
/** True when the circle overlaps the box, including tangent contact. */
|
|
26
|
+
export declare function intersectsBox(circle: Circle2Like, box: box2.Box2Like): boolean;
|
|
27
|
+
/** Return the smallest circle containing both circles. */
|
|
28
|
+
export declare function merge(out: Circle2, a: Circle2Like, b: Circle2Like): Circle2;
|
|
29
|
+
//# sourceMappingURL=circle2.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"circle2.d.ts","sourceRoot":"","sources":["../src/circle2.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC;AAC/B,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAE9C,2EAA2E;AAC3E,MAAM,MAAM,OAAO,GAAG,YAAY,GAAG;IAAE,QAAQ,CAAC,SAAS,EAAE,IAAI,CAAA;CAAE,CAAC;AAElE,yCAAyC;AACzC,MAAM,MAAM,WAAW,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC;AAE5C,oEAAoE;AACpE,wBAAgB,MAAM,CAAC,EAAE,SAAI,EAAE,EAAE,SAAI,EAAE,MAAM,SAAI,GAAG,OAAO,CAE1D;AAED,uFAAuF;AACvF,wBAAgB,UAAU,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,QAAQ,EAAE,GAAG,OAAO,CAuB7E;AAED,qDAAqD;AACrD,wBAAgB,KAAK,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,GAAG,IAAI,CAAC,IAAI,CASpE;AAED,sCAAsC;AACtC,wBAAgB,MAAM,CAAC,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,GAAG,IAAI,CAI3D;AAED,gCAAgC;AAChC,wBAAgB,MAAM,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,CAElD;AAED,sDAAsD;AACtD,wBAAgB,YAAY,CAAC,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,QAAQ,GAAG,IAAI,CAmBlF;AAED,oEAAoE;AACpE,wBAAgB,aAAa,CAAC,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,QAAQ,GAAG,OAAO,CAK3E;AAED,gEAAgE;AAChE,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,WAAW,GAAG,OAAO,CAKxE;AAED,wEAAwE;AACxE,wBAAgB,aAAa,CAAC,MAAM,EAAE,WAAW,EAAE,GAAG,EAAE,IAAI,CAAC,QAAQ,GAAG,OAAO,CAE9E;AAED,0DAA0D;AAC1D,wBAAgB,KAAK,CAAC,GAAG,EAAE,OAAO,EAAE,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,WAAW,GAAG,OAAO,CAgB3E"}
|
package/dist/color.d.ts
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { Color, ColorLike } from './types';
|
|
2
|
+
export type { Color, ColorLike };
|
|
3
|
+
/** Create a Color (default RGBA = (0, 0, 0, 1) = opaque black). */
|
|
4
|
+
export declare function create(r?: number, g?: number, b?: number, a?: number): Color;
|
|
5
|
+
/** Allocate a new Color copy. */
|
|
6
|
+
export declare function clone(c: ColorLike): Color;
|
|
7
|
+
/**
|
|
8
|
+
* out = sRGB → linear conversion (RGB channels only; alpha passed through).
|
|
9
|
+
*
|
|
10
|
+
* @degrade NaN propagation / negatives returned verbatim (HDR-friendly); alpha is strictly untouched.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* color.srgbToLinear(out, color.create(NaN, -0.1, 0.5, 0.8));
|
|
15
|
+
* // → out = (NaN, -0.1, ~0.214, 0.8); alpha 0.8 passed through unchanged.
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare function srgbToLinear(out: Color, c: ColorLike): Color;
|
|
19
|
+
/**
|
|
20
|
+
* out = linear → sRGB conversion (RGB channels only; alpha passed through).
|
|
21
|
+
*
|
|
22
|
+
* @degrade NaN propagation / negatives returned verbatim; alpha is strictly untouched.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```ts
|
|
26
|
+
* color.linearToSrgb(out, color.create(NaN, -0.05, 0.5, 1));
|
|
27
|
+
* // → out = (NaN, -0.05, ~0.735, 1); alpha is strictly untouched.
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export declare function linearToSrgb(out: Color, c: ColorLike): Color;
|
|
31
|
+
/**
|
|
32
|
+
* Write a Color from a hex string.
|
|
33
|
+
*
|
|
34
|
+
* Only supports the two forms `#RRGGBB` (7 chars) and `#RRGGBBAA` (9 chars) (D-P7);
|
|
35
|
+
* the CSS-style `#RGB` / `#RGBA` short forms are not supported.
|
|
36
|
+
*
|
|
37
|
+
* @degrade Any illegal input (short form / non-hex chars / missing # / wrong length / empty string,
|
|
38
|
+
* etc.) silently falls back to (0, 0, 0, 1); never throws (D-P12 / AC-06).
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```ts
|
|
42
|
+
* color.fromHex(out, '#ff8000'); // → (1, 0.502, 0, 1)
|
|
43
|
+
* color.fromHex(out, '#ff800080'); // → (1, 0.502, 0, 0.502)
|
|
44
|
+
* color.fromHex(out, '#fff'); // → (0, 0, 0, 1) short form unsupported → silent fall-back
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
export declare function fromHex(out: Color, hex: string): Color;
|
|
48
|
+
/**
|
|
49
|
+
* Serialize as hex string: alpha=1 → `#rrggbb`; alpha<1 → `#rrggbbaa`.
|
|
50
|
+
*
|
|
51
|
+
* @degrade Out-of-range components (HDR > 1 / negatives) are clamped to [0, 1] then rounded;
|
|
52
|
+
* **truncated** rather than throwing (symmetric with fromHex's silent fall-back). NaN components →
|
|
53
|
+
* literal '00' (same byte as 0.0; prevents the hex-string builder from throwing; alpha=NaN takes the
|
|
54
|
+
* alpha=1 path, emitting the short `#rrggbb` form).
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```ts
|
|
58
|
+
* color.toHex(color.create(2, -0.1, 0.5, 1)); // → '#ff0080' (HDR/negative clamp)
|
|
59
|
+
* color.toHex(color.create(1, 0, 0, 0.5)); // → '#ff000080'
|
|
60
|
+
* color.toHex(color.create(NaN, 0, 0, NaN)); // → '#000000' (NaN→'00', alpha=NaN takes short form)
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
export declare function toHex(c: ColorLike): string;
|
|
64
|
+
//# sourceMappingURL=color.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"color.d.ts","sourceRoot":"","sources":["../src/color.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEhD,YAAY,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC;AAIjC,mEAAmE;AACnE,wBAAgB,MAAM,CAAC,CAAC,SAAI,EAAE,CAAC,SAAI,EAAE,CAAC,SAAI,EAAE,CAAC,SAAI,GAAG,KAAK,CAExD;AAED,iCAAiC;AACjC,wBAAgB,KAAK,CAAC,CAAC,EAAE,SAAS,GAAG,KAAK,CAEzC;AAgCD;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,KAAK,EAAE,CAAC,EAAE,SAAS,GAAG,KAAK,CAM5D;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,KAAK,EAAE,CAAC,EAAE,SAAS,GAAG,KAAK,CAM5D;AAMD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,GAAG,KAAK,CActD;AAUD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,SAAS,GAAG,MAAM,CAU1C"}
|
package/dist/easing.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** Cubic ease-in-out: Bevy `EaseFunction::CubicInOut`, clamped to [0, 1]. */
|
|
2
|
+
export declare function cubicInOut(t: number): number;
|
|
3
|
+
/**
|
|
4
|
+
* Smoothstep S-curve: `3t² − 2t³` on the clamped input. GLSL `smoothstep` (with edges 0/1),
|
|
5
|
+
* Bevy `EaseFunction::SmoothStep`. f(0)=0, f(1)=1, f′(0)=f′(1)=0 (slow-in / slow-out).
|
|
6
|
+
* Input clamped to [0, 1]. Use to ease a normalized time / lerp factor instead of a linear ramp.
|
|
7
|
+
*/
|
|
8
|
+
export declare function smoothstep(t: number): number;
|
|
9
|
+
/**
|
|
10
|
+
* Smootherstep (Perlin) S-curve: `6t⁵ − 15t⁴ + 10t³` on the clamped input. Bevy
|
|
11
|
+
* `EaseFunction::SmootherStep`. Like {@link smoothstep} but ALSO has zero 2nd derivatives at
|
|
12
|
+
* the endpoints (f″(0)=f″(1)=0), so acceleration is continuous — a gentler, more natural ease.
|
|
13
|
+
* Input clamped to [0, 1].
|
|
14
|
+
*/
|
|
15
|
+
export declare function smootherstep(t: number): number;
|
|
16
|
+
/** Elastic ease-in-out: Bevy `EaseFunction::ElasticInOut`, clamped to [0, 1]. */
|
|
17
|
+
export declare function elasticInOut(t: number): number;
|
|
18
|
+
//# sourceMappingURL=easing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"easing.d.ts","sourceRoot":"","sources":["../src/easing.ts"],"names":[],"mappings":"AAaA,6EAA6E;AAC7E,wBAAgB,UAAU,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAG5C;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAG5C;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAG9C;AAED,iFAAiF;AACjF,wBAAgB,YAAY,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAO9C"}
|