Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A-Frame 1.5.0 Frustum Culling issue due to THREE.js PR 25591 #42

Open
diarmidmackenzie opened this issue Jul 25, 2024 · 0 comments
Open

Comments

@diarmidmackenzie
Copy link
Owner

From A-Frame 1.5.0, we have an issue with frustum culling due to three,js changes to how this works for Instanced Meshes.

The key change is this one:
mrdoob/three.js#25591

Key changes are that:

  • frustrum culling is enabled on instanced meshes by default
  • the bounding sphere for frustum culling is automatically computed, the first time it is needed
  • the key property is a new boundingSphere property on the InstancedMesh itself. The values set on this override anything set on the geometry of the InstancedMesh.
  • however, applications need to manually recompute this every time they add or modify an instance's position using setMatrixAt()

Up to this point, frustum culling support in this component allowed the user to manually configure a bounding sphere using the fcradius and fccenter properties.

This still works OK if an instance mesh has members at start of day.

However if an instanced mesh is empty at start of day, the boundingSphere property on the InstancedMesh gets set to an empty sphere initially, and is never updated.

A further change is that the bounding sphere specified using fcradius and fccenter will now be applied to every instance, which can give a larger overall bounding sphere than specified, if the instances are spread out.

Restoring previous function should be a fairly simple fix. When we set boundingSphere on the InstancedMesh's geometry, we also set it on the InstancedMesh itself. This should also be back-compatible with the pre-1.5.0 way of doing things.

However, it could also be good to make available the new functionality to auto-compute boundingSpheres. How to do that, while continuing to offer the old interface, needs a little more thought.

Furthermore, three.js also auto-computes a boundingBox for the InstancedMesh, but again applications need to re-compute this on each add/remove/move. This is used when an InstancedMesh is passed in to Box3.expandByObject(). Perhaps we should try to make that function work as well?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant