Skip to content

Commit db8222b

Browse files
committed
add "pad" using max u/v/w norm around cone bounds
... during autorange / scene bounds computation. - This pad values is a "worse case" solution (i.e. it pads too much for most situations), but gives nice visual results (I think).
1 parent a2db567 commit db8222b

File tree

6 files changed

+22
-3
lines changed

6 files changed

+22
-3
lines changed

src/plots/gl3d/scene.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -480,9 +480,12 @@ proto.plot = function(sceneData, fullLayout, layout) {
480480
var axLetter = axis._name.charAt(0);
481481

482482
for(j = 0; j < objects.length; j++) {
483-
var objBounds = objects[j].bounds;
484-
sceneBounds[0][i] = Math.min(sceneBounds[0][i], objBounds[0][i] / dataScale[i]);
485-
sceneBounds[1][i] = Math.max(sceneBounds[1][i], objBounds[1][i] / dataScale[i]);
483+
var obj = objects[j];
484+
var objBounds = obj.bounds;
485+
// add worse-case pad for cone traces
486+
var pad = (obj._trace.data._normMax || 0) * dataScale[i];
487+
sceneBounds[0][i] = Math.min(sceneBounds[0][i], objBounds[0][i] / dataScale[i] - pad);
488+
sceneBounds[1][i] = Math.max(sceneBounds[1][i], objBounds[1][i] / dataScale[i] + pad);
486489
}
487490

488491
for(j = 0; j < annotations.length; j++) {

src/traces/cone/calc.js

+2
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,7 @@ module.exports = function calc(gd, trace) {
2828
normMin = Math.min(normMin, norm);
2929
}
3030

31+
trace._normMax = normMax;
32+
3133
colorscaleCalc(trace, [normMin, normMax], '', 'c');
3234
};
21.2 KB
Loading
-94 Bytes
Loading
-904 Bytes
Loading

test/image/mocks/gl3d_cone-simple.json

+14
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,21 @@
1010
"w": [0, 0, 2],
1111
"sizemode": "absolute",
1212
"sizeref": 2
13+
},
14+
{
15+
"type": "cone",
16+
"x": [1, 2, 3],
17+
"y": [1, 2, 3],
18+
"z": [1, 2, 3],
19+
"u": [1, 0, 0],
20+
"v": [0, 3, 0],
21+
"w": [0, 0, 2],
22+
"scene": "scene2"
1323
}
1424
],
1525
"layout": {
1626
"scene": {
27+
"domain": {"x": [0, 0.5]},
1728
"xaxis": {
1829
"range": [-2, 5]
1930
},
@@ -23,6 +34,9 @@
2334
"zaxis": {
2435
"range": [-2, 5]
2536
}
37+
},
38+
"scene2": {
39+
"domain": {"x": [0.5, 1]}
2640
}
2741
}
2842
}

0 commit comments

Comments
 (0)