Vector3 oldPosition = new Vector3();
Vector3 oldDirection = new Vector3();
if (cam != null) {
oldPosition.set(cam.position);
oldDirection.set(cam.direction);
cam = new PerspectiveCamera(28, Gdx.graphics.getWidth(),
Gdx.graphics.getHeight());
cam.position.set(oldPosition);
cam.direction.set(oldDirection);
} else {
cam = new PerspectiveCamera(28, Gdx.graphics.getWidth(),
Gdx.graphics.getHeight());
cam.position.set(0, 0f, 16f);
cam.direction.set(0, 0, -1);
}
cam.up.set(0, 1, 0);