@@ -20,7 +20,6 @@ var str2RgbaArray = require('../../lib/str2rgbarray');
2020
2121var MIN_RESOLUTION = 128 ;
2222
23-
2423function SurfaceTrace ( scene , surface , uid ) {
2524 this . scene = scene ;
2625 this . uid = uid ;
@@ -136,7 +135,7 @@ function refine(coords) {
136135 Math . floor ( ( coords [ 0 ] . shape [ 1 ] ) * scaleF + 1 ) | 0 ] ;
137136 var nsize = nshape [ 0 ] * nshape [ 1 ] ;
138137
139- for ( var i = 0 ; i < 3 ; ++ i ) {
138+ for ( var i = 0 ; i < coords . length ; ++ i ) {
140139 var padImg = padField ( coords [ i ] ) ;
141140 var scaledImg = ndarray ( new Float32Array ( nsize ) , nshape ) ;
142141 homography ( scaledImg , padImg , [ scaleF , 0 , 0 ,
@@ -230,9 +229,6 @@ proto.update = function(data) {
230229 } ) ;
231230 }
232231
233- //Refine if necessary
234- this . dataScale = refine ( coords ) ;
235-
236232 var params = {
237233 colormap : colormap ,
238234 levels : [ [ ] , [ ] , [ ] ] ,
@@ -249,10 +245,33 @@ proto.update = function(data) {
249245 dynamicColor : [ [ 1 , 1 , 1 , 1 ] , [ 1 , 1 , 1 , 1 ] , [ 1 , 1 , 1 , 1 ] ] ,
250246 dynamicWidth : [ 1 , 1 , 1 ] ,
251247 dynamicTint : [ 1 , 1 , 1 ] ,
252- opacity : 1 ,
253- colorBounds : [ data . zmin * scaleFactor [ 2 ] , data . zmax * scaleFactor [ 2 ] ]
248+ opacity : 1
254249 } ;
255250
251+ params . intensityBounds = [ data . cmin , data . cmax ] ;
252+
253+ //Refine if necessary
254+ if ( data . surfacecolor ) {
255+ var intensity = ndarray ( new Float32Array ( xlen * ylen ) , [ xlen , ylen ] ) ;
256+
257+ fill ( intensity , function ( row , col ) {
258+ return data . surfacecolor [ col ] [ row ] ;
259+ } ) ;
260+
261+ coords . push ( intensity ) ;
262+ }
263+ else {
264+ // when 'z' is used as 'intensity',
265+ // we must scale its value
266+ params . intensityBounds [ 0 ] *= scaleFactor [ 2 ] ;
267+ params . intensityBounds [ 1 ] *= scaleFactor [ 2 ] ;
268+ }
269+
270+ this . dataScale = refine ( coords ) ;
271+
272+ if ( data . surfacecolor ) {
273+ params . intensity = coords . pop ( ) ;
274+ }
256275
257276 if ( 'opacity' in data ) {
258277 if ( data . opacity < 1 ) {
@@ -300,6 +319,7 @@ proto.update = function(data) {
300319 }
301320
302321 params . coords = coords ;
322+
303323 surface . update ( params ) ;
304324
305325 surface . highlightEnable = highlightEnable ;
0 commit comments