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

TrackballControls: extends OrbitControls - API refactor #17857

Closed
wants to merge 1 commit into from

Conversation

sciecode
Copy link
Contributor

@sciecode sciecode commented Nov 3, 2019

Based on @WestLangley's #17842 (comment)

Similar to what was done to MapControls on #16961


Notes:

  • Introduces fixedUp which controls whether or not to maintain camera.up direction on rotation.

  • Noticeable rotationSpeed changes, due to the different mouse coordinates used in OrbitControls.

  • Implements @Mugen87's backwards compatibility changes on TrackballControls: Refactor API. #17842

@WestLangley
Copy link
Collaborator

I posted #17858 just to show how I implemented it. It may, or may not, be a better implementation.

I'd only change OrbitControls js, jsm, and one example file at this point, however. Don't remove the original TrackballControls. Why change 32 files when you can change 3 for now?

@sciecode
Copy link
Contributor Author

sciecode commented Nov 4, 2019

I'd only change OrbitControls js, jsm, and one example file at this point

I will force-push a simpler PR, no problem.

Don't remove the original TrackballControls.

We did a similar thing when extending OrbitControls for MapControls, how's this case different?
Is it because TrackballControls is more broadly used? Given that we implement the backwards compatibilities changes proposed by @Mugen87 on his PR (which I did here), I don't see this being an issue.

@sciecode
Copy link
Contributor Author

sciecode commented Nov 4, 2019

As far as implementations go, I feel like both PRs are handling the TrackballControls behavior adequately. However, I noticed the following differences:

This PR:

  • Modifies camera.up.
  • Works when user changes camera.up after controls instantiation (dev also doesn't support this, it's just an added bonus)

West PR:

  • Doesn't modify camera.up.
  • Fails to handle autoRotate = true option.
  • Fails to handle screenSpacePanning = false option (correctly).

I don't know how impactful is keeping camera.up constant in the overall scheme, nor do I know if it's easy to adapt his PR to work with autoRotate = true and screenSpacePanning = false.

@sciecode sciecode reopened this Nov 4, 2019
@WestLangley
Copy link
Collaborator

We did a similar thing when extending OrbitControls for MapControls, how's this case different?

The sensitivity and keyboard control are different from the original TrackballControls. I think we should keep the old code around for awhile since the new TrackballControls is different.

Fails to handle autoRotate = true option.

IMO, auto rotate does not make sense with TrackballControls because there is no natural 'up direction'.

Fails to handle screenSpacePanning = false option (correctly).

Since there is no natural 'up direction', only screen-space panning makes sense for TrackballControls, IMO.

@sciecode
Copy link
Contributor Author

sciecode commented Nov 4, 2019

The sensitivity and keyboard control are different from the original TrackballControls. I think we should keep the old code around for awhile since the new TrackballControls is different.

Makes sense 👍

GitHack - Trackball Example

@sciecode sciecode marked this pull request as ready for review November 4, 2019 12:01
// Zoom - middle mouse, or mousewheel / touch: two-finger spread or squish
// Pan - right mouse, or left mouse + ctrl/meta/shiftKey, or arrow keys / touch: two-finger move

THREE.TrackballControls = function ( object, domElement ) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I really think this code and the definition of MapControls should go in its own module file. The following code looks weird, IMO:

import { TrackballControls } from './jsm/controls/OrbitControls.js';

Yes, I'm aware that the JS versions would have a dependency to OrbitControls but I think this is still better than having strange imports.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, not sure actually. This is more of a preference / library consistency kind of deal, so I think that's up to you guys. I'll be happy to change if we decide on that course of action.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

However, if we choose to do it. Keeping the old API available won't be an option and we will need to apply backwards compatibility.

The sensitivity and keyboard control are different from the original TrackballControls.

^ this could be a problem for the users.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think it's necessary to keep the old API around. Users can checkout the repo at any release and use the respective version of TrackballControls if necessary. There are even live links to older versions:

https://rawcdn.githack.com/mrdoob/three.js/r109/examples/js/controls/TrackballControls.js

Copy link
Collaborator

Choose a reason for hiding this comment

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

Come on, @Mugen87. We tell users to always use files from the same release.

Copy link
Collaborator

@Mugen87 Mugen87 Nov 5, 2019

Choose a reason for hiding this comment

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

Sorry, I really don't understand your argumentation. We normally remove legacy/obsolete classes with very few exceptions. If we would keep all files, the repository would not be manageable anymore.

If users can't invest time in migration, it's okay to use one of the previous releases. Hence, I don't get your goal with retaining the API of TrackballControls. It's good to align it without keeping the old stuff around. Moreover, as demonstrated by my PR, API changes can be often done gracefully (meaning backwards compatible).

Copy link
Collaborator

Choose a reason for hiding this comment

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

If we would keep all files, the repository would not be manageable anymore.

Come on, dude.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't get your goal with retaining the API of TrackballControls.

#17858 (comment)

@Mugen87
Copy link
Collaborator

Mugen87 commented Jan 27, 2020

@sciecode I think this can be closed now. See the discussion in #18483 for more information.

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.

3 participants