[英]three.js: GridHelper makes non standard grid?
I have been told that the standard normal vector for geometries in three.js is (0, 0, 1)
. 有人告诉我three.js中几何的标准法线向量是
(0, 0, 1)
0,0,1 (0, 0, 1)
。
However, when I make an instance of the GridHelper constructor, it makes a plane that is spanned by the X and Z axis. 但是,当我创建GridHelper构造函数的实例时,它将创建一个由X和Z轴跨越的平面。 Such a plane has a normal vector of
(0, 1, 0)
. 这样的平面的法线向量为
(0, 1, 0)
。
This can be seen by this screenshot, showing the vertices arry of the geometry of my GridHelper: 可以从此屏幕快照中看到,该屏幕显示了GridHelper的几何形状的顶点:
and it is confirmed by visual inspection: 并通过目视检查确认:
This is how I instantiate my GridHelper: 这就是我实例化GridHelper的方法:
var myGridHelper = new THREE.GridHelper(10, 20);
How come GridHelper does not comply with the standard normal vector? 为什么GridHelper不符合标准法线向量?
If this feature/bug is not going to change: Can I solve it by always initiating my GridHelper instances with this code: 如果此功能/错误不会改变:是否可以通过始终使用以下代码启动GridHelper实例来解决此问题:
var standardPlaneNormal = new THREE.Vector3(0, 0, 1);
var GridHelperPlaneNormal = new THREE.Vector3(0, 1, 0);
var quaternion = new THREE.Quaternion();
quaternion.setFromUnitVectors(standardPlaneNormal, GridHelperPlaneNormal);
var myGridHelper = new THREE.GridHelper(10, 20);
myGridHelper.rotation.setFromQuaternion(quaternion);
? ?
If you want to use the lookAt()
method with GridHelper
, you need to rotate the grid geometry so the grid lies in the XY-plane, instead of the XZ-plane. 如果要在
lookAt()
使用lookAt()
方法, GridHelper
需要旋转网格几何形状,以便网格位于XY平面而不是XZ平面。 Once you do that, lookAt()
will work as expected. 完成后,
lookAt()
将按预期工作。
var grid = new THREE.GridHelper( 10, 2 );
grid.geometry.rotateX( Math.PI / 2 );
var vector = new THREE.Vector3( 1, 1, 1 );
grid.lookAt( vector );
scene.add( grid );
three.js r.76 three.js r.76
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.