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
improve interplay between vector and cone position attributes
- x/y/z always refers vector positions (their length should match
  u/v/w)
- if nothing else provided, x/y/z correspond to the cone position also,
- to set cone position, use `cones.(x|y|z)` for now
- update attribute descriptions and trace meta info
  • Loading branch information
etpinard committed May 17, 2018
commit cb7ef43933987885b170a8e497dee103c8cdea88
61 changes: 39 additions & 22 deletions src/traces/cone/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,29 +22,29 @@ var attrs = {
role: 'info',
editType: 'calc+clearAxisTypes',
description: [
'Sets the x positions of the cones.',
'When `vx`, `vy`, `vz` are not set,',
' these are also the x coordinates of the u/v/w vector field.'
'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.'
].join(' ')
},
y: {
valType: 'data_array',
role: 'info',
editType: 'calc+clearAxisTypes',
description: [
'Sets the y positions of the cones.',
'When `vx`, `vy`, `vz` are not set,',
' these are also the y coordinates of the u/v/w vector field.'
'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.'
].join(' ')
},
z: {
valType: 'data_array',
role: 'info',
editType: 'calc+clearAxisTypes',
description: [
'Sets the z positions of the cones.',
'When `vx`, `vy`, `vz` are not set,',
' these are also the z coordinates of the u/v/w vector field.'
'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.'
].join(' ')
},

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

vx: {
valType: 'data_array',
editType: 'calc',
description: 'Sets the x coordinates of the vector field mesh.'
},
vy: {
valType: 'data_array',
editType: 'calc',
description: 'Sets the y coordinates of the vector field mesh.'
},
vz: {
valType: 'data_array',
cones: {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@alexcjohnson I went with cones.(x|y|z) which looks a lot like attribute containers contours and bins. Hope you'll like it.

// 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: 'Sets the z coordinates of the vector field mesh.'
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: {
Expand Down
9 changes: 5 additions & 4 deletions src/traces/cone/convert.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ var anchor2coneOffset = {tip: 1, tail: 0, cm: 0.25, center: 0.5};
function convert(scene, trace) {
var sceneLayout = scene.fullSceneLayout;
var dataScale = scene.dataScale;
var hasConesPos = trace.cones && trace.cones.x && trace.cones.y && trace.cones.z;
var coneOpts = {};

function toDataCoords(arr, axisName) {
Expand All @@ -91,11 +92,11 @@ function convert(scene, trace) {
toDataCoords(trace.z, 'zaxis')
);

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

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

coerce('vx');
coerce('vy');
coerce('vz');
coerce('cones.x');
coerce('cones.y');
coerce('cones.z');

coerce('sizeref');
coerce('sizemode');
Expand All @@ -56,14 +56,12 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
coerce('lightposition.y');
coerce('lightposition.z');

// TODO should the default be viridis
// ... and should we restrict cmin,cmax > 0 ???
colorscaleDefaults(traceIn, traceOut, layout, coerce, {prefix: '', cLetter: 'c'});

coerce('text');

// disable 1D transforms
// x/y/z should match lengths, u/v/w and vx/vy/vz should match as well, but
// 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.
traceOut._length = null;
};
11 changes: 10 additions & 1 deletion src/traces/cone/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,16 @@ module.exports = {

meta: {
description: [
'...'
'Use cone traces to visualize vector fields.',
'',
'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`.'
Copy link
Collaborator

Choose a reason for hiding this comment

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

"To display cones at different positions from the field data, use array attributes cones.x, cones.y and cones.z. Where these positions do not match data points, the field is interpolated ..." (How, what algorithm? And does the algorithm extend outside the convex hull of the data? Perhaps also mention interpolation in attributes.cones.description?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How, what algorithm?

Can @kig help us out here?

].join(' ')
}
};
56 changes: 29 additions & 27 deletions test/image/mocks/gl3d_cone-sparse.json
Original file line number Diff line number Diff line change
Expand Up @@ -5036,33 +5036,35 @@
0.021351568113512426,
0.611131516169977
],
"vx": [
0,
15,
30,
35,
40,
55,
70
],
"vy": [
0,
15,
30,
35,
40,
45,
50
],
"vz": [
0,
1,
2,
3,
30,
31,
50
]
"cones": {
"x": [
0,
15,
30,
35,
40,
55,
70
],
"y": [
0,
15,
30,
35,
40,
45,
50
],
"z": [
0,
1,
2,
3,
30,
31,
50
]
}
}
],
"layout": {
Expand Down