nape-js API
    Preparing search index...

    Class AABB

    Axis-aligned bounding box defined by min/max corners or x/y/width/height.

    Internally wraps a ZPP_AABB and is registered as the public nape.geom.AABB class in the compiled namespace.

    Converted from nape-compiled.js lines 14950–15653.

    Index

    Constructors

    • Create an AABB at position (x, y) with the given width and height. All values default to 0.

      Parameters

      • x: number = 0

        The x position of the left edge (default 0).

      • y: number = 0

        The y position of the top edge (default 0).

      • width: number = 0

        The width of the box (default 0). Must be ≥ 0.

      • height: number = 0

        The height of the box (default 0). Must be ≥ 0.

      Returns AABB

    Accessors

    • get height(): number

      Height of the box (maxy − miny). Must be ≥ 0.

      Returns number

    • set height(height: number): void

      Height of the box (maxy − miny). Must be ≥ 0.

      Parameters

      • height: number

      Returns void

    • get max(): any

      The bottom-right corner as a Vec2 (maxx, maxy). The returned Vec2 is a live view; mutating it updates the AABB.

      Returns any

    • set max(max: any): void

      Set the bottom-right corner. The new max must not be below the current min.

      Parameters

      • max: any

        A Vec2 whose components become the new (maxx, maxy).

      Returns void

    • get min(): any

      The top-left corner as a Vec2 (minx, miny). The returned Vec2 is a live view; mutating it updates the AABB.

      Returns any

    • set min(min: any): void

      Set the top-left corner. The new min must not exceed the current max.

      Parameters

      • min: any

        A Vec2 whose components become the new (minx, miny).

      Returns void

    • get width(): number

      Width of the box (maxx − minx). Must be ≥ 0.

      Returns number

    • set width(width: number): void

      Width of the box (maxx − minx). Must be ≥ 0.

      Parameters

      • width: number

      Returns void

    • get x(): number

      The x position of the left edge (minx). Setting shifts the box horizontally.

      Returns number

    • set x(x: number): void

      The x position of the left edge (minx). Setting shifts the box horizontally.

      Parameters

      • x: number

      Returns void

    • get y(): number

      The y position of the top edge (miny). Setting shifts the box vertically.

      Returns number

    • set y(y: number): void

      The y position of the top edge (miny). Setting shifts the box vertically.

      Parameters

      • y: number

      Returns void

    Methods

    • Return a new AABB with the same bounds. Alias for copy().

      Returns AABB

      A new AABB with the same position and dimensions.

    • Check whether this AABB is equal to another, within an optional epsilon tolerance.

      Parameters

      • other: AABB

        The AABB to compare against.

      • epsilon: number = 0

        Maximum allowed difference per component (default 0).

      Returns boolean

      true if all four bounds (minx, miny, maxx, maxy) differ by at most epsilon.

    • String representation in the form { x: … y: … w: … h: … }.

      Returns string

      A human-readable string of this AABB's position and dimensions.

    • Create the smallest AABB that contains all the given points. Disposes weak Vec2 arguments after use.

      Parameters

      • points: Vec2[]

        An array of Vec2 points to enclose. Must contain at least one point.

      Returns AABB

      A new AABB enclosing all the points.