Warning

Nightly releases are generated automatically from the latest source code and are intended for experimental purposes only. These builds may contain incomplete or untested features, bugs, or security vulnerabilities, and as such, are not for production use. Users should be aware that nightly releases may cause unexpected behavior, data loss, or system instability. Use of these releases is at the user's own risk, and it is advised to have adequate backups before testing. The software is provided as is with no guarantees or support.

BoxVolume

This interfaces provides functions for working with BoxVolumes. BoxVolumes are axis aligned bounding boxes (AABB). They are usually used to describe the minimal bounding box of a node. They consist of six values, 3 for the minimum and 3 for the maximum corner.

interface BoxVolume {
    contains(other: BoxVolume): boolean;
    copy(other: BoxVolume): void;
    equals(other: BoxVolume): boolean;
    extend(
        newMin: Float32Array<ArrayBufferLike> | [number, number, number],
        newMax: Float32Array<ArrayBufferLike> | [number, number, number],
    ): void;
    extendByTransformedVolume(
        other: BoxVolume,
        transform?:
            | Float32Array<ArrayBufferLike>
            | [
                number,
                number,
                number,
                number,
                number,
                number,
                number,
                number,
                number,
                number,
                number,
                number,
                number,
                number,
                number,
                number,
            ],
    ): void;
    extendByVolume(other: BoxVolume): void;
    fromArray(array: number[] | Float32Array<ArrayBufferLike>): boolean;
    getCenter(): Float32Array<ArrayBufferLike>;
    getCornerPoints(): Float32Array<ArrayBufferLike>[];
    getDiameter(): number;
    getMax(): Float32Array<ArrayBufferLike>;
    getMin(): Float32Array<ArrayBufferLike>;
    getRadialVec(): Float32Array<ArrayBufferLike>;
    getSize(): Float32Array<ArrayBufferLike>;
    includePoint(p: Float32Array<ArrayBufferLike>): void;
    isValid(): boolean;
    overlaps(other: BoxVolume): boolean;
    reset(): void;
    setFromCenterSize(
        center: Float32Array<ArrayBufferLike> | [number, number, number],
        size: Float32Array<ArrayBufferLike> | [number, number, number],
    ): BoxVolume;
    setMax(max: Float32Array<ArrayBufferLike> | [number, number, number]): void;
    setMin(min: Float32Array<ArrayBufferLike> | [number, number, number]): void;
    transformFrom(
        matrix:
            | Float32Array<ArrayBufferLike>
            | [
                number,
                number,
                number,
                number,
                number,
                number,
                number,
                number,
                number,
                number,
                number,
                number,
                number,
                number,
                number,
                number,
            ],
        other: BoxVolume,
    ): BoxVolume;
    transformFromArray(
        matrix:
            | Float32Array<ArrayBufferLike>
            | [
                number,
                number,
                number,
                number,
                number,
                number,
                number,
                number,
                number,
                number,
                number,
                number,
                number,
                number,
                number,
                number,
            ],
        otherVolume: number[],
    ): BoxVolume;
}

Methods

  • Checks if the given BoxVolume contains the other BoxVolume.

    Parameters

    Returns boolean

    true if the given BoxVolume contains the other BoxVolume, false otherwise

  • Sets the minimum and maximum corners of the BoxVolume to that of a given BoxVolume.

    Parameters

    • other: BoxVolume

      the BoxVolume to copy the corners from

    Returns void

  • Checks if the given BoxVolume equals the other BoxVolume.

    Parameters

    Returns boolean

    true if the given BoxVolume equals the other BoxVolume, false otherwise

  • Extends this box in such a way that both, newMin and newMax, are included. If one of the given values is already inside the box, nothing is done (i.e., the box is potentially extended, but never shrunk after calling this function). If this box has no valid minimum / maximum yet, the given values are used.

    Parameters

    • newMin: Float32Array<ArrayBufferLike> | [number, number, number]

      The potential new minimum corner of the box in the format [x, y, z].

    • newMax: Float32Array<ArrayBufferLike> | [number, number, number]

      The potential new maximum corner of the box in the format [x, y, z].

    Returns void

  • Extends a BoxVolume by a transformed BoxVolume.

    Parameters

    • other: BoxVolume

      the BoxVolume to extend by

    • Optionaltransform:
          | Float32Array<ArrayBufferLike>
          | [
              number,
              number,
              number,
              number,
              number,
              number,
              number,
              number,
              number,
              number,
              number,
              number,
              number,
              number,
              number,
              number,
          ]

      the transformation matrix to apply to the other BoxVolume

    Returns void

  • Extends a BoxVolume by another BoxVolume. The resulting BoxVolume will span over the other BoxVolume, too. If the other BoxVolume is already inside this BoxVolume, nothing is done.

    Parameters

    Returns void

  • Creates a BoxVolume from an array.

    Parameters

    • array: number[] | Float32Array<ArrayBufferLike>

      the number array with 6 values, representing the minimum and maximum corners of the BoxVolume

    Returns boolean

    true if the new BoxVolume is valid, false otherwise

  • Gets the center point of the BoxVolume. The point is specified as a single array with the format [x, y, z].

    Returns Float32Array<ArrayBufferLike>

    the center point of the BoxVolume

  • Gets the corner points of a BoxVolume.

    Returns Float32Array<ArrayBufferLike>[]

    An array of eight Float32Array objects. Each Float32Array represents a corner point of the bounding box in 3D space, with the fourth component set to 1.

  • Gets the diameter of the BoxVolume.

    Returns number

    The diameter of the bounding box, which is the Euclidean distance between the minimum and maximum coordinates.

  • Gets the maximum point of the BoxVolume. The point is specified as a single array with the format [x, y, z].

    Returns Float32Array<ArrayBufferLike>

    the maximum point of the BoxVolume

  • Gets the minimum point of the BoxVolume. The point is specified as a single array with the format [x, y, z].

    Returns Float32Array<ArrayBufferLike>

    the minimum point of the BoxVolume

  • Gets the radial vector of the BoxVolume.

    Returns Float32Array<ArrayBufferLike>

    A Float32Array representing the radial vector, which is half the difference between the maximum and minimum coordinates of the bounding box.

  • Gets the size of the BoxVolume.

    Returns Float32Array<ArrayBufferLike>

    the size of the BoxVolume, specified as a single array with the format [max_x - min_x, max_y - min_y, max_z - min_z].

  • Extends the BoxVolume to include the given point. If the point is already inside the BoxVolume, nothing is done.

    Parameters

    • p: Float32Array<ArrayBufferLike>

      the point to include in the BoxVolume with the format [x, y, z]

    Returns void

  • Checks if the BoxVolume is valid.

    Returns boolean

    true if the BoxVolume is valid, false otherwise

  • Checks if two BoxVolumes are overlapping.

    Parameters

    Returns boolean

    true if the BoxVolumes are overlapping, false otherwise

  • Resets the BoxVolume to its initial state.

    Returns void

  • Creates the BoxVolume from a center point and a size.

    Parameters

    • center: Float32Array<ArrayBufferLike> | [number, number, number]

      the center point of the new BoxVolume, consisting of the x, y, and z coordinates

    • size: Float32Array<ArrayBufferLike> | [number, number, number]

      the size of the new BoxVolume, consisting of the width, height, and depth

    Returns BoxVolume

    the new BoxVolume

  • Sets the maximum corner of the BoxVolume. The point is specified as a single array with the format [x, y, z].

    Parameters

    • max: Float32Array<ArrayBufferLike> | [number, number, number]

      the maximum corner of the BoxVolume

    Returns void

  • Sets the minimum corner of the BoxVolume. The point is specified as a single array with the format [x, y, z].

    Parameters

    • min: Float32Array<ArrayBufferLike> | [number, number, number]

      the minimum corner of the BoxVolume

    Returns void

  • Creates a new BoxVolume from a given BoxVolume which is transformed by a matrix.

    Parameters

    • matrix:
          | Float32Array<ArrayBufferLike>
          | [
              number,
              number,
              number,
              number,
              number,
              number,
              number,
              number,
              number,
              number,
              number,
              number,
              number,
              number,
              number,
              number,
          ]

      the transformation matrix

    • other: BoxVolume

      the BoxVolume to transform

    Returns BoxVolume

    the new BoxVolume

  • Creates a new BoxVolume from a given BoxVolume, defined by an array, which is then transformed by a matrix.

    Parameters

    • matrix:
          | Float32Array<ArrayBufferLike>
          | [
              number,
              number,
              number,
              number,
              number,
              number,
              number,
              number,
              number,
              number,
              number,
              number,
              number,
              number,
              number,
              number,
          ]

      the transformation matrix

    • otherVolume: number[]

      the BoxVolume to transform defined by a 6-element array of the minimum and maximum corners.

    Returns BoxVolume

    the new BoxVolume