Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

setDefaultCamera removed in v6.x. #1147

Closed
nyan-left opened this issue Mar 30, 2021 · 1 comment
Closed

setDefaultCamera removed in v6.x. #1147

nyan-left opened this issue Mar 30, 2021 · 1 comment

Comments

@nyan-left
Copy link

Hi there,

Looks like setDefaultCamera was removed in 6.x. I could not find any mention of this in the release notes. Was this intentional?

const { setDefaultCamera } = useThree();

now warns:

Property 'setDefaultCamera' does not exist on type 'RootState'.ts(2339
@taseenb
Copy link

taseenb commented Mar 30, 2021

Use const { set } = useThree()

function CustomCamera (props) {
    const cameraRef = useRef()
    const set = useThree(({ set }) => set)
    const size = useThree(({ size }) => size)
    
    useLayoutEffect(() => {
        if (cameraRef.current) {
          cameraRef.current.aspect = size.width / size.height
          cameraRef.current.updateProjectionMatrix()
        }
      }, [size, props])
    
      useLayoutEffect(() => {
        set(() => ({ camera: cameraRef.current }))
      }, [])
    
    return <perspectiveCamera ref={cameraRef} />
}

https://github.com/pmndrs/react-three-fiber/blob/master/markdown/api.md#usethree

@drcmda drcmda closed this as completed Mar 30, 2021
@pmndrs pmndrs locked and limited conversation to collaborators Mar 30, 2021

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants