import Vec3 from "./vec3";
export default class Box {
    constructor(position, size) {
        this.position = position;
        this.size = size;
    }
    center() {
        return new Vec3([
            this.position.x + this.size.x / 2,
            this.position.y + this.size.y / 2,
            this.position.z + this.size.z / 2,
        ]);
    }
    get upperBound() {
        return new Vec3([
            this.position.x + this.size.x,
            this.position.y + this.size.y,
            this.position.z + this.size.z,
        ]);
    }
    contains(box) {
        return ((box.position.x >= this.position.x &&
            box.position.x <= this.position.x + this.size.x &&
            box.position.y >= this.position.y &&
            box.position.y <= this.position.y + this.size.y &&
            box.position.z >= this.position.z &&
            box.position.z <= this.position.z + this.size.z) &&
            (box.position.x + box.size.x >= this.position.x &&
                box.position.x + box.size.x <= this.position.x + this.size.x &&
                box.position.y + box.size.y >= this.position.y &&
                box.position.y + box.size.y <= this.position.y + this.size.y &&
                box.position.z + box.size.z >= this.position.z &&
                box.position.z + box.size.z <= this.position.z + this.size.z));
    }
    overlaps(box) {
        return this.position.x <= box.position.x + box.size.x &&
            this.position.x + this.size.x >= box.position.x &&
            this.position.y <= box.position.y + box.size.y &&
            this.position.y + this.size.y >= box.position.y &&
            this.position.z <= box.position.z + box.size.z &&
            this.position.z + this.size.z >= box.position.z;
    }
    containsPoint(x, y, z) {
        return (x >= this.position.x && x <= this.position.x + this.size.x &&
            y >= this.position.y && y <= this.position.y + this.size.y &&
            z >= this.position.z && z <= this.position.z + this.size.z);
    }
}
