@@ -217,23 +217,64 @@ describe('Test gl3d plots', function() {
217217
218218 it ( 'should be able to toggle visibility' , function ( done ) {
219219 var _mock = Lib . extendDeep ( { } , mock2 ) ;
220- var objects ;
220+ _mock . data [ 0 ] . x = [ 0 , 1 , 3 ] ;
221+ _mock . data [ 0 ] . y = [ 0 , 1 , 2 ] ;
222+ _mock . data . push ( {
223+ type : 'surface' ,
224+ z : [ [ 1 , 2 , 3 ] , [ 1 , 2 , 3 ] , [ 2 , 1 , 2 ] ]
225+ } , {
226+ type : 'mesh3d' ,
227+ x : [ 0 , 1 , 2 , 0 ] , y : [ 0 , 0 , 1 , 2 ] , z : [ 0 , 2 , 0 , 1 ] ,
228+ i : [ 0 , 0 , 0 , 1 ] , j : [ 1 , 2 , 3 , 2 ] , k : [ 2 , 3 , 1 , 3 ]
229+ } ) ;
230+
231+ // scatter3d traces are made of 5 gl-vis objects,
232+ // surface and mesh3d are made of 1 gl-vis object each.
233+ var order0 = [ 0 , 0 , 0 , 0 , 0 , 1 , 2 ] ;
234+
235+ function assertObjects ( expected ) {
236+ var objects = gd . _fullLayout . scene . _scene . glplot . objects ;
237+ var actual = objects . map ( function ( o ) {
238+ return o . _trace . data . index ;
239+ } ) ;
240+
241+ expect ( actual ) . toEqual ( expected ) ;
242+ }
221243
222244 Plotly . plot ( gd , _mock )
223245 . then ( delay )
224246 . then ( function ( ) {
225- objects = gd . _fullLayout . scene . _scene . glplot . objects ;
226- expect ( objects . length ) . toEqual ( 5 ) ;
247+ assertObjects ( order0 ) ;
227248
228249 return Plotly . restyle ( gd , 'visible' , 'legendonly' ) ;
229250 } )
230251 . then ( function ( ) {
231- expect ( objects . length ) . toEqual ( 0 ) ;
252+ assertObjects ( [ ] ) ;
232253
233254 return Plotly . restyle ( gd , 'visible' , true ) ;
234255 } )
235256 . then ( function ( ) {
236- expect ( objects . length ) . toEqual ( 5 ) ;
257+ assertObjects ( order0 ) ;
258+
259+ return Plotly . restyle ( gd , 'visible' , false , [ 0 ] ) ;
260+ } )
261+ . then ( function ( ) {
262+ assertObjects ( [ 1 , 2 ] ) ;
263+
264+ return Plotly . restyle ( gd , 'visible' , true , [ 0 ] ) ;
265+ } )
266+ . then ( function ( ) {
267+ assertObjects ( order0 ) ;
268+
269+ return Plotly . restyle ( gd , 'visible' , 'legendonly' , [ 1 ] ) ;
270+ } )
271+ . then ( function ( ) {
272+ assertObjects ( [ 0 , 0 , 0 , 0 , 0 , 2 ] ) ;
273+
274+ return Plotly . restyle ( gd , 'visible' , true , [ 1 ] ) ;
275+ } )
276+ . then ( function ( ) {
277+ assertObjects ( order0 ) ;
237278 } )
238279 . then ( done ) ;
239280 } ) ;
0 commit comments