three.js - Three.js 剪裁平面
问题描述
我从https://github.com/mrdoob/three.js/pull/20290实现了一项技术
几乎一切正常,但我需要使用 spotLight.shadow.camera frustum 剪辑模型:
shadowCameraHelper = new THREE.CameraHelper( three.spotLight.shadow.camera );
我了解如何获得飞机进行剪裁:
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 ], 75, 0x00ff00) );
helpers.add( new THREE.PlaneHelper( frustum.planes[ 2 ], 75, 0x00ff00 ) );
helpers.add( new THREE.PlaneHelper( frustum.planes[ 3 ], 75, 0xff0000 ) );
helpers.add( new THREE.PlaneHelper( frustum.planes[ 4 ], 75, 0x0000ff ) );
helpers.add( new THREE.PlaneHelper( frustum.planes[ 5 ], 75, 0x0000ff ) );
spotLight.shadow.camera.add(helpers)
我不明白如何为飞机设置正确的定位来剪辑模型。完美,它必须是局部裁剪(但全局也可以)。
所有 Threejs 对象都放置在 Cesium 空间中,因此坐标类似于:
(x: 2847473.624183968, y: 2197845.085011498, z: 5249482.064107984)
所以我有两个问题:
如何将 frustum.planes 完全适合 CameraHelper
如何用 frustum.planes 剪辑模型?
还是我做错了什么,还有其他方法可以解决问题?
解决方案
推荐阅读
- python - 将元组列表转换为字典
- javascript - 移动另一个 div 的 CSS 动画
- r - R - 将 SpatialLines 转换为栅格
- ruby-on-rails - 为password_expired获取不匹配的路由器
- java - 使用 UTF-16LE 编码和 Apache Commons IO 读写文本文件
- sql - 为什么不匹配?
- javascript - 当我有未知数量的 div 时如何设置 id/class
- asp.net-core-2.1 - 将 .NET Core API 映像(存储在 wwwroot 目录下)链接返回给客户端
- java - MockEndpoint 无法运行路由
- laravel - Office 365 在 laravel 上给出错误的序列错误