@@ -586,9 +586,7 @@ describe('Test gl3d plots', function() {
586586 . then ( delay ( 20 ) )
587587 . then ( function ( ) {
588588 expect ( gd . _fullLayout . scene . camera . projection . type === 'perspective' ) . toBe ( true ) ;
589- } )
590- . then ( function ( ) {
591- expect ( gd . _fullLayout . scene . _scene . glplot . camera . _ortho ) . toBe ( false ) ;
589+ expect ( gd . _fullLayout . scene . _scene . glplot . camera . _ortho === false ) . toBe ( true ) ;
592590 } )
593591 . then ( done ) ;
594592 } ) ;
@@ -614,9 +612,7 @@ describe('Test gl3d plots', function() {
614612 . then ( delay ( 20 ) )
615613 . then ( function ( ) {
616614 expect ( gd . _fullLayout . scene . camera . projection . type === 'orthographic' ) . toBe ( true ) ;
617- } )
618- . then ( function ( ) {
619- expect ( gd . _fullLayout . scene . _scene . glplot . camera . _ortho ) . toBe ( true ) ;
615+ expect ( gd . _fullLayout . scene . _scene . glplot . camera . _ortho === true ) . toBe ( true ) ;
620616 } )
621617 . then ( done ) ;
622618 } ) ;
@@ -645,18 +641,28 @@ describe('Test gl3d plots', function() {
645641 } )
646642 . then ( function ( ) {
647643 expect ( gd . _fullLayout . scene . camera . projection . type === 'orthographic' ) . toBe ( true ) ;
644+ expect ( gd . _fullLayout . scene . _scene . glplot . camera . _ortho === true ) . toBe ( true ) ;
648645 } )
649646 . then ( function ( ) {
650- expect ( gd . _fullLayout . scene . _scene . glplot . camera . _ortho ) . toBe ( true ) ;
647+ return Plotly . relayout ( gd , 'scene.camera.eye.z' , 2 ) ;
648+ } )
649+ . then ( function ( ) {
650+ expect ( gd . _fullLayout . scene . camera . projection . type === 'orthographic' ) . toBe ( true ) ;
651+ expect ( gd . _fullLayout . scene . _scene . glplot . camera . _ortho === true ) . toBe ( true ) ;
651652 } )
652653 . then ( function ( ) {
653654 return Plotly . relayout ( gd , 'scene.camera.projection.type' , 'perspective' ) ;
654655 } )
655656 . then ( function ( ) {
656657 expect ( gd . _fullLayout . scene . camera . projection . type === 'perspective' ) . toBe ( true ) ;
658+ expect ( gd . _fullLayout . scene . _scene . glplot . camera . _ortho === false ) . toBe ( true ) ;
657659 } )
658660 . then ( function ( ) {
659- expect ( gd . _fullLayout . scene . _scene . glplot . camera . _ortho ) . toBe ( false ) ;
661+ return Plotly . relayout ( gd , 'scene.camera.eye.z' , 3 ) ;
662+ } )
663+ . then ( function ( ) {
664+ expect ( gd . _fullLayout . scene . camera . projection . type === 'perspective' ) . toBe ( true ) ;
665+ expect ( gd . _fullLayout . scene . _scene . glplot . camera . _ortho === false ) . toBe ( true ) ;
660666 } )
661667 . then ( done ) ;
662668 } ) ;
@@ -1193,7 +1199,7 @@ describe('Test gl3d drag and wheel interactions', function() {
11931199 . then ( done ) ;
11941200 } ) ;
11951201
1196- it ( '@gl should update the scene camera' , function ( done ) {
1202+ it ( '@gl should update the scene camera - perspective case ' , function ( done ) {
11971203 var sceneLayout , sceneLayout2 , sceneTarget , sceneTarget2 , relayoutCallback ;
11981204
11991205 var mock = {
@@ -1226,6 +1232,114 @@ describe('Test gl3d drag and wheel interactions', function() {
12261232 . toEqual ( { x : 0.1 , y : 0.1 , z : 1 } ) ;
12271233 expect ( sceneLayout2 . camera . eye )
12281234 . toEqual ( { x : 2.5 , y : 2.5 , z : 2.5 } ) ;
1235+ expect ( sceneLayout . camera . projection )
1236+ . toEqual ( { type : 'perspective' } ) ;
1237+ expect ( sceneLayout2 . camera . projection )
1238+ . toEqual ( { type : 'perspective' } ) ;
1239+
1240+ return scroll ( sceneTarget ) ;
1241+ } )
1242+ . then ( function ( ) {
1243+ _assertAndReset ( 1 ) ;
1244+ return scroll ( sceneTarget2 ) ;
1245+ } )
1246+ . then ( function ( ) {
1247+ _assertAndReset ( 1 ) ;
1248+ return drag ( sceneTarget2 , [ 0 , 0 ] , [ 100 , 100 ] ) ;
1249+ } )
1250+ . then ( function ( ) {
1251+ _assertAndReset ( 1 ) ;
1252+ return drag ( sceneTarget , [ 0 , 0 ] , [ 100 , 100 ] ) ;
1253+ } )
1254+ . then ( function ( ) {
1255+ _assertAndReset ( 1 ) ;
1256+ return Plotly . relayout ( gd , { 'scene.dragmode' : false , 'scene2.dragmode' : false } ) ;
1257+ } )
1258+ . then ( function ( ) {
1259+ _assertAndReset ( 1 ) ;
1260+ return drag ( sceneTarget , [ 0 , 0 ] , [ 100 , 100 ] ) ;
1261+ } )
1262+ . then ( function ( ) {
1263+ return drag ( sceneTarget2 , [ 0 , 0 ] , [ 100 , 100 ] ) ;
1264+ } )
1265+ . then ( function ( ) {
1266+ _assertAndReset ( 0 ) ;
1267+
1268+ return Plotly . relayout ( gd , { 'scene.dragmode' : 'orbit' , 'scene2.dragmode' : 'turntable' } ) ;
1269+ } )
1270+ . then ( function ( ) {
1271+ expect ( relayoutCallback ) . toHaveBeenCalledTimes ( 1 ) ;
1272+ relayoutCallback . calls . reset ( ) ;
1273+
1274+ return drag ( sceneTarget , [ 0 , 0 ] , [ 100 , 100 ] ) ;
1275+ } )
1276+ . then ( function ( ) {
1277+ return drag ( sceneTarget2 , [ 0 , 0 ] , [ 100 , 100 ] ) ;
1278+ } )
1279+ . then ( function ( ) {
1280+ _assertAndReset ( 2 ) ;
1281+ return Plotly . plot ( gd , [ ] , { } , { scrollZoom : false } ) ;
1282+ } )
1283+ . then ( function ( ) {
1284+ return scroll ( sceneTarget ) ;
1285+ } )
1286+ . then ( function ( ) {
1287+ return scroll ( sceneTarget2 ) ;
1288+ } )
1289+ . then ( function ( ) {
1290+ _assertAndReset ( 0 ) ;
1291+ return Plotly . plot ( gd , [ ] , { } , { scrollZoom : 'gl3d' } ) ;
1292+ } )
1293+ . then ( function ( ) {
1294+ return scroll ( sceneTarget ) ;
1295+ } )
1296+ . then ( function ( ) {
1297+ return scroll ( sceneTarget2 ) ;
1298+ } )
1299+ . then ( function ( ) {
1300+ _assertAndReset ( 2 ) ;
1301+ } )
1302+ . catch ( failTest )
1303+ . then ( done ) ;
1304+ } ) ;
1305+
1306+ it ( '@gl should update the scene camera - orthographic case' , function ( done ) {
1307+ var sceneLayout , sceneLayout2 , sceneTarget , sceneTarget2 , relayoutCallback ;
1308+
1309+ var mock = {
1310+ data : [
1311+ { type : 'scatter3d' , x : [ 1 , 2 , 3 ] , y : [ 2 , 3 , 1 ] , z : [ 3 , 1 , 2 ] } ,
1312+ { type : 'surface' , scene : 'scene2' , x : [ 1 , 2 ] , y : [ 2 , 1 ] , z : [ [ 1 , 2 ] , [ 2 , 1 ] ] }
1313+ ] ,
1314+ layout : {
1315+ scene : { camera : { projection : { type : 'orthographic' } , eye : { x : 0.1 , y : 0.1 , z : 1 } } } ,
1316+ scene2 : { camera : { projection : { type : 'orthographic' } , eye : { x : 2.5 , y : 2.5 , z : 2.5 } } }
1317+ }
1318+ } ;
1319+
1320+ function _assertAndReset ( cnt ) {
1321+ expect ( relayoutCallback ) . toHaveBeenCalledTimes ( cnt ) ;
1322+ relayoutCallback . calls . reset ( ) ;
1323+ }
1324+
1325+ Plotly . plot ( gd , mock )
1326+ . then ( function ( ) {
1327+ relayoutCallback = jasmine . createSpy ( 'relayoutCallback' ) ;
1328+ gd . on ( 'plotly_relayout' , relayoutCallback ) ;
1329+
1330+ sceneLayout = gd . _fullLayout . scene ;
1331+ sceneLayout2 = gd . _fullLayout . scene2 ;
1332+ sceneTarget = gd . querySelector ( '.svg-container .gl-container #scene canvas' ) ;
1333+ sceneTarget2 = gd . querySelector ( '.svg-container .gl-container #scene2 canvas' ) ;
1334+
1335+ expect ( sceneLayout . camera . eye )
1336+ . toEqual ( { x : 0.1 , y : 0.1 , z : 1 } ) ;
1337+ expect ( sceneLayout2 . camera . eye )
1338+ . toEqual ( { x : 2.5 , y : 2.5 , z : 2.5 } ) ;
1339+ expect ( sceneLayout . camera . projection )
1340+ . toEqual ( { type : 'orthographic' } ) ;
1341+ expect ( sceneLayout2 . camera . projection )
1342+ . toEqual ( { type : 'orthographic' } ) ;
12291343
12301344 return scroll ( sceneTarget ) ;
12311345 } )
0 commit comments