Intersection of ray and scene's bounding box in 2D

I’m trying to get the point of intersection between a ray and the borders of the screen when in 2D mode. (SceneMode.SCENE2D).

I have created a ray with the point and angle, but I’m having trouble finding a way to intersect it with a rectangle on the XY plane, or to even create this rectangle from the current camera’s view.

Generally what I’m trying to achieve is to create a polyline from a given point and an angle, to the edge of the screen.

This polyline should be updated with cesium’s change detection.

Any help with my approach (ray and rectangle of the camera) or any other ideas will be welcomed.

Thanks!

You may find this GitHub issue helpful: https://github.com/CesiumGS/cesium/issues/871

There’s some links there with code samples about either doing a ray cast or using the scene.pick functions to get the points on the edge of the screen.