Fix the bug with the incorrect color for the 3d rendering and slightly restructure the rendering code