Threejs:禁用某些对象的视锥剔除 [英] Threejs: Disable frustum culling for some objects

查看:120
本文介绍了Threejs:禁用某些对象的视锥剔除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为了解决z-fighting的问题,我把camera的近远都限制在一个很小的范围内.但是当我想添加一个更大的物体时,它被视锥剔除了.

In order to solve the problem of z-fighting, I limited the near and far of camera to a small range.But when I want to add a larger object,it was culled by view frustum.

我尝试了 object3d.frustumCulled 属性,没有按预期工作,原因如下:https://github.com/mrdoob/three.js/issues/12170

I tried object3d.frustumCulled property,not working as expected,the reason is as follows: https://github.com/mrdoob/three.js/issues/12170

那么,有没有办法在不改变远近相机的情况下确保某些特定物体不被视锥剔除?谢谢.

So,is there a way to ensure that some specific objects are not frustum culled without changing the camera near and far? THX.

推荐答案

剔除并不意味着是否绘制了对象.它可以绘制或不绘制取决于它的位置.这是一个试图说出这样的话的优化:

Culling doesn't mean that an object is drawn or not. It can be either drawn or not drawn depending on where it is. It is an optimization that tries to say something like this:

嘿,我有一个非常便宜的检查(平面/球体相交),我可以做并告诉您是否需要尝试绘制它.

Hey, i have a really cheap check (plane/sphere intersection) that i can do and tell you if you need to attempt to draw this at all.

所以你做了一个便宜的检查,如果对象保证完全不在视锥体中,你永远不会发出绘制调用.如果它相交,您必须发出绘制调用,但如果没有三角形实际上位于截锥体中,您可能仍然看不到任何东西.

So you do a cheap check, and if the object is guaranteed to be entirely out of the frustum, you never issue the draw call. If it intersects, you have to issue a draw call, but you may still see nothing if none of the triangles are actually in the frustum.

如果您下载类似 spectre.js 的东西并检查您的绘制调用,您实际上会看到使用 frustumCulled = false 您会获得场景中每个对象的绘制调用.您的屏幕可能是空的.

If you download something like specter.js and inspect your draw calls, you will infact see that with frustumCulled = false you get a draw call for every object in your scene. Your screen may be empty.

这篇关于Threejs:禁用某些对象的视锥剔除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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