How to obtain the aspect ratio / frustum of a render control?

What's the easiest way to obtain the actual frustum of my camera (i.e. considering the current aspect ratio of the render control)? A possible solution is to use the resize event to obtain the render control size:

let onResize (cb : V2i -> 'msg) =
    onEvent "onresize" ["{ X: $(document).width(), Y: $(document).height()  }"] (List.head >> Pickler.json.UnPickleOfString >> cb)

onBoot "$(window).trigger('resize')" (
    body [onResize RenderControlResized] [

Can this be simplified?

Posted 6 months ago
Votes Newest


Hi, your solution is correct.

I wrote some backround information about this topic:


  • These values are hidden because they need to be system-intrinsic for fast performance
  • You can use those values freely within the scene graph using renderControlWithClientValues (or the according CameraController)
  • In case you have only one client with only one renderControl, you can evacuate view and proj trafo into your model (and subsequently into javascript) using renderControl', which exposes the calculation of those trafos to the outside. Just do the same calculations in your model (in some "hacky" way) .This changes the performance of the system.
  • Recommendation: Can you solve the problem differently? You should rarely ever need the trafos outside of 3d rendering, and if you do, it will probably have massive performance implications.

Please ask here if there are any more questions.

1 Answers
6 months ago
4 minutes ago