Orthographic Camera


using GeometryBasics

using AbstractPlotting

function colormesh((geometry, color))
    mesh1 = normal_mesh(geometry)
    npoints = length(GeometryBasics.coordinates(mesh1))
    return GeometryBasics.pointmeta(mesh1; color=fill(color, npoints))
end
# create an array of differently colored boxes in the direction of the 3 axes
x = Vec3f0(0); baselen = 0.2f0; dirlen = 1f0
rectangles = [
    (Rect(Vec3f0(x), Vec3f0(dirlen, baselen, baselen)), RGBAf0(1,0,0,1)),
    (Rect(Vec3f0(x), Vec3f0(baselen, dirlen, baselen)), RGBAf0(0,1,0,1)),
    (Rect(Vec3f0(x), Vec3f0(baselen, baselen, dirlen)), RGBAf0(0,0,1,1))
]

meshes = map(colormesh, rectangles)
scene = mesh(merge(meshes))
center!(scene)
cam = cameracontrols(scene)
dir = widths(scene_limits(scene)) ./ 2.
dir_scaled = Vec3f0(
 dir[1] * scene.transformation.scale[][1],
 0.0,
 dir[3] * scene.transformation.scale[][2],
)
cam.upvector[] = (0.0, 0.0, 1.0)
cam.lookat[] = minimum(scene_limits(scene)) + dir_scaled
cam.eyeposition[] = (cam.lookat[][1], cam.lookat[][2] + 6.3, cam.lookat[][3])
cam.projectiontype[] = AbstractPlotting.Orthographic
update_cam!(scene, cam)
# stop scene display from centering, which would overwrite the camera paramter we just set
scene.center = false
scene