如何将对象旋转到另一个对象的向上/正常/面向向量

时间:2014-03-16 15:55:18

标签: javascript html5 graphics three.js

如果我有这样的自定义平面几何体:

planeGeometry.vertices[0] = new THREE.Vector3(0, 10, 0);
planeGeometry.vertices[1] = new THREE.Vector3(10, 10, 0);
planeGeometry.vertices[2] = new THREE.Vector3(0, 0, 0);
planeGeometry.vertices[3] = new THREE.Vector3(10, 0, 0);

// faceUVs, mesh etc omitted

var right = planeGeometry.vertices[0].clone().sub(planeGeometry.vertices[1]);
var up = planeGeometry.vertices[1].clone().sub(planeGeometry.vertices[3]);

var up = up.normalize();
var normal = up.clone().cross(right).normalize();

如何旋转另一个Object3D(在我的情况下为CSS3DObject)以使其面向正常向上矢量?我可以创建四元数或旋转矩阵来执行此操作吗?

0 个答案:

没有答案