THREE.js将THREE.planeGeometry转为THREE.plane

问题描述 投票:0回答:1

我正在尝试配置一个THREE.plane的位置进行localClipping,我发现它有点不直观。我有一个想法,是否有可能创建一些planeGeometry,操纵它,并将其位置和方向转换为创建一个THREE.plane在它的位置?

这对于配置剪裁平面的位置很有用。

javascript three.js linear-algebra plane
1个回答
1
投票

你想从一个有THREE.PlaneMesh设置一个PlaneGeometry,你想要考虑网格的positionquaternion(或rotation)。换句话说,你希望THREE.Plane与平面Mesh对齐。

最简单的方法是使用plane.setFromNormalAndCoplanarPoint()

法线是旋转后平面网格的法线。共面点是平面网格中的任何点; position会这样做。

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

© www.soinside.com 2019 - 2024. All rights reserved.