Skip to content

Commit e0ff37f

Browse files
committed
first cut streamtube hover
1 parent e99ffc9 commit e0ff37f

File tree

5 files changed

+27
-17
lines changed

5 files changed

+27
-17
lines changed

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
"gl-select-box": "^1.0.2",
8484
"gl-spikes2d": "^1.0.1",
8585
"gl-surface3d": "^1.3.4",
86-
"gl-streamtube3d": "[email protected]:gl-vis/gl-streamtube3d#d004f17506ed7fafc30586836d1a76b55dea8e48",
86+
"gl-streamtube3d": "[email protected]:gl-vis/gl-streamtube3d#0ce19fad7570e9d501d7dcc218f3101528dd3e64",
8787
"glslify": "^6.1.1",
8888
"has-hover": "^1.0.1",
8989
"has-passive-events": "^1.0.0",

src/plots/gl3d/scene.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ function render(scene) {
8888

8989
var tx;
9090

91-
if(trace.type === 'cone') {
91+
if(trace.type === 'cone' || trace.type === 'streamtube') {
9292
var coneTx = [];
9393
if(isHoverinfoAll || hoverinfoParts.indexOf('u') !== -1) {
9494
coneTx.push('u: ' + formatter('xaxis', selection.traceCoordinate[3]));

src/traces/streamtube/attributes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,11 @@ var attrs = {
8989
description: ''
9090
},
9191

92+
// TODO maybe just remove completely?
9293
text: {
9394
valType: 'string',
9495
role: 'info',
9596
dflt: '',
96-
arrayOk: true,
9797
editType: 'calc',
9898
description: [
9999
'Sets the text elements associated with the cones.',

src/traces/streamtube/convert.js

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ var Lib = require('../../lib');
1515
var parseColorScale = require('../../lib/gl_format_color').parseColorScale;
1616
var zip3 = require('../../lib/zip3');
1717

18+
var axisName2scaleIndex = {xaxis: 0, yaxis: 1, zaxis: 2};
19+
1820
function Streamtube(scene, uid) {
1921
this.scene = scene;
2022
this.uid = uid;
@@ -25,28 +27,36 @@ function Streamtube(scene, uid) {
2527
var proto = Streamtube.prototype;
2628

2729
proto.handlePick = function(selection) {
30+
var sceneLayout = this.scene.fullSceneLayout;
31+
var dataScale = this.scene.dataScale;
32+
33+
function fromDataScale(v, axisName) {
34+
var ax = sceneLayout[axisName];
35+
var scale = dataScale[axisName2scaleIndex[axisName]];
36+
return ax.l2c(v) / scale;
37+
}
38+
2839
if(selection.object === this.mesh) {
29-
var selectIndex = selection.index = selection.data.index;
40+
var pos = selection.data.position;
41+
var vel = selection.data.velocity;
42+
43+
var uu = fromDataScale(vel[0], 'xaxis');
44+
var vv = fromDataScale(vel[1], 'yaxis');
45+
var ww = fromDataScale(vel[2], 'zaxis')
3046

3147
selection.traceCoordinate = [
32-
this.data.x[selectIndex],
33-
this.data.y[selectIndex],
34-
this.data.z[selectIndex]
35-
];
48+
fromDataScale(pos[0], 'xaxis'),
49+
fromDataScale(pos[1], 'yaxis'),
50+
fromDataScale(pos[2], 'zaxis'),
3651

37-
var text = this.data.text;
38-
if(Array.isArray(text) && text[selectIndex] !== undefined) {
39-
selection.textLabel = text[selectIndex];
40-
} else if(text) {
41-
selection.textLabel = text;
42-
}
52+
uu, vv, ww,
53+
Math.sqrt(uu * uu + vv * vv + ww * ww)
54+
];
4355

4456
return true;
4557
}
4658
};
4759

48-
var axisName2scaleIndex = {xaxis: 0, yaxis: 1, zaxis: 2};
49-
5060
function distinctVals(col) {
5161
return Lib.distinctVals(col).vals;
5262
}

0 commit comments

Comments
 (0)