import { type_adapters } from "./type_adapters.js";

/**
 *
 * @param {Object} j
 * @returns {AbstractShape3D}
 */
export function shape_from_json(j) {
    const type = j.type;

    const adapter = type_adapters[type];

    if (adapter === undefined) {
        throw new Error(`Unsupported shape type '${type}'`);
    }

    return adapter.read(j);
}

