Skip to content

Allow customizing intersectsFrustum in Object3D #32606

@OndrejSpanel

Description

@OndrejSpanel

Description

Sometimes the default frustum culling does not work very well for some particular objects. One example are objects which have a bounding box which is very different from a box, e.g. is very long in one or two dimensions than. In such case the default sphere based culling gives many false positives.

Still, bounding sphere is a reasonable default behaviour and it is probably not desirable to implement a bounding box based culling for all objects.

Solution

Introduce a method intersectsFrustum into Object3D so that objects can customize it based on its internal knowledge. The default implementation would be very simple, it would just call frustum.intersectsObject(this)

Alternatives

One can disable frustum culling for the object completely and set visible manually before rendering them. This is possible, but it cannot be combined with automatic shadow mapping, because shadow frustum is different.

Moreover, when doing this, one needs to build or obtain the frustum, which can be quite complicated when preparation for the custom shadow pass is implemented in onBeforeRenderScene. With the proposed change, the frustum is already available in the place where _frustum.intersectsObject( object ) is done now.

Additional context

The same change was already suggested in e828fd0 with different motivation.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions