import { OrthographicCamera as ThreeOrthographicCamera, PerspectiveCamera as ThreePerspectiveCamera } from "three";
import { ProjectionType } from "./ProjectionType.js";

/**
 *
 * @param {Camera} component
 * @returns {THREE.PerspectiveCamera| THREE.OrthographicCamera}
 */
export function build_three_camera_object(component) {

    let result;
    switch (component.projectionType.getValue()) {
        default:
            console.error(`Unsupported camera projection type "${component.projectionType.getValue()}", defaulting to perspective projection`);
        //fallthrough
        case ProjectionType.Perspective:
            result = new ThreePerspectiveCamera(component.fov.getValue(), 1, 1, 50);
            break;
        case ProjectionType.Orthographic:
            result = new ThreeOrthographicCamera(-10, 10, 20, -20, 1, 1);
            break;
    }


    result.far = component.clip_far;
    result.near = component.clip_near;

    return result;
}
