Plane.negate()
Plane.negate()
方法用于反转平面法向量。即改变平面朝向及其法向量的方向。
plane.negate();
该方法不接受任何参数。
该方法没有返回值。
var plane = new THREE.Plane(new THREE.Vector3(0, 1, 0), 0);
console.log(plane.normal); // 输出: Vector3(0, 1, 0)
plane.negate();
console.log(plane.normal); // 输出: Vector3(0,-1, 0)
在这个示例中,我们创建了一个法向量指向 y 轴正方向,距离原点为 0 的平面。然后我们通过调用 negate()
方法来反转平面上的法向量,这样它就指向 y 轴负方向了。
该方法只改变平面法向量的方向,不会改变平面的位置。如果想要完全改变平面的方向,可以先平移平面再反转法向量。
var plane = new THREE.Plane(new THREE.Vector3(0, 1, 0), 0);
plane.translate(new THREE.Vector3(0, 0, 1)); // 移动平面
console.log(plane.normal); // 输出: Vector3(0, 1, 0)
plane.negate(); // 反转法向量
console.log(plane.normal); // 输出: Vector3(0,-1, 0)