function update_xr(game: Game, entity: Entity, camera: CameraXr) {
let transform = game.World.Transform[entity];
let pose = game.XrFrame!.getViewerPose(game.XrSpace);
camera.Eyes = [];
for (let viewpoint of pose.views) {
let eye: XrEye = {
Viewpoint: viewpoint,
Pv: mat4_create(),
Position: [0, 0, 0],
FogColor: camera.ClearColor,
FogDistance: game.XrSession?.renderState.depthFar ?? 0,
};
mat4_multiply(eye.Pv , transform.World, viewpoint.transform.matrix);
mat4_get_translation(eye.Position, eye.Pv );
mat4_invert(eye.Pv , eye.Pv );
mat4_multiply(eye.Pv, viewpoint.projectionMatrix, eye.Pv );
camera.Eyes.push(eye);
}
}