matrix - 在three.js中按照平面旋转组
问题描述
我有一组形状很少(球体几何、线条和平面)。组中有一个平面需要与组外的另一个平面类似地定向。但我希望小组也有相应的方向。
这是我尝试过的
let lookatpos = new THREE.Vector3(/*Normal to the plane from group*/);
//change the group lookat to the normal of the plane
group.lookAt(lookatpos);
let v2 = new THREE.Vector3(/*normal to the second plane*/);
var axis = lookatpos.clone().cross(v2);
var angle = Math.acos(lookatpos.dot(v2));
if (angle == NaN)
return;
var rotationWorldMatrix = new THREE.Matrix4();
rotationWorldMatrix.makeRotationAxis(axis.normalize(), angle);
currentmesh.matrix.multiply(rotationWorldMatrix);
group.matrix.multiply(rotationWorldMatrix);
currentmesh.rotation.setFromRotationMatrix(currentmesh.matrix);
group.rotation.setFromRotationMatrix(group.matrix);
根据我从 Rotate plane 获得的提示,使其与另一个平面平行
但是我正在反转组的方向,尝试否定法线,但问题仍然存在。有人可以帮我吗?
解决方案
推荐阅读
- ruby - Ruby 中的切换案例
- node.js - Mongoose 不区分大小写的架构
- ajax - Laravel 和 AJAX 401 未经授权
- c# - Linq 在多个字段上加入和分组并截断日期中的时间
- javascript - 从本地磁盘加载图像
- java - oatomcat.jdbc.pool.ConnectionPool :无法创建池的初始连接。Spring Boot + MySql
- polymer - 无法下载 Chromium 设置“PUPPETEER_SKIP_CHROMIUM_DOWNLOAD”环境变量以跳过下载
- python - 如何在具有通用视图的 URL 中使用 slug?
- c - 如何处理 gdb 中的`__int128`?
- c# - 图像 iTextSharp 的坏边框