@@ -75,7 +75,7 @@ describe('Test gl3d plots', function() {
75
75
destroyGraphDiv ( ) ;
76
76
} ) ;
77
77
78
- it ( '@gl should not rotate camera on the very first click before scene is complete and modebar setup ' , function ( done ) {
78
+ it ( '@gl should not rotate camera on the very first click before scene is complete and then should rotate ' , function ( done ) {
79
79
var _mock = Lib . extendDeep (
80
80
{
81
81
layout : {
@@ -117,28 +117,43 @@ describe('Test gl3d plots', function() {
117
117
ptData = eventData . points [ 0 ] ;
118
118
} ) ;
119
119
} )
120
+ . then ( delay ( 20 ) )
121
+ . then ( function ( ) {
122
+ var cameraIn = gd . _fullLayout . scene . camera ;
123
+ expect ( cameraIn . up . x ) . toEqual ( 0 , 'cameraIn.up.x' ) ;
124
+ expect ( cameraIn . up . y ) . toEqual ( 0 , 'cameraIn.up.y' ) ;
125
+ expect ( cameraIn . up . z ) . toEqual ( 1 , 'cameraIn.up.z' ) ;
126
+ expect ( cameraIn . center . x ) . toEqual ( 0 , 'cameraIn.center.x' ) ;
127
+ expect ( cameraIn . center . y ) . toEqual ( 0 , 'cameraIn.center.y' ) ;
128
+ expect ( cameraIn . center . z ) . toEqual ( 0 , 'cameraIn.center.z' ) ;
129
+ expect ( cameraIn . eye . x ) . toEqual ( 1.2 , 'cameraIn.eye.x' ) ;
130
+ expect ( cameraIn . eye . y ) . toEqual ( 1.2 , 'cameraIn.eye.y' ) ;
131
+ expect ( cameraIn . eye . z ) . toEqual ( 1.2 , 'cameraIn.eye.z' ) ;
132
+
133
+ var cameraBefore = gd . _fullLayout . scene . _scene . glplot . camera ;
134
+ expect ( cameraBefore . up [ 0 ] ) . toBeCloseTo ( 0 , 3 , 'cameraBefore.up[0]' ) ;
135
+ expect ( cameraBefore . up [ 1 ] ) . toBeCloseTo ( 0 , 3 , 'cameraBefore.up[1]' ) ;
136
+ expect ( cameraBefore . up [ 2 ] ) . toBeCloseTo ( 1 , 3 , 'cameraBefore.up[2]' ) ;
137
+ expect ( cameraBefore . center [ 0 ] ) . toBeCloseTo ( 0 , 3 , 'cameraBefore.center[0]' ) ;
138
+ expect ( cameraBefore . center [ 1 ] ) . toBeCloseTo ( 0 , 3 , 'cameraBefore.center[1]' ) ;
139
+ expect ( cameraBefore . center [ 2 ] ) . toBeCloseTo ( 0 , 3 , 'cameraBefore.center[2]' ) ;
140
+ expect ( cameraBefore . eye [ 0 ] ) . toBeCloseTo ( 1.2 , 3 , 'cameraBefore.eye[0]' ) ;
141
+ expect ( cameraBefore . eye [ 1 ] ) . toBeCloseTo ( 1.2 , 3 , 'cameraBefore.eye[1]' ) ;
142
+ expect ( cameraBefore . eye [ 2 ] ) . toBeCloseTo ( 1.2 , 3 , 'cameraBefore.eye[2]' ) ;
143
+ } )
120
144
. then ( _click )
121
145
. then ( delay ( 20 ) )
122
146
. then ( function ( ) {
123
- expect ( gd . _fullLayout . scene . camera . up . x ) . toEqual ( 0 , 'camera.up.x' ) ;
124
- expect ( gd . _fullLayout . scene . camera . up . y ) . toEqual ( 0 , 'camera.up.y' ) ;
125
- expect ( gd . _fullLayout . scene . camera . up . z ) . toEqual ( 1 , 'camera.up.z' ) ;
126
- expect ( gd . _fullLayout . scene . camera . eye . x ) . toEqual ( 1.2 , 'camera.eye.x' ) ;
127
- expect ( gd . _fullLayout . scene . camera . eye . y ) . toEqual ( 1.2 , 'camera.eye.y' ) ;
128
- expect ( gd . _fullLayout . scene . camera . eye . z ) . toEqual ( 1.2 , 'camera.eye.z' ) ;
129
- expect ( gd . _fullLayout . scene . camera . center . x ) . toEqual ( 0 , 'camera.center.x' ) ;
130
- expect ( gd . _fullLayout . scene . camera . center . y ) . toEqual ( 0 , 'camera.center.y' ) ;
131
- expect ( gd . _fullLayout . scene . camera . center . z ) . toEqual ( 0 , 'camera.center.z' ) ;
132
-
133
- expect ( gd . _fullLayout . scene . _scene . glplot . camera . up [ 0 ] ) . toEqual ( 0 , 'camera.up[0]' ) ;
134
- expect ( gd . _fullLayout . scene . _scene . glplot . camera . up [ 1 ] ) . toEqual ( 0 , 'camera.up[1]' ) ;
135
- expect ( gd . _fullLayout . scene . _scene . glplot . camera . up [ 2 ] ) . toEqual ( 1 , 'camera.up[2]' ) ;
136
- expect ( gd . _fullLayout . scene . _scene . glplot . camera . eye [ 0 ] ) . toBeCloseTo ( 1.2 , 6 , 'camera.eye[0]' ) ;
137
- expect ( gd . _fullLayout . scene . _scene . glplot . camera . eye [ 1 ] ) . toBeCloseTo ( 1.2 , 6 , 'camera.eye[1]' ) ;
138
- expect ( gd . _fullLayout . scene . _scene . glplot . camera . eye [ 2 ] ) . toBeCloseTo ( 1.2 , 6 , 'camera.eye[2]' ) ;
139
- expect ( gd . _fullLayout . scene . _scene . glplot . camera . center [ 0 ] ) . toEqual ( 0 , 'camera.center[0]' ) ;
140
- expect ( gd . _fullLayout . scene . _scene . glplot . camera . center [ 1 ] ) . toEqual ( 0 , 'camera.center[1]' ) ;
141
- expect ( gd . _fullLayout . scene . _scene . glplot . camera . center [ 2 ] ) . toEqual ( 0 , 'camera.center[2]' ) ;
147
+ var cameraAfter = gd . _fullLayout . scene . _scene . glplot . camera ;
148
+ expect ( cameraAfter . up [ 0 ] ) . toBeCloseTo ( 0 , 3 , 'cameraAfter.up[0]' ) ;
149
+ expect ( cameraAfter . up [ 1 ] ) . toBeCloseTo ( 0 , 3 , 'cameraAfter.up[1]' ) ;
150
+ expect ( cameraAfter . up [ 2 ] ) . toBeCloseTo ( 1 , 3 , 'cameraAfter.up[2]' ) ;
151
+ expect ( cameraAfter . center [ 0 ] ) . toBeCloseTo ( 0 , 3 , 'cameraAfter.center[0]' ) ;
152
+ expect ( cameraAfter . center [ 1 ] ) . toBeCloseTo ( 0 , 3 , 'cameraAfter.center[1]' ) ;
153
+ expect ( cameraAfter . center [ 2 ] ) . toBeCloseTo ( 0 , 3 , 'cameraAfter.center[2]' ) ;
154
+ expect ( cameraAfter . eye [ 0 ] ) . not . toBeCloseTo ( 1.2 , 3 , 'cameraAfter.eye[0]' ) ;
155
+ expect ( cameraAfter . eye [ 1 ] ) . not . toBeCloseTo ( 1.2 , 3 , 'cameraAfter.eye[1]' ) ;
156
+ expect ( cameraAfter . eye [ 2 ] ) . not . toBeCloseTo ( 1.2 , 3 , 'cameraAfter.eye[2]' ) ;
142
157
} )
143
158
. then ( done ) ;
144
159
} ) ;
@@ -433,10 +448,7 @@ describe('Test gl3d plots', function() {
433
448
// N.B. gl3d click events are 'mouseover' events
434
449
// with button 1 pressed
435
450
function _click ( ) {
436
- var x = 605 ;
437
- var y = 271 ;
438
- mouseEvent ( 'mousemove' , x , y ) ;
439
- mouseEvent ( 'mouseover' , x , y , { buttons : 1 } ) ;
451
+ mouseEvent ( 'mouseover' , 605 , 271 , { buttons : 1 } ) ;
440
452
return delay ( 20 ) ( ) ;
441
453
}
442
454
0 commit comments