@@ -26,7 +26,7 @@ function SurfaceTrace(scene, surface, uid) {
2626 this . data = null ;
2727 this . showContour = [ false , false , false ] ;
2828 this . contourLocations = [ [ ] , [ ] , [ ] ] ;
29- this . onPointsContour = [ false , false ] ; // note: only available on x & y not z.
29+ this . contourRelative = [ 0 , 0 ] ; // note: only available on x & y not z.
3030 this . minValues = [ Infinity , Infinity , Infinity ] ;
3131 this . maxValues = [ - Infinity , - Infinity , - Infinity ] ;
3232 this . dataScaleX = 1.0 ;
@@ -359,43 +359,47 @@ function insertIfNewLevel(arr, newValue) {
359359
360360proto . setContourLevels = function ( ) {
361361 var newLevels = [ [ ] , [ ] , [ ] ] ;
362- var needsUpdate = false ;
363362 var useNewLevels = [ false , false , false ] ;
363+ var needsUpdate = false ;
364364
365365 var i , j , value ;
366366
367367 for ( i = 0 ; i < 3 ; ++ i ) {
368368 if ( this . showContour [ i ] ) {
369369 needsUpdate = true ;
370370
371- newLevels [ i ] = [ ] ;
371+ if ( i < 2 ) {
372+ var ratios = Array . isArray ( this . contourRelative [ i ] ) ?
373+ this . contourRelative [ i ] : [ this . contourRelative [ i ] ] ;
372374
373- if ( i < 2 && this . onPointsContour [ i ] !== 0 ) {
374- useNewLevels [ i ] = true ;
375+ for ( var k = 0 ; k < ratios . length ; k ++ ) {
376+ var ratio = ratios [ k ] ;
377+ if ( ratio !== 0 ) {
375378
376- var ratio = this . onPointsContour [ i ] ;
379+ var len = ( i === 0 ) ?
380+ this . data . z [ 0 ] . length :
381+ this . data . _ylength ;
377382
378- var len = ( i === 0 ) ?
379- this . data . z [ 0 ] . length :
380- this . data . _ylength ;
383+ for ( var q = ( ratio < 1 ) ? 1 : 0 ; q < len ; q ++ ) {
381384
382- for ( var q = ( ratio < 1 ) ? 1 : 0 ; q < len ; q ++ ) {
385+ var here = ( i === 0 ) ?
386+ this . getXat ( q , 0 ) * this . scene . dataScale [ i ] :
387+ this . getYat ( 0 , q ) * this . scene . dataScale [ i ] ;
383388
384- var here = ( i === 0 ) ?
385- this . getXat ( q , 0 ) * this . scene . dataScale [ i ] :
386- this . getYat ( 0 , q ) * this . scene . dataScale [ i ] ;
389+ if ( ratio < 1 ) {
390+ var prev = ( i === 0 ) ?
391+ this . getXat ( q - 1 , 0 ) * this . scene . dataScale [ i ] :
392+ this . getYat ( 0 , q - 1 ) * this . scene . dataScale [ i ] ;
387393
388- if ( ratio < 1 ) {
389- var prev = ( i === 0 ) ?
390- this . getXat ( q - 1 , 0 ) * this . scene . dataScale [ i ] :
391- this . getYat ( 0 , q - 1 ) * this . scene . dataScale [ i ] ;
394+ value = here * ratio + prev * ( 1 - ratio ) ;
395+ } else {
396+ value = here ;
397+ }
392398
393- value = here * ratio + prev * ( 1 - ratio ) ;
394- } else {
395- value = here ;
399+ insertIfNewLevel ( newLevels [ i ] , value ) ;
400+ useNewLevels [ i ] = true ;
401+ }
396402 }
397-
398- insertIfNewLevel ( newLevels [ i ] , value ) ;
399403 }
400404 }
401405
@@ -412,11 +416,13 @@ proto.setContourLevels = function() {
412416 }
413417
414418 if ( needsUpdate ) {
415- var levels = [ ] ;
419+ var allLevels = [ [ ] , [ ] , [ ] ] ;
416420 for ( i = 0 ; i < 3 ; ++ i ) {
417- levels [ i ] = ( useNewLevels [ i ] ) ? newLevels [ i ] : this . scene . contourLevels [ i ] ;
421+ if ( this . showContour [ i ] ) {
422+ allLevels [ i ] = useNewLevels [ i ] ? newLevels [ i ] : this . scene . contourLevels [ i ] ;
423+ }
418424 }
419- this . surface . update ( { levels : levels } ) ;
425+ this . surface . update ( { levels : allLevels } ) ;
420426 }
421427} ;
422428
@@ -608,11 +614,11 @@ proto.update = function(data) {
608614 params . contourWidth [ i ] = contourParams . width ;
609615
610616 this . contourLocations [ i ] = contourParams . locations ;
611- if ( i < 2 ) this . onPointsContour [ i ] = contourParams . onpoints ;
617+ if ( i < 2 ) this . contourRelative [ i ] = contourParams . relative ;
612618 } else {
613619 this . showContour [ i ] = false ;
614620 this . contourLocations [ i ] = [ ] ;
615- if ( i < 2 ) this . onPointsContour [ i ] = 0 ;
621+ if ( i < 2 ) this . contourRelative [ i ] = 0 ;
616622 }
617623
618624 if ( contourParams . highlight ) {
0 commit comments