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

Bounds incorrectly calculates center to be (0,0,0) on first render #1881

Closed
dmaslan opened this issue Mar 18, 2024 · 2 comments
Closed

Bounds incorrectly calculates center to be (0,0,0) on first render #1881

dmaslan opened this issue Mar 18, 2024 · 2 comments
Labels
bug Something isn't working Stale Inactive issue

Comments

@dmaslan
Copy link

dmaslan commented Mar 18, 2024

  • three version: 0.159.0
  • @react-three/fiber version: 8.15.19
  • @react-three/drei version: 9.102.6
  • node version: 18.17.1
  • npm (or yarn) version: 9.6.7

Problem description:

I am using CameraControls (from drei) to allow the user to switch between different views of a 3D model that is being loaded with the useFBX() hook. I'm noticing that the first time I call the setCamera function below, the center is being incorrectly calculated to be (0,0,0), even though the box.min and box.max values are being correctly calculated. The size property also seems to be wrong. The subsequent times the function is called, all values are correct.

As a workaround, I am using the min and max to calculate the center.

Screenshot 2024-03-18 160039

Relevant code:

    const bounds = useBounds()

    function setCamera() {
      console.log(bounds.getSize())
      const target = computeCameraTarget(
        activeCamera.position,
        activeCamera.rotation,
        calculateDistance(cameraPos, bounds.getSize().center),
      )
      cameraControlsRef.current.setLookAt(
        activeCamera.position.y,
        activeCamera.position.z,
        activeCamera.position.x,
        target.y,
        target.z,
        target.x,
        true,
      )
    }
@dmaslan dmaslan added the bug Something isn't working label Mar 18, 2024
Copy link

Thank you for contributing! We’re marking this issue as stale as a gentle reminder to revisit it and give it the attention it needs to move forward.

Any activity, like adding an update or comment, will automatically remove the stale label so it stays on our radar.

Feel free to reach out on Discord if you need support or feedback from the community. This issue will close automatically soon if there’s no further activity. Thank you for understanding and for being part of the project!

@github-actions github-actions bot added the Stale Inactive issue label Oct 30, 2024
Copy link

github-actions bot commented Nov 8, 2024

We’re closing this issue to keep our project manageable and make room for other active work, but we truly appreciate your effort and contribution.

If you’d like to continue working on this, please feel free to re-open it or reach out on Discord — our community is always ready to support you. Thanks again for helping us stay organized and for understanding our approach!

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Nov 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Stale Inactive issue
Projects
None yet
Development

No branches or pull requests

1 participant