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

OrbitControls: refactoring #16961

Merged
merged 9 commits into from
Jul 10, 2019
Merged

OrbitControls: refactoring #16961

merged 9 commits into from
Jul 10, 2019

Conversation

sciecode
Copy link
Contributor

@sciecode sciecode commented Jul 1, 2019

Based on #16803 discussed changes.

@WestLangley is this what you had in mind, when you suggested defining MapControls in the same file?

Would appreciate if someone could test *.ts, as I'm not familiar with it.

This PR requires a build update, because of constants.js changes.

@WestLangley
Copy link
Collaborator

@WestLangley is this what you had in mind, when you suggested defining MapControls in the same file?

Exactly. We would add a note to the migration guide.

@sciecode I will be able to check this later this week, but if it is what I expect, it will be awesome. :-)

@Mugen87
Copy link
Collaborator

Mugen87 commented Jul 2, 2019

In the meantime, consider to fix the new lgtm errors introduced by this PR, see https://lgtm.com/projects/g/mrdoob/three.js/rev/pr-698532000338fcc35a1f7bc7776474e32d7321da

@sciecode
Copy link
Contributor Author

sciecode commented Jul 2, 2019

@Mugen87 those aren't fixable errors.
OrbitControls module can't detect TOUCH constant because I'm not pushing updated build files.
Once build is updated, the errors will get fixed automatically.

@Mugen87
Copy link
Collaborator

Mugen87 commented Jul 2, 2019

Um, I don't think it's good to modify the core for this change. three.js (the core lib) should no know anything about its examples files.

@sciecode
Copy link
Contributor Author

sciecode commented Jul 2, 2019

I'm not sure what would be the best way to expose these constants to the user, if we don't alter core.
modularize.js doesn't export non-scoped variables, so we would need to set these as member props. Which doesn't sound right to me.

@Mugen87
Copy link
Collaborator

Mugen87 commented Jul 2, 2019

modularize.js doesn't export non-scoped variables, so we would need to set these as member props.

We are already doing this in other files for example in SAOPass (BTW: This pattern was introduced even before the ES6 module migration). We can improve this once the ES6 modules become the canonical versions of the code.

SAOPass.OUTPUT = {
'Beauty': 1,
'Default': 0,
'SAO': 2,
'Depth': 3,
'Normal': 4
};

@sciecode
Copy link
Contributor Author

sciecode commented Jul 2, 2019

Update PR with suggested constants changes.
I'm not very confident about OrbitControls.d.ts btw.

@WestLangley
Copy link
Collaborator

As I said in #16803,

Please do your best to make sure the behavior is not changed. This is a refactoring only.

I was referring to backwards-compatibility in general, and the API in particular.

OribtControls already accesses THREE.MOUSE. I would like to address @Mugen87 's issues in a later PR. The code base is in flux anyway.

An API change can be implemented is a smaller PR with proper user warnings included. Please revert the last commit.

@sciecode
Copy link
Contributor Author

sciecode commented Jul 2, 2019

done... 🙄 👀

@WestLangley
Copy link
Collaborator

@mrdoob Let's merge this ASAP. Please rebuild concurrently.

@sciecode If there are problems with the TS files, they can be fixed easily enough. Thanks!

@WestLangley
Copy link
Collaborator

@sciecode If you can fix the conflict, I think we can go ahead and merge this.

@sciecode
Copy link
Contributor Author

Should be ready to merge.

@WestLangley
Copy link
Collaborator

OK, let's go for it! Thanks!

@mrdoob This PR requires a rebuild.

@WestLangley WestLangley merged commit 8d04711 into mrdoob:dev Jul 10, 2019
@sciecode sciecode deleted the dev-orbit2 branch July 10, 2019 20:29
@mrdoob
Copy link
Owner

mrdoob commented Jul 10, 2019

Rebuilt 👌

@WestLangley
Copy link
Collaborator

Thanks!

@EliasHasle
Copy link
Contributor

When MapControls are basically OrbitControls with a different button mapping, it makes sense that they share code/file. But I would actually expect from something named MapControls that dollying follows a ray through the pointer screen position. Would this be easy to implement, maybe as an option, in the refactored version? Maybe it would even be an interesting feature to have in OrbitControls too?

@sciecode
Copy link
Contributor Author

But I would actually expect from something named MapControls that dollying follows a ray through the pointer screen position.

Are you familiar with .screenSpacePanning flag? Is this what you are referring to?

@EliasHasle
Copy link
Contributor

EliasHasle commented Jul 29, 2019

No, not screen space panning. I mean when you zoom. Try Google Earth. When you zoom with the mouse wheel, the map position of the mouse pointer is conserved. This holds even if you rotate the view with the middle mouse button. Very convenient. I have made something similar for 2D views, that I shared in a new repository a few days ago: https://github.com/EliasHasle/map-view-controls (no examples included, and the code may need a small overhaul)

@sciecode
Copy link
Contributor Author

sciecode commented Jul 29, 2019

I see what you mean. It would require some tweaking to adjust to the current way we're handling dolly zoom, but it's definitely possible.

Just not sure if it fits the current "general purpose" idea behind the example files, or if it's more of application-level feature. There has been a bit of reluctance against adding new features, especially because of the need to keep things simple. I don't particularly have any opinion about it to be honest.

@EliasHasle
Copy link
Contributor

I think it is an essential feature for something called "Map controls". There is no hurry, though. :-)

@WestLangley
Copy link
Collaborator

When you zoom with the mouse wheel, the map position of the mouse pointer is conserved.

@EliasHasle I think that is a great idea. I hacked it into Orbit/MapControls and the result is beautiful! :-)

@pepe-escrich
Copy link

When you zoom with the mouse wheel, the map position of the mouse pointer is conserved.

@EliasHasle I think that is a great idea. I hacked it into Orbit/MapControls and the result is beautiful! :-)

@WestLangley This is just what I was looking for ...Thank you very much!

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.

6 participants