ThreeJS:如何检测对象是否呈现/可见 [英] ThreeJS: How to detect if an object is rendered/visible
本文介绍了ThreeJS:如何检测对象是否呈现/可见的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何尽可能快地检测到相机的眼睛是否可以看到 Threejs 对象?obj.visible 属性是一个 setter,所以没有用.此外,frustumCullum 还不够,因为它仅指示对象是否在相机视口之外.我需要知道一个物体是否隐藏在另一个更大的物体后面.
How can I detect, as fast as possible, if a threejs object is visible for the eyes of the camera? The obj.visible attribute is a setter, so not useful. Also frustumCullum is not enough, as it only indicates if an object is out of the camera viewport. I need to know if an object is hidden behind another much larger object.
有人有想法吗?
干杯
马库斯
推荐答案
也许你可以使用 THREE.Raycaster()?
Maybe you could use THREE.Raycaster()?
var intersects = raycaster.intersectObjects( objects );
if ( intersects.length > 0 ) {
// find the object by name? intersects[0].
// Hidden if index > 0
}
这篇关于ThreeJS:如何检测对象是否呈现/可见的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文