Babylon + Sockets

I’m working on a game using Babylon which will have multiplayer.

I think having an extension of Babylon (e.g. @babylonjs/socket) for having a client/server could be really useful. I would be ok with working on it, though I probably won’t unless it receives some support.

What do you think of it?

There are already a few libraries like Nengi.js, and - as well as lesser known ones. Unless you have some specific features not easily integrated into current solutions, I feel it would be a waste of time


(warning, personal opinion :wink: )
I think this could be a community project, but should not be provided in a @babylonjs package. I am also not sure how much you can abstract it. or belter - abstract it more than the direct communication with the server. What would be an API for such a package?

An easy example:


import { Engine } from '@babylonjs/core';
import { Client } from 'babylonjs-socket';

const engine = new Engine(canvas);

//Client(URL, engine)
const client = new Client('', engine);


import { Scene, Engine } from '@babylonjs/core';
import { Server } from 'babylonjs-socket';

const engine = new NullEngine();
const scene = new Scene(engine);

const server = new Server(scene);

Server#start will internally listen for the scene to be rendered and then send a packet to clients with the serialized scene (or maybe the data that needs to be changed from the last frame sent).

Maybe Socket.IO can be used for the socket part?

I would definitely recommend nengi too; I’m building a project with and I’m finding the nengi API really clean and intuitive

1 Like