Right now, frustum culling is disabled by default. Meaning
Object3D.frustumCulled is set to
false in the constructor of
InstancedMesh. This was done since view frustum culling requires proper bounding volumes to work and they can’t be computed for
However, there is a PR trying to fix this:
Related issue: Fixed #18334.
This PR adds a `boundingBox` and `boundingSphere` property as well as two new methods for bounding volume computation to `InstancedMesh`.
Since bounding volumes on geometry level are not sufficient for certain use cases like skinned and instanced meshes, the idea is to provide bounding volumes on object3D level for better results. I've tried to find alternative approaches but could not come up with a better solution for implementing proper bounding volumes for `InstancedMesh` and `SkinnedMesh`. The following policy is currently implemented:
- Bounding volumes on object3D level supersede bounding volumes on geometry level.
- When a geometry is created, bounding volumes are `null`. If the renderer needs bounding volumes e.g. for view frustum culling, it computes them _once_ based on the current data. This is also true for bounding volumes on object3D level.
- When application or engine logic changes geometry data, bounding volumes have to be recomputed, too. This is also true for bounding volumes at object3D level when respective data of `InstancedMesh` are changed (e.g. `instanceMatrix`). The examples are changed to reflect this pattern.
- With this PR, `InstancedMesh.frustumCulled` is not set to `false` anymore. User who dynamically change instanced meshes now have to recompute at least the bounding sphere for proper view frustum culling.
A subsequent PR could try to enhance `InstancedMesh.raycast()` so bounding volumes are used.
Updated the build files for testing purposes.
12:04PM - 24 Mar 21 UTC