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
2 changes: 1 addition & 1 deletion src/plots/gl3d/scene.js
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ proto.plot = function(sceneData, fullLayout, layout) {
var obj = objects[j];
var objBounds = obj.bounds;
// add worse-case pad for cone traces
var pad = (obj._trace.data._normMax || 0) * dataScale[i];
var pad = 0.75 * (obj._trace.data._compMax || 0) * dataScale[i];
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This gives a better estimate. The data off #2641 (comment) now gives:

image

Copy link
Collaborator

Choose a reason for hiding this comment

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

Great! Yeah, I was wrong with [0, 4] - this looks awesome.

Copy link
Collaborator

Choose a reason for hiding this comment

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

hmm, this is still not quite right though. If I double all the u, v, w values, the cones don't change (as they shouldn't) but the padding increases.

var t={type: 'cone', x: [1, 1, 1, 1, 3, 3, 3, 3], y: [1, 1, 3, 3, 1, 1, 3, 3], z: [1, 3, 1, 3, 1, 3, 1, 3],
u: [1, 2, 3, 4, 1, 2, 3, 4], v: [1, 1, 2, 2, 3, 3, 4, 4], w: [4, 4, 1, 1, 2, 2, 3, 3]}

// the resulting image should be independent of what I multiply by here
function m(v) { return v*2; }

t.u = t.u.map(m); t.v = t.v.map(m); t.w=t.w.map(m); Plotly.newPlot(gd,[t], {scene: {camera: {eye: {x: -0.01, y: 2.52, z: 0.42}}}, width: 800, height: 800})

v * 1 (as above):
screen shot 2018-05-18 at 9 20 22 am

v * 2:
screen shot 2018-05-18 at 9 20 10 am

I don't need to tell you what happens with v / 10 do I? 😉

Copy link
Contributor Author

Choose a reason for hiding this comment

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

latest attempt: 3d26d47

sceneBounds[0][i] = Math.min(sceneBounds[0][i], objBounds[0][i] / dataScale[i] - pad);
sceneBounds[1][i] = Math.max(sceneBounds[1][i], objBounds[1][i] / dataScale[i] + pad);
}
Expand Down
10 changes: 9 additions & 1 deletion src/traces/cone/calc.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,26 @@ module.exports = function calc(gd, trace) {
var len = Math.min(u.length, v.length, w.length);
var normMax = -Infinity;
var normMin = Infinity;
var compMax = -Infinity;

for(var i = 0; i < len; i++) {
var uu = u[i];
var u2 = uu * uu;
var vv = v[i];
var v2 = vv * vv;
var ww = w[i];
var norm = Math.sqrt(uu * uu + vv * vv + ww * ww);
var w2 = ww * ww;
var norm = Math.sqrt(u2 + v2 + w2);

normMax = Math.max(normMax, norm);
normMin = Math.min(normMin, norm);
compMax = Math.max(compMax, u2, v2, w2);
}

// stash max norm value to convert cmix/cmax -> vertexIntensityBounds
trace._normMax = normMax;
// stash max 'component' value for autorange pad
trace._compMax = Math.sqrt(compMax);

colorscaleCalc(trace, [normMin, normMax], '', 'c');
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Shoutout to @alexcjohnson for the tip!

};
Binary file added test/image/baselines/gl3d_cone-autorange.png
Loading
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_cone-simple.png
Loading
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_cone-wind.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 28 additions & 0 deletions test/image/mocks/gl3d_cone-autorange.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"data": [
{
"type": "cone",
"x": [ 1, 1, 1, 1, 3, 3, 3, 3 ],
"y": [ 1, 1, 3, 3, 1, 1, 3, 3 ],
"z": [ 1, 3, 1, 3, 1, 3, 1, 3 ],
"u": [ 1, 2, 3, 4, 1, 2, 3, 4 ],
"v": [ 1, 1, 2, 2, 3, 3, 4, 4 ],
"w": [ 4, 4, 1, 1, 2, 2, 3, 3 ],
"showscale": false
}
],
"layout": {
"scene": {
"camera": {
"eye": {
"x": -0.009629409001286008,
"y": 2.5216768185264913,
"z": 0.42700218501677245
}
}
},
"width": 500,
"height": 500,
"margin": {"t": 0, "b": 0, "l": 0, "r": 0}
}
}