Optimise performance with invisible objects?

I’m creating a scene containing hundreds of meshes, but many of them are invisible and will only be made visible on demand. However, the performance seems to feel the hit of their presence anyway. I used Layers to make them invisible hoping that would mean they’d get completely removed from the rendering queue as long as I used a Camera unable to see them, but that does not seem to be the case, the system is still quite slow to update. Is there anything else I can do to boost performance? Some setting that would help? Or do I have to fall back on removing/adding them to the scene?

If they are invisible - why hold them in the scene in the first place :thinking: ? For a few models that’d make sense, but hundreds seems like a questionable idea.

1 Like

Well, right now, basically just for convenience - since I might have to turn them visible at a moment’s notice, it makes it as easy as flicking a switch. So I didn’t think much about it, but I might have to go with that if it’s the only way. Still, I don’t understand what other overhead is left since I’m rendering with a Camera that can’t see them.

Are you familiar with the performance analysis in Chrome? Using this tool, you should be able to see what parts of your code use most of the available frame time.

I am, but I think it’s nothing happening in my code - it’s all inside THREE.js’s rendering methods. Nothing I can do on any of my frame-by-frame code changes anything. Anyway now I’m trying to test with removing objects altogether, once I’m done I’ll move to trying other things if it doesn’t fix it.

Well, the tool should show you which three.js functions allocate much processing time. Knowing this would be important for investigation.

Yes, I’ll look into it if this fix doesn’t solve the problem, it’s just that I didn’t check immediately because not knowing THREE’s internal methods I thought I would have a hard time making sense of the data on my own, and was hoping that there was a known solution to this problem.

Anyway, adding/removing objects from the scene did fix the issue so I’m marking that as solution, thanks!