三.JS旋转投影使y轴变成z轴
传统上,在 3D 投影中,Y 轴是代表“上下”的轴。我学会了将它与其他引擎一起思考,因为该轴是 Z 轴。我想知道 Three.JS 是否有办法制作 Z 轴“上/下”轴。如果是的话,有什么后果吗?
这是我想要的图表:
Traditionally, in 3D projections, the Y-axis is the axis that represents "up and down". I learned to think of it, with other engines, as that axis being the Z-axis. What I was wondering was whether there is a way in Three.JS to make the Z-axis the "up/down" axis. If so, are there any consequences to it?
Here is a diagram of what I want:
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您可以只更改相机而不是整个坐标系。例如:
这会更改相机的
向上
向量以使用Z-UP。为了说明示例,这里是您创建的 JSFiddle,稍加修改即可在设置
up
向量后调用lookAt
: http://jsfiddle.net/NycWc/1/You could just change the camera rather than the entire coordinate system. For example:
This changes the
up
vector for the camera to use Z-UP.To illustrate an example, here's the JSFiddle you created slightly modified to call
lookAt
after setting theup
vector: http://jsfiddle.net/NycWc/1/以下将达到您想要的结果:
根据文档:
.DEFAULT_UP:矢量3
对象的默认向上方向,也用作 DirectionalLight、HemisphereLight 和 Spotlight(创建从上到下照射的灯光)的默认位置。
默认设置为 ( 0, 1, 0 )。
要了解详细信息,请参阅源代码。
The following will achieve your desired result:
According to the documentation:
.DEFAULT_UP : Vector3
The default up direction for objects, also used as the default position for DirectionalLight, HemisphereLight and Spotlight (which creates lights shining from the top down).
Set to ( 0, 1, 0 ) by default.
To learn more, see the source code.
我对一个对象有这个问题。这是我修复它的方法。
正如您所要求的那样,这改变了它的方向。
I had this issue with an object. Here's how I fixed it.
This took changed it's orientation in just the way you're asking.
xyz 坐标系应始终使用右手定则设置。创建自己的约定根本不是一个好的计划,并且会引起很多混乱。您可以随意旋转坐标系,但不要改变轴的方向。如果您确实想做您所显示的内容,您可以创建一个 x,y,-z 坐标系。
The xyz coordinate frame should always be set up with the right hand rule. Creating your own convention is simply not such a good plan and will cause a lot of confusion. You can rotate the coordinate frame at will but don't change the direction of the axis. If you really want to do what you display you can make an x,y,-z coordinate frame.