Viewer config format
Current format:
{
"modelPath":"path/to/xml"
"instrumentPosition":{"x":0,"y":0,"z":0},
"minDeltaTime":20,
"numberOfLights":0,
"lightsPos":[],
"lightsParams":[],
"ambientLight":0.2,
}
New format:
{
"model": {
"path":"path/to/xml",
"version":2,
"position":{"x":0,"y":0,"z":0},
"rotation":{
"axis":{"x":0,"y":0,"z":1},
"angle":90
},
"lods":[10, 100]
},
"collision": {
"modelPath":"path/to/xml",
"margin":0.04,
"debugGUI":false,
"enabled":true,
"onlySim":true
},
"camera": {
"position": {"x":0,"y":0,"z":10}
},
"minDeltaTime":20,
"lights":{
[{"position":{"x":20,"y":30,"z":10}, "color":16777215,"intensity":1,"reach":525,"visible":true}]
},
"ambientLight":0.2
}
The version is needed to be able to clean the asset storage automatically when the 3D model changes.
Architecture review
To have better performance on the Nomad 3D Viewer server and avoid blocking calls while requesting collision detection, it is necessary to review the architecture.
Proposition:
Changes:
- Move the collision part of the viewer config to the models.json file.
The Nomad 3D Viewer server must run without a client requesting collision detection based on a view. Also move the content of the viewer config. - Nomad 3D Viewer server is starting a collision server for each nomad server if collision is enabled. It sends the positions to the collision server without waiting for the calculation of the collisions.
- The collisions are published by the collision server to both Nomad Server and Nomad 3D Viewer server.
- The Viewer requests the current positions and collisions in the same request.
- Same subscriber is used as in NomadPositions to get the collisions.
- The request subscribe collisions is sent to the new Nomad Server (real or sim) with the collision server endpoint.
TODO:
- Move the collision part of the viewer config to the models.json file.
Move the viewer config content to models.json. - The Viewer requests the current positions and collisions in the same request.
- Multiple collision servers.
- Collision server publishes collisions (not in response to positions request). Implement an AsyncCollisionServer in addition to CollisionServer. The AsyncCollisionServer receives positions with a subscriber.
- Nomad Server subscribes to collision server collisions.
Notes:
- There is a way to respond asynchronously in a Node.js module. Example is shown here: https://github.com/justadudewhohacks/node-addon-tutorial?tab=readme-ov-file However it seems that there is a new thread which is created at each async call?