@@ -28,28 +28,13 @@ var proto = Cone.prototype;
28
28
proto . handlePick = function ( selection ) {
29
29
if ( selection . object === this . pts ) {
30
30
var selectIndex = selection . index = selection . data . index ;
31
- var xx , yy , zz ;
32
- var uu , vv , ww ;
33
-
34
- if ( this . _uvw ) {
35
- uu = this . _uvw [ selectIndex ] [ 0 ] ;
36
- vv = this . _uvw [ selectIndex ] [ 1 ] ;
37
- ww = this . _uvw [ selectIndex ] [ 2 ] ;
38
- } else {
39
- uu = this . data . u [ selectIndex ] ;
40
- vv = this . data . v [ selectIndex ] ;
41
- ww = this . data . w [ selectIndex ] ;
42
- }
43
-
44
- if ( this . _xyz ) {
45
- xx = this . _xyz [ selectIndex ] [ 0 ] ;
46
- yy = this . _xyz [ selectIndex ] [ 1 ] ;
47
- zz = this . _xyz [ selectIndex ] [ 2 ] ;
48
- } else {
49
- xx = this . data . x [ selectIndex ] ;
50
- yy = this . data . y [ selectIndex ] ;
51
- zz = this . data . z [ selectIndex ] ;
52
- }
31
+ var dataScale = this . scene . dataScale ;
32
+ var xx = this . _positions [ selectIndex ] [ 0 ] / dataScale [ 0 ] ;
33
+ var yy = this . _positions [ selectIndex ] [ 1 ] / dataScale [ 1 ] ;
34
+ var zz = this . _positions [ selectIndex ] [ 2 ] / dataScale [ 2 ] ;
35
+ var uu = this . _vectors [ selectIndex ] [ 0 ] / dataScale [ 0 ] ;
36
+ var vv = this . _vectors [ selectIndex ] [ 1 ] / dataScale [ 1 ] ;
37
+ var ww = this . _vectors [ selectIndex ] [ 2 ] / dataScale [ 2 ] ;
53
38
54
39
selection . traceCoordinate = [
55
40
xx , yy , zz ,
@@ -83,7 +68,6 @@ var anchor2coneOffset = {tip: 1, tail: 0, cm: 0.25, center: 0.5};
83
68
function convert ( scene , trace ) {
84
69
var sceneLayout = scene . fullSceneLayout ;
85
70
var dataScale = scene . dataScale ;
86
- var hasConesPos = trace . cones && trace . cones . x && trace . cones . y && trace . cones . z ;
87
71
var coneOpts = { } ;
88
72
89
73
function toDataCoords ( arr , axisName ) {
@@ -104,7 +88,7 @@ function convert(scene, trace) {
104
88
toDataCoords ( trace . z , 'zaxis' )
105
89
) ;
106
90
107
- if ( hasConesPos ) {
91
+ if ( trace . cones && trace . cones . x && trace . cones . y && trace . cones . z ) {
108
92
coneOpts . meshgrid = [
109
93
toDataCoords ( trace . cones . x , 'xaxis' ) ,
110
94
toDataCoords ( trace . cones . y , 'yaxis' ) ,
@@ -118,32 +102,7 @@ function convert(scene, trace) {
118
102
coneOpts [ sizeMode2sizeKey [ trace . sizemode ] ] = trace . sizeref ;
119
103
coneOpts . coneOffset = anchor2coneOffset [ trace . anchor ] ;
120
104
121
- var meshOpts = conePlot ( coneOpts ) ;
122
-
123
- if ( hasConesPos ) {
124
- // used for transparent gl-scatter3d hover trace
125
- var pts = meshOpts . _pts = [ ] ;
126
- // used on hover
127
- var xyz = meshOpts . _xyz = [ ] ;
128
- var uvw = meshOpts . _uvw = [ ] ;
129
-
130
- // that 48 increment comes from gl-vis/gl-cone3d/cone.js
131
- for ( var i = 0 ; i < meshOpts . positions . length ; i += 48 ) {
132
- var pos = meshOpts . positions [ i ] ;
133
- pts . push ( [ pos [ 0 ] , pos [ 1 ] , pos [ 2 ] ] ) ;
134
- xyz . push ( [ pos [ 0 ] / dataScale [ 0 ] , pos [ 1 ] / dataScale [ 1 ] , pos [ 2 ] / dataScale [ 2 ] ] ) ;
135
-
136
- var vec = meshOpts . vectors [ i ] ;
137
- uvw . push ( [ vec [ 0 ] / dataScale [ 0 ] , vec [ 1 ] / dataScale [ 1 ] , vec [ 2 ] / dataScale [ 2 ] ] ) ;
138
- }
139
-
140
- } else {
141
- meshOpts . _pts = coneOpts . positions ;
142
- // don't fill _xyz and _uvw here,
143
- // trace arrays do just fine on hover
144
- }
145
-
146
- return meshOpts ;
105
+ return conePlot ( coneOpts ) ;
147
106
}
148
107
149
108
proto . update = function ( data ) {
@@ -170,7 +129,7 @@ function createConeTrace(scene, data) {
170
129
171
130
var pts = createScatterPlot ( {
172
131
gl : gl ,
173
- position : meshData . _pts ,
132
+ position : meshData . _positions ,
174
133
project : false ,
175
134
opacity : 0
176
135
} ) ;
@@ -179,11 +138,13 @@ function createConeTrace(scene, data) {
179
138
cone . mesh = mesh ;
180
139
cone . pts = pts ;
181
140
cone . data = data ;
182
- cone . _xyz = meshData . _xyz ;
183
- cone . _uvw = meshData . _uvw ;
184
141
mesh . _trace = cone ;
185
142
pts . _trace = cone ;
186
143
144
+ // stash these for hover
145
+ cone . _positions = meshData . _positions ;
146
+ cone . _vectors = meshData . _vectors ;
147
+
187
148
scene . glplot . add ( pts ) ;
188
149
scene . glplot . add ( mesh ) ;
189
150
0 commit comments