Any reason to keep PMREMGenerator alive? Or always dispose after getting initial textures?

The demos dispose of the PMREMGenerator instance right after the environment textures are created. Seems like it is used only for setup, f.e. take your env map, PMREM it, throw the generator away.

What use cases are there for keep it alive?

Only thing I can imagine is perhaps loading new env maps in a dynamic model viewer, or something. But for games where assets are pre-determined, no need to keep it, right?

Or maybe in a game, we switch from one scene to another, and we wish to generate a new env map, so we keep it around for when we switch scenes? We could also just make a new one each time.

Any thought when to keep it?

Well, if you have already provided the answer: If you want to pre-process more than one environment map in your app. This can happen in a row or after a certain amount of time (e.g. when changing a level in a game).

1 Like

Thanks! Just double checking or getting confirmation. I’m building stuff on top so the user doesn’t have to know about it.

This is useful along with When to dispose: How to completely clean up a Three.js scene