@@ -392,6 +392,122 @@ describe('Test gl3d plots', function() {
392
392
. then ( done ) ;
393
393
} ) ;
394
394
395
+ it ( '@gl should set the camera dragmode to orbit if the camera.up.z vector is set to be tilted' , function ( done ) {
396
+ Plotly . plot ( gd , {
397
+ data : [ {
398
+ type : 'scatter3d' ,
399
+ x : [ 1 , 2 , 3 ] ,
400
+ y : [ 2 , 3 , 1 ] ,
401
+ z : [ 3 , 1 , 2 ]
402
+ } ] ,
403
+ layout : {
404
+ scene : {
405
+ camera : {
406
+ up : { x :- 0.5777 , y :- 0.5777 , z :0.5777 }
407
+ }
408
+ }
409
+ }
410
+ } )
411
+ . then ( delay ( 20 ) )
412
+ . then ( function ( ) {
413
+ expect ( gd . _fullLayout . scene . dragmode === 'orbit' ) . toBe ( true ) ;
414
+ } )
415
+ . then ( done ) ;
416
+ } ) ;
417
+
418
+ it ( '@gl should set the camera dragmode to turntable if the camera.up.z vector is set to be upwards' , function ( done ) {
419
+ Plotly . plot ( gd , {
420
+ data : [ {
421
+ type : 'scatter3d' ,
422
+ x : [ 1 , 2 , 3 ] ,
423
+ y : [ 2 , 3 , 1 ] ,
424
+ z : [ 3 , 1 , 2 ]
425
+ } ] ,
426
+ layout : {
427
+ scene : {
428
+ camera : {
429
+ up : { x :0 , y :0 , z :100 }
430
+ }
431
+ }
432
+ }
433
+ } )
434
+ . then ( delay ( 20 ) )
435
+ . then ( function ( ) {
436
+ expect ( gd . _fullLayout . scene . dragmode === 'turntable' ) . toBe ( true ) ;
437
+ } )
438
+ . then ( done ) ;
439
+ } ) ;
440
+
441
+ it ( '@gl should set the camera dragmode to turntable if the camera.up is not set' , function ( done ) {
442
+ Plotly . plot ( gd , {
443
+ data : [ {
444
+ type : 'scatter3d' ,
445
+ x : [ 1 , 2 , 3 ] ,
446
+ y : [ 2 , 3 , 1 ] ,
447
+ z : [ 3 , 1 , 2 ]
448
+ } ] ,
449
+ layout : {
450
+ scene : {
451
+ camera : {
452
+ eye : { x :1 , y :1 , z :1 } ,
453
+ center : { x :0 , y :0 , z :0 }
454
+ }
455
+ }
456
+ }
457
+ } )
458
+ . then ( delay ( 20 ) )
459
+ . then ( function ( ) {
460
+ expect ( gd . _fullLayout . scene . dragmode === 'turntable' ) . toBe ( true ) ;
461
+ } )
462
+ . then ( done ) ;
463
+ } ) ;
464
+
465
+ it ( '@gl should set the camera dragmode to turntable if any of camera.up.[x|y|z] is missing' , function ( done ) {
466
+ Plotly . plot ( gd , {
467
+ data : [ {
468
+ type : 'scatter3d' ,
469
+ x : [ 1 , 2 , 3 ] ,
470
+ y : [ 2 , 3 , 1 ] ,
471
+ z : [ 3 , 1 , 2 ]
472
+ } ] ,
473
+ layout : {
474
+ scene : {
475
+ camera : {
476
+ up : { x :null , z :0 }
477
+ }
478
+ }
479
+ }
480
+ } )
481
+ . then ( delay ( 20 ) )
482
+ . then ( function ( ) {
483
+ expect ( gd . _fullLayout . scene . dragmode === 'turntable' ) . toBe ( true ) ;
484
+ } )
485
+ . then ( done ) ;
486
+ } ) ;
487
+
488
+ it ( '@gl should set the camera dragmode to turntable if all camera.up.[x|y|z] are zero or missing' , function ( done ) {
489
+ Plotly . plot ( gd , {
490
+ data : [ {
491
+ type : 'scatter3d' ,
492
+ x : [ 1 , 2 , 3 ] ,
493
+ y : [ 2 , 3 , 1 ] ,
494
+ z : [ 3 , 1 , 2 ]
495
+ } ] ,
496
+ layout : {
497
+ scene : {
498
+ camera : {
499
+ up : { x :0 , y :0 , z :0 }
500
+ }
501
+ }
502
+ }
503
+ } )
504
+ . then ( delay ( 20 ) )
505
+ . then ( function ( ) {
506
+ expect ( gd . _fullLayout . scene . dragmode === 'turntable' ) . toBe ( true ) ;
507
+ } )
508
+ . then ( done ) ;
509
+ } ) ;
510
+
395
511
it ( '@gl should be able to reversibly change trace type' , function ( done ) {
396
512
var _mock = Lib . extendDeep ( { } , mock2 ) ;
397
513
var sceneLayout = { aspectratio : { x : 1 , y : 1 , z : 1 } , dragmode : 'turntable' } ;
@@ -405,6 +521,7 @@ describe('Test gl3d plots', function() {
405
521
expect ( gd . layout . yaxis === undefined ) . toBe ( true ) ;
406
522
expect ( gd . _fullLayout . _has ( 'gl3d' ) ) . toBe ( true ) ;
407
523
expect ( gd . _fullLayout . scene . _scene ) . toBeDefined ( ) ;
524
+ expect ( gd . _fullLayout . scene . _scene . camera ) . toBeDefined ( true ) ;
408
525
409
526
return Plotly . restyle ( gd , 'type' , 'scatter' ) ;
410
527
} )
0 commit comments