Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/465.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何将一个对象旋转到另一个对象';s向上/法线/朝向向量_Javascript_Html_Graphics_Three.js - Fatal编程技术网

Javascript 如何将一个对象旋转到另一个对象';s向上/法线/朝向向量

Javascript 如何将一个对象旋转到另一个对象';s向上/法线/朝向向量,javascript,html,graphics,three.js,Javascript,Html,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); // f

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

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)使其面向法线和上方向向量?我可以创建一个四元数或旋转矩阵来实现这一点吗?

通常的方法是设置
cssObject.quaternion=mesh.quaternion
。但是如果我像这样创建自定义位置的顶点,或者在运行时置换某些顶点,网格的四元数会跟随还是有办法更新它?不,四元数不会“跟随”顶点发生变化。