Skip to content

Commit 4a649f0

Browse files
committed
record glplot aspect in fullLayout aspectratio
1 parent 6e9bafb commit 4a649f0

File tree

4 files changed

+42
-5
lines changed

4 files changed

+42
-5
lines changed

package-lock.json

+2-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181
"gl-mat4": "^1.2.0",
8282
"gl-mesh3d": "^2.1.1",
8383
"gl-plot2d": "^1.4.2",
84-
"gl-plot3d": "^2.2.2",
84+
"gl-plot3d": "git://github.com/gl-vis/gl-plot3d.git#4d41ca21b3c0a25db8776ce92261995323bb62e8",
8585
"gl-pointcloud2d": "^1.0.2",
8686
"gl-scatter3d": "^1.2.2",
8787
"gl-select-box": "^1.0.3",

src/plots/gl3d/scene.js

+21-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
var createCamera = require('gl-plot3d').createCamera;
1313
var createPlot = require('gl-plot3d').createScene;
14+
var mouseWheel = require('mouse-wheel');
1415
var getContext = require('webgl-context');
1516
var passiveSupported = require('has-passive-events');
1617

@@ -243,7 +244,26 @@ function tryCreatePlot(scene, cameraObject, pixelRatio, canvas, gl) {
243244
}
244245
}
245246

246-
return failed < 2;
247+
if(failed < 2) {
248+
scene.wheelListener = mouseWheel(scene.glplot.canvas, function(dx, dy) {
249+
// TODO remove now that we can disable scroll via scrollZoom?
250+
if(scene.glplot.camera.keyBindingMode === false) return;
251+
if(!scene.glplot.camera.enableWheel) return;
252+
253+
if(scene.glplot.camera._ortho) {
254+
var s = (dx > dy) ? 1.1 : 1.0 / 1.1;
255+
256+
scene.fullSceneLayout.aspectratio.x = scene.glplot.aspect[0] *= s;
257+
scene.fullSceneLayout.aspectratio.y = scene.glplot.aspect[1] *= s;
258+
scene.fullSceneLayout.aspectratio.z = scene.glplot.aspect[2] *= s;
259+
260+
scene.glplot.redraw();
261+
}
262+
}, true);
263+
264+
return true;
265+
}
266+
return false;
247267
}
248268

249269
function initializeGLPlot(scene, pixelRatio, canvas, gl) {

test/jasmine/tests/gl3d_plot_interact_test.js

+18
Original file line numberDiff line numberDiff line change
@@ -906,6 +906,24 @@ describe('Test gl3d drag and wheel interactions', function() {
906906
return scroll(sceneTarget2);
907907
})
908908
.then(function() {
909+
expect(
910+
gd._fullLayout.scene2.aspectratio.x
911+
).toEqual(
912+
gd._fullLayout.scene2._scene.glplot.aspect[0]
913+
);
914+
915+
expect(
916+
gd._fullLayout.scene2.aspectratio.y
917+
).toEqual(
918+
gd._fullLayout.scene2._scene.glplot.aspect[1]
919+
);
920+
921+
expect(
922+
gd._fullLayout.scene2.aspectratio.z
923+
).toEqual(
924+
gd._fullLayout.scene2._scene.glplot.aspect[2]
925+
);
926+
909927
_assertAndReset(2);
910928
})
911929
.catch(failTest)

0 commit comments

Comments
 (0)