import { v3_length } from "../../vec3/v3_length.js";
import { AbstractShape3D } from "./AbstractShape3D.js";

/**
 * Describes a point, shape that encloses no space
 */
export class PointShape3D extends AbstractShape3D {
    get volume() {
        return 0;
    }

    get surface_area() {
        return 0;
    }

    compute_bounding_box(result) {
        result[0] = 0;
        result[1] = 0;
        result[2] = 0;
        result[3] = 0;
        result[4] = 0;
        result[5] = 0;
    }

    signed_distance_at_point(point) {
        return v3_length(point[0], point[1], point[2]);
    }

    contains_point(point) {
        return false;
    }

    nearest_point_on_surface(result, reference) {
        result[0] = 0;
        result[1] = 0;
        result[2] = 0;
    }

    sample_random_point_in_volume(result, result_offset, random) {
        result[result_offset] = 0;
        result[result_offset + 1] = 0;
        result[result_offset + 2] = 0;
    }

    support(result, result_offset, direction_x, direction_y, direction_z) {
        result[result_offset] = 0;
        result[result_offset + 1] = 0;
        result[result_offset + 2] = 0;
    }

    equals(other) {
        // Parameterless: identity is the type alone (a point has no fields).
        return super.equals(other);
    }

    hash() {
        // Constant — every PointShape3D is identical. Distinct from the
        // base-class 0 so it doesn't collide with a hypothetical default shape.
        return 0x504f494e; // "POIN"
    }

    static INSTANCE = new PointShape3D();
}
