InstanceMesh Performance Issue
jamiemarkwhite opened this issue · comments
Hi, I have been comparing performance between an old custom implementation of cannon + web workers against use-cannon with 1500 instance mesh spheres and the performance was bad with use-cannon and fine with the custom version. After a lot of digging I think I may have found the performance issue...
In physics-provider.tsx (line 181) the function iterates through 'Object.values(refs)' which seem to include multiple entries of the instance mesh. So it appears the function is iterating through as many instance-mesh references as there are instances of the mesh.
I tested my theory by removing duplicate InstanceMesh references from Object.values(refs) and gained a significant performance boost.
So, you might want to take a look at the cause of this duplication in the refs array, if indeed it IS actually a problem and not intentional for the physics to behave correctly.
Appologies, but I haven't been able to look any deeper into this.
Cheers.