Skip to content

Commit 71ae66e

Browse files
committed
new isosurface traces
1 parent 9bbe295 commit 71ae66e

File tree

11 files changed

+7493
-1
lines changed

11 files changed

+7493
-1
lines changed

lib/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ Plotly.register([
2525

2626
require('./scatter3d'),
2727
require('./surface'),
28+
require('./isosurface'),
2829
require('./mesh3d'),
2930
require('./cone'),
3031
require('./streamtube'),

lib/isosurface.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/**
2+
* Copyright 2012-2018, Plotly, Inc.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the MIT license found in the
6+
* LICENSE file in the root directory of this source tree.
7+
*/
8+
9+
'use strict';
10+
11+
module.exports = require('../src/traces/isosurface');

package-lock.json

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
"es6-promise": "^3.0.2",
7171
"fast-isnumeric": "^1.1.2",
7272
"font-atlas-sdf": "^1.3.3",
73+
"isosurface": "git://github.com/archmoj/isosurface.git#e2c41594417a2ba363bb430c7d38adfe18312fc5",
7374
"gl-cone3d": "^1.2.1",
7475
"gl-contour2d": "^1.1.4",
7576
"gl-error3d": "^1.0.9",
Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
/**
2+
* Copyright 2012-2018, Plotly, Inc.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the MIT license found in the
6+
* LICENSE file in the root directory of this source tree.
7+
*/
8+
9+
'use strict';
10+
11+
var colorscaleAttrs = require('../../components/colorscale/attributes');
12+
var colorbarAttrs = require('../../components/colorbar/attributes');
13+
var surfaceAtts = require('../surface/attributes');
14+
var baseAttrs = require('../../plots/attributes');
15+
16+
var extendFlat = require('../../lib/extend').extendFlat;
17+
18+
module.exports = extendFlat({
19+
x: {
20+
valType: 'data_array',
21+
editType: 'calc+clearAxisTypes',
22+
description: [
23+
'Sets the X coordinates of the vertices. The nth element of vectors `x`, `y` and `z`',
24+
'jointly represent the X, Y and Z coordinates of the nth vertex.'
25+
].join(' ')
26+
},
27+
y: {
28+
valType: 'data_array',
29+
editType: 'calc+clearAxisTypes',
30+
description: [
31+
'Sets the Y coordinates of the vertices. The nth element of vectors `x`, `y` and `z`',
32+
'jointly represent the X, Y and Z coordinates of the nth vertex.'
33+
].join(' ')
34+
},
35+
z: {
36+
valType: 'data_array',
37+
editType: 'calc+clearAxisTypes',
38+
description: [
39+
'Sets the Z coordinates of the vertices. The nth element of vectors `x`, `y` and `z`',
40+
'jointly represent the X, Y and Z coordinates of the nth vertex.'
41+
].join(' ')
42+
},
43+
value: {
44+
valType: 'data_array',
45+
editType: 'calc+clearAxisTypes',
46+
description: [
47+
'Sets the 4th dimension of the vertices.'
48+
].join(' ')
49+
},
50+
51+
text: {
52+
valType: 'string',
53+
role: 'info',
54+
dflt: '',
55+
arrayOk: true,
56+
editType: 'calc',
57+
description: [
58+
'Sets the text elements associated with the vertices.',
59+
'If trace `hoverinfo` contains a *text* flag and *hovertext* is not set,',
60+
'these elements will be seen in the hover labels.'
61+
].join(' ')
62+
},
63+
64+
intensity: {
65+
valType: 'data_array',
66+
editType: 'calc',
67+
description: [
68+
'Sets the vertex intensity values,',
69+
'used for plotting fields on isosurfaces'
70+
].join(' ')
71+
},
72+
73+
// Color field
74+
color: {
75+
valType: 'color',
76+
role: 'style',
77+
editType: 'calc',
78+
description: 'Sets the color of the whole isosurface'
79+
},
80+
vertexcolor: {
81+
valType: 'data_array',
82+
role: 'style',
83+
editType: 'calc',
84+
description: [
85+
'Sets the color of each vertex',
86+
'Overrides *color*.'
87+
].join(' ')
88+
},
89+
facecolor: {
90+
valType: 'data_array',
91+
role: 'style',
92+
editType: 'calc',
93+
description: [
94+
'Sets the color of each face',
95+
'Overrides *color* and *vertexcolor*.'
96+
].join(' ')
97+
},
98+
transforms: undefined
99+
},
100+
101+
colorscaleAttrs('', {
102+
colorAttr: '`intensity`',
103+
showScaleDflt: true,
104+
editTypeOverride: 'calc'
105+
}), {
106+
107+
colorbar: colorbarAttrs,
108+
109+
opacity: surfaceAtts.opacity,
110+
111+
// Flat shaded mode
112+
flatshading: {
113+
valType: 'boolean',
114+
role: 'style',
115+
dflt: false,
116+
editType: 'calc',
117+
description: [
118+
'Determines whether or not normal smoothing is applied to the isosurfaces,',
119+
'creating isosurfaces with an angular, low-poly look via flat reflections.'
120+
].join(' ')
121+
},
122+
123+
contour: {
124+
show: extendFlat({}, surfaceAtts.contours.x.show, {
125+
description: [
126+
'Sets whether or not dynamic contours are shown on hover'
127+
].join(' ')
128+
}),
129+
color: surfaceAtts.contours.x.color,
130+
width: surfaceAtts.contours.x.width,
131+
editType: 'calc'
132+
},
133+
134+
lightposition: {
135+
x: extendFlat({}, surfaceAtts.lightposition.x, {dflt: 1e5}),
136+
y: extendFlat({}, surfaceAtts.lightposition.y, {dflt: 1e5}),
137+
z: extendFlat({}, surfaceAtts.lightposition.z, {dflt: 0}),
138+
editType: 'calc'
139+
},
140+
lighting: extendFlat({
141+
vertexnormalsepsilon: {
142+
valType: 'number',
143+
role: 'style',
144+
min: 0.00,
145+
max: 1,
146+
dflt: 1e-12, // otherwise finely tessellated things eg. the brain will have no specular light reflection
147+
editType: 'calc',
148+
description: 'Epsilon for vertex normals calculation avoids math issues arising from degenerate geometry.'
149+
},
150+
facenormalsepsilon: {
151+
valType: 'number',
152+
role: 'style',
153+
min: 0.00,
154+
max: 1,
155+
dflt: 1e-6, // even the brain model doesn't appear to need finer than this
156+
editType: 'calc',
157+
description: 'Epsilon for face normals calculation avoids math issues arising from degenerate geometry.'
158+
},
159+
editType: 'calc'
160+
}, surfaceAtts.lighting),
161+
162+
hoverinfo: extendFlat({}, baseAttrs.hoverinfo, {editType: 'calc'})
163+
});

src/traces/isosurface/calc.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
* Copyright 2012-2018, Plotly, Inc.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the MIT license found in the
6+
* LICENSE file in the root directory of this source tree.
7+
*/
8+
9+
'use strict';
10+
11+
var colorscaleCalc = require('../../components/colorscale/calc');
12+
13+
module.exports = function calc(gd, trace) {
14+
if(trace.intensity) {
15+
colorscaleCalc(gd, trace, {
16+
vals: trace.intensity,
17+
containerStr: '',
18+
cLetter: 'c'
19+
});
20+
}
21+
};

0 commit comments

Comments
 (0)