function update(game: Game, entity: Entity) {
let camera = game.World.Camera2D[entity];
camera.ViewportWidth = game.ViewportWidth;
camera.ViewportHeight = game.ViewportHeight;
let projection = camera.Projection;
let aspect = game.ViewportWidth / game.ViewportHeight;
if (projection.Radius[0] === 0 && projection.Radius[1] === 0) {
let radius = game.ViewportHeight / game.UnitSize / 2;
mat2d_from_ortho(projection.Projection, radius * aspect, radius);
} else {
let target_aspect = projection.Radius[0] / projection.Radius[1];
if (aspect < target_aspect) {
mat2d_from_ortho(
projection.Projection,
projection.Radius[0],
projection.Radius[0] / aspect
);
} else {
mat2d_from_ortho(
projection.Projection,
projection.Radius[1] * aspect,
projection.Radius[1]
);
}
}
mat2d_invert(projection.Inverse, projection.Projection);
}