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.
There are already a few libraries like Nengi.js, Lance.gg and colyseus.io - 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 )
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?
import { Engine } from '@babylonjs/core';
import { Client } from 'babylonjs-socket';
const engine = new Engine(canvas);
//Client(URL, engine)
const client = new Client('https://example.com:12000', engine);
client.connect();
server:
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(12000);
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).