import { Vector3d } from "../math/vector3d.ts"; import { Bounds } from "../physics/bounds.ts"; import { AABB3d } from "../physics/broadphase/aabb3d.ts"; /** * An axis-aligned 3D box, usable as a {@link Body} collision shape. * * This is the shape that lets a body collide along **Z** as well as X and Y. * Every other built-in shape ({@link Polygon}, {@link Rect}, {@link RoundRect}, * {@link Ellipse}) is planar and is resolved by the 2D SAT narrowphase, which * can only ever produce a 2D pushback — see {@link ResponseObject#overlapV}. * A `Box3d` pair is instead resolved by an AABB-vs-AABB narrowphase that also * fills {@link ResponseObject#overlapZ}. * * Coordinate convention matches the rest of melonJS 3D code (see * {@link Camera3d}): **Y-down, +Z forward / away from the camera.** * * ## Position is the CENTER * * Unlike {@link Rect} (top-left) and like {@link Ellipse} (center), `pos` is * the box **center**. That matches how 3D objects are placed everywhere else * in the engine — {@link Mesh}, {@link Sprite3d} and the ground-shadow * footprint all work from a center plus half-extents — and it keeps the * narrowphase free of corner/center conversions on the hot path. * * ## Mixing with 2D shapes * * A `Box3d` can collide with a planar shape. The planar shape is treated as * **unbounded along Z** (an infinitely extruded prism of its own outline), so * the pair degrades to the ordinary 2D test on the XY footprint and the box's * z never causes it to miss. This keeps an existing 2D game working unchanged * when a single `Box3d` body is introduced: its world shapes go on colliding * exactly as before. Use `collisionType` / `collisionMask` to opt specific * shapes out of a 3D body. * @category Geometry * @example * // a 64x16x64 floor slab centered on the origin * const floor = new Box3d(0, 0, 0, 64, 16, 64); * myFloor.body.addShape(floor); */ export declare class Box3d { /** * the center of the box, as an offset from the owning body's position */ pos: Vector3d; /** * half the box size on each axis. Always non-negative; a negative * extent passed to {@link Box3d#setShape} is stored as its magnitude, * since a box with a mirrored axis has no meaning to the narrowphase. */ halfExtents: Vector3d; /** * the shape type (used internally) * @default "Box3d" */ type: string; /** * @param x - center of the box on the horizontal axis * @param y - center of the box on the vertical axis * @param z - center of the box on the depth axis * @param width - width of the box * @param height - height of the box * @param depth - depth of the box */ constructor(x?: number, y?: number, z?: number, width?: number, height?: number, depth?: number); /** * set new position and size for this box * @param x - center of the box on the horizontal axis * @param y - center of the box on the vertical axis * @param z - center of the box on the depth axis * @param width - width of the box * @param height - height of the box * @param depth - depth of the box * @returns this box, for chaining */ setShape(x: number, y: number, z: number, width: number, height: number, depth: number): this; /** * width of the box */ get width(): number; set width(value: number); /** * height of the box */ get height(): number; set height(value: number); /** * depth of the box */ get depth(): number; set depth(value: number); /** * translate this box by the given offset * @param x - x offset, or a vector carrying the whole offset * @param [y] - y offset * @param [z] - z offset * @returns this box, for chaining */ shift(x: number | Vector3d, y?: number, z?: number): this; /** * the 2D XY footprint of this box. * * Deliberately 2D: this is the {@link Renderable#getBounds} contract that * {@link Body} and the broadphase pre-gate already speak. For the depth * extent use {@link Box3d#getBounds3d}. * @returns the XY footprint */ getBounds(): Bounds; /** * the 3D bounds of this box, in the body's local space. * @param [out] - an existing AABB3d to write into, to avoid allocating * @returns the 3D bounds */ getBounds3d(out?: AABB3d): AABB3d; /** * true if this box contains the given point * @param x - point x, or a vector carrying the whole point * @param [y] - point y * @param [z] - point z */ contains(x: number | Vector3d, y?: number, z?: number): boolean; /** * clone this box * @returns a new Box3d */ clone(): Box3d; } export declare const box3dPool: import("../system/pool.ts").Pool; //# sourceMappingURL=box3d.d.ts.map