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

feat: useCubeCamera hook #1389

Merged
merged 4 commits into from
Apr 5, 2023
Merged

feat: useCubeCamera hook #1389

merged 4 commits into from
Apr 5, 2023

Conversation

abernier
Copy link
Member

@abernier abernier commented Apr 5, 2023

Note Merged
see useCubeCamera doc

Why / What

New hook useCubeCamera() "low-level" version:

const { fbo, update, camera } = useCubeCamera({resolution?, near?, far?, fog?, envMap?})

useFrame(() => {
  // camera.position.set(...) // (1) position the cube-camera wherever you want

  ref.current.visible = false
  update() // 📸
  ref.current.visible = true
})

<group {...props}>
  <primitive object={camera} /> {/* add to the scene or (1) */}
  <mesh ref={ref}>
    <sphereGeometry args={[5, 64, 64]} />
    <meshStandardMaterial roughness={0} metalness={1} envMap={fbo.texture} />
  </mesh>
</group>

Classic component <CubeCamera> version (uses hook internally):

<CubeCamera {...props}>
  {(texture) => (
    <mesh>
      <sphereGeometry args={[5, 64, 64]} />
      <meshStandardMaterial roughness={0} metalness={1} envMap={texture} />
    </mesh>
  )}
</CubeCamera>

Checklist

  • Documentation updated
  • Storybook entry added
  • Ready to be merged

@vercel
Copy link

vercel bot commented Apr 5, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
drei ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 5, 2023 10:45pm

@codesandbox-ci
Copy link

codesandbox-ci bot commented Apr 5, 2023

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.

Latest deployment of this branch, based on commit cfd4718:

Sandbox Source
epic-euclid-9ss4ck Configuration
Ground reflections and video textures Configuration
arc-x-pmndrs-colors Configuration

@abernier abernier marked this pull request as ready for review April 5, 2023 19:53
@CodyJasonBennett CodyJasonBennett changed the title useCubeCamera hook feat: useCubeCamera hook Apr 5, 2023
@abernier abernier merged commit 17eb192 into master Apr 5, 2023
@abernier
Copy link
Member Author

abernier commented Apr 5, 2023

thank you @CodyJasonBennett for your review 👌🏻

@github-actions
Copy link

github-actions bot commented Apr 5, 2023

🎉 This PR is included in version 9.64.0 🎉

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.

2 participants