Skip to content

3D cone traces #2641

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

Merged
merged 32 commits into from
May 18, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
ec64895
scaffold cone
etpinard Apr 16, 2018
5736290
move 3d parseColorScale to gl_format_color
etpinard May 16, 2018
cb7cb7f
get cone colorbar and vx/vy/vz mesh grid to work
etpinard May 16, 2018
89eaf11
add three cone mocks
etpinard May 16, 2018
863b0da
implement 'sizemode' and 'sizeref'
etpinard May 16, 2018
fa32a74
add lib/cone.js + add cone to gl3d bundle
etpinard May 16, 2018
71e46af
hook in hover labels for cones
etpinard May 16, 2018
a2c3694
clean up scene computeTraceBounds
etpinard May 17, 2018
a2db567
find min/max u/v/w norm in calc directly
etpinard May 17, 2018
db8222b
add "pad" using max u/v/w norm around cone bounds
etpinard May 17, 2018
55700b8
add 'anchor' to mimic gl-cone3d's coneOffset
etpinard May 17, 2018
e4a2035
add cone-specific hoverinfo flags
etpinard May 17, 2018
a02dd11
fixup cmin/cmax -> vertexIntensityBounds
etpinard May 17, 2018
cb7ef43
improve interplay between vector and cone position attributes
etpinard May 17, 2018
e718c66
fixup hover gl-scatter3d trace for cone with set `cones.(x|y|z)`
etpinard May 17, 2018
f651eec
use stashed gl-cone3d field as hover x/y/z u/v/w fields
etpinard May 17, 2018
3f3bfac
rename image-exporter -> orca
etpinard May 17, 2018
aaf7249
mv gl3d_cone-* out of `npm run test-image` into noci_test.sh
etpinard May 17, 2018
d5d6f33
add some cone tests
etpinard May 17, 2018
b7465fb
add hover label test for cones
etpinard May 17, 2018
5a42de0
comment out cones.(x|y|z) attributes for now
etpinard May 17, 2018
04d3d91
better pad value for autoranged cones
etpinard May 18, 2018
2a45dae
revert to current gl-cone3d master
etpinard May 18, 2018
8dca9ae
factor out `visible: false` converse test
etpinard May 18, 2018
3d26d47
fixup cone autorange pad computation
etpinard May 18, 2018
5a59bc7
fixup pad autorange (again)
etpinard May 18, 2018
3dd6cf5
pass gl-mesh3d lighting params
etpinard May 18, 2018
fb2ec1e
use gl-cone2d "vectorScale" to get better autorange pad value
etpinard May 18, 2018
74ecbf8
scaled pad value by normMax only under sizemode: 'scaled'
etpinard May 18, 2018
abb11e0
sub in npm version for gl-cone3d
etpinard May 18, 2018
8e8f5d6
fixup tests post 74ecbf8
etpinard May 18, 2018
2c08357
add autorange test case for "scaled up the x/y/z arrays"
etpinard May 18, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
comment out cones.(x|y|z) attributes for now
  • Loading branch information
etpinard committed May 17, 2018
commit 5a42de085bf5829a5108a7c8551d92a95cb48d6f
86 changes: 47 additions & 39 deletions src/traces/cone/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ var attrs = {
editType: 'calc+clearAxisTypes',
description: [
'Sets the x coordinates of the vector field',
'If `cones` positions are not provided, this array',
'corresponds to the x coordinates of the cones displayed as well.'
'and of the displayed cones.'
].join(' ')
},
y: {
Expand All @@ -33,8 +32,7 @@ var attrs = {
editType: 'calc+clearAxisTypes',
description: [
'Sets the y coordinates of the vector field',
'If `cones` positions are not provided, this array',
'corresponds to the y coordinates of the cones displayed as well.'
'and of the displayed cones.'
].join(' ')
},
z: {
Expand All @@ -43,8 +41,7 @@ var attrs = {
editType: 'calc+clearAxisTypes',
description: [
'Sets the z coordinates of the vector field',
'If `cones` positions are not provided, this array',
'corresponds to the z coordinates of the cones displayed as well.'
'and of the displayed cones.'
].join(' ')
},

Expand All @@ -64,38 +61,49 @@ var attrs = {
description: 'Sets the z components of the vector field.'
},

cones: {
// potential attributes to add:
//
// - meshmode: 'cartesian-product', 'pts', 'grid'
//
// under `meshmode: 'grid'`
// - (x|y|z)grid.start
// - (x|y|z)grid.end
// - (x|y|z)grid.size

x: {
valType: 'data_array',
editType: 'calc',
description: 'Sets the x coordinates of the cones to be displayed.'
},
y: {
valType: 'data_array',
editType: 'calc',
description: 'Sets the y coordinates of the cones to be displayed.'
},
z: {
valType: 'data_array',
editType: 'calc',
description: 'Sets the z coordinates of the cones to be displayed.'
},

editType: 'calc',
description: [
'By setting `cones.x`, `cones.y` and `cones.z` to 1D arrays,',
'plotly creates a mesh using the cartesian product of those 3 arrays.'
].join(' ')
},
// TODO add way to specify cone positions independently of the vector field
// provided, similar to MATLAB's coneplot Cx/Cy/Cz meshgrids,
// see https://www.mathworks.com/help/matlab/ref/coneplot.html
//
// Alternatively, if our goal is only to 'fill in gaps' in the vector data,
// we could try to extend the heatmap 'connectgaps' algorithm to 3D.
// From AJ: this particular algorithm which amounts to a Poisson equation,
// both for interpolation and extrapolation - is the right one to use for
// cones too. It makes a field with zero divergence, which is a good
// baseline assumption for vector fields.
//
// cones: {
// // potential attributes to add:
// //
// // - meshmode: 'cartesian-product', 'pts', 'grid'
// //
// // under `meshmode: 'grid'`
// // - (x|y|z)grid.start
// // - (x|y|z)grid.end
// // - (x|y|z)grid.size
//
// x: {
// valType: 'data_array',
// editType: 'calc',
// description: 'Sets the x coordinates of the cones to be displayed.'
// },
// y: {
// valType: 'data_array',
// editType: 'calc',
// description: 'Sets the y coordinates of the cones to be displayed.'
// },
// z: {
// valType: 'data_array',
// editType: 'calc',
// description: 'Sets the z coordinates of the cones to be displayed.'
// },
//
// editType: 'calc',
// description: [
// 'By setting `cones.x`, `cones.y` and `cones.z` to 1D arrays,',
// 'plotly creates a mesh using the cartesian product of those 3 arrays.'
// ].join(' ')
// },

sizemode: {
valType: 'enumerated',
Expand Down Expand Up @@ -128,7 +136,7 @@ var attrs = {
dflt: 'cm',
description: [
'Sets the cones\' anchor with respect to their x/y/z positions.',
'Note that *cm* denote the cone\'s center of mass with corresponds to',
'Note that *cm* denote the cone\'s center of mass which corresponds to',
'1/4 from the tail to tip.'
].join(' ')
},
Expand Down
34 changes: 13 additions & 21 deletions src/traces/cone/convert.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,12 @@ var proto = Cone.prototype;
proto.handlePick = function(selection) {
if(selection.object === this.pts) {
var selectIndex = selection.index = selection.data.index;
var dataScale = this.scene.dataScale;
var xx = this._positions[selectIndex][0] / dataScale[0];
var yy = this._positions[selectIndex][1] / dataScale[1];
var zz = this._positions[selectIndex][2] / dataScale[2];
var uu = this._vectors[selectIndex][0] / dataScale[0];
var vv = this._vectors[selectIndex][1] / dataScale[1];
var ww = this._vectors[selectIndex][2] / dataScale[2];
var xx = this.data.x[selectIndex];
var yy = this.data.y[selectIndex];
var zz = this.data.z[selectIndex];
var uu = this.data.u[selectIndex];
var vv = this.data.v[selectIndex];
var ww = this.data.w[selectIndex];

selection.traceCoordinate = [
xx, yy, zz,
Expand Down Expand Up @@ -88,21 +87,18 @@ function convert(scene, trace) {
toDataCoords(trace.z, 'zaxis')
);

if(trace.cones && trace.cones.x && trace.cones.y && trace.cones.z) {
coneOpts.meshgrid = [
toDataCoords(trace.cones.x, 'xaxis'),
toDataCoords(trace.cones.y, 'yaxis'),
toDataCoords(trace.cones.z, 'zaxis')
];
}

coneOpts.colormap = parseColorScale(trace.colorscale);
coneOpts.vertexIntensityBounds = [trace.cmin / trace._normMax, trace.cmax / trace._normMax];

coneOpts[sizeMode2sizeKey[trace.sizemode]] = trace.sizeref;
coneOpts.coneOffset = anchor2coneOffset[trace.anchor];

return conePlot(coneOpts);
var meshData = conePlot(coneOpts);

// stash positions for gl-scatter3d 'hover' trace
meshData._pts = coneOpts.positions;

return meshData;
}

proto.update = function(data) {
Expand All @@ -129,7 +125,7 @@ function createConeTrace(scene, data) {

var pts = createScatterPlot({
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a little bit hacky and not very efficient, but this works:

peek 2018-05-16 17-24

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, that was fast! Is it possible to get (u, v, w) in the hovertext as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's possible!

peek 2018-05-16 23-31

but maybe someone would argue that 6 fields in one hover label in too much by default. Maybe we could just show the vector norm value? Or maybe have hoverinfo: 'x+y+z+norm' by default and optionally up to: x+y+z+u+v+w+norm+text

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'x+y+z+norm' by default and optionally up to: x+y+z+u+v+w+norm+text

I like it!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done in e4a2035

gl: gl,
position: meshData._positions,
position: meshData._pts,
project: false,
opacity: 0
});
Expand All @@ -141,10 +137,6 @@ function createConeTrace(scene, data) {
mesh._trace = cone;
pts._trace = cone;

// stash these for hover
cone._positions = meshData._positions;
cone._vectors = meshData._vectors;

scene.glplot.add(pts);
scene.glplot.add(mesh);

Expand Down
8 changes: 1 addition & 7 deletions src/traces/cone/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
return;
}

coerce('cones.x');
coerce('cones.y');
coerce('cones.z');

coerce('sizeref');
coerce('sizemode');

Expand All @@ -60,8 +56,6 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout

coerce('text');

// disable 1D transforms
// x/y/z and u/v/w should match lengths, cones.(x|y|z) should match as well, but
// the two sets have different lengths so transforms wouldn't work.
// disable 1D transforms (for now)
traceOut._length = null;
};
7 changes: 2 additions & 5 deletions src/traces/cone/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,8 @@ module.exports = {
'Specify a vector field using 6 1D arrays,',
'3 position arrays `x`, `y` and `z`',
'and 3 vector component arrays `u`, `v`, `w`.',
'',
'If nothing else is provided, the cones are drawn exactly at the positions given',
'by `x`, `y` and `z`.',
'To specify the cone positions manually, use arrays attributes',
'`cones.x`, `cones.y` and `cones.z`.'
'The cones are drawn exactly at the positions given',
'by `x`, `y` and `z`.'
].join(' ')
}
};
Binary file removed test/image/baselines/gl3d_cone-sparse.png
Binary file not shown.
Loading