Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable panning in "orbit" mode #273

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 5 additions & 12 deletions js/src/figure.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure what you mean by this comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just wanted to explain why enableKeys is switched off:

The problem is that if there are multiple ipyvolume widgets on the same page and I press, e.g., the left arrow key, all of them pan to the left. Which is most likely not the expected behavior.

But I can simply remove the comment if it causes confusion.

... or replace it by whatever you prefer. Just tell me.

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()

Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -2032,4 +2025,4 @@ var WidgetManagerHackModel = widgets.WidgetModel.extend({
// WEBPACK FOOTER
// ./src/volume.js
// module id = 1
// module chunks = 0
// module chunks = 0