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
4 changes: 3 additions & 1 deletion src/traces/cone/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,9 @@ var attrs = {
arrayOk: true,
editType: 'calc',
description: [

'Sets the text elements associated with the cones.',
'If trace `hoverinfo` contains a *text* flag and *hovertext* is not set,',
'these elements will be seen in the hover labels.'
].join(' ')
}
};
Expand Down
50 changes: 35 additions & 15 deletions src/traces/cone/convert.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,24 @@
* LICENSE file in the root directory of this source tree.
*/


'use strict';

var createMesh = require('gl-cone3d').createConeMesh;
var createScatterPlot = require('gl-scatter3d');
var createConeMesh = require('gl-cone3d').createConeMesh;
var cone2mesh = require('./helpers').cone2mesh;

function Mesh3DTrace(scene, mesh, uid) {
function Cone(scene, uid) {
this.scene = scene;
this.uid = uid;
this.mesh = mesh;
this.mesh = null;
this.pts = null;
this.data = null;
}

var proto = Mesh3DTrace.prototype;
var proto = Cone.prototype;

proto.handlePick = function(selection) {
if(selection.object === this.mesh) {
if(selection.object === this.pts) {
var selectIndex = selection.index = selection.data.index;

selection.traceCoordinate = [
Expand All @@ -48,25 +49,44 @@ function convert(scene, trace) {

proto.update = function(data) {
this.data = data;
this.mesh.update(convert(this.scene, data));

var meshData = convert(this.scene, data);

this.mesh.update(meshData);
this.pts.update({position: meshData._pts});
};

proto.dispose = function() {
this.scene.glplot.remove(this.pts);
this.pts.dispose();
this.scene.glplot.remove(this.mesh);
this.mesh.dispose();
};

function createMesh3DTrace(scene, data) {
function createConeTrace(scene, data) {
var gl = scene.glplot.gl;
var meshData = convert(scene, data);
var mesh = createMesh(gl, meshData);
var result = new Mesh3DTrace(scene, mesh, data.uid);

result.data = data;
mesh._trace = result;
var meshData = convert(scene, data);
var mesh = createConeMesh(gl, meshData);

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._pts,
project: false,
opacity: 0
});

var cone = new Cone(scene, data.uid);
cone.mesh = mesh;
cone.pts = pts;
cone.data = data;
mesh._trace = cone;
pts._trace = cone;

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

return result;
return cone;
}

module.exports = createMesh3DTrace;
module.exports = createConeTrace;
5 changes: 4 additions & 1 deletion src/traces/cone/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,8 @@ exports.cone2mesh = function cone2mesh(trace, sceneLayout, dataScale) {

coneOpts[sizeMode2sizeKey[trace.sizemode]] = trace.sizeref;

return conePlot(coneOpts);
var meshOpts = conePlot(coneOpts);
meshOpts._pts = coneOpts.positions;

return meshOpts;
};
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.
7 changes: 0 additions & 7 deletions test/image/mocks/gl3d_cone-simple.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
{
"data": [
{
"type": "scatter3d",
"mode": "markers",
"x": [1, 2, 3],
"y": [1, 2, 3],
"z": [1, 2, 3]
},
{
"type": "cone",
"x": [1, 2, 3],
Expand Down