import { Vector3d } from "../../math/vector3d.ts"; import type { XYZPoint } from "../../utils/types.ts"; /** * A 3D axis-aligned bounding box — the 3D sibling of {@link Bounds}. * * Used by {@link Octree} as the bounding primitive of every node * (root, subnodes, queries). Intentionally minimal: only the * operations the {@link Octree} hot path needs are implemented, with * a small handful of helpers ({@link AABB3d#contains}, * {@link AABB3d#overlaps}, {@link AABB3d#overlapsSphere}) for * test-driven `querySphere` / `queryAABB` callers. * * Coordinate convention matches the rest of melonJS 3D code (see * {@link Camera3d}): **Y-down, +Z forward / away from the camera.** * * Lives next to {@link Octree} under `physics/broadphase/` rather * than `math/` to mirror {@link Bounds} (which lives in `physics/`, * not `math/`). Aabb is a primitive of the broadphase, not a generic * math primitive — it never escapes a query result. * @category Geometry */ export declare class AABB3d { min: XYZPoint; max: XYZPoint; /** * Construct an empty AABB (min = +∞, max = −∞). The empty AABB * satisfies `addPoint(p)` => `min = max = p` for the first point * added, and `overlaps(b)` => `false` against any other AABB — * same convention as {@link Bounds}. * @param [min] - optional initial minimum corner * @param [max] - optional initial maximum corner */ constructor(min?: XYZPoint, max?: XYZPoint); /** * Reset the AABB to its empty state. */ clear(): void; /** * Set min and max corners directly. Mirror of `Bounds.setMinMax`. * @param minX - minimum corner x * @param minY - minimum corner y * @param minZ - minimum corner z * @param maxX - maximum corner x * @param maxY - maximum corner y * @param maxZ - maximum corner z */ setMinMax(minX: number, minY: number, minZ: number, maxX: number, maxY: number, maxZ: number): void; get x(): number; get y(): number; get z(): number; get width(): number; get height(): number; get depth(): number; get left(): number; get right(): number; get top(): number; get bottom(): number; get front(): number; get back(): number; get centerX(): number; get centerY(): number; get centerZ(): number; /** * True if every coordinate is a finite number. Used by the * {@link Octree} to reject inserts whose bounding box is the * empty AABB (a sprite with no shape and never updated) — without * this guard a `±Infinity` corner would silently classify into * an arbitrary octant and never come back out via `remove`. */ isFinite(): boolean; /** * True if this AABB fully encloses the given point. * @param x - point x * @param y - point y * @param z - point z */ contains(x: number, y: number, z: number): boolean; /** * True if this AABB overlaps the given AABB on every axis. The * intersection includes the boundary (shared face/edge/corner * counts as overlap), same convention as {@link Bounds.overlaps} * so {@link Octree} candidate sets don't drop items that sit * exactly on an octant boundary. * @param aabb - the other AABB to test against */ overlaps(aabb: AABB3d): boolean; /** * True if this AABB overlaps a sphere. Computes the squared * distance from the sphere center to the nearest point on the * AABB and compares against `r²` — avoids the `sqrt` on the hot * path. Used by `Octree.querySphere`. * @param cx - sphere center x * @param cy - sphere center y * @param cz - sphere center z * @param r - sphere radius (must be ≥ 0; `r=0` becomes a point-in-AABB test) */ overlapsSphere(cx: number, cy: number, cz: number, r: number): boolean; /** * Expand this AABB to include the given point. * @param p - the point to fold in */ addPoint(p: XYZPoint | Vector3d): void; /** * Expand this AABB to include the given AABB. With `clear=true`, * copies the input AABB directly — same shape as {@link Bounds.addBounds}. * @param aabb - the AABB to fold in * @param [clear] - reset this AABB before folding */ addAABB(aabb: AABB3d, clear?: boolean): void; /** * Returns a deep copy of this AABB. */ clone(): AABB3d; } //# sourceMappingURL=aabb3d.d.ts.map