Skip to content
Snippets Groups Projects
Commit ec7670c8 authored by Alexander Rose's avatar Alexander Rose
Browse files

camera, tweaked naming

parent 969e61ef
No related branches found
No related tags found
No related merge requests found
...@@ -48,31 +48,32 @@ export interface CameraState { ...@@ -48,31 +48,32 @@ export interface CameraState {
export interface Camera { export interface Camera {
update: (props: any, block: any) => void, update: (props: any, block: any) => void,
setState: (newState: CameraState) => void, setState: (newState: CameraState) => void,
getState: () => CameraState,
isDirty: () => boolean isDirty: () => boolean
} }
export namespace Camera { export namespace Camera {
export function create (regl: REGL.Regl, element: HTMLElement, props: Partial<CameraState> = {}): Camera { export function create (regl: REGL.Regl, element: HTMLElement, initialState: Partial<CameraState> = {}): Camera {
const state: CameraState = { const state: CameraState = {
center: defaults(props.center, Vec3.zero()), center: defaults(initialState.center, Vec3.zero()),
theta: defaults(props.theta, 0), theta: defaults(initialState.theta, 0),
phi: defaults(props.phi, 0), phi: defaults(initialState.phi, 0),
distance: Math.log(defaults(props.distance, 10.0)), distance: Math.log(defaults(initialState.distance, 10.0)),
eye: Vec3.zero(), eye: Vec3.zero(),
up: defaults(props.up, Vec3.create(0, 1, 0)), up: defaults(initialState.up, Vec3.create(0, 1, 0)),
fovy: defaults(props.fovy, Math.PI / 4.0), fovy: defaults(initialState.fovy, Math.PI / 4.0),
near: defaults(props.near, 0.01), near: defaults(initialState.near, 0.01),
far: defaults(props.far, 1000.0), far: defaults(initialState.far, 1000.0),
noScroll: defaults(props.noScroll, false), noScroll: defaults(initialState.noScroll, false),
flipY: defaults(props.flipY, false), flipY: defaults(initialState.flipY, false),
dtheta: 0, dtheta: 0,
dphi: 0, dphi: 0,
rotationSpeed: defaults(props.rotationSpeed, 1), rotationSpeed: defaults(initialState.rotationSpeed, 1),
zoomSpeed: defaults(props.zoomSpeed, 1), zoomSpeed: defaults(initialState.zoomSpeed, 1),
renderOnDirty: defaults(props.renderOnDirty, false), renderOnDirty: defaults(initialState.renderOnDirty, false),
damping: defaults(props.damping, 0.9), damping: defaults(initialState.damping, 0.9),
minDistance: Math.log(defaults(props.minDistance, 0.1)), minDistance: Math.log(defaults(initialState.minDistance, 0.1)),
maxDistance: Math.log(defaults(props.maxDistance, 1000)) maxDistance: Math.log(defaults(initialState.maxDistance, 1000))
} }
const view = Mat4.identity() const view = Mat4.identity()
...@@ -183,6 +184,7 @@ export namespace Camera { ...@@ -183,6 +184,7 @@ export namespace Camera {
return { return {
update, update,
setState, setState,
getState: () => Object.assign({}, state),
isDirty: () => dirty isDirty: () => dirty
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment