From d3bce32e48c8cf6f33a0db1a8a3f3eab392ddc63 Mon Sep 17 00:00:00 2001 From: Matthias Geier Date: Tue, 24 Sep 2019 13:14:14 +0200 Subject: [PATCH] Enable panning in "orbit" mode --- js/src/figure.js | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/js/src/figure.js b/js/src/figure.js index e0d800ce..fd6163df 100644 --- a/js/src/figure.js +++ b/js/src/figure.js @@ -395,13 +395,6 @@ var FigureView = widgets.DOMWidgetView.extend({ if (this.model.get('camera')) { this.camera = this.model.get('camera').obj this.model.get('camera').on('change', () => { - // the threejs' lookAt ignore the quaternion, and uses the up vector - // we manually set it ourselve - var up = new THREE.Vector3(0, 1, 0); - up.applyQuaternion(this.camera.quaternion); - this.camera.up = up; - this.camera.lookAt(0, 0, 0); - // TODO: shouldn't we do the same with the orbit control? this.control_trackball.position0 = this.camera.position.clone(); this.control_trackball.up0 = this.camera.up.clone(); // TODO: if we implement figure.look_at, we should update control's target as well @@ -634,7 +627,10 @@ var FigureView = widgets.DOMWidgetView.extend({ this.control_orbit = new THREE.OrbitControls(this.camera, this.renderer.domElement); this.control_trackball.dynamicDampingFactor = 1. this.control_trackball.noPan = true; - this.control_orbit.enablePan = false; + // All widgets on the page would receive those keypresses all the time: + this.control_orbit.enableKeys = false; + this.control_orbit.panSpeed = 1.0; + this.control_orbit.screenSpacePanning = true; this.control_orbit.dampingFactor = 1. this.update_mouse_mode() @@ -1462,9 +1458,6 @@ var FigureView = widgets.DOMWidgetView.extend({ _real_update: function() { this.control_trackball.handleResize() this._update_requested = false - // since the threejs animation system can update the camera, - // make sure we keep looking at the center - this.camera.lookAt(0, 0, 0) this.renderer.setClearColor(this.get_style_color('background-color')) this.x_axis.visible = this.get_style('axes.x.visible axes.visible') @@ -2032,4 +2025,4 @@ var WidgetManagerHackModel = widgets.WidgetModel.extend({ // WEBPACK FOOTER // ./src/volume.js // module id = 1 -// module chunks = 0 \ No newline at end of file +// module chunks = 0