Is there an example of using multiplayer in babylonjs?
My aim is to create the two given steps:
(a) Create a room with user-name and other users enter the room
(b) One cube is present in the room and all users can rotate its ArcRotateCam. This should be reflected on all the users screen
I followed the forum link that I had posted and set up a scene where the model gets uploaded well and is broadcasted in all the client’s scenes. Now I would like to update the rotation of camera in all the scenes. For example, if client 1 rotates the camera then client 2 should get the rotated camera’s transforms and apply it to its camera. How do I do this?
index.html
var camera = new BABYLON.FreeCamera('camera1', new BABYLON.Vector3(0, 5, -10), scene);
//more code
scene.onBeforeRenderObservable.add(() => { //Gets called each frame
socket.emit('modelRotate');
updateModel(scene);
})
socket.on('modelRotate', function () {
updateModel(scene);
});
function updateModel(scene) {
camera.node.rotation = new BABYLON.Vector3(camera.node.rotation.x, camera.node.rotation.y, camera.node.rotation.z);
}