camera.js 888 Bytes
import { PerspectiveCamera, OrthographicCamera } from 'three';

const Camera = ({
    width = window.innerWidth,
    height = window.innerHeight,
    fov = 25
}) => {
    const makePerspectiveCamera = () => {
        const aspect = width / height;
        const near = 1;
        const far = 2000;
        const newCamera = new PerspectiveCamera(fov, aspect, near, far);
        return newCamera;
    };
    const makeOrthographicCamera = () => {
        const halfW = width * 0.5;
        const halfH = height * 0.5;
        const near = -10000;
        const far = 10000;
        const newCamera = new OrthographicCamera(
            -halfW,
            halfW,
            halfH,
            -halfH,
            near,
            far
        );
        return newCamera;
    };
    return {
        makePerspectiveCamera,
        makeOrthographicCamera
    };
};
export default Camera;