FPS limit

What would be the best way to limit the render RAF? For instance max 60 FPS, and in “low” option get max 30 FPS. Also to avoid rendering way too much for high refresh rate monitors.

Original Post on Discord

by user 615280976855171083

That’s a good question. I dont think we have a feature for that right now but it would be a good addition

We are currently using three.js docs which must be used for WebXR. Looks like there’s no option built into threejs to limit FPS when using this method :thinking:

Yes, good question. I took a quick look, seems model-viewer limits FPS to max. 60

But looks like they also just use setAnimationLoop :eyes: so maybe that’s simply not true :smile:

You mean modelviewer or threejs?

model-viewer. If anyone I thought they may have FPS controls and such already built in

I also had to add this code to prevent updating too much in one script. :yum:

by user 615280976855171083

(As delta being a private scoped variable, which is meant for one and only one instance of this script of course.)

by user 615280976855171083

For something like that you could also use coroutines with WaitForSeconds maybe

Not in TypeScript, can we ? Though it’d be pretty heavy.

by user 615280976855171083

Yes you can

Why heavy?

but maybe more heavy than your code. not sure. But it’s just generators

And we have a method yield WaitForSeconds(x) that you can use

But maybe not necessary in your case.

I think the delta solution is perfectly fine too

Ahh it’s called in start(), not in update(). Yeah that’s an interesting implementation.

by user 615280976855171083

Ah yeah, i mean better would be onEnable actually if it should always run