Three.js剪切平面

问题描述

我从https://github.com/mrdoob/three.js/pull/20290实施了一种技术

几乎所有东西都可以正常工作,但是我需要使用spotLight.shadow.camera视锥截断模型:

shadowCameraHelper = new THREE.CameraHelper( three.spotLight.shadow.camera );

enter image description here

我了解如何获取用于裁剪的飞机

frustum = new THREE.Frustum();
frustum.setFromMatrix( new THREE.Matrix4().multiply( spotLight.shadow.camera.projectionMatrix,spotLight.shadow.camera.matrixWorldInverse ) );

当我将辅助程序添加到相机中时,我发现它们几乎适合SpotLightHelper-由于spotLight.shadow.camera.near参数(如果我理解正确),会略有差异:

helpers = new THREE.Group();
helpers.add( new THREE.PlaneHelper( frustum.planes[ 0 ],75,0xff0000 ) );
helpers.add( new THREE.PlaneHelper( frustum.planes[ 1 ],0x00ff00) );
helpers.add( new THREE.PlaneHelper( frustum.planes[ 2 ],0x00ff00 ) );
helpers.add( new THREE.PlaneHelper( frustum.planes[ 3 ],0xff0000 ) );
helpers.add( new THREE.PlaneHelper( frustum.planes[ 4 ],0x0000ff ) );
helpers.add( new THREE.PlaneHelper( frustum.planes[ 5 ],0x0000ff ) );

spotLight.shadow.camera.add(helpers)

enter image description here

enter image description here

我不知道如何为飞机设置正确的位置以裁剪模型。完美地,它必须是局部裁剪(但全局也可以)。

所有Threejs对象都放置在铯空间中,因此坐标类似于:

(x: 2847473.624183968,y: 2197845.085011498,z: 5249482.064107984)

所以我有两个问题:

如何将视锥面完全适合CameraHelper

如何用截锥体平面修剪模型?

还是我做错了什么,还有其他方法可以解决问题?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)