0

I've taken a look at the Clipping examples in the Threejs site, and the ThreeCSG operations, but I am not able to find an example that has "both".

To be more specific, I require a PlaneGeometry of PlaneBufferGeometry that applies a CSG operation as smooth as a Clipping, but this PlaneGeometry could be moving, changing its position and orientation.

As an example, a Sphere and a Plane are on the scene, the Plane starts facing in Z and is spinning in Y, cutting one side of the sphere at all times, but the plane could be a box or any other object.

Is it possible?

4

1 回答 1

0

让我们来看看两个单独的问题。

对于平面剪裁,事情很容易做到。

// plane in Z Direction
var plane = new THREE.Plane( new THREE.Vector3( 0, 0, 1), 1);
// tell the renderer to use it for clipping
renderer.clippingPlanes = [ plane ];
// enable clipping in the renderer
renderer.localClippingEnabled = true;
// create a new PhongMaterial
var material = new THREE.MeshPhongMaterial( {
                    side: THREE.DoubleSide,    // to be able to look inside
                    clippingPlanes: [ plane ], // the clipping plane
                    clipShadows: true          // also clip shadows
                } ),

正如你在这里看到的。

请注意,它们clippingPlanes是一个数组,因此您一次可以提供多个。

正如你在这里看到的。

裁剪和 CSG 之间的主要区别在于,在裁剪期间不会创建新几何体,因为它只检查三角形是否应该是渲染器。

对于 CSG,它有所不同,因为它为每个操作创建了新的几何图形。

将 CSG 视为NewObject = ObjectA - ObjectB.

这是一个运行任务更多的算法,可能无法实时执行,具体取决于对象的复杂性。

因此可以组合 CSG,然后在生成的对象上使用剪切平面。

于 2017-02-01T12:29:47.037 回答