pmndrs / drei

🥉 useful helpers for react-three-fiber
https://docs.pmnd.rs/drei
MIT License
8.23k stars 675 forks source link

fix(GizmoHelper): allow GizmoHelper to be used with camera-controls #2066

Closed a3ng7n closed 1 month ago

a3ng7n commented 1 month ago

When using camera-controls sets target via the getTarget method, and updates the control position via the setPosition method.

Why

Allows GizmoHelper to be used alongside CameraControls/camera-controls. resolves #1399

What

Fixes two issues:

  1. CameraControls doesn't expose a target property directly - so when focusPoint is set at animation start, get the target via CameraControls getTarget instead.
  2. CameraControls doesn't seem to like having its camera moved directly, and will continuously attempt to reset the mainCamera's position - the fix is to call CameraControls setPosition method after the mainCamera's position is updated, and before it has a chance to revert it.

Checklist

I did create a storybook entry that's just a duplicate of the GizmoHelper story below but using CameraControls to test the fix out - but I didn't think it was really value added / worthy of another tutorial entry https://github.com/pmndrs/drei/blob/f4f910f76f48e16ef73c52f2d69bd5bbf96a138e/.storybook/stories/GizmoHelper.stories.tsx#L51-L86 lmk if you think otherwise and I'll update this PR with it

vercel[bot] commented 1 month ago

@a3ng7n is attempting to deploy a commit to the Poimandres Team on Vercel.

A member of the Team first needs to authorize it.

codesandbox-ci[bot] commented 1 month ago

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

CodyJasonBennett commented 1 month ago

Thanks.

github-actions[bot] commented 1 month ago

:tada: This PR is included in version 9.111.2 :tada:

The release is available on:

Your semantic-release bot :package::rocket: