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
23 changes: 15 additions & 8 deletions src/traces/cone/calc.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,25 @@

'use strict';

var cone2mesh = require('./helpers').cone2mesh;
var colorscaleCalc = require('../../components/colorscale/calc');

module.exports = function calc(gd, trace) {
var fullLayout = gd._fullLayout;
var u = trace.u;
var v = trace.v;
var w = trace.w;
var len = Math.min(u.length, v.length, w.length);
var normMax = -Infinity;
var normMin = Infinity;

// TODO skip when 'cmin' and 'cmax' are set
// TODO find way to "merge" this cone2mesh call with the one in convert.js
//
// TODO should show in absolute or normalize length?
for(var i = 0; i < len; i++) {
var uu = u[i];
var vv = v[i];
var ww = w[i];
var norm = Math.sqrt(uu * uu + vv * vv + ww * ww);

var meshData = cone2mesh(trace, fullLayout[trace.scene]);
normMax = Math.max(normMax, norm);
normMin = Math.min(normMin, norm);
}

colorscaleCalc(trace, meshData.vertexIntensity, '', 'c');
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!

};
56 changes: 54 additions & 2 deletions src/traces/cone/convert.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@
'use strict';

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

var simpleMap = require('../../lib').simpleMap;
var parseColorScale = require('../../lib/gl_format_color').parseColorScale;

function Cone(scene, uid) {
this.scene = scene;
Expand Down Expand Up @@ -43,8 +46,57 @@ proto.handlePick = function(selection) {
}
};

function zip3(x, y, z) {
var result = new Array(x.length);
for(var i = 0; i < x.length; i++) {
result[i] = [x[i], y[i], z[i]];
}
return result;
}

var axisName2scaleIndex = {xaxis: 0, yaxis: 1, zaxis: 2};
var sizeMode2sizeKey = {scaled: 'coneSize', absolute: 'absoluteConeSize'};

function convert(scene, trace) {
return cone2mesh(trace, scene.fullSceneLayout, scene.dataScale);
var sceneLayout = scene.fullSceneLayout;
var dataScale = scene.dataScale;
var coneOpts = {};

function toDataCoords(arr, axisName) {
var ax = sceneLayout[axisName];
var scale = dataScale[axisName2scaleIndex[axisName]];
return simpleMap(arr, function(v) { return ax.d2l(v) * scale; });
}

coneOpts.vectors = zip3(
toDataCoords(trace.u, 'xaxis'),
toDataCoords(trace.v, 'yaxis'),
toDataCoords(trace.w, 'zaxis')
);

coneOpts.positions = zip3(
toDataCoords(trace.x, 'xaxis'),
toDataCoords(trace.y, 'yaxis'),
toDataCoords(trace.z, 'zaxis')
);

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

coneOpts.colormap = parseColorScale(trace.colorscale);
coneOpts.vertexIntensityBounds = [trace.cmin / trace.cmax, 1];

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

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

return meshOpts;
}

proto.update = function(data) {
Expand Down
71 changes: 0 additions & 71 deletions src/traces/cone/helpers.js

This file was deleted.