@@ -128,7 +128,7 @@ function render(scene) {
128
128
}
129
129
tx = vectorTx . join ( '<br>' ) ;
130
130
} else if ( trace . type === 'isosurface' || trace . type === 'volume' ) {
131
- labels . valueLabel = Axes . tickText ( scene . mockAxis , scene . mockAxis . d2l ( selection . traceCoordinate [ 3 ] ) , 'hover' ) . text ;
131
+ labels . valueLabel = Axes . tickText ( scene . _mockAxis , scene . _mockAxis . d2l ( selection . traceCoordinate [ 3 ] ) , 'hover' ) . text ;
132
132
vectorTx . push ( 'value: ' + labels . valueLabel ) ;
133
133
if ( selection . textLabel ) {
134
134
vectorTx . push ( selection . textLabel ) ;
@@ -197,19 +197,19 @@ function render(scene) {
197
197
scene . drawAnnotations ( scene ) ;
198
198
}
199
199
200
- function tryCreatePlot ( scene , cameraObject , pixelRatio , canvas , gl ) {
200
+ function tryCreatePlot ( scene ) {
201
201
var glplotOptions = {
202
- canvas : canvas ,
203
- gl : gl ,
202
+ canvas : scene . canvas ,
203
+ gl : scene . gl ,
204
204
container : scene . container ,
205
205
axes : scene . axesOptions ,
206
206
spikes : scene . spikeOptions ,
207
207
pickRadius : 10 ,
208
208
snapToData : true ,
209
209
autoScale : true ,
210
210
autoBounds : false ,
211
- cameraObject : cameraObject ,
212
- pixelRatio : pixelRatio
211
+ cameraObject : scene . camera ,
212
+ pixelRatio : scene . pixelRatio
213
213
} ;
214
214
215
215
// for static plots, we reuse the WebGL context
@@ -248,10 +248,10 @@ function tryCreatePlot(scene, cameraObject, pixelRatio, canvas, gl) {
248
248
return failed < 2 ;
249
249
}
250
250
251
- function initializeGLPlot ( scene , canvas , gl ) {
251
+ function initializeGLPlot ( scene ) {
252
252
scene . initializeGLCamera ( ) ;
253
253
254
- var success = tryCreatePlot ( scene , scene . camera , scene . pixelRatio , canvas , gl ) ;
254
+ var success = tryCreatePlot ( scene ) ;
255
255
/*
256
256
* createPlot will throw when webgl is not enabled in the client.
257
257
* Lets return an instance of the module with all functions noop'd.
@@ -413,17 +413,15 @@ proto.initializeGLCamera = function() {
413
413
414
414
proto . recoverContext = function ( ) {
415
415
var scene = this ;
416
- var gl = this . glplot . gl ;
417
- var canvas = this . glplot . canvas ;
418
416
419
- this . glplot . dispose ( ) ;
417
+ scene . glplot . dispose ( ) ;
420
418
421
419
function tryRecover ( ) {
422
- if ( gl . isContextLost ( ) ) {
420
+ if ( scene . glplot . gl . isContextLost ( ) ) {
423
421
requestAnimationFrame ( tryRecover ) ;
424
422
return ;
425
423
}
426
- if ( ! initializeGLPlot ( scene , canvas , gl ) ) {
424
+ if ( ! initializeGLPlot ( scene ) ) {
427
425
Lib . error ( 'Catastrophic and unrecoverable WebGL error. Context lost.' ) ;
428
426
return ;
429
427
}
@@ -506,10 +504,7 @@ proto.plot = function(sceneData, fullLayout, layout) {
506
504
var fullSceneLayout = fullLayout [ this . id ] ;
507
505
var sceneLayout = layout [ this . id ] ;
508
506
509
- if ( fullSceneLayout . bgcolor ) this . glplot . clearColor = str2RGBAarray ( fullSceneLayout . bgcolor ) ;
510
- else this . glplot . clearColor = [ 0 , 0 , 0 , 0 ] ;
511
-
512
- this . glplot . snapToData = true ;
507
+ this . glplot . setClearColor ( str2RGBAarray ( fullSceneLayout . bgcolor ) ) ;
513
508
514
509
// Update layout
515
510
this . fullLayout = fullLayout ;
@@ -688,8 +683,10 @@ proto.plot = function(sceneData, fullLayout, layout) {
688
683
axisDataRange [ i ] = sceneBounds [ 1 ] [ i ] - sceneBounds [ 0 ] [ i ] ;
689
684
690
685
// Update plot bounds
691
- this . glplot . bounds [ 0 ] [ i ] = sceneBounds [ 0 ] [ i ] * dataScale [ i ] ;
692
- this . glplot . bounds [ 1 ] [ i ] = sceneBounds [ 1 ] [ i ] * dataScale [ i ] ;
686
+ this . glplot . setBounds ( i , {
687
+ min : sceneBounds [ 0 ] [ i ] * dataScale [ i ] ,
688
+ max : sceneBounds [ 1 ] [ i ] * dataScale [ i ]
689
+ } ) ;
693
690
}
694
691
695
692
var axesScaleRatio = [ 1 , 1 , 1 ] ;
@@ -821,21 +818,10 @@ proto.setViewport = function(sceneLayout) {
821
818
var oldOrtho = this . camera . _ortho ;
822
819
823
820
if ( newOrtho !== oldOrtho ) {
824
- this . glplot . redraw ( ) ;
825
-
826
- var RGBA = this . glplot . clearColor ;
827
- this . glplot . gl . clearColor (
828
- RGBA [ 0 ] , RGBA [ 1 ] , RGBA [ 2 ] , RGBA [ 3 ]
829
- ) ;
830
- this . glplot . gl . clear (
831
- this . glplot . gl . DEPTH_BUFFER_BIT |
832
- this . glplot . gl . COLOR_BUFFER_BIT
833
- ) ;
834
-
821
+ this . glplot . redraw ( ) ; // TODO: figure out why we need to redraw here?
822
+ this . glplot . clearRGBA ( ) ;
835
823
this . glplot . dispose ( ) ;
836
-
837
824
initializeGLPlot ( this ) ;
838
- this . camera . _ortho = newOrtho ;
839
825
}
840
826
} ;
841
827
@@ -1046,17 +1032,17 @@ proto.setConvert = function() {
1046
1032
} ;
1047
1033
1048
1034
proto . make4thDimension = function ( ) {
1049
- var _this = this ;
1050
- var gd = _this . graphDiv ;
1035
+ var scene = this ;
1036
+ var gd = scene . graphDiv ;
1051
1037
var fullLayout = gd . _fullLayout ;
1052
1038
1053
1039
// mock axis for hover formatting
1054
- _this . mockAxis = {
1040
+ scene . _mockAxis = {
1055
1041
type : 'linear' ,
1056
1042
showexponent : 'all' ,
1057
1043
exponentformat : 'B'
1058
1044
} ;
1059
- Axes . setConvert ( _this . mockAxis , fullLayout ) ;
1045
+ Axes . setConvert ( scene . _mockAxis , fullLayout ) ;
1060
1046
} ;
1061
1047
1062
1048
module . exports = Scene ;
0 commit comments