Edward
Edward

Reputation: 557

Knowing how much one can load in three.js

So I was looking into loading character models, and a bit of stress testing by loading that same model several times to create an army. Worked fine on a high-end computer, but when testing it on a 32-bit work laptop it gave an Out Of Memory Error. My question is is there any way to know how much memory a model will take, whether it is external files or generated on runtime, then find out how much the client can handle, and moderate the memory usage appropriately (smaller army, load low-end models, reduce texture size, etc)?

Upvotes: 1

Views: 270

Answers (1)

M -
M -

Reputation: 28472

Due to security and privacy concerns, WebGL does not have access to the system's memory or processing capabilities. It was designed this way to prevent malicious behavior, so there's no way of finding out how many models it can handle before crashing.

However, WebGL does have access to several of the GPU's capabilities. If you check out Three's WebGLRenderer.capabilities you'll see you have access to several max values. You could use these as comparison points, and then define what constitutes a 'high-end' and 'low-end' machine based on your use-case. You can see a nicely-formatted output of the same capabilities by visiting http://webglreport.com/ on any machine, and you can see global device capabilities at http://webglstats.com/

Additionally, you should take screen.width and screen.height into consideration. You won't need to load high-definition textures and models if the device's width or height don't exceed something like 1000 pixels.

Finally, you could give the user the option of choosing a "High" or "Low" experience and let them determine for themselves.

Upvotes: 2

Related Questions