How to query all the meshes in a selected spatial block?

My use case: I have a NullEngine on my server that has all the meshes I need loaded into the scene of infinite dimensions. Now I have multiple client who stream their camera position to my server through websocket. And in response I want to send them all the objects in the region near to their camera. And these objects would be rendered in their UI using babylon lib inside their browser.
Now I have 2 questions,

  1. Is this an acceptable approach. Is there a better approach or flaws or tweak to the shared approach that would make things more efficient.
  2. Would it be possible to query all the meshes bounded in a region efficiently using the null engine. For eg, My client’s camera is at (0.1, 0.1, 0.1) I would want to get all meshes present inside the region bound within vertices (0,0,0), (1,0,0), (0,1,0), (0,0,1), (1,1,0), (1,0,1), (0,1,1), (1,1,1).

New to babylon js so any references to the documentations/simple examples would also help.

For the first question:
How many clients? How many objects? How often do the objects change? How often do the number of objects change? How often do the objects move? Basically, what are you trying to do?

For the second question: Yes. Are you sure you need within vertices, or do you need “in view of the camera within a certain distance?”

Here’s a link to The Very First Step.

HiGreg,

To answer your questions,
How many clients. → a lot maybe 10-100
How many objects. → trying to build an open world where users can come and publish their mesh in the form of .glb files. Which can then be viewed by all other users. So, hard to say assuming each user would add his own object maybe a lot.
How often do the number of objects change → each time a user adds a new object.
How often do the objects change → Objects once placed in the 3D space won’t change at all and there are no animations needed as well. Just need to be able to add new objects.

do you need “in view of the camera" → this would do fine as well. You have any pointers?
would it be possible to stream the the view from the NullEngine directly?

Going through the link you shared right now.

Thank You

Here are some links which may help.
Babylon+Colyseus docs - Babylon.js docs
Working example GitHub - BabylonJSGames/BabylonJS-Platformer-Game-Prototype: A 3d platformer browser game prototype made with the BabylonJS framework written in TypeScript.

VRSpace - GitHub - jalmasi/vrspace: VRSpace: Multiuser Virtual Reality Engine

1 Like