Multiplayer kind synchronization of camera #629
sumanthyedoti
started this conversation in
General
Replies: 1 comment
-
const vec = new THREE.Vector3()
useEffect(() => {
const event = socket.on('move', msg => vec.set(...msg))
return () => socket.remove(event) // whatever the api is ...
}, [])
useFrame(state => {
camera.position.lerp(vec, 0.1)
camera.updateProjectionMatrix() what i don't understand is the role that controls plays. you can't have controls and at the same time set the camera, because that is what controls does, it mutates the camera. so you have two places writing into it and that has to be unreliable. if you want to take over the camera you must disable controls, if you want controls you must disable the socket. or figure out how to set controls instead of the camera, but i dont think threejs lets you do that. last time i needed it they told me to fork controls :-/ |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
scenario:
The view of a 3D scene has to be synchronized across users.
What is the proper approach to achieve this?
I implemented it by trying to sync camera position
syncing the position using
useSpring
It's worked. But not reliable.
Please suggest the correct way to do this. Thanks.
Beta Was this translation helpful? Give feedback.
All reactions