Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increase the speed of isosurface creation #3521

Merged
merged 3 commits into from Feb 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
36 changes: 7 additions & 29 deletions src/traces/isosurface/attributes.js
Expand Up @@ -10,7 +10,6 @@

var colorscaleAttrs = require('../../components/colorscale/attributes');
var colorbarAttrs = require('../../components/colorbar/attributes');
var surfaceAtts = require('../surface/attributes');
var meshAttrs = require('../mesh3d/attributes');
var baseAttrs = require('../../plots/attributes');

Expand Down Expand Up @@ -225,7 +224,7 @@ var attrs = module.exports = overrideAll(extendFlat({
'If trace `hoverinfo` contains a *text* flag and *hovertext* is not set,',
'these elements will be seen in the hover labels.'
].join(' ')
},
}
},

colorscaleAttrs('', {
Expand All @@ -236,37 +235,16 @@ colorscaleAttrs('', {

colorbar: colorbarAttrs,

// Flat shaded mode
flatshading: {
valType: 'boolean',
role: 'style',
dflt: false,
description: [
'Determines whether or not normal smoothing is applied to the isosurfaces,',
'creating isosurfaces with an angular, low-poly look via flat reflections.'
].join(' ')
},

contour: {
show: extendFlat({}, surfaceAtts.contours.x.show, {
description: [
'Sets whether or not dynamic contours are shown on hover.',
'Contours are more useful when hovering on caps and slices.'
].join(' ')
}),
color: surfaceAtts.contours.x.color,
width: surfaceAtts.contours.x.width
},

lightposition: {
x: extendFlat({}, surfaceAtts.lightposition.x, {dflt: 1e5}),
y: extendFlat({}, surfaceAtts.lightposition.y, {dflt: 1e5}),
z: extendFlat({}, surfaceAtts.lightposition.z, {dflt: 0})
},
contour: meshAttrs.contour,
lightposition: meshAttrs.lightposition,
lighting: meshAttrs.lighting,
flatshading: meshAttrs.flatshading,

hoverinfo: extendFlat({}, baseAttrs.hoverinfo)
}), 'calc', 'nested');

// required defaults to speed up surface normal calculations
attrs.flatshading.dflt = true; attrs.lighting.facenormalsepsilon.dflt = 0;

attrs.x.editType = attrs.y.editType = attrs.z.editType = attrs.value.editType = 'calc+clearAxisTypes';
attrs.transforms = undefined;
6 changes: 3 additions & 3 deletions src/traces/isosurface/convert.js
Expand Up @@ -396,9 +396,9 @@ function generateIsosurfaceMesh(data) {

function tryCreateTri(style, xyzv, abc, min, max, isSecondPass) {

abc = [-1, -1, -1]; // Note: for the moment we had to override indices
// for planar surfaces (i.e. caps and slices) due to group shading
// bug of gl-mesh3d. But don't worry this would run faster!
abc = [-1, -1, -1]; // Note: for the moment we override indices
// to run faster! But it is possible to comment this line
// to reduce the number of vertices.

var tryDrawTri = function(style, xyzv, abc) {
if( // we check here if the points are in `real` iso-min/max range
Expand Down
2 changes: 1 addition & 1 deletion src/traces/isosurface/defaults.js
Expand Up @@ -95,7 +95,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
'lightposition.x',
'lightposition.y',
'lightposition.z',
'flatshading',
'flatshading'
].forEach(function(x) { coerce(x); });

colorscaleDefaults(traceIn, traceOut, layout, coerce, {prefix: '', cLetter: 'c'});
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/gl3d_isosurface_math.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/gl3d_isosurface_xycaps_volume_slices.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Expand Up @@ -1878,11 +1878,11 @@
1.000, 1.450, 1.900, 2.350, 2.800, 3.250, 3.700, 4.150, 4.600, 5.050, 5.500, 5.950, 6.400, 6.850, 7.300, 7.750, 8.200, 8.650, 9.100, 9.550, 10.000
],
"lighting": {
"ambient": 0.5,
"diffuse": 1.0,
"specular": 0.75,
"roughness": 1.0,
"fresnel": 0.25
"ambient": 0.5,
"diffuse": 1.0,
"specular": 0.75,
"roughness": 1.0,
"fresnel": 0.25
},
"lightposition": {
"x": 10000,
Expand Down
10 changes: 5 additions & 5 deletions test/image/mocks/gl3d_isosurface_thin_caps_different_dims.json
Expand Up @@ -3638,11 +3638,11 @@
-10, -8, -6, -4, -2, 0, 2, 4, 6, 8, 10
],
"lighting": {
"ambient": 0.5,
"diffuse": 1.0,
"specular": 0.75,
"roughness": 1.0,
"fresnel": 0.25
"ambient": 0.5,
"diffuse": 1.0,
"specular": 0.75,
"roughness": 1.0,
"fresnel": 0.25
},
"lightposition": {
"x": 10000,
Expand Down
Expand Up @@ -1878,11 +1878,11 @@
0.000, 0.015, 0.120, 0.405, 0.960, 1.875, 3.240, 5.145, 7.680, 10.935, 15.000, 19.965, 25.920, 32.955, 41.160, 50.625, 61.440, 73.695, 87.480, 102.885, 120.000
],
"lighting": {
"ambient": 0.5,
"diffuse": 1.0,
"specular": 0.75,
"roughness": 1.0,
"fresnel": 0.25
"ambient": 0.5,
"diffuse": 1.0,
"specular": 0.75,
"roughness": 1.0,
"fresnel": 0.25
},
"lightposition": {
"x": 10000,
Expand Down
10 changes: 5 additions & 5 deletions test/image/mocks/gl3d_isosurface_with_surface-pattern.json
Expand Up @@ -1878,11 +1878,11 @@
-10.000, -9.998, -9.980, -9.932, -9.840, -9.688, -9.460, -9.143, -8.720, -8.178, -7.500, -6.672, -5.680, -4.507, -3.140, -1.563, 0.240, 2.282, 4.580, 7.147, 10.000
],
"lighting": {
"ambient": 0.5,
"diffuse": 1.0,
"specular": 0.75,
"roughness": 1.0,
"fresnel": 0.25
"ambient": 0.5,
"diffuse": 1.0,
"specular": 0.75,
"roughness": 1.0,
"fresnel": 0.25
},
"lightposition": {
"x": 10000,
Expand Down
10 changes: 5 additions & 5 deletions test/image/mocks/gl3d_isosurface_xycaps_volume_slices.json
Expand Up @@ -2838,11 +2838,11 @@
0, 0.008, 0.061, 0.207, 0.492, 0.960, 1.659, 2.634, 3.932, 5.599, 7.680, 10.222, 13.271, 16.873, 21.074, 25.920, 31.457, 37.732, 44.790, 52.677, 61.440, 71.124, 81.777, 93.443, 106.168, 120
],
"lighting": {
"ambient": 0.5,
"diffuse": 1.0,
"specular": 0.75,
"roughness": 1.0,
"fresnel": 0.25
"ambient": 0.5,
"diffuse": 1.0,
"specular": 0.75,
"roughness": 1.0,
"fresnel": 0.25
},
"lightposition": {
"x": 10000,
Expand Down