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

Improve OrbitControls use case #12727

Closed
wants to merge 6 commits into from
Closed

Improve OrbitControls use case #12727

wants to merge 6 commits into from

Conversation

clement-igonet
Copy link

Comparing to previous example:

  • zoom is activated
  • we keep z axis up
  • mesh is funnier

@WestLangley
Copy link
Collaborator

... and mouse controls have been swapped.

https://rawgit.com/clement-igonet/three.js/orbitControls_example/examples/misc_controls_orbit.html

'textures/land_ocean_ice_cloud_2048.jpg',
function( tex ) {
material.map = tex;
material.needsUpdate = true;
Copy link
Collaborator

Choose a reason for hiding this comment

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

FYI. This coding pattern causes two shaders to be compiled -- one with a map and one without.

Copy link
Author

Choose a reason for hiding this comment

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

OK. I've just fixed it.

@mrdoob
Copy link
Owner

mrdoob commented Nov 24, 2017

It no longer... orbits? 🤔

@clement-igonet
Copy link
Author

clement-igonet commented Nov 24, 2017 via email

@clement-igonet
Copy link
Author

clement-igonet commented Nov 24, 2017

Ok, I'm going to unswap mouse buttons if disturbing.
-> done

@WestLangley
Copy link
Collaborator

See if #12742 addresses your concerns.

@clement-igonet
Copy link
Author

clement-igonet commented Nov 25, 2017 via email

@clement-igonet
Copy link
Author

Target axes added to the scene.
It's convenient to track where camera target is.

v.setFromMatrixColumn( objectMatrix, 1 ); // get Y column of objectMatrix
v.setFromMatrixColumn( objectMatrix, 0 ); // get X column of objectMatrix

v.applyAxisAngle( new THREE.Vector3( 0, 0, 1 ), Math.PI / 2 );
Copy link
Collaborator

Choose a reason for hiding this comment

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

This only works in your application because you have changed camera.up.

Also, avoid calling new unnecessarily. You are instantiating a Vector3 that must be garbage-collected.

Yes, we can improve OrbitControls panning, but this is not the way to do it.

Copy link
Author

@clement-igonet clement-igonet Dec 24, 2017

Choose a reason for hiding this comment

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

Ok. Copy.
My inspiration comes from here: https://stackoverflow.com/questions/10747510/how-to-rotate-a-three-js-vector3-around-an-axis/10747728#10747728
You commented but did not say anything about unnecessary "new" in this place.
At least, do you agree with the behaviour of the camera ?

@clement-igonet
Copy link
Author

clement-igonet commented Feb 3, 2018

camera.up removed.
@WestLangley, @mrdoob : Is this last improvement version acceptable ?


v.applyAxisAngle( new THREE.Vector3( 0, 0, 1 ), Math.PI / 2 );

v.applyAxisAngle( new THREE.Vector3( 0, 1, 0 ), Math.PI / 2 );
Copy link
Collaborator

Choose a reason for hiding this comment

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

This logic is not correct if camera.up is changed.

Also, we need to avoid instantiating a new Vector3 here. This method can be called many times per second.

Also, this PR will change the behavior for current users. It would be better to have the panning method as an option.

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