-
Notifications
You must be signed in to change notification settings - Fork 5
client values
Aardvark.Media is mult-client, and does not have explicit notation of different clients. This is because we want shared state between all clients for "free" (i.e. there is no structural overhead for providing every client with the same state). Specifically, client information is patched into the rendering system in-place at runtime to achieve maximum resource reuse, which means that we have no knowledge about which client is currently rendering, or whos projTrafo belongs where.
Consequently, we can not put client values into the Model without changing the system to lose efficiency. However, we have some restricted options:
-
ClientValues are available per-client within a renderControl and/or CameraController
-
In the special case that you have only one client, we can supply custom viewTrafo and projTrafo
-
We could imagine a new implementation that instantiates the view for each client separately and exposes the ClientValues
ClientValues can be used within the view function (and they stay inside the view function). This functionality is exposed by the renderControl
node
let renderControl (cam : IMod<Camera>) (attributes : AttributeMap<'msg>) (sg : ISg<'msg>)
let renderControlWithClientValues (cam : IMod<Camera>) (attributes : AttributeMap<'msg>) (sg : Aardvark.Service.ClientValues -> ISg<'msg>)
and the default CameraController
let controlledControlWithClientValues (state : MCameraControllerState) (f : Message -> 'msg) (frustum : IMod<Frustum>) (att : AttributeMap<'msg>) (sg : Aardvark.Service.ClientValues -> ISg<'msg>)
where Aardvark.Service.ClientValues
contains a session identifier, viewTrafo and projTrafo. These values only exist within the context of a SceneGraph, so we may use them freely in this context.
In case only one client exists, we can enforce a custom view and proj trafo using renderControl'
:
let renderControl' (cam : IMod<Camera>) (attributes : AttributeMap<'msg>) (config : RenderControlConfig) (sg : ISg<'msg>)
let renderControlWithClientValues' (cam : IMod<Camera>) (attributes : AttributeMap<'msg>) (config : RenderControlConfig) (sg : Aardvark.Service.ClientValues -> ISg<'msg>)
Where the type RenderControlConfig
controls how aspect-ratio correction is performed (or not at all). The executed code looks like this:
let cam = { cam with frustum = config.adjustAspect c.size cam.frustum }
{
viewTrafo = CameraView.viewTrafo cam.cameraView
projTrafo = Frustum.projTrafo cam.frustum
}
Use this code-snippet in your application to evacuate the viewTrafo and projTrafo into your model. Careful: This behaviour breaks when multiple clients are connected.
We can imagine a world in which the view function is created per-client, and supplies the connected ClientValues (sessionId, etc.) to the outside world. The signature of view would change:
view : 'mmodel -> DomNode<'msg>
view : ClientValues -> 'mmodel -> DomNode<'msg>
This means that the view (including SceneGraph and resources) is replicated for each client. There are massive consequences for user interaction. This is not implemented at the moment, talk to me if you need this.