Source: https://www.youtube.com/shorts/xyQQNKZo9JE
Source? Wow, my brain is fried after watching that. Too much compute power for me.
Can anyone tell me which language would be best for this?
Check out Monument Valley 1&2
I played a similar game called 'Monument Valley' about ten years back. Have a look.
It's not that hard.
You need several models for each perspective. When the camera aligns with a predefined angle, you swap in the corresponding model.
That's the way to keep physics accurate.
You can cheat a bit if you don't need perfect physics.
In this case, the first perspective swap - the roll - works best with a model swap. The second one can be handled without swapping; just use an invisible collider or move the ball model to its next spot.
Both approaches are straightforward in any modern game engine.
Off the top of my head, you could track the vertex coordinates of each edge the ball can travel on. Since the ball moves in a straight line, you just need to keep the range of coordinates where it won't fall off.
It's basically a simple path problem. You have a path where the ball can roll, and both ends lie on the same plane. In the engine the structure and ball exist in 3D, but from one side it looks 2D. If it's on the XY plane, the XY coordinates at both ends match, so the ball can travel through.
It reminds me a bit of the experimental 4D game Miegakure that never got finished.
Do all the physics on the GPU using screen-space normal and velocity buffers.
I haven't tried it, but three.js could be used for this.