Three.js看起来似乎被翻转了 [英] Three.js lookat seems to be flipped

查看:420
本文介绍了Three.js看起来似乎被翻转了的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在这里有一个演示我的意思:测试网站或(备份

I have a demo of what I mean here: Test Site or (Backup)

出于某种原因,即使鼠标矢量是正确的,我的物体也会旋转90度,总是偏向正Y轴。据我所知,唯一可能出错的电话是: ship.mesh.lookAt(mouse); ,我每次都这样打电话屏幕是动画的。

For some reason, even though the mouse vector is correct my object is rotated by 90 degrees always in favor of the positive Y axis. The only call that this could be going wrong, as far as I can tell, in is the call: ship.mesh.lookAt(mouse);, I call this every time the screen is animated.

任何人都可以告诉我该怎么做才能解决这个问题以及为什么要这样做?

Can anyone tell me what to do to fix this and why it is doing it?

推荐答案

object.lookAt(position)定位对象以使对象的本地正 z轴指向期望的位置。

object.lookAt( position ) orients the object so that the object's local positive z-axis points toward the desired position.

您的船只前沿指向本地正 y轴的方向。

Your "ship's" front points in the direction of the local positive y-axis.

编辑:

要重新定向几何体,请在创建几何体后立即应用矩阵,如下所示:

To re-orient your geometry, apply a matrix right after the geometry is created, like so:

geometry.applyMatrix( new THREE.Matrix4().makeRotationX( Math.PI / 2 ) );

这篇关于Three.js看起来似乎被翻转了的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆