I am not sure if this is already implemented under the hood but I decided to ask away anyway.
My use case is large environments and camera & AI agent collision detection.
Doing ray intersects on large mesh is quite slow and perhaps applying octree on triangle level could give one or two orders of magnitude performance boost. This would work by placing mesh triangles in octree and find matching triangles by ray bounding box in mesh local coordinates. Then you could still move the mesh around freely if needed without need to update the octree. Only changing mesh content would require updating the octree.
Even if you create specialized collision shapes they can get quite complex and costly on large levels.
Submeshing in turn seems to affect overall performance adversely and collision engine with submeshing did not really solve my performance issues. I am still planning to try the webworker collision detection but I am afraid the ray intersect cost is still order of magnitude too large.
Any opinion on this? I am thinking about this because in some other webgl framework the ray intersection implementation was order of magnitude faster. I could ray pick against all my models in scene (500k triangles) 60 times per second and use that for camera collision detection. Would like to achieve something like that with babylon.js as well if possible.
When I do intersection in babylonjs against 40k triangles the time spent is around 100ms.
I am thinking of writing implementation for faster mesh intersect. It would be nice to test WebAssembly for this. Any opinion what would be best language for babylon.js plugins. I considering golang as I have been writing a bit with it but there is no convenient binding implementation for it at the moment. Rust could be cool or c++?
It seems a lot can be done using the GPU. Now I am a long way from attempting any GPU work but am interested in seeing if I can eventually do something with CPU side but it may take a long time.
I am taking a different approach just using BJS and javascript as a proof of concept. Will have some idea if it works in a few days or so. Will be interested how you get on.