import { CapsuleShape3D } from "../CapsuleShape3D.js";
import { CylinderShape3D } from "../CylinderShape3D.js";
import { SphereShape3D } from "../SphereShape3D.js";
import { TransformedShape3D } from "../TransformedShape3D.js";
import { UnionShape3D } from "../UnionShape3D.js";
import { UnitCubeShape3D } from "../UnitCubeShape3D.js";

/**
 *
 * @param {AbstractShape3D} shape
 * @returns {string}
 */
export function shape_to_type(shape) {
    if (shape instanceof UnionShape3D) {
        return 'union';
    } else if (shape instanceof UnitCubeShape3D) {
        return 'cube';
    } else if (shape instanceof SphereShape3D) {
        // Covers UnitSphereShape3D (radius 1) and SphereShape3D (arbitrary);
        // the 'sphere' adapter carries the radius.
        return 'sphere';
    } else if (shape instanceof TransformedShape3D) {
        return 'transform';
    } else if (shape instanceof CapsuleShape3D) {
        return 'capsule';
    } else if (shape instanceof CylinderShape3D) {
        return 'cylinder';
    } else {
        throw new Error('Unsupported shape');
    }
}
