问题描述
我正在尝试为localClipping配置THREE.plane的位置,而我发现它有点不直观.我有一个想法,是否可以创建一些planeGeometry,对其进行操作,并将其位置和方向转换为在其位置创建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.
推荐答案
您要从具有PlaneGeometry
的Mesh
设置THREE.Plane
,并且要考虑网格物体的position
和quaternion
(或rotation
).换句话说,您希望THREE.Plane
与平面Mesh
对齐.
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
.
最简单的方法是使用plane.setFromNormalAndCoplanarPoint()
.
法线是旋转后平面网格的法线.共面点是平面网格中的任何点. position
可以.
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
three.js r.96
这篇关于THREE.js将THREE.planeGeometry更改为THREE.plane的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!