Three.js 相机旋转很奇怪
我刚刚开始使用 Three.js。真的就像刚才一样。
在玩了一个小时左右并构建了一个可以帮助我理解不同元素(相机、灯光、对象)如何协同工作的工具后,我发现了一些奇怪的东西。
该工具: http://hotblocks.nl/tests/ Three/cubes.html
这个是当前的默认设置:
- 相机位于向上 210 度、
- 向后 500 度、
- 向右 246 度
- 相机稍微向左旋转
- 灯光位于正上方并向各个方向照射
如您所见,物体位于视口的最底部。所以我想把相机向下转动,这样我就能看到更多。
尝试一下:调低camera.rotation.x
。
可以,但是旋转角度不对!不是相机旋转,而是世界绕其 Z 轴旋转。
这不对吧?
Y 轴也是错误的。它围绕 Y 轴旋转世界。
围绕 Z 轴旋转相机效果非常好:相机旋转,而不是世界旋转。
我做错了吗?还是理解错了?
PS 由于相机旋转仅围绕其 Y 轴,因此结果中对象的垂直边缘也应该是垂直的。在默认设置中,它们是。围绕 X 轴旋转相机不会改变这一点,但确实会改变。只有绕 Z 轴旋转才能改变这一点(而且确实如此)。我错了吗?
PPS 我了解 Camera.lookAt( THREE.Vector3 target )
,但这会改变相机的旋转,包括其 Z 轴,这不是必需的,从逻辑上讲。
I've just started with Three.js. Like really just now.
After playing with it for an hour or so and building a tool that helps me understand how the different elements work together (Camera, Light, Objects), I found something strange.
The tool: http://hotblocks.nl/tests/three/cubes.html
This is the current default set up:
- the Camera is positioned 210 upwards and
- 500 backwards and
- 246 to the right
- the Camera is rotated slightly to the left
- the light is directly above and shines in all directions
As you can see, the objects are at the very bottom of the viewport. So I want to turn the Camera downward, so I can see more of them.
Try that: turn camera.rotation.x
down.
That works, but the angle of rotation is wrong! Instead of the Camera rotating, it's the World rotating around its Z axis.
That's not right, is it?
The Y axis is also wrong. It rotates the World around its Y axis.
Rotating the Camera around its Z axis, works perfectly: the Camera rotates, not the World.
Am I doing it wrong? Or understanding it wrong?
PS Since the Camera rotation is only around its Y axis, the objects' vertical edges should be vertical in the result as well. In the default set up, they are. Rotating the camera around its X axis, shouldn't change that, but it does. Only rotating around its Z axis should change that (and it does). Am I wrong?
PPS I know about Camera.lookAt( THREE.Vector3 target )
, but that changes the rotation of the camera, including its Z axis, and that shouldn't be necessary, logically.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 Github 上收到的答案:https://github.com/mrdoob/ Three.js/issues/第1163章
Answer received on Github: https://github.com/mrdoob/three.js/issues/1163