math 0.0.3 → 0.1.0
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/API.md +1605 -0
- package/LICENSE +21 -0
- package/README.md +197 -0
- package/dist/color/color.js +136 -0
- package/dist/color/color.js.map +1 -0
- package/dist/color/colorspace.js +43 -0
- package/dist/color/colorspace.js.map +1 -0
- package/dist/color/hsl.js +123 -0
- package/dist/color/hsl.js.map +1 -0
- package/dist/color/index.js +7 -0
- package/dist/color/index.js.map +1 -0
- package/dist/color/parse.js +276 -0
- package/dist/color/parse.js.map +1 -0
- package/dist/core/angle.js +43 -0
- package/dist/core/angle.js.map +1 -0
- package/dist/core/euler.js +212 -0
- package/dist/core/euler.js.map +1 -0
- package/dist/core/mat2.js +385 -0
- package/dist/core/mat2.js.map +1 -0
- package/dist/core/mat2d.js +422 -0
- package/dist/core/mat2d.js.map +1 -0
- package/dist/core/mat3.js +749 -0
- package/dist/core/mat3.js.map +1 -0
- package/dist/core/mat4.js +2197 -0
- package/dist/core/mat4.js.map +1 -0
- package/dist/core/polar.js +200 -0
- package/dist/core/polar.js.map +1 -0
- package/dist/core/quat.js +730 -0
- package/dist/core/quat.js.map +1 -0
- package/dist/core/quat2.js +883 -0
- package/dist/core/quat2.js.map +1 -0
- package/dist/core/scalar.js +112 -0
- package/dist/core/scalar.js.map +1 -0
- package/dist/core/spherical.js +248 -0
- package/dist/core/spherical.js.map +1 -0
- package/dist/core/vec2.js +597 -0
- package/dist/core/vec2.js.map +1 -0
- package/dist/core/vec3.js +916 -0
- package/dist/core/vec3.js.map +1 -0
- package/dist/core/vec4.js +573 -0
- package/dist/core/vec4.js.map +1 -0
- package/dist/geometry/circumcircle.js +39 -0
- package/dist/geometry/circumcircle.js.map +1 -0
- package/dist/geometry/index.js +6 -0
- package/dist/geometry/index.js.map +1 -0
- package/dist/geometry/polygon2-decompose.js +411 -0
- package/dist/geometry/polygon2-decompose.js.map +1 -0
- package/dist/geometry/polygon2-triangulate.js +222 -0
- package/dist/geometry/polygon2-triangulate.js.map +1 -0
- package/dist/geometry/quickhull2.js +123 -0
- package/dist/geometry/quickhull2.js.map +1 -0
- package/dist/geometry/quickhull3.js +605 -0
- package/dist/geometry/quickhull3.js.map +1 -0
- package/dist/ik/fabrik2.js +675 -0
- package/dist/ik/fabrik2.js.map +1 -0
- package/dist/ik/fabrik3.js +912 -0
- package/dist/ik/fabrik3.js.map +1 -0
- package/dist/ik/index.js +5 -0
- package/dist/ik/index.js.map +1 -0
- package/dist/index.js +27 -0
- package/dist/index.js.map +1 -0
- package/dist/noise/fractal.js +185 -0
- package/dist/noise/fractal.js.map +1 -0
- package/dist/noise/index.js +16 -0
- package/dist/noise/index.js.map +1 -0
- package/dist/noise/perlin2d.js +50 -0
- package/dist/noise/perlin2d.js.map +1 -0
- package/dist/noise/perlin3d.js +72 -0
- package/dist/noise/perlin3d.js.map +1 -0
- package/dist/noise/permutation.js +120 -0
- package/dist/noise/permutation.js.map +1 -0
- package/dist/noise/simplex2d.js +84 -0
- package/dist/noise/simplex2d.js.map +1 -0
- package/dist/noise/simplex3d.js +147 -0
- package/dist/noise/simplex3d.js.map +1 -0
- package/dist/noise/simplex4d.js +149 -0
- package/dist/noise/simplex4d.js.map +1 -0
- package/dist/noise/worley2d.js +50 -0
- package/dist/noise/worley2d.js.map +1 -0
- package/dist/noise/worley3d.js +61 -0
- package/dist/noise/worley3d.js.map +1 -0
- package/dist/random/index.js +9 -0
- package/dist/random/index.js.map +1 -0
- package/dist/random/isaac32.js +164 -0
- package/dist/random/isaac32.js.map +1 -0
- package/dist/random/isaac64.js +215 -0
- package/dist/random/isaac64.js.map +1 -0
- package/dist/random/mulberry32.js +48 -0
- package/dist/random/mulberry32.js.map +1 -0
- package/dist/random/random.js +120 -0
- package/dist/random/random.js.map +1 -0
- package/dist/shapes/box2.js +300 -0
- package/dist/shapes/box2.js.map +1 -0
- package/dist/shapes/box3.js +550 -0
- package/dist/shapes/box3.js.map +1 -0
- package/dist/shapes/circle.js +6 -0
- package/dist/shapes/circle.js.map +1 -0
- package/dist/shapes/frustum.js +662 -0
- package/dist/shapes/frustum.js.map +1 -0
- package/dist/shapes/index.js +25 -0
- package/dist/shapes/index.js.map +1 -0
- package/dist/shapes/obb3.js +557 -0
- package/dist/shapes/obb3.js.map +1 -0
- package/dist/shapes/plane3.js +267 -0
- package/dist/shapes/plane3.js.map +1 -0
- package/dist/shapes/polygon2.js +451 -0
- package/dist/shapes/polygon2.js.map +1 -0
- package/dist/shapes/raycast3.js +164 -0
- package/dist/shapes/raycast3.js.map +1 -0
- package/dist/shapes/segment2.js +82 -0
- package/dist/shapes/segment2.js.map +1 -0
- package/dist/shapes/sphere.js +23 -0
- package/dist/shapes/sphere.js.map +1 -0
- package/dist/shapes/triangle2.js +79 -0
- package/dist/shapes/triangle2.js.map +1 -0
- package/dist/shapes/triangle3.js +60 -0
- package/dist/shapes/triangle3.js.map +1 -0
- package/dist/src/color/color.d.ts +50 -0
- package/dist/src/color/colorspace.d.ts +15 -0
- package/dist/src/color/hsl.d.ts +28 -0
- package/dist/src/color/index.d.ts +5 -0
- package/dist/src/color/parse.d.ts +15 -0
- package/dist/src/core/angle.d.ts +29 -0
- package/dist/src/core/arrays.d.ts +4 -0
- package/dist/src/core/euler.d.ts +78 -0
- package/dist/src/core/index.d.ts +27 -0
- package/dist/src/core/mat2.d.ts +217 -0
- package/dist/src/core/mat2d.d.ts +218 -0
- package/dist/src/core/mat3.d.ts +295 -0
- package/dist/src/core/mat4.d.ts +667 -0
- package/dist/src/core/polar.d.ts +151 -0
- package/dist/src/core/quat.d.ts +370 -0
- package/dist/src/core/quat2.d.ts +344 -0
- package/dist/src/core/scalar.d.ts +75 -0
- package/dist/src/core/spherical.d.ts +165 -0
- package/dist/src/core/vec2.d.ts +403 -0
- package/dist/src/core/vec3.d.ts +493 -0
- package/dist/src/core/vec4.d.ts +336 -0
- package/dist/src/geometry/circumcircle.d.ts +9 -0
- package/dist/src/geometry/index.d.ts +5 -0
- package/dist/src/geometry/polygon2-decompose.d.ts +25 -0
- package/dist/src/geometry/polygon2-triangulate.d.ts +15 -0
- package/dist/src/geometry/quickhull2.d.ts +10 -0
- package/dist/src/geometry/quickhull3.d.ts +27 -0
- package/dist/src/ik/fabrik2.d.ts +314 -0
- package/dist/src/ik/fabrik3.d.ts +371 -0
- package/dist/src/ik/index.d.ts +2 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/noise/fractal.d.ts +95 -0
- package/dist/src/noise/index.d.ts +9 -0
- package/dist/src/noise/perlin2d.d.ts +19 -0
- package/dist/src/noise/perlin3d.d.ts +20 -0
- package/dist/src/noise/permutation.d.ts +22 -0
- package/dist/src/noise/simplex2d.d.ts +19 -0
- package/dist/src/noise/simplex3d.d.ts +20 -0
- package/dist/src/noise/simplex4d.d.ts +24 -0
- package/dist/src/noise/worley2d.d.ts +22 -0
- package/dist/src/noise/worley3d.d.ts +23 -0
- package/dist/src/random/index.d.ts +8 -0
- package/dist/src/random/isaac32.d.ts +62 -0
- package/dist/src/random/isaac64.d.ts +75 -0
- package/dist/src/random/mulberry32.d.ts +43 -0
- package/dist/src/random/random.d.ts +67 -0
- package/dist/src/shapes/box2.d.ts +174 -0
- package/dist/src/shapes/box3.d.ts +213 -0
- package/dist/src/shapes/circle.d.ts +7 -0
- package/dist/src/shapes/frustum.d.ts +147 -0
- package/dist/src/shapes/index.d.ts +20 -0
- package/dist/src/shapes/obb3.d.ts +105 -0
- package/dist/src/shapes/plane3.d.ts +130 -0
- package/dist/src/shapes/polygon2.d.ts +155 -0
- package/dist/src/shapes/raycast3.d.ts +42 -0
- package/dist/src/shapes/segment2.d.ts +34 -0
- package/dist/src/shapes/sphere.d.ts +19 -0
- package/dist/src/shapes/triangle2.d.ts +53 -0
- package/dist/src/shapes/triangle3.d.ts +29 -0
- package/dist/src/time/easing.d.ts +21 -0
- package/dist/src/time/index.d.ts +6 -0
- package/dist/src/time/spring-core.d.ts +15 -0
- package/dist/src/time/spring.d.ts +36 -0
- package/dist/src/time/spring2.d.ts +11 -0
- package/dist/src/time/spring3.d.ts +11 -0
- package/dist/src/time/spring4.d.ts +11 -0
- package/dist/time/easing.js +24 -0
- package/dist/time/easing.js.map +1 -0
- package/dist/time/index.js +11 -0
- package/dist/time/index.js.map +1 -0
- package/dist/time/spring-core.js +48 -0
- package/dist/time/spring-core.js.map +1 -0
- package/dist/time/spring.js +62 -0
- package/dist/time/spring.js.map +1 -0
- package/dist/time/spring2.js +31 -0
- package/dist/time/spring2.js.map +1 -0
- package/dist/time/spring3.js +32 -0
- package/dist/time/spring3.js.map +1 -0
- package/dist/time/spring4.js +32 -0
- package/dist/time/spring4.js.map +1 -0
- package/package.json +90 -16
- package/skills/math/SKILL.md +140 -0
- package/AUTHORS +0 -1
- package/Cakefile +0 -28
- package/math.coffee +0 -112
- package/math.js +0 -141
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import type { Vec2 } from '../core/vec2.js';
|
|
2
|
+
import type { Circle } from './circle.js';
|
|
3
|
+
/** An axis-aligned box in 2D space, as [minX, minY, maxX, maxY] */
|
|
4
|
+
export type Box2 = [minX: number, minY: number, maxX: number, maxY: number];
|
|
5
|
+
/**
|
|
6
|
+
* Create a new empty Box2 with "min" set to positive infinity and "max" set to negative infinity
|
|
7
|
+
* @returns A new Box2
|
|
8
|
+
*/
|
|
9
|
+
export declare function create(): Box2;
|
|
10
|
+
/**
|
|
11
|
+
* Clones a Box2
|
|
12
|
+
* @param box - A Box2 to clone
|
|
13
|
+
* @returns a clone of box
|
|
14
|
+
*/
|
|
15
|
+
export declare function clone(box: Box2): Box2;
|
|
16
|
+
/**
|
|
17
|
+
* Copies a Box2 to another Box2
|
|
18
|
+
* @param out the output Box2
|
|
19
|
+
* @param box the input Box2
|
|
20
|
+
* @returns the output Box2
|
|
21
|
+
*/
|
|
22
|
+
export declare function copy(out: Box2, box: Box2): Box2;
|
|
23
|
+
/**
|
|
24
|
+
* Sets the min and max values of a Box2
|
|
25
|
+
* @param out - The output Box2
|
|
26
|
+
* @param minX - The minimum X coordinate
|
|
27
|
+
* @param minY - The minimum Y coordinate
|
|
28
|
+
* @param maxX - The maximum X coordinate
|
|
29
|
+
* @param maxY - The maximum Y coordinate
|
|
30
|
+
* @returns The updated Box2
|
|
31
|
+
*/
|
|
32
|
+
export declare function set(out: Box2, minX: number, minY: number, maxX: number, maxY: number): Box2;
|
|
33
|
+
/**
|
|
34
|
+
* Sets the min and max values of a Box2 from Vec2 vectors
|
|
35
|
+
* @param out - The output Box2
|
|
36
|
+
* @param min - The minimum corner
|
|
37
|
+
* @param max - The maximum corner
|
|
38
|
+
* @returns The updated Box2
|
|
39
|
+
*/
|
|
40
|
+
export declare function setFromVectors(out: Box2, min: Vec2, max: Vec2): Box2;
|
|
41
|
+
/**
|
|
42
|
+
* Extracts the minimum corner of a Box2
|
|
43
|
+
* @param out - The output Vec2 for the minimum corner
|
|
44
|
+
* @param box - The input Box2
|
|
45
|
+
* @returns The minimum corner
|
|
46
|
+
*/
|
|
47
|
+
export declare function min(out: Vec2, box: Box2): Vec2;
|
|
48
|
+
/**
|
|
49
|
+
* Extracts the maximum corner of a Box2
|
|
50
|
+
* @param out - The output Vec2 for the maximum corner
|
|
51
|
+
* @param box - The input Box2
|
|
52
|
+
* @returns The maximum corner
|
|
53
|
+
*/
|
|
54
|
+
export declare function max(out: Vec2, box: Box2): Vec2;
|
|
55
|
+
/**
|
|
56
|
+
* Set a Box2 to empty (min to positive infinity, max to negative infinity)
|
|
57
|
+
* @param out - The Box2 to make empty
|
|
58
|
+
* @returns The emptied Box2
|
|
59
|
+
*/
|
|
60
|
+
export declare function empty(out: Box2): Box2;
|
|
61
|
+
/**
|
|
62
|
+
* Returns whether or not the boxes have exactly the same elements in the same position (when compared with ===)
|
|
63
|
+
* @param a - The first box
|
|
64
|
+
* @param b - The second box
|
|
65
|
+
* @returns True if the boxes are equal, false otherwise
|
|
66
|
+
*/
|
|
67
|
+
export declare function exactEquals(a: Box2, b: Box2): boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Returns whether or not the boxes have approximately the same elements in the same position
|
|
70
|
+
* @param a - The first box
|
|
71
|
+
* @param b - The second box
|
|
72
|
+
* @returns True if the boxes are equal, false otherwise
|
|
73
|
+
*/
|
|
74
|
+
export declare function equals(a: Box2, b: Box2): boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Sets the box from a center point and size
|
|
77
|
+
* @param out - The output Box2
|
|
78
|
+
* @param center - The center point
|
|
79
|
+
* @param size - The size of the box
|
|
80
|
+
* @returns The updated Box2
|
|
81
|
+
*/
|
|
82
|
+
export declare function setFromCenterAndSize(out: Box2, center: Vec2, size: Vec2): Box2;
|
|
83
|
+
/**
|
|
84
|
+
* Expands a Box2 to include a point
|
|
85
|
+
* @param out - The output Box2
|
|
86
|
+
* @param box - The input Box2
|
|
87
|
+
* @param point - The point to include
|
|
88
|
+
* @returns The expanded Box2
|
|
89
|
+
*/
|
|
90
|
+
export declare function expandByPoint(out: Box2, box: Box2, point: Vec2): Box2;
|
|
91
|
+
/**
|
|
92
|
+
* Widens a Box2 by a vector on both sides
|
|
93
|
+
* Subtracts the vector from min and adds it to max
|
|
94
|
+
* @param out - The output Box2
|
|
95
|
+
* @param box - The input Box2
|
|
96
|
+
* @param vector - The vector to expand by
|
|
97
|
+
* @returns The expanded Box2
|
|
98
|
+
*/
|
|
99
|
+
export declare function expandByExtents(out: Box2, box: Box2, vector: Vec2): Box2;
|
|
100
|
+
/**
|
|
101
|
+
* Expands a Box2 uniformly by a scalar margin on all sides
|
|
102
|
+
* Subtracts the margin from min and adds it to max on each axis
|
|
103
|
+
* @param out - The output Box2
|
|
104
|
+
* @param box - The input Box2
|
|
105
|
+
* @param margin - The uniform margin to expand by
|
|
106
|
+
* @returns The expanded Box2
|
|
107
|
+
*/
|
|
108
|
+
export declare function expandByMargin(out: Box2, box: Box2, margin: number): Box2;
|
|
109
|
+
/**
|
|
110
|
+
* Computes the union of two bounding boxes
|
|
111
|
+
* Returns a Box2 that encompasses both input boxes
|
|
112
|
+
* @param out - The output Box2
|
|
113
|
+
* @param boxA - The first Box2
|
|
114
|
+
* @param boxB - The second Box2
|
|
115
|
+
* @returns The union Box2
|
|
116
|
+
*/
|
|
117
|
+
export declare function union(out: Box2, boxA: Box2, boxB: Box2): Box2;
|
|
118
|
+
/**
|
|
119
|
+
* Calculate the center point of a bounding box
|
|
120
|
+
* @param out - The output Vec2 for the center
|
|
121
|
+
* @param box - The input Box2
|
|
122
|
+
* @returns The center point
|
|
123
|
+
*/
|
|
124
|
+
export declare function center(out: Vec2, box: Box2): Vec2;
|
|
125
|
+
/**
|
|
126
|
+
* Calculate the extents (half-size) of a bounding box
|
|
127
|
+
* @param out - The output Vec2 for the extents
|
|
128
|
+
* @param box - The input Box2
|
|
129
|
+
* @returns The extents (distance from center to each edge)
|
|
130
|
+
*/
|
|
131
|
+
export declare function extents(out: Vec2, box: Box2): Vec2;
|
|
132
|
+
/**
|
|
133
|
+
* Calculate the size (dimensions) of a bounding box
|
|
134
|
+
* @param out - The output Vec2 for the size
|
|
135
|
+
* @param box - The input Box2
|
|
136
|
+
* @returns The size (width, height)
|
|
137
|
+
*/
|
|
138
|
+
export declare function size(out: Vec2, box: Box2): Vec2;
|
|
139
|
+
/**
|
|
140
|
+
* Calculate the area of a bounding box
|
|
141
|
+
* @param box - The input Box2
|
|
142
|
+
* @returns The area (width * height)
|
|
143
|
+
*/
|
|
144
|
+
export declare function area(box: Box2): number;
|
|
145
|
+
/**
|
|
146
|
+
* Scale a bounding box by a vector, handling non-uniform and negative scaling
|
|
147
|
+
* @param out - The output Box2
|
|
148
|
+
* @param box - The input Box2
|
|
149
|
+
* @param scale - The scale to apply (as a Vec2)
|
|
150
|
+
* @returns The scaled Box2
|
|
151
|
+
*/
|
|
152
|
+
export declare function scale(out: Box2, box: Box2, scale: Vec2): Box2;
|
|
153
|
+
/**
|
|
154
|
+
* Test if a point is contained within the bounding box
|
|
155
|
+
* @param box - The bounding box
|
|
156
|
+
* @param point - The point to test
|
|
157
|
+
* @returns true if the point is inside or on the boundary of the box
|
|
158
|
+
*/
|
|
159
|
+
export declare function containsPoint(box: Box2, point: Vec2): boolean;
|
|
160
|
+
/**
|
|
161
|
+
* Test if one Box2 completely contains another Box2
|
|
162
|
+
* @param container - The potentially containing Box2
|
|
163
|
+
* @param contained - The Box2 that might be contained
|
|
164
|
+
* @returns true if the container Box2 completely contains the contained Box2
|
|
165
|
+
*/
|
|
166
|
+
export declare function containsBox2(container: Box2, contained: Box2): boolean;
|
|
167
|
+
/**
|
|
168
|
+
* Check whether two bounding boxes intersect
|
|
169
|
+
*/
|
|
170
|
+
export declare function intersectsBox2(boxA: Box2, boxB: Box2): boolean;
|
|
171
|
+
/**
|
|
172
|
+
* Test intersection between an axis-aligned bounding box and a circle.
|
|
173
|
+
*/
|
|
174
|
+
export declare function intersectsCircle(box: Box2, circle: Circle): boolean;
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import type { Mat4 } from '../core/mat4.js';
|
|
2
|
+
import type { Vec3 } from '../core/vec3.js';
|
|
3
|
+
import type { Plane3 } from './plane3.js';
|
|
4
|
+
import type { Sphere } from './sphere.js';
|
|
5
|
+
/** A box in 3D space */
|
|
6
|
+
export type Box3 = [minX: number, minY: number, minZ: number, maxX: number, maxY: number, maxZ: number];
|
|
7
|
+
/**
|
|
8
|
+
* Create a new empty Box3 with "min" set to positive infinity and "max" set to negative infinity
|
|
9
|
+
* @returns A new Box3
|
|
10
|
+
*/
|
|
11
|
+
export declare function create(): Box3;
|
|
12
|
+
/**
|
|
13
|
+
* Clones a Box3
|
|
14
|
+
* @param box - A Box3 to clone
|
|
15
|
+
* @returns a clone of box
|
|
16
|
+
*/
|
|
17
|
+
export declare function clone(box: Box3): Box3;
|
|
18
|
+
/**
|
|
19
|
+
* Copies a Box3 to another Box3
|
|
20
|
+
* @param out the output Box3
|
|
21
|
+
* @param box the input Box3
|
|
22
|
+
* @returns the output Box3
|
|
23
|
+
*/
|
|
24
|
+
export declare function copy(out: Box3, box: Box3): Box3;
|
|
25
|
+
/**
|
|
26
|
+
* Sets the min and max values of a Box3
|
|
27
|
+
* @param out - The output Box3
|
|
28
|
+
* @param minX - The minimum X coordinate
|
|
29
|
+
* @param minY - The minimum Y coordinate
|
|
30
|
+
* @param minZ - The minimum Z coordinate
|
|
31
|
+
* @param maxX - The maximum X coordinate
|
|
32
|
+
* @param maxY - The maximum Y coordinate
|
|
33
|
+
* @param maxZ - The maximum Z coordinate
|
|
34
|
+
* @returns The updated Box3
|
|
35
|
+
*/
|
|
36
|
+
export declare function set(out: Box3, minX: number, minY: number, minZ: number, maxX: number, maxY: number, maxZ: number): Box3;
|
|
37
|
+
/**
|
|
38
|
+
* Sets the min and max values of a Box3 from Vec3 vectors
|
|
39
|
+
* @param out - The output Box3
|
|
40
|
+
* @param min - The minimum corner
|
|
41
|
+
* @param max - The maximum corner
|
|
42
|
+
* @returns The updated Box3
|
|
43
|
+
*/
|
|
44
|
+
export declare function setFromVectors(out: Box3, min: Vec3, max: Vec3): Box3;
|
|
45
|
+
/**
|
|
46
|
+
* Extracts the minimum corner of a Box3
|
|
47
|
+
* @param out - The output Vec3 for the minimum corner
|
|
48
|
+
* @param box - The input Box3
|
|
49
|
+
* @returns The minimum corner
|
|
50
|
+
*/
|
|
51
|
+
export declare function min(out: Vec3, box: Box3): Vec3;
|
|
52
|
+
/**
|
|
53
|
+
* Extracts the maximum corner of a Box3
|
|
54
|
+
* @param out - The output Vec3 for the maximum corner
|
|
55
|
+
* @param box - The input Box3
|
|
56
|
+
* @returns The maximum corner
|
|
57
|
+
*/
|
|
58
|
+
export declare function max(out: Vec3, box: Box3): Vec3;
|
|
59
|
+
/**
|
|
60
|
+
* Set a Box3 to empty (min to positive infinity, max to negative infinity)
|
|
61
|
+
* @param out - The Box3 to make empty
|
|
62
|
+
* @returns The emptied Box3
|
|
63
|
+
*/
|
|
64
|
+
export declare function empty(out: Box3): Box3;
|
|
65
|
+
/**
|
|
66
|
+
* Returns whether or not the boxes have exactly the same elements in the same position (when compared with ===)
|
|
67
|
+
* @param a - The first box
|
|
68
|
+
* @param b - The second box
|
|
69
|
+
* @returns True if the boxes are equal, false otherwise
|
|
70
|
+
*/
|
|
71
|
+
export declare function exactEquals(a: Box3, b: Box3): boolean;
|
|
72
|
+
/**
|
|
73
|
+
* Returns whether or not the boxes have approximately the same elements in the same position
|
|
74
|
+
* @param a - The first box
|
|
75
|
+
* @param b - The second box
|
|
76
|
+
* @returns True if the boxes are equal, false otherwise
|
|
77
|
+
*/
|
|
78
|
+
export declare function equals(a: Box3, b: Box3): boolean;
|
|
79
|
+
/**
|
|
80
|
+
* Sets the box from a center point and size
|
|
81
|
+
* @param out - The output Box3
|
|
82
|
+
* @param center - The center point
|
|
83
|
+
* @param size - The size of the box
|
|
84
|
+
* @returns The updated Box3
|
|
85
|
+
*/
|
|
86
|
+
export declare function setFromCenterAndSize(out: Box3, center: Vec3, size: Vec3): Box3;
|
|
87
|
+
/**
|
|
88
|
+
* Expands a Box3 to include a point
|
|
89
|
+
* @param out - The output Box3
|
|
90
|
+
* @param box - The input Box3
|
|
91
|
+
* @param point - The point to include
|
|
92
|
+
* @returns The expanded Box3
|
|
93
|
+
*/
|
|
94
|
+
export declare function expandByPoint(out: Box3, box: Box3, point: Vec3): Box3;
|
|
95
|
+
/**
|
|
96
|
+
* Widens a Box3 by a vector on both sides
|
|
97
|
+
* Subtracts the vector from min and adds it to max
|
|
98
|
+
* @param out - The output Box3
|
|
99
|
+
* @param box - The input Box3
|
|
100
|
+
* @param vector - The vector to expand by
|
|
101
|
+
* @returns The expanded Box3
|
|
102
|
+
*/
|
|
103
|
+
export declare function expandByExtents(out: Box3, box: Box3, vector: Vec3): Box3;
|
|
104
|
+
/**
|
|
105
|
+
* Expands a Box3 uniformly by a scalar margin on all sides
|
|
106
|
+
* Subtracts the margin from min and adds it to max on each axis
|
|
107
|
+
* @param out - The output Box3
|
|
108
|
+
* @param box - The input Box3
|
|
109
|
+
* @param margin - The uniform margin to expand by
|
|
110
|
+
* @returns The expanded Box3
|
|
111
|
+
*/
|
|
112
|
+
export declare function expandByMargin(out: Box3, box: Box3, margin: number): Box3;
|
|
113
|
+
/**
|
|
114
|
+
* Computes the union of two bounding boxes
|
|
115
|
+
* Returns a Box3 that encompasses both input boxes
|
|
116
|
+
* @param out - The output Box3
|
|
117
|
+
* @param boxA - The first Box3
|
|
118
|
+
* @param boxB - The second Box3
|
|
119
|
+
* @returns The union Box3
|
|
120
|
+
*/
|
|
121
|
+
export declare function union(out: Box3, boxA: Box3, boxB: Box3): Box3;
|
|
122
|
+
/**
|
|
123
|
+
* Calculate the center point of a bounding box
|
|
124
|
+
* @param out - The output Vec3 for the center
|
|
125
|
+
* @param box - The input Box3
|
|
126
|
+
* @returns The center point
|
|
127
|
+
*/
|
|
128
|
+
export declare function center(out: Vec3, box: Box3): Vec3;
|
|
129
|
+
/**
|
|
130
|
+
* Calculate the extents (half-size) of a bounding box
|
|
131
|
+
* @param out - The output Vec3 for the extents
|
|
132
|
+
* @param box - The input Box3
|
|
133
|
+
* @returns The extents (distance from center to each face)
|
|
134
|
+
*/
|
|
135
|
+
export declare function extents(out: Vec3, box: Box3): Vec3;
|
|
136
|
+
/**
|
|
137
|
+
* Calculate the size (dimensions) of a bounding box
|
|
138
|
+
* @param out - The output Vec3 for the size
|
|
139
|
+
* @param box - The input Box3
|
|
140
|
+
* @returns The size (width, height, depth)
|
|
141
|
+
*/
|
|
142
|
+
export declare function size(out: Vec3, box: Box3): Vec3;
|
|
143
|
+
/**
|
|
144
|
+
* Calculate the surface area of a bounding box
|
|
145
|
+
* @param box - The input Box3
|
|
146
|
+
* @returns The surface area
|
|
147
|
+
*/
|
|
148
|
+
export declare function surfaceArea(box: Box3): number;
|
|
149
|
+
/**
|
|
150
|
+
* Scale a bounding box by a vector, handling non-uniform and negative scaling
|
|
151
|
+
* @param out - The output Box3
|
|
152
|
+
* @param box - The input Box3
|
|
153
|
+
* @param scale - The scale to apply (as a Vec3)
|
|
154
|
+
* @returns The scaled Box3
|
|
155
|
+
*/
|
|
156
|
+
export declare function scale(out: Box3, box: Box3, scale: Vec3): Box3;
|
|
157
|
+
/**
|
|
158
|
+
* Transform a bounding box by a 4x4 matrix.
|
|
159
|
+
* Uses Arvo's trick — transform the center, build new half-extents from
|
|
160
|
+
* |M| · extents — which is ~4× fewer ops than transforming all 8 corners.
|
|
161
|
+
* Reference: Jim Arvo, "Transforming Axis-Aligned Bounding Boxes",
|
|
162
|
+
* Graphics Gems I (1990).
|
|
163
|
+
* https://github.com/erich666/GraphicsGems/blob/master/gems/TransBox.c
|
|
164
|
+
* Assumes mat is affine (no perspective), which is always true for AABB
|
|
165
|
+
* transforms in practice.
|
|
166
|
+
* Safe under aliasing (out and box may be the same array): all six box
|
|
167
|
+
* components are read into locals before out is written.
|
|
168
|
+
* @param out - The output Box3
|
|
169
|
+
* @param box - The input Box3
|
|
170
|
+
* @param mat - The 4x4 transformation matrix
|
|
171
|
+
* @returns The transformed Box3
|
|
172
|
+
*/
|
|
173
|
+
export declare function transformMat4(out: Box3, box: Box3, mat: Mat4): Box3;
|
|
174
|
+
/**
|
|
175
|
+
* Test if a point is contained within the bounding box
|
|
176
|
+
* @param box - The bounding box
|
|
177
|
+
* @param point - The point to test
|
|
178
|
+
* @returns true if the point is inside or on the boundary of the box
|
|
179
|
+
*/
|
|
180
|
+
export declare function containsPoint(box: Box3, point: Vec3): boolean;
|
|
181
|
+
/**
|
|
182
|
+
* Test if one Box3 completely contains another Box3
|
|
183
|
+
* @param container - The potentially containing Box3
|
|
184
|
+
* @param contained - The Box3 that might be contained
|
|
185
|
+
* @returns true if the container Box3 completely contains the contained Box3
|
|
186
|
+
*/
|
|
187
|
+
export declare function containsBox3(container: Box3, contained: Box3): boolean;
|
|
188
|
+
/**
|
|
189
|
+
* Check whether two bounding boxes intersect
|
|
190
|
+
*/
|
|
191
|
+
export declare function intersectsBox3(boxA: Box3, boxB: Box3): boolean;
|
|
192
|
+
/**
|
|
193
|
+
* Test whether an axis-aligned bounding box intersects a triangle, via the
|
|
194
|
+
* separating-axis theorem over 13 axes: the 3 box face normals, the triangle
|
|
195
|
+
* face normal, and the 9 box-axis × triangle-edge cross products.
|
|
196
|
+
*
|
|
197
|
+
* Fully inlined with local scalars — no scratch arrays or per-call allocations.
|
|
198
|
+
* Axes are tested cheapest-first (box faces, i.e. the triangle-vs-box AABB
|
|
199
|
+
* reject) so the common non-overlapping case exits before any edge or cross
|
|
200
|
+
* product is computed. On each edge-cross axis two of the three vertices project
|
|
201
|
+
* to the same value (the axis is perpendicular to that edge), so only two
|
|
202
|
+
* projections are needed. An all-zero cross axis (edge parallel to a box axis)
|
|
203
|
+
* collapses every projection and the radius to 0, passing automatically.
|
|
204
|
+
*/
|
|
205
|
+
export declare function intersectsTriangle3(box: Box3, a: Vec3, b: Vec3, c: Vec3): boolean;
|
|
206
|
+
/**
|
|
207
|
+
* Test intersection between axis-aligned bounding box and a sphere.
|
|
208
|
+
*/
|
|
209
|
+
export declare function intersectsSphere(box: Box3, sphere: Sphere): boolean;
|
|
210
|
+
/**
|
|
211
|
+
* Test intersection between axis-aligned bounding box and plane.
|
|
212
|
+
*/
|
|
213
|
+
export declare function intersectsPlane3(box: Box3, plane: Plane3): boolean;
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import type { Mat4 } from '../core/mat4.js';
|
|
2
|
+
import type { Vec3 } from '../core/vec3.js';
|
|
3
|
+
import type { Box3 } from './box3.js';
|
|
4
|
+
import type { Plane3 } from './plane3.js';
|
|
5
|
+
import type { Sphere } from './sphere.js';
|
|
6
|
+
/**
|
|
7
|
+
* A view frustum, represented as the six bounding planes of a camera's view volume.
|
|
8
|
+
* Ordered as [left, right, bottom, top, near, far]. Plane normals point inward, so a
|
|
9
|
+
* point is inside the frustum when its signed distance to every plane is >= 0.
|
|
10
|
+
*/
|
|
11
|
+
export type Frustum = [Plane3, Plane3, Plane3, Plane3, Plane3, Plane3];
|
|
12
|
+
/**
|
|
13
|
+
* The eight corners of a frustum, as returned by [[corners]].
|
|
14
|
+
* Ordered near bottom-left, near top-left, near top-right, near bottom-right,
|
|
15
|
+
* then the same four in the far plane.
|
|
16
|
+
*/
|
|
17
|
+
export type FrustumCorners = [Vec3, Vec3, Vec3, Vec3, Vec3, Vec3, Vec3, Vec3];
|
|
18
|
+
/**
|
|
19
|
+
* Creates a new frustum of zeroed planes.
|
|
20
|
+
* @returns A new frustum
|
|
21
|
+
*/
|
|
22
|
+
export declare function create(): Frustum;
|
|
23
|
+
/**
|
|
24
|
+
* Clones a frustum.
|
|
25
|
+
* @param f - The frustum to clone
|
|
26
|
+
* @returns A new frustum
|
|
27
|
+
*/
|
|
28
|
+
export declare function clone(f: Frustum): Frustum;
|
|
29
|
+
/**
|
|
30
|
+
* Copies one frustum to another.
|
|
31
|
+
* @param out - The output frustum
|
|
32
|
+
* @param f - The source frustum
|
|
33
|
+
* @returns The output frustum
|
|
34
|
+
*/
|
|
35
|
+
export declare function copy(out: Frustum, f: Frustum): Frustum;
|
|
36
|
+
/**
|
|
37
|
+
* Extracts the six planes of a view frustum from a projection and view matrix, using the
|
|
38
|
+
* OpenGL / WebGL clip-space depth convention (NDC z in [-1, 1]).
|
|
39
|
+
*
|
|
40
|
+
* Pair this with `mat4.perspectiveNO`, `mat4.frustumNO` or `mat4.orthoNO`.
|
|
41
|
+
*
|
|
42
|
+
* @param out - The output frustum
|
|
43
|
+
* @param proj - The projection matrix
|
|
44
|
+
* @param view - The view matrix
|
|
45
|
+
* @returns The output frustum
|
|
46
|
+
*/
|
|
47
|
+
export declare function setFromViewProjectionMatrixNO(out: Frustum, proj: Mat4, view: Mat4): Frustum;
|
|
48
|
+
/**
|
|
49
|
+
* Extracts the six planes of a view frustum from a projection and view matrix, using the
|
|
50
|
+
* WebGPU / Vulkan / D3D / Metal clip-space depth convention (NDC z in [0, 1]).
|
|
51
|
+
*
|
|
52
|
+
* Pair this with `mat4.perspectiveZO`, `mat4.frustumZO` or `mat4.orthoZO`.
|
|
53
|
+
*
|
|
54
|
+
* @param out - The output frustum
|
|
55
|
+
* @param proj - The projection matrix
|
|
56
|
+
* @param view - The view matrix
|
|
57
|
+
* @returns The output frustum
|
|
58
|
+
*/
|
|
59
|
+
export declare function setFromViewProjectionMatrixZO(out: Frustum, proj: Mat4, view: Mat4): Frustum;
|
|
60
|
+
/**
|
|
61
|
+
* Extracts only the four lateral planes (left, right, bottom, top) of a view frustum from a
|
|
62
|
+
* projection and view matrix, skipping near and far. This is convention-independent — the
|
|
63
|
+
* NO/ZO split only affects the near plane — so it pairs with any projection matrix.
|
|
64
|
+
*
|
|
65
|
+
* Intended for streaming pipelines that already cull distant content and only need to reject
|
|
66
|
+
* objects outside the camera's sides. Test against the result with `frustum.sidesIntersectsSphere`,
|
|
67
|
+
* `frustum.sidesIntersectsBox3`, `frustum.sidesContainsPoint` or `frustum.sidesIntersectsRay`.
|
|
68
|
+
*
|
|
69
|
+
* @param out - The output frustum; only slots 0-3 are written
|
|
70
|
+
* @param proj - The projection matrix
|
|
71
|
+
* @param view - The view matrix
|
|
72
|
+
* @returns The output frustum
|
|
73
|
+
*/
|
|
74
|
+
export declare function setFromViewProjectionMatrixSides(out: Frustum, proj: Mat4, view: Mat4): Frustum;
|
|
75
|
+
/**
|
|
76
|
+
* Tests if a sphere intersects the frustum.
|
|
77
|
+
* @param f - The frustum
|
|
78
|
+
* @param s - The sphere
|
|
79
|
+
* @returns True if the sphere intersects or is inside the frustum
|
|
80
|
+
*/
|
|
81
|
+
export declare function intersectsSphere(f: Frustum, s: Sphere): boolean;
|
|
82
|
+
/**
|
|
83
|
+
* Tests if a sphere intersects the lateral planes of a sides-only frustum, skipping near and far.
|
|
84
|
+
* @param f - The sides-only frustum
|
|
85
|
+
* @param s - The sphere
|
|
86
|
+
* @returns True if the sphere intersects or is inside the frustum's sides
|
|
87
|
+
*/
|
|
88
|
+
export declare function sidesIntersectsSphere(f: Frustum, s: Sphere): boolean;
|
|
89
|
+
/**
|
|
90
|
+
* Tests if an axis-aligned box intersects the frustum, using the p-vertex test.
|
|
91
|
+
* @param f - The frustum
|
|
92
|
+
* @param box - The box
|
|
93
|
+
* @returns True if the box intersects or is inside the frustum
|
|
94
|
+
*/
|
|
95
|
+
export declare function intersectsBox3(f: Frustum, box: Box3): boolean;
|
|
96
|
+
/**
|
|
97
|
+
* Tests if an axis-aligned box intersects the lateral planes of a sides-only frustum, using the
|
|
98
|
+
* p-vertex test, skipping near and far.
|
|
99
|
+
* @param f - The sides-only frustum
|
|
100
|
+
* @param box - The box
|
|
101
|
+
* @returns True if the box intersects or is inside the frustum's sides
|
|
102
|
+
*/
|
|
103
|
+
export declare function sidesIntersectsBox3(f: Frustum, box: Box3): boolean;
|
|
104
|
+
/**
|
|
105
|
+
* Tests if a point is inside the frustum.
|
|
106
|
+
* @param f - The frustum
|
|
107
|
+
* @param p - The point
|
|
108
|
+
* @returns True if the point is inside or on the boundary of the frustum
|
|
109
|
+
*/
|
|
110
|
+
export declare function containsPoint(f: Frustum, p: Vec3): boolean;
|
|
111
|
+
/**
|
|
112
|
+
* Tests if a point is inside the lateral planes of a sides-only frustum, skipping near and far.
|
|
113
|
+
* @param f - The sides-only frustum
|
|
114
|
+
* @param p - The point
|
|
115
|
+
* @returns True if the point is inside or on the boundary of the frustum's sides
|
|
116
|
+
*/
|
|
117
|
+
export declare function sidesContainsPoint(f: Frustum, p: Vec3): boolean;
|
|
118
|
+
/**
|
|
119
|
+
* Tests if a ray intersects the frustum, using a slab test over the planes.
|
|
120
|
+
* A ray that starts inside the frustum always intersects.
|
|
121
|
+
* @param f - The frustum
|
|
122
|
+
* @param origin - Ray origin
|
|
123
|
+
* @param direction - Ray direction (need not be normalized)
|
|
124
|
+
* @returns True if the ray intersects the frustum
|
|
125
|
+
*/
|
|
126
|
+
export declare function intersectsRay(f: Frustum, origin: Vec3, direction: Vec3): boolean;
|
|
127
|
+
/**
|
|
128
|
+
* Tests if a ray intersects the lateral planes of a sides-only frustum, using a slab test over the
|
|
129
|
+
* planes, skipping near and far. A ray that starts inside the sides always intersects.
|
|
130
|
+
* @param f - The sides-only frustum
|
|
131
|
+
* @param origin - Ray origin
|
|
132
|
+
* @param direction - Ray direction (need not be normalized)
|
|
133
|
+
* @returns True if the ray intersects the frustum's sides
|
|
134
|
+
*/
|
|
135
|
+
export declare function sidesIntersectsRay(f: Frustum, origin: Vec3, direction: Vec3): boolean;
|
|
136
|
+
/**
|
|
137
|
+
* Computes the eight corners of the frustum by intersecting three planes each.
|
|
138
|
+
* The frustum must be a full six-plane frustum (near and far present).
|
|
139
|
+
*
|
|
140
|
+
* Output order: near bottom-left, near top-left, near top-right, near bottom-right,
|
|
141
|
+
* far bottom-left, far top-left, far top-right, far bottom-right.
|
|
142
|
+
*
|
|
143
|
+
* @param out - The output corners (8 vec3s)
|
|
144
|
+
* @param f - The frustum
|
|
145
|
+
* @returns The output corners
|
|
146
|
+
*/
|
|
147
|
+
export declare function corners(out: FrustumCorners, f: Frustum): FrustumCorners;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export type * from '../core/index.js';
|
|
2
|
+
export * as box2 from './box2.js';
|
|
3
|
+
export type { Box2 } from './box2.js';
|
|
4
|
+
export * as box3 from './box3.js';
|
|
5
|
+
export type { Box3 } from './box3.js';
|
|
6
|
+
export * as obb3 from './obb3.js';
|
|
7
|
+
export type { OBB3 } from './obb3.js';
|
|
8
|
+
export * as plane3 from './plane3.js';
|
|
9
|
+
export type { Plane3 } from './plane3.js';
|
|
10
|
+
export * as sphere from './sphere.js';
|
|
11
|
+
export type { Sphere } from './sphere.js';
|
|
12
|
+
export * as circle from './circle.js';
|
|
13
|
+
export type { Circle } from './circle.js';
|
|
14
|
+
export * as segment2 from './segment2.js';
|
|
15
|
+
export * as polygon2 from './polygon2.js';
|
|
16
|
+
export * as triangle2 from './triangle2.js';
|
|
17
|
+
export * as triangle3 from './triangle3.js';
|
|
18
|
+
export * as raycast3 from './raycast3.js';
|
|
19
|
+
export * as frustum from './frustum.js';
|
|
20
|
+
export type { Frustum, FrustumCorners } from './frustum.js';
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import type { Mat3 } from '../core/mat3.js';
|
|
2
|
+
import type { Mat4 } from '../core/mat4.js';
|
|
3
|
+
import type { Quat } from '../core/quat.js';
|
|
4
|
+
import type { Vec3 } from '../core/vec3.js';
|
|
5
|
+
import type { Box3 } from './box3.js';
|
|
6
|
+
/** An oriented bounding box in 3D space */
|
|
7
|
+
export type OBB3 = {
|
|
8
|
+
center: Vec3;
|
|
9
|
+
halfExtents: Vec3;
|
|
10
|
+
rotation: Mat3;
|
|
11
|
+
};
|
|
12
|
+
export declare function create(): OBB3;
|
|
13
|
+
export declare function clone(a: OBB3): OBB3;
|
|
14
|
+
export declare function copy(out: OBB3, a: OBB3): OBB3;
|
|
15
|
+
/**
|
|
16
|
+
* Sets an OBB from center, half extents, and a rotation matrix.
|
|
17
|
+
* @param out the OBB to store the result
|
|
18
|
+
* @param center the center of the OBB
|
|
19
|
+
* @param halfExtents the half extents of the OBB
|
|
20
|
+
* @param rotation the Mat3 rotation matrix
|
|
21
|
+
* @returns the OBB with the given center, half extents, and rotation
|
|
22
|
+
*/
|
|
23
|
+
export declare function set(out: OBB3, center: Vec3, halfExtents: Vec3, rotation: Mat3): OBB3;
|
|
24
|
+
/**
|
|
25
|
+
* Sets an OBB from center, half extents, and a quaternion.
|
|
26
|
+
* Convenience helper for users who store orientation as a quaternion.
|
|
27
|
+
*
|
|
28
|
+
* @param out - The OBB to store the result
|
|
29
|
+
* @param center - The center of the OBB
|
|
30
|
+
* @param halfExtents - The half extents of the OBB
|
|
31
|
+
* @param q - The quaternion representing the OBB's orientation
|
|
32
|
+
* @returns out
|
|
33
|
+
*/
|
|
34
|
+
export declare function setFromCenterHalfExtentsQuaternion(out: OBB3, center: Vec3, halfExtents: Vec3, q: Quat): OBB3;
|
|
35
|
+
/**
|
|
36
|
+
* Creates an OBB from an axis-aligned bounding box (AABB).
|
|
37
|
+
* The resulting OBB will have the same center and extents as the AABB,
|
|
38
|
+
* with no rotation (identity orientation).
|
|
39
|
+
*
|
|
40
|
+
* @param out - The OBB to store the result
|
|
41
|
+
* @param aabb - The AABB (min and max corners)
|
|
42
|
+
* @returns out
|
|
43
|
+
*/
|
|
44
|
+
export declare function setFromBox3(out: OBB3, aabb: Box3): OBB3;
|
|
45
|
+
/**
|
|
46
|
+
* Tests whether a point is contained within an OBB.
|
|
47
|
+
*
|
|
48
|
+
* @param obb - The OBB to test
|
|
49
|
+
* @param point - The point to test
|
|
50
|
+
* @returns true if the point is inside the OBB
|
|
51
|
+
*/
|
|
52
|
+
export declare function containsPoint(obb: OBB3, point: Vec3): boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Clamps a point to the surface or interior of an OBB.
|
|
55
|
+
* Reference: Closest Point on OBB to Point in Real-Time Collision Detection
|
|
56
|
+
* by Christer Ericson (chapter 5.1.4)
|
|
57
|
+
*
|
|
58
|
+
* @param out - The clamped point result
|
|
59
|
+
* @param obb - The OBB
|
|
60
|
+
* @param point - The point to clamp
|
|
61
|
+
* @returns out
|
|
62
|
+
*/
|
|
63
|
+
export declare function clampPoint(out: Vec3, obb: OBB3, point: Vec3): Vec3;
|
|
64
|
+
/**
|
|
65
|
+
* Tests whether an OBB intersects with another OBB using the Separating Axis Theorem.
|
|
66
|
+
* Reference: OBB-OBB Intersection in Real-Time Collision Detection
|
|
67
|
+
* by Christer Ericson (chapter 4.4.1)
|
|
68
|
+
*
|
|
69
|
+
* A cross-product axis A_i x B_j degenerates to ~zero when those edges are near
|
|
70
|
+
* parallel, which makes its (un-normalised) separation test numerically unstable.
|
|
71
|
+
* Such an axis carries no separation information not already covered by the face
|
|
72
|
+
* axes, so it is skipped when `1 - R[i][j]^2` (its squared length, = sin^2 of the
|
|
73
|
+
* angle between the edges) falls below `epsilon`. This is scale-invariant — R is a
|
|
74
|
+
* matrix of cosines — unlike fudging the projected radii.
|
|
75
|
+
*
|
|
76
|
+
* @param a - The first OBB
|
|
77
|
+
* @param b - The second OBB
|
|
78
|
+
* @param epsilon - Squared-sine threshold below which near-parallel edge axes are skipped
|
|
79
|
+
* @returns true if the OBBs intersect
|
|
80
|
+
*/
|
|
81
|
+
export declare function intersectsOBB3(a: OBB3, b: OBB3, epsilon?: number): boolean;
|
|
82
|
+
/**
|
|
83
|
+
* Tests whether an OBB intersects with an AABB.
|
|
84
|
+
*
|
|
85
|
+
* Specialised form of {@link intersectsOBB3}: the AABB's axes are the world axes, so
|
|
86
|
+
* the axis dot-product matrix R is just the OBB's rotation (no 9 dot-products), and the
|
|
87
|
+
* AABB's centre/half-extents come straight from its min/max. The near-parallel edge
|
|
88
|
+
* skip works identically — here it fires when an OBB axis aligns with a world axis.
|
|
89
|
+
*
|
|
90
|
+
* @param obb - The OBB
|
|
91
|
+
* @param aabb - The AABB (axis-aligned bounding box)
|
|
92
|
+
* @returns true if they intersect
|
|
93
|
+
*/
|
|
94
|
+
export declare function intersectsBox3(obb: OBB3, aabb: Box3): boolean;
|
|
95
|
+
/**
|
|
96
|
+
* Applies a 4x4 transformation matrix to an OBB.
|
|
97
|
+
* This can be used to transform the bounding volume with the world matrix
|
|
98
|
+
* of a 3D object to keep both entities in sync.
|
|
99
|
+
*
|
|
100
|
+
* @param out - The transformed OBB
|
|
101
|
+
* @param obb - The OBB to transform
|
|
102
|
+
* @param matrix - The 4x4 transformation matrix
|
|
103
|
+
* @returns out
|
|
104
|
+
*/
|
|
105
|
+
export declare function applyMatrix4(out: OBB3, obb: OBB3, matrix: Mat4): OBB3;
|