如何确定平面是否在 Three.js 相机 Frustum 中 [英] How to determine if plane is in Three.js camera Frustum

查看:56
本文介绍了如何确定平面是否在 Three.js 相机 Frustum 中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果飞机在相机的视锥体内,我很难制作一个返回 true 的函数.我在 github 上找到了这篇文章,在 github,但是无论对象是否在截锥体.

I am having a hard time making a function that returns true if a plane is inside of the camera's view frustrum. I found this post, on github, but the recipe always returns false whether or not the object is in the frustum.

有人已经聪明地实现了这一点吗?非常感谢.

Anyone already implemented this intelligently? Much thanks.

推荐答案

也许矩阵没有更新?

camera.updateMatrix(); // make sure camera's local matrix is updated
camera.updateMatrixWorld(); // make sure camera's world matrix is updated
camera.matrixWorldInverse.getInverse( camera.matrixWorld );

plane.updateMatrix(); // make sure plane's local matrix is updated
plane.updateMatrixWorld(); // make sure plane's world matrix is updated

var frustum = new THREE.Frustum();
frustum.setFromMatrix( new THREE.Matrix4().multiplyMatrices( camera.projectionMatrix, camera.matrixWorldInverse ) );
alert( frustum.contains( plane ) );

这篇关于如何确定平面是否在 Three.js 相机 Frustum 中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆