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

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

Merged

Conversation

a3ng7n
Copy link
Contributor

@a3ng7n a3ng7n commented Aug 16, 2024

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

  • Ready to be merged

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

const GizmoHelperScene1 = (props: ComponentProps<typeof GizmoHelper>) => {
return (
<React.Suspense fallback={null}>
<Tokyo />
<GizmoHelper {...props}>
<GizmoViewcube />
</GizmoHelper>
<OrbitControls makeDefault />
</React.Suspense>
)
}
export const GizmoHelperSt1: Story = {
name: 'Cube',
render: (args) => <GizmoHelperScene1 {...args} />,
} satisfies Story
const GizmoHelperScene2 = (props: ComponentProps<typeof GizmoHelper>) => {
return (
<React.Suspense fallback={null}>
<Tokyo />
<GizmoHelper {...props}>
<GizmoViewport />
</GizmoHelper>
<OrbitControls makeDefault />
</React.Suspense>
)
}
export const GizmoHelperSt2: Story = {
name: 'Viewport',
render: (args) => <GizmoHelperScene2 {...args} />,
} satisfies Story
lmk if you think otherwise and I'll update this PR with it

when using camera-controls sets target via the getTarget method, and
updates the control position via the setPosition method
Copy link

vercel bot commented Aug 16, 2024

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

A member of the Team first needs to authorize it.

Copy link

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 CodyJasonBennett merged commit d681f3e into pmndrs:master Aug 19, 2024
3 of 4 checks passed
@CodyJasonBennett
Copy link
Member

Thanks.

Copy link

🎉 This PR is included in version 9.111.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Gizmo helper with camera controls won't work
2 participants