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

setPosition does not set position #368

Closed
stam opened this issue Feb 13, 2023 · 5 comments
Closed

setPosition does not set position #368

stam opened this issue Feb 13, 2023 · 5 comments

Comments

@stam
Copy link

stam commented Feb 13, 2023

Describe the bug

Both setPosition and setLookAt don't reliably set a camera position.

To Reproduce

Steps to reproduce the behavior:

  1. Go to https://codesandbox.io/s/camera-controls-setposition-7dl2e3?file=/src/index.js
  2. Click the "Move camera" button
  3. Truck the camera position using middle mouse button
  4. Click the "Move camera" button again
  5. Location after 4 is not the same location after 2

Code

const newCameraPosition = new Vector3(1, 2, 3);

cameraControls.setLookAt(
    newCameraPosition.x,
    newCameraPosition.y,
    newCameraPosition.z,
    0,
    0,
    0,
    false
  );

Live example

https://codesandbox.io/s/camera-controls-setposition-7dl2e3?file=/src/index.js:3164-3214

Expected behavior

Setposition after 2 and 4 use the same vector3, so they should use the same camera position

Screenshots or Video

No response

Device

No response

OS

No response

Browser

No response

@yomotsu
Copy link
Owner

yomotsu commented Feb 13, 2023

Thanks for your report.
Actually, it is caused by clicking the green box.
If you don't click the green box, I think the problem never happens.

I think that is the same as a known issue: focalOffset( setOrbitPoint ) breaks setLookAt.
#303

You need to set focalOffset to 0, 0, 0 before calling setLookat

@stam
Copy link
Author

stam commented Feb 14, 2023

Hey, thanks for a pointer in the right direction, but setFocalOffset 0,0,0 doesn't solve my issue. I'm building a feature which saves the camera position and restores it.

If you save a cameraposition (with focaloffset), then restore that cameraposition by setting focalOffset (0,0,0), it's not going to be the same cameraposition as the one you saved.

Is there a way to get the actualCameraPosition which takes the focalOffset into account?

@yomotsu
Copy link
Owner

yomotsu commented Feb 14, 2023

focalOffset is like a post process.
The actual position cannot be got as long as using focalOffset...
Unfortunately, problems caused by focalOffset can't be fixed I think...😢

I've tried to fix it many times but I couldn't...

@yomotsu
Copy link
Owner

yomotsu commented Feb 16, 2023

Even if we could have the actualCameraPosition and move the negative amount of actualCameraPosition to collapse, it doesn't move the expected point. Because focalOffset moves to the point forcibly right after the position update.

@stam
Copy link
Author

stam commented Mar 1, 2023

Okay, if this is the same bug as 303 I'll close this issue

@stam stam closed this as not planned Won't fix, can't repro, duplicate, stale Mar 1, 2023
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

2 participants