break;
}
// Update camera location
Point3 eye = new Point3(camera.getX(), camera.getZ(), camera.getY());
Matrix4 transform;
float yaw = camera.getYaw();
float pitch;
if (camera.getLens() == Camera.Lens.SPHERICAL) {
pitch = 0;
} else {
pitch = camera.getPitch();
}
double pitchCos = Math.cos(pitch);
if (Math.abs(pitchCos) > 1E-6) {
// Set the point the camera is pointed to
Point3 target = new Point3(
camera.getX() - (float)(Math.sin(yaw) * pitchCos),
camera.getZ() - (float)Math.sin(pitch),
camera.getY() + (float)(Math.cos(yaw) * pitchCos));
Vector3 up = new Vector3(0, 1, 0);
transform = Matrix4.lookAt(eye, target, up);
} else {
// Compute matrix directly when the camera points is at top
transform = new Matrix4((float)-Math.cos(yaw), (float)-Math.sin(yaw), 0, camera.getX(),
0, 0, 1, camera.getZ(),
(float)-Math.sin(yaw), (float)Math.cos(yaw), 0, camera.getY());
}
this.sunflow.parameter("transform", transform);
this.sunflow.parameter("fov", (float)Math.toDegrees(camera.getFieldOfView()));