javascript - THREE.js Turn THREE.planeGeometry to THREE.plane
问题描述
I am trying to configure the position of a THREE.plane for localClipping, and Im finding it a little unintuitive. I had a thought, is it possible to create some planeGeometry, manipulate it, and convert its position and orientation to the create a THREE.plane in its place?
This would be useful for configuring the position of a clipping planes.
解决方案
You want to set a THREE.Plane
from a Mesh
having a PlaneGeometry
, and you want to take into consideration the mesh's position
and quaternion
(or rotation
). In other words, you want the THREE.Plane
to align with the planar Mesh
.
The easiest way to do that is to use plane.setFromNormalAndCoplanarPoint()
.
The normal is the normal to the plane mesh after rotation. The coplanar point is any point in the plane mesh; the position
will do.
var plane = new THREE.Plane();
var normal = new THREE.Vector3();
var point = new THREE.Vector3();
normal.set( 0, 0, 1 ).applyQuaternion( planeMesh.quaternion );
point.copy( planeMesh.position );
plane.setFromNormalAndCoplanarPoint( normal, point );
three.js r.96
推荐阅读
- c# - 检查字符串是否以列表项值开头
- ios - 尝试使用它在 json 结构中的位置来解码 swift 4.2 中的值
- c - 尝试在C中更改二维数组中的元素
- asp.net-mvc - 使用 emmet(ZenCoding) 和 Visual Studio for Mac(不是 VS Code)
- python-3.x - 当我使用列作为键合并数据框时,它会无限次重复其他列
- python - 我想帮助使用 if in 语句优化三重 for 循环
- playframework - 在播放框架中使用redis作为缓存时接收超时
- amazon-web-services - AWS CodeDeploy:卡在安装步骤
- python - 哪个小部件最适合创建动态选项卡?
- angular - 如何在 Angular 7 中设置超时 KeyUp