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

Allow TrackballControls to work in a static scene like OrbitControls does #17816

Closed
wants to merge 3 commits into from

Conversation

mkhorton
Copy link

Adds _this.update() to mousewheel(), mousemove() and touchmove() events in TrackballControls.

From the documentation, TrackballControls and OrbitControls look like they're drop-in replacements for one another, they both have the same constructor, etc. However, unlike OrbitControls, TrackballControls does not work in a static scene with no animation loop present.

See this Stack Overflow thread for a discussion.

PR would allow TrackballControls to work in static scenes.

@Mugen87
Copy link
Collaborator

Mugen87 commented Oct 26, 2019

Current version: https://jsfiddle.net/6dagmj0c/
With your change: https://jsfiddle.net/dp1ry53v/2/

PR would allow TrackballControls to work in static scenes.

Yes, it is necessary to set TrackballControls.staticMoving to true. Otherwise the interaction feels weird.

Can you please also update the JSM version by running node utils/modularize.js (from the project's root directory)? In this way, it's easier to verify the existing examples via: http://raw.githack.com/mkhorton/three.js/patch-1/examples/index.html

@mkhorton
Copy link
Author

mkhorton commented Oct 26, 2019

Thanks @Mugen87, I've run modularize.js and added a note to the TrackballControls docs about setting TrackballControls.staticMoving to true in static scenes.

@Mugen87
Copy link
Collaborator

Mugen87 commented Oct 27, 2019

The issue with this change is that it makes the call of TrackballControls.update() obsolete when no damping is used. The official example misc_controls_trackball now works even if the update call is removed from the animation loop.

Hence, the documentation of update() should be changed to something similar like OrbitControls.update(). Besides, it's necessary to check the examples and remove controls.update() when TrackballControls.staticMoving is set to true. Otherwise unnecessary updates are performed which is not good.

This change also needs a note in the migration guide.

@Mugen87
Copy link
Collaborator

Mugen87 commented Nov 5, 2019

Let's revisit this change if it's clear what happens to TrackballControls, see #17842, #17857, #17858.

@Mugen87 Mugen87 closed this Nov 5, 2019
@mkhorton
Copy link
Author

mkhorton commented Nov 5, 2019

Thanks for the update!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants