import { CameraEvent , ChartScene } from './types' ; /**
 * Handle Camera Event
 *
 * Updates the `ChartScene`'s camera position based on the `CameraEvent`
 * Applies a y position change to the selected scene, and applies a x position change to all registered scenes.
 */ export const handleCameraEvent = ( { dx , dy , sceneId } , scenes ) => { const selectedScene = scenes . find ( ( { id } ) => id === sceneId ) ; if ( selectedScene ) { selectedScene . camera . position . y += dy ; selectedScene . camera . updateProjectionMatrix ( ) ; if ( dx !== 0 ) { scenes . forEach ( scene => { scene . camera . position . x -= dx ; scene . camera . updateProjectionMatrix ( ) ; } ) ; } } else { throw new Error ( `invalid chart scene ${ sceneId } requested - no such chart scene present. This should never occur.` ) ; } } ;