Bear with me, I wanted to make a playground to demonstrate, but as this regards the render loop it wouldn’t really work.
We use our own custom render loop to ensure frames are not rendered when nothing changes in the scene. This is the majority of the time in our application, so it’s a good battery saver.
However, now when migrating to Babylon I have run into an issue with the ArcRotateCamera (probably all cameras). To now when to render a frame I need to know when someone has interacted with the Camera. So I listen for onViewMatrixChangedObservable (and onProjectionMatrixChangedObservable). Only these events only happens at scene.render().
The matrices only change when it renders (makes sense), but how do I listen for input to the ArcRotateCamera? How do I know that someone has interacted?
i think you most read the document before you start using because their are a lot tools and ways that help you for do complicated stuff easily
but if you don’t do that that be complicated .
the webgl + optimizing has any deep level math and when we mix science + math it can be hard in any level but your request is so easy and i just show how that initialized the better reference is BABYLONJS document
Tried your solution, but auto-rotate won’t work. It really feels like there should be an event in the camera which one can listen to to know when a render is needed.
Edit: Also the inertial movement will break. Do not do it like this, see my final post.
but those events can only be based on the fact that the camera moves which will only happen during render so yup chicken and egg
I would suggest to use both the scene pointer events + a check on camera.autoRotate so that you can detect it in your case.
Implementing generically would cost a lot of cpu as animation/potential changes would require to be checked in order to render and it is usually pretty specific to a particular use case.
I think I found a sensible solution - my impression is that on each browserframe I shall call camera.update();
This makes the camera do the cheap checks, and if a change has happened it will trigger the updated matrices.
You should set sceneNeedRender = false before the call to scene.render() because the update to this variable (from onProjectionMatrixChangedObservable and onViewMatrixChangedObservable) will be done during the course of this call.