本文介绍了THREE.js将THREE.planeGeometry更改为THREE.plane的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为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.

推荐答案

您要从具有PlaneGeometryMesh设置THREE.Plane,并且要考虑网格物体的positionquaternion(或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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-05 04:36