javascript - Threejs 将裁剪应用于对象的特定区域

标签 javascript three.js

我正在使用 THREE.Plane 来裁剪我的 STL 模型。

localPlane = new THREE.Plane( new THREE.Vector3( 0, -1, 0 ), 4);
.
.
.
material = new THREE.MeshPhongMaterial( {
    color: 0xffffff,
    side: THREE.DoubleSide,
    clippingPlanes: [
        localPlane,
    ],
    clipShadows: true
} );

它正在工作;但问题是整个物体的顶部都被这个无穷大的平面 chop 了。我想让它只剪掉它的一小部分(好像没有办法缩放THREE.Plane)

我也尝试过使用 ThreeCSG.js,但它似乎对 STL 对象不方便!

这是我得到的: The whole model is cut through top

最佳答案

是的,three.js 支持删除剪切平面的交点。您可以使用这样的模式:

// clipping planes
var localPlanes = [
    new THREE.Plane( new THREE.Vector3( - 1, 0, 0 ), 1 ),
    new THREE.Plane( new THREE.Vector3( 0, - 1, 0 ), 1 )
];

// material
var material = new THREE.MeshPhongMaterial( {
    color: 0xffffff,
    side: THREE.DoubleSide,
    clippingPlanes: localPlanes,
    clipIntersection: true
} );

另请参阅 three.js example .

three.js r.85

关于javascript - Threejs 将裁剪应用于对象的特定区域,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44325757/

相关文章:

javascript - 离开路线时重置 Controller 属性 ember.js

javascript - Threejs r73阴影变化——如何控制相机视锥体的阴影?

javascript - Three.js 相机旋转顺序

javascript - 如何在 3D Canvas 中捕获图像以及 Logo 和文本?

Three.js 可变半径管

javascript - 相机在 three.js 中找不到对象

javascript - 无法读取未定义的属性 'indexOf'

javascript - 使用 typescript 获取服务器端数据

javascript - 正则表达式提取WUB内的字符

javascript - laravel 在 javascript 中设置图像源路径错误