Skip to content

Sync multiple cameras position / quaternion / rotation in @react-three/fiber

License

Notifications You must be signed in to change notification settings

darnfish/use-synced-camera

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

useSyncedCamera

Sync multiple cameras position/quaternion/rotation in react-three/fiber

You can view a demo here, or watch below:

f1959dc74467ecb3.mp4

Installation

yarn add use-synced-camera

Usage

import useSyncedCamera from 'use-synced-camera'

import { useThree } from '@react-three/fiber'
import { OrbitControls } from '@react-three/drei'

function SceneA() {
  const update = useSyncedCamera(useThree)
  
  return (
    <>
      <Model />
      <OrbitControls onChange={update} />
    </>
  )
}

function SceneB() {
  const update = useSyncedCamera(useThree)
  
  return (
    <>
      <Model />
      <OrbitControls onChange={update} />
    </>
  )
}

function App() {
  return (
    <Canvas>
      <SceneA>
    </Canvas>
    <Canvas>
      <SceneB>
    </Canvas>
  )
}

License

MIT

About

Sync multiple cameras position / quaternion / rotation in @react-three/fiber

Topics

Resources

License

Stars

Watchers

Forks