@@ -559,13 +559,12 @@ proto.destroy = function() {
559559// for reset camera button in mode bar
560560proto . setCameraToDefault = function setCameraToDefault ( ) {
561561 // as in Gl3d.layoutAttributes
562- var lookAtInput = [
563- [ 1.25 , 1.25 , 1.25 ] ,
564- [ 0 , 0 , 0 ] ,
565- [ 0 , 0 , 1 ]
566- ] ;
567- this . glplot . camera . lookAt . apply ( this , lookAtInput ) ;
568- this . graphDiv . emit ( 'plotly_relayout' , lookAtInput ) ;
562+
563+ this . setCamera ( {
564+ eye : { x : 1.25 , y : 1.25 , z : 1.25 } ,
565+ center : { x : 0 , y : 0 , z : 0 } ,
566+ up : { x : 0 , y : 0 , z : 1 }
567+ } ) ;
569568} ;
570569
571570// get camera position in plotly coords from 'orbit-camera' coords
@@ -585,16 +584,22 @@ proto.getCamera = function getCamera() {
585584
586585// set camera position with a set of plotly coords
587586proto . setCamera = function setCamera ( cameraData ) {
588- var up = cameraData . up ;
589- var center = cameraData . center ;
590- var eye = cameraData . eye ;
591- var lookAtInput = [
592- [ eye . x , eye . y , eye . z ] ,
593- [ center . x , center . y , center . z ] ,
594- [ up . x , up . y , up . z ]
595- ] ;
596- this . glplot . camera . lookAt . apply ( this , lookAtInput ) ;
597- this . graphDiv . emit ( 'plotly_relayout' , lookAtInput ) ;
587+
588+ // getOrbitCamera :: plotly_coords -> orbit_camera_coords
589+ function getOrbitCamera ( camera ) {
590+ return [
591+ [ camera . eye . x , camera . eye . y , camera . eye . z ] ,
592+ [ camera . center . x , camera . center . y , camera . center . z ] ,
593+ [ camera . up . x , camera . up . y , camera . up . z ]
594+ ] ;
595+ }
596+
597+ var update = { } ;
598+
599+ update [ this . id ] = cameraData ;
600+
601+ this . glplot . camera . lookAt . apply ( this , getOrbitCamera ( cameraData ) ) ;
602+ this . graphDiv . emit ( 'plotly_relayout' , update ) ;
598603} ;
599604
600605// save camera to user layout (i.e. gd.layout)
0 commit comments