@@ -116,7 +116,6 @@ function calc(gd, trace) {
116116 opts . marker . snap = stash . tree || TOO_MANY_POINTS ;
117117 }
118118
119- // save scene opts batch
120119 scene . lineOptions . push ( opts . line ) ;
121120 scene . errorXOptions . push ( opts . errorX ) ;
122121 scene . errorYOptions . push ( opts . errorY ) ;
@@ -128,7 +127,6 @@ function calc(gd, trace) {
128127 scene . textSelectedOptions . push ( opts . textSel ) ;
129128 scene . textUnselectedOptions . push ( opts . textUnsel ) ;
130129
131- // stash scene ref
132130 stash . _scene = scene ;
133131 stash . index = scene . count ;
134132 stash . x = x ;
@@ -146,7 +144,6 @@ function expandForErrorBars(trace, ax, opts) {
146144 extremes . max = extremes . max . concat ( errExt . max ) ;
147145}
148146
149- // create scene options
150147function sceneOptions ( gd , subplot , trace , positions , x , y ) {
151148 var opts = convert . style ( gd , trace ) ;
152149
@@ -193,13 +190,12 @@ function sceneOptions(gd, subplot, trace, positions, x, y) {
193190 return opts ;
194191}
195192
196-
197193// make sure scene exists on subplot, return it
198194function sceneUpdate ( gd , subplot ) {
199195 var scene = subplot . _scene ;
200196
201197 var resetOpts = {
202- // number of traces in subplot, since scene:subplot → 1:1
198+ // number of traces in subplot, since scene:subplot -> 1:1
203199 count : 0 ,
204200 // whether scene requires init hook in plot call (dirty plot call)
205201 dirty : true ,
@@ -216,16 +212,16 @@ function sceneUpdate(gd, subplot) {
216212 textUnselectedOptions : [ ]
217213 } ;
218214
215+ // regl- component stubs, initialized in dirty plot call
219216 var initOpts = {
220217 selectBatch : null ,
221218 unselectBatch : null ,
222- // regl- component stubs, initialized in dirty plot call
223219 fill2d : false ,
224220 scatter2d : false ,
225221 error2d : false ,
226222 line2d : false ,
227223 glText : false ,
228- select2d : null
224+ select2d : false
229225 } ;
230226
231227 if ( ! subplot . _scene ) {
@@ -325,7 +321,7 @@ function sceneUpdate(gd, subplot) {
325321 } ;
326322 }
327323
328- // In case if we have scene from the last calc - reset data
324+ // in case if we have scene from the last calc - reset data
329325 if ( ! scene . dirty ) {
330326 Lib . extendFlat ( scene , resetOpts ) ;
331327 }
@@ -363,6 +359,7 @@ function plot(gd, subplot, cdata) {
363359 return ;
364360 }
365361
362+ var count = scene . count ;
366363 var regl = fullLayout . _glcanvas . data ( ) [ 0 ] . regl ;
367364
368365 // that is needed for fills
@@ -383,28 +380,28 @@ function plot(gd, subplot, cdata) {
383380 scene . fill2d = createLine ( regl ) ;
384381 }
385382 if ( scene . glText === true ) {
386- scene . glText = new Array ( scene . count ) ;
387- for ( i = 0 ; i < scene . count ; i ++ ) {
383+ scene . glText = new Array ( count ) ;
384+ for ( i = 0 ; i < count ; i ++ ) {
388385 scene . glText [ i ] = new Text ( regl ) ;
389386 }
390387 }
391388
392389 // update main marker options
393390 if ( scene . glText ) {
394- if ( scene . count > scene . glText . length ) {
391+ if ( count > scene . glText . length ) {
395392 // add gl text marker
396- var textsToAdd = scene . count - scene . glText . length ;
393+ var textsToAdd = count - scene . glText . length ;
397394 for ( i = 0 ; i < textsToAdd ; i ++ ) {
398395 scene . glText . push ( new Text ( regl ) ) ;
399396 }
400- } else if ( scene . count < scene . glText . length ) {
397+ } else if ( count < scene . glText . length ) {
401398 // remove gl text marker
402- var textsToRemove = scene . glText . length - scene . count ;
403- var removedTexts = scene . glText . splice ( scene . count , textsToRemove ) ;
399+ var textsToRemove = scene . glText . length - count ;
400+ var removedTexts = scene . glText . splice ( count , textsToRemove ) ;
404401 removedTexts . forEach ( function ( text ) { text . destroy ( ) ; } ) ;
405402 }
406403
407- for ( i = 0 ; i < scene . count ; i ++ ) {
404+ for ( i = 0 ; i < count ; i ++ ) {
408405 scene . glText [ i ] . update ( scene . textOptions [ i ] ) ;
409406 }
410407 }
@@ -437,7 +434,7 @@ function plot(gd, subplot, cdata) {
437434 }
438435
439436 // fill requires linked traces, so we generate it's positions here
440- scene . fillOrder = Lib . repeat ( null , scene . count ) ;
437+ scene . fillOrder = Lib . repeat ( null , count ) ;
441438 if ( scene . fill2d ) {
442439 scene . fillOptions = scene . fillOptions . map ( function ( fillOptions , i ) {
443440 var cdscatter = cdata [ i ] ;
@@ -562,7 +559,7 @@ function plot(gd, subplot, cdata) {
562559 var selectMode = dragmode === 'lasso' || dragmode === 'select' ;
563560 var clickSelectEnabled = fullLayout . clickmode . indexOf ( 'select' ) > - 1 ;
564561
565- for ( i = 0 ; i < cdata . length ; i ++ ) {
562+ for ( i = 0 ; i < count ; i ++ ) {
566563 var cd0 = cdata [ i ] [ 0 ] ;
567564 var trace = cd0 . trace ;
568565 var stash = cd0 . t ;
@@ -610,11 +607,9 @@ function plot(gd, subplot, cdata) {
610607 }
611608 }
612609
613-
614610 if ( selectMode ) {
615- // create select2d
611+ // create scatter instance by cloning scatter2d
616612 if ( ! scene . select2d ) {
617- // create scatter instance by cloning scatter2d
618613 scene . select2d = createScatter ( fullLayout . _glcanvas . data ( ) [ 1 ] . regl ) ;
619614 }
620615
@@ -639,9 +634,9 @@ function plot(gd, subplot, cdata) {
639634 } ) ;
640635 }
641636 } else {
637+ // reset 'context' scatter2d opts to base opts,
638+ // thus unsetting markerUnselectedOptions from selection
642639 if ( scene . scatter2d ) {
643- // reset scatter2d opts to base opts,
644- // thus unsetting markerUnselectedOptions from selection
645640 scene . scatter2d . update ( scene . markerOptions ) ;
646641 }
647642 }
@@ -680,7 +675,6 @@ function plot(gd, subplot, cdata) {
680675 }
681676}
682677
683-
684678function hoverPoints ( pointData , xval , yval , hovermode ) {
685679 var cd = pointData . cd ;
686680 var stash = cd [ 0 ] . t ;
@@ -758,7 +752,6 @@ function hoverPoints(pointData, xval, yval, hovermode) {
758752 return [ pointData ] ;
759753}
760754
761-
762755function calcHover ( pointData , x , y , trace ) {
763756 var xa = pointData . xa ;
764757 var ya = pointData . ya ;
@@ -924,7 +917,6 @@ function selectPoints(searchInfo, selectionTester) {
924917 scene . selectBatch [ stash . index ] = els ;
925918 scene . unselectBatch [ stash . index ] = unels ;
926919
927- // update text options
928920 if ( hasText ) {
929921 styleTextSelection ( cd ) ;
930922 }
0 commit comments