Recently I’ve been using babylonjs to implement a 3d project and I found after load a lot of meshes (more than 100 million triangles totally), the fps will drop rapidly when panning the scene (or camera). After doing some performance indicating, I end up with finding the InputManager is always executing picking function when _onPointerUp, _onPointerDown and _onPointerMove, which makes every panning process so slow.
So eventually I just have to override the
scene.pointerUpPredicate functions and make them always return a false result to let the picking process end up there. And my question is, am I doing the right way for reducing the fps turbulence? Or is there any advanced methods for improving this? Many thanks!
First of all, welcome to Babylon! This idea might not work if you’re using those events at other times (Do you have a Playground that shows your use case?), but it looks like Scene.attachControl has options to disable the calling of the
_onPointer...() events. If you disable the events from there, does the performance improve?
One direct way, which will also have other benefits, is to merge meshes which of the same material which never move or rotate, assuming you have many. Not only does this reduce this overhead, but anything inside the render loop on the cpu side.
Because the cpu side is single threaded having a bunch of them kind of negates the parallel nature of he gpu. There is also a significance overhead for each gpu call, so few of them helps A lot.
You can flag your meshes with mesh.isPickable = false to avoid any interaction with the pointers
It works for my code. Many thanks for the advice!
Thanks for the advice. I used the method Deltakosh suggested, it worked. So I thank maybe it is the easiest way. But still appreciate for your help!