Skip to content

Commit 5b24f51

Browse files
committed
logic to enable turntable default
1 parent 3ab1b1d commit 5b24f51

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/plots/gl3d/layout/defaults.js

+26
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,32 @@ function handleGl3dDefaults(sceneLayoutIn, sceneLayoutOut, coerce, opts) {
9797
sceneLayoutIn.aspectmode = sceneLayoutOut.aspectmode;
9898
}
9999

100+
function enableTurnTable() {
101+
sceneLayoutIn.dragmode = 'turntable';
102+
}
103+
104+
if(!sceneLayoutIn.dragmode) {
105+
// Because the default is now set to orbit mode
106+
// (i.e. in order to apply camera.z.up at init time)
107+
// we set turnable our disarable option here.
108+
109+
if(sceneLayoutIn.camera &&
110+
sceneLayoutIn.camera.up) {
111+
112+
var x = sceneLayoutIn.camera.up.x;
113+
var y = sceneLayoutIn.camera.up.y;
114+
var z = sceneLayoutIn.camera.up.z;
115+
116+
if(!x || !y || !z) {
117+
enableTurnTable();
118+
} else if(z / Math.sqrt(x*x + y*y + z*z) > 0.999) {
119+
enableTurnTable();
120+
}
121+
} else {
122+
enableTurnTable();
123+
}
124+
}
125+
100126
supplyGl3dAxisLayoutDefaults(sceneLayoutIn, sceneLayoutOut, {
101127
font: opts.font,
102128
scene: opts.id,

0 commit comments

Comments
 (0)