Skip to content

Commit 4836861

Browse files
committed
try fixing cone 'absolute' scaling
1 parent 6257642 commit 4836861

File tree

2 files changed

+24
-14
lines changed

2 files changed

+24
-14
lines changed

src/traces/cone/attributes.js

+13-7
Original file line numberDiff line numberDiff line change
@@ -112,20 +112,26 @@ var attrs = {
112112
editType: 'calc',
113113
dflt: 'scaled',
114114
description: [
115-
'Sets the mode by which the cones are sized.',
116-
'If *scaled*, `sizeref` scales such that the reference cone size',
117-
'for the maximum vector magnitude is 1.',
118-
'If *absolute*, `sizeref` scales such that the reference cone size',
119-
'for vector magnitude 1 is one grid unit.'
115+
'Determines whether `sizeref` is set as a *scaled* (i.e unitless) scalar',
116+
'(normalized by the max u/v/w norm in the vector field) or as',
117+
'*absolute* value (in unit of velocity).'
120118
].join(' ')
121119
},
122120
sizeref: {
123121
valType: 'number',
124122
role: 'info',
125123
editType: 'calc',
126124
min: 0,
127-
dflt: 1,
128-
description: 'Sets the cone size reference value.'
125+
description: [
126+
'Adjusts the cone size scaling.',
127+
'The size of the cones is determined by their u/v/w norm multiplied a factor and `sizeref`.',
128+
'This factor (computed internally) corresponds to the minimum "time" to travel across two',
129+
'two successive x/y/z positions at the average velocity of those two successive positions',
130+
'All cones in a given trace use the same factor.',
131+
'With `sizemode` set to *scaled*, `sizeref` is unitless, its default value is *0.5*',
132+
'With `sizemode` set to *absolute*, `sizeref` has units of velocity, its the default value is',
133+
'half the sample\'s maximum vector norm.'
134+
].join(' ')
129135
},
130136

131137
anchor: {

src/traces/cone/convert.js

+11-7
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ function zip3(x, y, z) {
5959
}
6060

6161
var axisName2scaleIndex = {xaxis: 0, yaxis: 1, zaxis: 2};
62-
var sizeMode2sizeKey = {scaled: 'coneSize', absolute: 'absoluteConeSize'};
6362
var anchor2coneOffset = {tip: 1, tail: 0, cm: 0.25, center: 0.5};
6463
var anchor2coneSpan = {tip: 1, tail: 1, cm: 0.75, center: 0.5};
6564

@@ -88,15 +87,21 @@ function convert(scene, trace) {
8887

8988
coneOpts.colormap = parseColorScale(trace.colorscale);
9089
coneOpts.vertexIntensityBounds = [trace.cmin / trace._normMax, trace.cmax / trace._normMax];
91-
92-
coneOpts[sizeMode2sizeKey[trace.sizemode]] = trace.sizeref;
9390
coneOpts.coneOffset = anchor2coneOffset[trace.anchor];
9491

95-
var meshData = conePlot(coneOpts);
92+
if(trace.sizemode === 'scaled') {
93+
// unitless sizeref
94+
coneOpts.coneSize = trace.sizeref || 0.5;
95+
} else {
96+
// sizeref here has unit of velocity
97+
coneOpts.coneSize = (trace.sizeref / trace._normMax) || 0.5;
98+
}
9699

100+
var meshData = conePlot(coneOpts);
97101

98102
// pass gl-mesh3d lighting attributes
99-
meshData.lightPosition = [trace.lightposition.x, trace.lightposition.y, trace.lightposition.z];
103+
var lp = trace.lightposition;
104+
meshData.lightPosition = [lp.x, lp.y, lp.z];
100105
meshData.ambient = trace.lighting.ambient;
101106
meshData.diffuse = trace.lighting.diffuse;
102107
meshData.specular = trace.lighting.specular;
@@ -105,8 +110,7 @@ function convert(scene, trace) {
105110
meshData.opacity = trace.opacity;
106111

107112
// stash autorange pad value
108-
trace._pad = anchor2coneSpan[trace.anchor] * meshData.vectorScale * trace.sizeref;
109-
if(trace.sizemode === 'scaled') trace._pad *= trace._normMax;
113+
trace._pad = anchor2coneSpan[trace.anchor] * meshData.vectorScale * meshData.coneScale * trace._normMax;
110114

111115
return meshData;
112116
}

0 commit comments

Comments
 (0)