import { Vector3d } from "../math/vector3d.ts"; import { AABB3d } from "../physics/broadphase/aabb3d.ts"; /** * A 3D sphere — `{ centre, radius }`. Sibling of {@link Ellipse} in * the geometry surface; used by {@link Octree} / `adapter.querySphere` * as the canonical 3D region-query shape, and by user code for any * sphere-vs-sphere / sphere-vs-AABB collision check under * {@link Camera3d}. * * Not currently part of the {@link BodyShape} union — `Body` is 2D- * only in melonJS today; Sphere is a math/geometry primitive that * would slot in once a 3D physics adapter ships. * @category Geometry * @example * import { Sphere } from "melonjs"; * * const a = new Sphere(0, 0, 0, 10); * const b = new Sphere(15, 0, 0, 10); * a.overlaps(b); // true — surfaces touch at x = 5 */ export declare class Sphere { /** Centre coordinates of the sphere (Y-down, +Z forward — Camera3d convention). */ pos: Vector3d; /** Sphere radius. Negative values are treated like their absolute value in {@link Sphere.overlaps} / {@link Sphere.contains}. */ radius: number; /** * Cached AABB for this sphere. Allocated lazily on the first * {@link Sphere.getBounds} call so a sphere used only for inline * `overlaps` checks doesn't pay for the AABB. * @ignore */ _bounds?: AABB3d; /** * @param x - centre x * @param y - centre y * @param z - centre z * @param radius - sphere radius */ constructor(x: number, y: number, z: number, radius: number); /** * Re-position and resize the sphere in one shot. Mirrors * {@link Ellipse.setShape}. * @param x - centre x * @param y - centre y * @param z - centre z * @param radius - sphere radius * @returns this sphere for chaining */ setShape(x: number, y: number, z: number, radius: number): this; /** * Test whether a point lies inside the sphere (boundary inclusive). * Squared-distance test — no `sqrt` on the hot path. Matches the * boundary convention of {@link AABB3d.contains}. * @param x - point x * @param y - point y * @param z - point z */ contains(x: number, y: number, z: number): boolean; /** * Vector form of {@link Sphere.contains}. * @param v - point */ contains(v: Vector3d): boolean; /** * Test whether this sphere overlaps another. Boundary inclusive * (touching surfaces count as overlap), matching * {@link AABB3d.overlaps}. * @param other - the other sphere */ overlaps(other: Sphere): boolean; /** * Test whether this sphere overlaps an axis-aligned box. Delegates * to {@link AABB3d.overlapsSphere} so the two shapes agree on * boundary semantics. * @param aabb - the box */ overlapsAABB(aabb: AABB3d): boolean; /** * Smallest {@link AABB3d} containing this sphere. Cached — repeat * calls without a `setShape` between return the same instance and * the same values. */ getBounds(): AABB3d; /** @ignore */ _updateBounds(): void; /** * Reset the sphere to a zero-radius point at the origin. */ clear(): this; /** * Deep copy of this sphere. The clone shares NOTHING with the * original — independent `pos` Vector3d, independent AABB cache. * Pulls from {@link spherePool} so back-to-back clones are * allocation-free. */ clone(): Sphere; } /** * A pool of {@link Sphere} instances. Mirrors {@link ellipsePool} — * `spherePool.get(x, y, z, r)` recycles an existing instance via * `setShape` before allocating a new one; release via the * matching `.release()` (the `createPool` contract). */ export declare const spherePool: import("../system/pool.ts").Pool; //# sourceMappingURL=sphere.d.ts.map