The background is at z=0, the walls are rotated around the y axis, the floor and ceiling around the x axis.
Theses 4 sprites are closer on the z axis (z=50).
That’s because sprites don’t use z-buffer depth test in common render pipeline. They sort by their pivots. If one sprite’s pivot in the camera view is closer to the camera pivot than other sprite’s pivot then sprite one render above other one. When you rotate the camera you are changing this ordering.
Well, for correct sorting you need to use a mesh or model components as @britzl said. They using z-buffer by default. In render_script it looks like
render.enable_state(render.STATE_DEPTH_TEST) -- check z-buffer
render.set_depth_mask(true) -- write to z-buffer
or enable this feature to sprite predicate too. But notice that z-buffer depth test may broke render-order of self-transparent sprites.
If you open up the model material you will see that there is a lightsource. In the basic 3d project template it gets updated based on mouse position:
If you skip the light update based on mouse position and instead copy and modify the material and position the light far from the camera (0 0 1000 0) everything should be equally affected by the light I think.