#Pause/resume rendering
1 messages · Page 1 of 1 (latest)
Yes via this.context.isPaused = true
Awesome, thanks !
(this pauses the whole update loop, you can listen to pause changes in scripts via onPausedChanged(newValue, oldValue) too)
I can't find documentation on these. For instance I search "pause" in the search bar but have no result. 😮
If you're asking to just not call the threejs render method we dont have a bool for that but you could just remove the main camera
I think it's not documented right now 😥 (+ the search is not great, we need to switch to another solution)
Ahh alright ! An API doc would be awesome in the future indeed. 😉
We actually had that for a while but it's not updated autmatically right now so a few versions behind (the reason was that it was re-uploaded too whenever we made a docs change and that took 'too long')
https://engine.needle.tools/docs/api/
^ old api
I'm also not sure how useful it is as long as the source code doesnt have more summary comments etc. Personally I wasnt very happy with that yet
Yeah indeed. Thanks anyway !
To auto-pause when the tab/window becomes "hidden" adding this script snippet to the .html seems to works fine in most cases:
<script>document.addEventListener("visibilitychange", () => { Needle.Context.Current.isPaused = document.visibilityState === "hidden"; })</script>
Beware that Current can be null depending on when the browser event fires (maybe thats why you say most cases).
You could instead use the NeedleEngine.register... static methods tho to save the context or query the dom element and get the context from it (needleEngineDomElement.context).
Im not sure if the list of all contexts is currently exposed - i have to check that later