React Three Fiber useThree

Created
Created
2021 Aug 4 9:55
Refs
Refs
RTF useThree camera
RTF useThree zoom
 
 
RTF useThree viewport
RTF useThree size
 
 

Optimization

rerender 안되려면
필요 state만 꼭 불러오도록
// Will only trigger re-render when the default camera is exchanged const camera = useThree((state) => state.camera) // Will only re-render on resize changes const viewport = useThree((state) => state.viewport) // ❌ You cannot expect reactivity from three.js internals! const zoom = useThree((state) => state.camera.zoom)
 
 
React Three Fiber Documentation
Hooks allow you to tie or request specific information to your component. For instance, components that want to participate in the renderloop can use useFrame, components that need to be informed of three.js specifics can use useThree and so on. All hooks clean up after themselves once the component unmounts.
React Three Fiber Documentation
 
 

Recommendations