-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
3D cone traces #2641
Changes from 1 commit
ec64895
5736290
cb7cb7f
89eaf11
863b0da
fa32a74
71e46af
a2c3694
a2db567
db8222b
55700b8
e4a2035
a02dd11
cb7ef43
e718c66
f651eec
3f3bfac
aaf7249
d5d6f33
b7465fb
5a42de0
04d3d91
2a45dae
8dca9ae
3d26d47
5a59bc7
3dd6cf5
fb2ec1e
74ecbf8
abb11e0
8e8f5d6
2c08357
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -63,6 +63,7 @@ function zip3(x, y, z) { | |
var axisName2scaleIndex = {xaxis: 0, yaxis: 1, zaxis: 2}; | ||
var sizeMode2sizeKey = {scaled: 'coneSize', absolute: 'absoluteConeSize'}; | ||
var anchor2coneOffset = {tip: 1, tail: 0, cm: 0.25, center: 0.5}; | ||
var anchor2coneSpan = {tip: 1, tail: 1, cm: 0.75, center: 0.5}; | ||
|
||
function convert(scene, trace) { | ||
var sceneLayout = scene.fullSceneLayout; | ||
|
@@ -107,6 +108,9 @@ function convert(scene, trace) { | |
meshData.fresnel = trace.lighting.fresnel; | ||
meshData.opacity = trace.opacity; | ||
|
||
// stash autorange pad value | ||
trace._pad = anchor2coneSpan[trace.anchor] * meshData.vectorScale * trace._normMax * trace.sizeref; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Awesome, I think we have a winner now! I don't see any cases (As I change the cone spacing, cone count in each direction, and vector length) where this fails to encompass all the cones, nor any where the padding looks unpleasantly large. 🏆 |
||
|
||
return meshData; | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -74,9 +74,9 @@ describe('@gl Test cone autorange:', function() { | |||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||
function _assertAxisRanges(msg, xrng, yrng, zrng) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
var sceneLayout = gd._fullLayout.scene; | ||||||||||||||||||||||||||||||||||||||||||||||||||
expect(sceneLayout.xaxis.range).toBeCloseToArray(xrng, 2, 'xaxis range -' + msg); | ||||||||||||||||||||||||||||||||||||||||||||||||||
expect(sceneLayout.yaxis.range).toBeCloseToArray(yrng, 2, 'yaxis range -' + msg); | ||||||||||||||||||||||||||||||||||||||||||||||||||
expect(sceneLayout.zaxis.range).toBeCloseToArray(zrng, 2, 'zaxis range -' + msg); | ||||||||||||||||||||||||||||||||||||||||||||||||||
expect(sceneLayout.xaxis.range).toBeCloseToArray(xrng, 2, 'xaxis range - ' + msg); | ||||||||||||||||||||||||||||||||||||||||||||||||||
expect(sceneLayout.yaxis.range).toBeCloseToArray(yrng, 2, 'yaxis range - ' + msg); | ||||||||||||||||||||||||||||||||||||||||||||||||||
expect(sceneLayout.zaxis.range).toBeCloseToArray(zrng, 2, 'zaxis range - ' + msg); | ||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||
it('should add pad around cone position to make sure they fit on the scene', function(done) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -89,7 +89,7 @@ describe('@gl Test cone autorange:', function() { | |||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||
Plotly.plot(gd, fig).then(function() { | ||||||||||||||||||||||||||||||||||||||||||||||||||
_assertAxisRanges('base', | ||||||||||||||||||||||||||||||||||||||||||||||||||
[-0.39, 4.39], [-0.39, 4.39], [-0.39, 4.39] | ||||||||||||||||||||||||||||||||||||||||||||||||||
[-0.66, 4.66], [-0.66, 4.66], [-0.66, 4.66] | ||||||||||||||||||||||||||||||||||||||||||||||||||
); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||
var trace = fig.data[0]; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -102,7 +102,7 @@ describe('@gl Test cone autorange:', function() { | |||||||||||||||||||||||||||||||||||||||||||||||||
}) | ||||||||||||||||||||||||||||||||||||||||||||||||||
.then(function() { | ||||||||||||||||||||||||||||||||||||||||||||||||||
_assertAxisRanges('scaled up', | ||||||||||||||||||||||||||||||||||||||||||||||||||
[-0.39, 4.39], [-0.39, 4.39], [-0.39, 4.39] | ||||||||||||||||||||||||||||||||||||||||||||||||||
[-0.66, 4.66], [-0.66, 4.66], [-0.66, 4.66] | ||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add one more test, to 🔒 this in a little more since it went through so many iterations: scale up the x/y/z arrays. At least one of the previous iterations had a problem with this but otherwise looked pretty good. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. there's this one: plotly.js/test/jasmine/tests/cone_test.js Lines 121 to 144 in abb11e0
am I missing anything? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's close, but there's a difference between adding another point that doesn't change the minimum spacing between cones, and expanding the whole x/y/z space and therefore expanding the minimum spacing as well. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. got it. Thanks! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done in -> 2c08357 |
||||||||||||||||||||||||||||||||||||||||||||||||||
); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||
var trace = fig.data[0]; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -115,7 +115,7 @@ describe('@gl Test cone autorange:', function() { | |||||||||||||||||||||||||||||||||||||||||||||||||
}) | ||||||||||||||||||||||||||||||||||||||||||||||||||
.then(function() { | ||||||||||||||||||||||||||||||||||||||||||||||||||
_assertAxisRanges('scaled down', | ||||||||||||||||||||||||||||||||||||||||||||||||||
[-0.39, 4.39], [-0.39, 4.39], [-0.39, 4.39] | ||||||||||||||||||||||||||||||||||||||||||||||||||
[-0.66, 4.66], [-0.66, 4.66], [-0.66, 4.66] | ||||||||||||||||||||||||||||||||||||||||||||||||||
); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||
var trace = fig.data[0]; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -140,21 +140,21 @@ describe('@gl Test cone autorange:', function() { | |||||||||||||||||||||||||||||||||||||||||||||||||
}) | ||||||||||||||||||||||||||||||||||||||||||||||||||
.then(function() { | ||||||||||||||||||||||||||||||||||||||||||||||||||
_assertAxisRanges('after adding one cone outside range but with norm-0', | ||||||||||||||||||||||||||||||||||||||||||||||||||
[-0.45, 6.45], [-0.45, 6.45], [-0.45, 6.45] | ||||||||||||||||||||||||||||||||||||||||||||||||||
[-0.72, 6.72], [-0.72, 6.72], [-0.72, 6.72] | ||||||||||||||||||||||||||||||||||||||||||||||||||
); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||
return Plotly.restyle(gd, 'sizeref', 10); | ||||||||||||||||||||||||||||||||||||||||||||||||||
}) | ||||||||||||||||||||||||||||||||||||||||||||||||||
.then(function() { | ||||||||||||||||||||||||||||||||||||||||||||||||||
_assertAxisRanges('after increasing sizeref', | ||||||||||||||||||||||||||||||||||||||||||||||||||
[-12.4, 18.4], [-12.4, 18.4], [-12.4, 18.4] | ||||||||||||||||||||||||||||||||||||||||||||||||||
[-15.06, 21.06], [-15.06, 21.06], [-15.06, 21.06] | ||||||||||||||||||||||||||||||||||||||||||||||||||
); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||
return Plotly.restyle(gd, 'sizeref', 0.1); | ||||||||||||||||||||||||||||||||||||||||||||||||||
}) | ||||||||||||||||||||||||||||||||||||||||||||||||||
.then(function() { | ||||||||||||||||||||||||||||||||||||||||||||||||||
_assertAxisRanges('after decreasing sizeref', | ||||||||||||||||||||||||||||||||||||||||||||||||||
[0.74, 5.26], [0.74, 5.26], [0.74, 5.26] | ||||||||||||||||||||||||||||||||||||||||||||||||||
[0.72, 5.28], [0.72, 5.28], [0.72, 5.28] | ||||||||||||||||||||||||||||||||||||||||||||||||||
); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||
return Plotly.restyle(gd, { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -164,7 +164,7 @@ describe('@gl Test cone autorange:', function() { | |||||||||||||||||||||||||||||||||||||||||||||||||
}) | ||||||||||||||||||||||||||||||||||||||||||||||||||
.then(function() { | ||||||||||||||||||||||||||||||||||||||||||||||||||
_assertAxisRanges('with sizemode absolute', | ||||||||||||||||||||||||||||||||||||||||||||||||||
[-1.25, 7.25], [-1.25, 7.25], [-1.25, 7.25] | ||||||||||||||||||||||||||||||||||||||||||||||||||
[-2.31, 8.31], [-2.31, 8.31], [-2.31, 8.31] | ||||||||||||||||||||||||||||||||||||||||||||||||||
); | ||||||||||||||||||||||||||||||||||||||||||||||||||
}) | ||||||||||||||||||||||||||||||||||||||||||||||||||
.catch(failTest) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment.
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!