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

Camera rotate on its y-axis #535

Open
SoraVN98 opened this issue Aug 12, 2024 · 2 comments
Open

Camera rotate on its y-axis #535

SoraVN98 opened this issue Aug 12, 2024 · 2 comments

Comments

@SoraVN98
Copy link

Is your feature request related to a problem? Please describe.

I want to my camera rotate on its own y-axis like pan movement (not truck) . I try to use rotate function but it seems like the camera move around the target.

Describe the solution you'd like

No response

Describe alternatives you've considered

No response

Additional context

No response

@yomotsu
Copy link
Owner

yomotsu commented Aug 17, 2024

Thanks for using camera-controls.
Unfortunately, that is intentional.
Camera-controls is a library designed for orbit rotation controls.

@Remi-Tribia
Copy link

Try to position the target just in front of the camera (1cm). Now if the camera orbits the target, it will have the same effect as if the camera were spinning on its axis.

You can calculate target position depending on camera position like so:

const calculateTarget = (camera: PerspectiveCamera, distance = 0.01): Vector3 =>
  (new Vector3()).addVectors(
    camera.getWorldPosition(new Vector3()),
    camera.getWorldDirection(new Vector3()).multiplyScalar(distance)
  );

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

No branches or pull requests

3 participants