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;
var fullTrace = obj._trace.data;
var pad = fullTrace._pad ? fullTrace._pad / dataScale[i] : 0;
var pad = fullTrace._pad || 0;

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
4 changes: 3 additions & 1 deletion src/traces/cone/calc.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ module.exports = function calc(gd, trace) {
// stash max norm value to convert cmix/cmax -> vertexIntensityBounds
trace._normMax = normMax;
// stash autorange pad using max 'component' value
trace._pad = Math.sqrt(compMax) / (normMax || 1);
trace._pad = trace.sizemode === 'absolute' ?
trace.sizeref :
2 * (Math.sqrt(compMax) / (normMax || 1)) * trace.sizeref;

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 modified 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.
51 changes: 50 additions & 1 deletion test/jasmine/tests/cone_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ describe('Test cone defaults', function() {
});
});

describe('@gl Test cone autorange', function() {
describe('@gl Test cone autorange:', function() {
var gd;

beforeEach(function() {
Expand Down Expand Up @@ -117,6 +117,55 @@ describe('@gl Test cone autorange', function() {
_assertAxisRanges('scaled down',
[-0.39, 4.39], [-0.39, 4.39], [-0.39, 4.39]
);

var trace = fig.data[0];

var x = trace.x.slice();
x.push(5);
var y = trace.y.slice();
y.push(5);
var z = trace.z.slice();
z.push(5);
var u = trace.u.slice();
u.push(0);
var v = trace.v.slice();
v.push(0);
var w = trace.w.slice();
w.push(0);

return Plotly.restyle(gd, {
x: [x], y: [y], z: [z],
u: [u], v: [v], w: [w]
});
})
.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]
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 unfortunately I can't get this to "stick" to the previous range[0] values without breaking other gl3d mocks that depend on

for(j = 0; j < objects.length; j++) {
var objBounds = objects[j].bounds;
sceneBounds[0][i] = Math.min(sceneBounds[0][i], objBounds[0][i] / dataScale[i]);
sceneBounds[1][i] = Math.max(sceneBounds[1][i], objBounds[1][i] / dataScale[i]);
}

which scales the autorange bounds with the dataScale:

var dataScale = [1, 1, 1];
for(j = 0; j < 3; ++j) {
if(dataBounds[0][j] > dataBounds[1][j]) {
dataScale[j] = 1.0;
}
else {
if(dataBounds[1][j] === dataBounds[0][j]) {
dataScale[j] = 1.0;
}
else {
dataScale[j] = 1.0 / (dataBounds[1][j] - dataBounds[0][j]);
}
}
}

Hopefully this iteration is close enough.


As a side note, we should spend some time replacing this dataScale hack. This thing was added to make date axes work properly in 3D. Timestamps don't fit in a Float32Array, so we can't just convert the datestrings to timestamps, but we do this better in scattergl, where we use Float64Array or split the data into two Float32Arrays when not supported.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

New issue about the dataScale mess -> #2646

);

return Plotly.restyle(gd, 'sizeref', 10);
})
.then(function() {
_assertAxisRanges('after increasing sizeref',
[-12.4, 18.4], [-12.4, 18.4], [-12.4, 18.4]
);

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]
);

return Plotly.restyle(gd, {
sizemode: 'absolute',
sizeref: 2
});
})
.then(function() {
_assertAxisRanges('with sizemode absolute',
[-1.25, 7.25], [-1.25, 7.25], [-1.25, 7.25]
);
})
.catch(failTest)
.then(done);
Expand Down