<commit_before>/**
 * Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info.
 *
 * @author <NAME> <<EMAIL>>
 */

import { PerspectiveCamera,  } from './perspective';
import { OrthographicCamera } from './orthographic';
import { Camera, DefaultCameraProps } from './base';
import { Vec3 } from 'mol-math/linear-algebra';

// TODO

// updateZoom () {
//     const fov = degToRad(this.perspectiveCamera.fov)
//     const height = 2 * Math.tan(fov / 2) * -this.camera.position.z
//     this.orthographicCamera.zoom = this.height / height
// }

export type CombinedCameraMode = 'perspective' | 'orthographic'

export interface CombinedCamera extends Camera {
    target: Vec3
    fov: number
    zoom: number
    mode: CombinedCameraMode
}

export const DefaultCombinedCameraProps = {
    ...DefaultCameraProps,
    target: Vec3.zero(),
    fov: Math.PI / 4,
    zoom: 1,
    mode: 'perspective' as CombinedCameraMode
}
export type CombinedCameraProps = Partial<typeof DefaultCombinedCameraProps>

export namespace CombinedCamera {
    export function create(props: CombinedCameraProps = {}): CombinedCamera {
        const { zoom, fov, mode, target: t } = { ...DefaultCombinedCameraProps, ...props };
        const target = Vec3.create(t[0], t[1], t[2])
        const camera = { ...Camera.create(props), zoom, fov, mode, target }
        update(camera)

        return camera
    }

    // const center = Vec3.zero()
    export function update(camera: CombinedCamera) {
        // console.log(camera.position, camera.direction)
        // Vec3.add(center, camera.position, camera.direction)

        const height = 2 * Math.tan(camera.fov / 2) * Vec3.distance(camera.position, camera.target)
        camera.zoom = camera.viewport.height / height

        switch (camera.mode) {
            case 'orthographic': OrthographicCamera.update(camera); break
            case 'perspective': PerspectiveCamera.update(camera); break
        }
    }
}<commit_msg>cleanup<commit_after>/**
 * Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info.
 *
 * @author <NAME> <<EMAIL>>
 */

import { PerspectiveCamera,  } from './perspective';
import { OrthographicCamera } from './orthographic';
import { Camera, DefaultCameraProps } from './base';
import { Vec3 } from 'mol-math/linear-algebra';

export type CombinedCameraMode = 'perspective' | 'orthographic'

export interface CombinedCamera extends Camera {
    target: Vec3
    fov: number
    zoom: number
    mode: CombinedCameraMode
}

export const DefaultCombinedCameraProps = {
    ...DefaultCameraProps,
    target: Vec3.zero(),
    fov: Math.PI / 4,
    zoom: 1,
    mode: 'perspective' as CombinedCameraMode
}
export type CombinedCameraProps = Partial<typeof DefaultCombinedCameraProps>

export namespace CombinedCamera {
    export function create(props: CombinedCameraProps = {}): CombinedCamera {
        const { zoom, fov, mode, target: t } = { ...DefaultCombinedCameraProps, ...props };
        const target = Vec3.create(t[0], t[1], t[2])
        const camera = { ...Camera.create(props), zoom, fov, mode, target }
        update(camera)

        return camera
    }

    export function update(camera: CombinedCamera) {
        const height = 2 * Math.tan(camera.fov / 2) * Vec3.distance(camera.position, camera.target)
        camera.zoom = camera.viewport.height / height

        switch (camera.mode) {
            case 'orthographic': OrthographicCamera.update(camera); break
            case 'perspective': PerspectiveCamera.update(camera); break
        }
    }
}
{'fraction_non_alphanumeric': 0.12210761081683859, 'fraction_numerical': 0.010036241984945637, 'mean_word_length': 3.13840830449827, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5756041', 'n_tokens_mistral': 1054, 'n_tokens_neox': 1005, 'n_words': 278}