相机旋转 Libgdx

rotation of the camera Libgdx

我想围绕物体的中心旋转相机,使我们注视相机的点在这个圆的另一侧(图 1)。当相机围绕物体旋转时,视野开始翻转(图2)。如何解决这个问题呢? 这就是我实现的围绕物体旋转。 (也许这是我项目的问题,但是 X 轴指向左侧,Y 轴朝上,Z轴向前)

camera.position.set((float) (x - 17 * Math.sin(angle)), 12, (float) (z - 17 * Math.cos(angle)));
    camera.lookAt((float) (x + 15 * Math.sin(angle)), 0, (float) (z + 15 * Math.cos(angle)));

[1]: [https://i.stack.imgur.com/o7p8R.jpg] [1]

[2]: [https://i.stack.imgur.com/uiXer.png] [2]

重置相机向上值。

camera.up.set(0, 1, 0); //sets rotation back to default

camera.position.set((float) (x - 17 * Math.sin(angle)), 12, (float) (z - 17 * Math.cos(angle)));
camera.lookAt((float) (x + 15 * Math.sin(angle)), 0, (float) (z + 15 * Math.cos(angle)));
camera.update();

希望对您有所帮助。