export default Detector; /** * the Detector class contains methods for detecting collisions between bodies using a broadphase algorithm. */ declare class Detector { /** * @param {Container} world - the physic world this detector is bind to */ constructor(world: Container); world: Container; /** * the default response object used for collisions * (will be automatically populated by the collides functions) * @type {ResponseObject} */ response: ResponseObject; /** * Pairs (key → [renderableA, renderableB]) that were colliding in * the previous step. Diffed against `_frameSeen` at end of step * to fire `onCollisionEnd` for pairs that just separated. * @ignore */ _activePairs: Map; /** * Pairs seen during the current step. Built up as the per-object * `collisions()` calls run; consumed by `endFrame()`. * @ignore */ _frameSeen: Map; /** * Two-slot pool of "symmetric view" objects passed to the new * collision lifecycle handlers (`onCollisionStart` / * `onCollisionActive` / `onCollisionEnd`). Each view carries the * receiver-symmetric form: `a` = receiver, `b` = partner, * `normal` = MTV of receiver, `depth` = penetration scalar, * plus the SAT-legacy `overlapN` / `overlapV` / `overlap` fields * flipped to match the same convention. * * Two slots are needed because both views may be live at the * same time (one handler can dispatch into the other through * world mutation). Slot 0 is used for the original-a-side * dispatch, slot 1 for the original-b-side. * @ignore */ _symViews: { a: null; b: null; overlap: number; overlapN: { x: number; y: number; }; overlapV: { x: number; y: number; }; normal: { x: number; y: number; }; depth: number; }[]; /** * Populate one of the pooled symmetric views from a SAT response. * `flip=false` builds the view for `response.a`'s side (legacy * fields kept as-is, `normal = -overlapN` = MTV of original a). * `flip=true` builds it for `response.b`'s side: `a` / `b` swap, * `overlapN` / `overlapV` negated, `normal = +overlapN` (the MTV * of original b). * @ignore */ _fillSymView(slot: any, satResponse: any, flip: any): { a: null; b: null; overlap: number; overlapN: { x: number; y: number; }; overlapV: { x: number; y: number; }; normal: { x: number; y: number; }; depth: number; }; /** * Called by the adapter at the start of a physics step. Resets the * "seen this frame" set so the end-of-step diff can fire * `onCollisionEnd` for pairs that no longer overlap. * @ignore */ beginFrame(): void; /** * Called by the adapter at the end of a physics step. Diffs the * "seen this frame" set against the previous-frame active pairs: * - pairs in active but not seen → fire onCollisionEnd * - swap active ← seen for the next step's diff * @ignore */ endFrame(): void; /** * Build a stable order-independent key for a pair of renderables, * using their GUID. Returns undefined if either lacks a GUID (defensive * — detached or pool-recycled objects mid-step). * @ignore */ _pairKey(a: any, b: any): string | undefined; /** * determine if two objects should collide (based on both respective objects body collision mask and type).
* you can redefine this function if you need any specific rules over what should collide with what. * @param {Renderable|Container|Entity|Sprite|NineSliceSprite} a - a reference to the object A. * @param {Renderable|Container|Entity|Sprite|NineSliceSprite} b - a reference to the object B. * @returns {boolean} true if they should collide, false otherwise */ shouldCollide(a: Renderable | Container | Entity | Sprite | NineSliceSprite, b: Renderable | Container | Entity | Sprite | NineSliceSprite): boolean; /** * detect collision between two bodies. * @param {Body} bodyA - a reference to body A. * @param {Body} bodyB - a reference to body B. * @returns {boolean} true if colliding */ collides(bodyA: Body, bodyB: Body, response?: ResponseObject): boolean; /** * find all the collisions for the specified object using a broadphase algorithm * @ignore * @param {Renderable|Container|Entity|Sprite|NineSliceSprite} objA - object to be tested for collision * @returns {boolean} in case of collision, false otherwise */ collisions(objA: Renderable | Container | Entity | Sprite | NineSliceSprite): boolean; /** * Checks for object colliding with the given line * @ignore * @param {Line} line - line to be tested for collision * @param {Array.} [result] - a user defined array that will be populated with intersecting physic objects. * @returns {Array.} an array of intersecting physic objects * @example * // define a line accross the viewport * let ray = new Line( * // absolute position of the line * 0, 0, [ * // starting point relative to the initial position * new Vector2d(0, 0), * // ending point * new Vector2d(app.viewport.width, app.viewport.height) * ]); * * // check for collition * result = me.collision.rayCast(ray); * * if (result.length > 0) { * // ... * } */ rayCast(line: Line, result?: Array): Array; } import type Container from "../../renderable/container.js"; import ResponseObject from "../response.js"; import type Renderable from "../../renderable/renderable.js"; import type Entity from "../../renderable/entity/entity.js"; import type Sprite from "../../renderable/sprite.js"; import type NineSliceSprite from "../../renderable/nineslicesprite.js"; import type { Line } from "../../geometries/line.ts"; //# sourceMappingURL=detector.d.ts.map