@@ -192,7 +192,7 @@ function render(scene) {
192192 scene . drawAnnotations ( scene ) ;
193193}
194194
195- function tryCreatePlot ( scene , camera , canvas , gl ) {
195+ function tryCreatePlot ( scene , camera , pixelRatio , canvas , gl ) {
196196
197197 var glplotOptions = {
198198 canvas : canvas ,
@@ -204,7 +204,8 @@ function tryCreatePlot(scene, camera, canvas, gl) {
204204 snapToData : true ,
205205 autoScale : true ,
206206 autoBounds : false ,
207- camera : camera
207+ camera : camera ,
208+ pixelRatio : pixelRatio
208209 } ;
209210
210211 // for static plots, we reuse the WebGL context
@@ -237,9 +238,9 @@ function tryCreatePlot(scene, camera, canvas, gl) {
237238 return true ;
238239}
239240
240- function initializeGLPlot ( scene , camera , canvas , gl ) {
241+ function initializeGLPlot ( scene , camera , pixelRatio , canvas , gl ) {
241242
242- var success = tryCreatePlot ( scene , camera , canvas , gl ) ;
243+ var success = tryCreatePlot ( scene , camera , pixelRatio , canvas , gl ) ;
243244 /*
244245 * createPlot will throw when webgl is not enabled in the client.
245246 * Lets return an instance of the module with all functions noop'd.
@@ -340,7 +341,7 @@ function Scene(options, fullLayout) {
340341 this . spikeOptions = createSpikeOptions ( fullLayout [ this . id ] ) ;
341342 this . container = sceneContainer ;
342343 this . staticMode = ! ! options . staticPlot ;
343- this . pixelRatio = options . plotGlPixelRatio || 2 ;
344+ this . pixelRatio = this . pixelRatio || options . plotGlPixelRatio || 2 ;
344345
345346 // Coordinate rescaling
346347 this . dataScale = [ 1 , 1 , 1 ] ;
@@ -351,7 +352,8 @@ function Scene(options, fullLayout) {
351352 this . drawAnnotations = Registry . getComponentMethod ( 'annotations3d' , 'draw' ) ;
352353
353354 var camera = fullLayout . scene . camera ;
354- initializeGLPlot ( this , camera ) ;
355+
356+ initializeGLPlot ( this , camera , this . pixelRatio ) ;
355357}
356358
357359var proto = Scene . prototype ;
@@ -377,14 +379,15 @@ proto.recoverContext = function() {
377379 var gl = this . glplot . gl ;
378380 var canvas = this . glplot . canvas ;
379381 var camera = this . glplot . camera ;
382+ var pixelRatio = this . glplot . pixelRatio ;
380383 this . glplot . dispose ( ) ;
381384
382385 function tryRecover ( ) {
383386 if ( gl . isContextLost ( ) ) {
384387 requestAnimationFrame ( tryRecover ) ;
385388 return ;
386389 }
387- if ( ! initializeGLPlot ( scene , camera , canvas , gl ) ) {
390+ if ( ! initializeGLPlot ( scene , camera , pixelRatio , canvas , gl ) ) {
388391 Lib . error ( 'Catastrophic and unrecoverable WebGL error. Context lost.' ) ;
389392 return ;
390393 }
@@ -780,6 +783,8 @@ proto.setCamera = function setCamera(cameraData) {
780783 if ( newOrtho !== oldOrtho ) {
781784 this . glplot . redraw ( ) ;
782785
786+ var pixelRatio = this . glplot . pixelRatio ;
787+
783788 var RGBA = this . glplot . clearColor ;
784789 this . glplot . gl . clearColor (
785790 RGBA [ 0 ] , RGBA [ 1 ] , RGBA [ 2 ] , RGBA [ 3 ]
@@ -791,7 +796,7 @@ proto.setCamera = function setCamera(cameraData) {
791796
792797 this . glplot . dispose ( ) ;
793798
794- initializeGLPlot ( this , cameraData ) ;
799+ initializeGLPlot ( this , cameraData , pixelRatio ) ;
795800 this . glplot . camera . _ortho = newOrtho ;
796801 }
797802} ;
0 commit comments