46
46
cmin: 1500,
47
47
cmax: 2000,
48
48
49
- smoothnormals: true,
49
+ smoothnormals: true,
50
50
isocaps: true,
51
51
52
- singlemesh: true,
53
-
54
52
colorscale: 'Portland'
55
53
}])
56
54
@@ -61,6 +59,7 @@ var isosurfacePlot = require('gl-isosurface3d');
61
59
62
60
var simpleMap = require ( '../../lib' ) . simpleMap ;
63
61
var parseColorScale = require ( '../../lib/gl_format_color' ) . parseColorScale ;
62
+ var str2RgbaArray = require ( '../../lib/str2rgbarray' ) ;
64
63
65
64
function Isosurface ( scene , uid ) {
66
65
this . scene = scene ;
@@ -164,13 +163,24 @@ function convert(scene, trace) {
164
163
165
164
isosurfaceOpts . values = trace . value ;
166
165
167
- isosurfaceOpts . colormap = parseColorScale ( trace . colorscale ) ;
168
- // isosurfaceOpts.capsColormap = parseColorScale(trace.capscolorscale);
166
+ if ( trace . colorscale ) {
167
+ isosurfaceOpts . colormap = parseColorScale ( trace . colorscale ) ;
168
+ }
169
+ if ( trace . color ) {
170
+ isosurfaceOpts . capsColormap = isosurfaceOpts . colormap ;
171
+ var color = str2RgbaArray ( trace . color ) . map ( function ( c ) { return c * 255 ; } ) ;
172
+ isosurfaceOpts . colormap = [ { index : 0 , rgb : color } , { index : 1 , rgb : color } ] ;
173
+ if ( ! isosurfaceOpts . capsColormap ) {
174
+ isosurfaceOpts . capsColormap = isosurfaceOpts . colormap ;
175
+ }
176
+ }
169
177
isosurfaceOpts . vertexIntensityBounds = [ trace . cmin , trace . cmax ] ;
170
178
isosurfaceOpts . isoBounds = [ trace . isomin , trace . isomax ] ;
171
179
172
180
isosurfaceOpts . isoCaps = trace . isocaps ;
173
- isosurfaceOpts . singleMesh = trace . singlemesh === undefined ? true : trace . singlemesh ;
181
+ isosurfaceOpts . singleMesh = false ; //trace.singlemesh === undefined ? true : trace.singlemesh;
182
+
183
+ isosurfaceOpts . smoothNormals = trace . smoothnormals === undefined ? true : trace . smoothnormals ;
174
184
175
185
var bounds = [ [ 0 , 0 , 0 ] , isosurfaceOpts . dimensions . slice ( ) ] ;
176
186
@@ -225,6 +235,7 @@ function createIsosurfaceTrace(scene, data) {
225
235
226
236
var meshData = convert ( scene , data ) ;
227
237
var mesh = isosurfacePlot . createTriMesh ( gl , meshData ) ;
238
+ var capMesh = isosurfacePlot . createTriMesh ( gl , meshData . caps ) ;
228
239
var trace = data ;
229
240
var xbnds = toDataCoords ( scene , trace . _xbnds , 'xaxis' ) ;
230
241
var ybnds = toDataCoords ( scene , trace . _ybnds , 'yaxis' ) ;
@@ -240,7 +251,16 @@ function createIsosurfaceTrace(scene, data) {
240
251
isosurface . meshData = meshData ;
241
252
mesh . _trace = isosurface ;
242
253
254
+ var caps = new Isosurface ( scene , data . uid ) ;
255
+ caps . mesh = capMesh ;
256
+ caps . data = data ;
257
+ caps . meshData = meshData ;
258
+ capMesh . _trace = caps ;
259
+
260
+ isosurface . caps = caps ;
261
+
243
262
scene . glplot . add ( mesh ) ;
263
+ scene . glplot . add ( capMesh ) ;
244
264
245
265
return isosurface ;
246
266
}
0 commit comments