Hi,
I am having a weird issue and am not quite sure where to look at.
I am regenerating a mesh on pointer move. The generation happens in like 30ms and if I move slow, the mesh gets updated. But if I move fast, the generation happens, but the render loop is not firing, causing a big lag. As you can see in the picture
Weirdly, I cannot reproduce this, when I use the Chrome Performance Dev Tools. Then it is butter smooth.
When I use the Babylon Performance Profile however, it won´t collect information in the time the loop stops.
This mainly happens in Chrome. In firefox its as smooth as with Chrome Performance Dev Tools.
I have tried a few options, like calling the engine._renderFrame() scene.render() functions at end of the
mesh generation. It did not help.
I have the feeling my pointer move events are fired so fast, that the render loop is not continuing. So I increase the render time of a frame by my movement.
One option that I tried, is tracking the frameId. So I only call mesh generation, if the frameId is different from the last one - so one generation per frame. But this is not working properly, when I release the pointer. It is stuck on the last frame.
The other work around is a combination with setTimeout. But this feels like a hack.
if (timeout) {
clearTimeout(timeout)
}
// sometimes generation is stuck in a frame. we use a timeout to get out of it... not nice but works ok
if (engine.frameId === lastFrameId) {
timeout = setTimeout(() => {
generate()
}, 1)
} else {
generate()
}
lastFrameId = engine.frameId
Any idea how this could be improved?Is there any way I can easily “hook” a function to the render loop?