ansanders
ansanders

Reputation: 17

AFrame / Three.js : why so many (JS)Strings in memory, when loading complex .obj files?

we have a pretty complex webscene where we dynamically load pretty complex .obj- and .mtl-files. After comparing the scene without any of these objects with the one that has multiple objects inside we noticed a weird behaviour:

firefox memory heap shows that most of the memory (>100MB for 5 Objects) is used for JSStrings. the rest of the memory is used for Objects which is self-explaining when we have complex object files in there.
But how come the high amount of Strings and are we able to reduce it? Does AFrame convert the content of the .obj-files into strings?

We thought about minimizing the .obj files itself and reducing vertices. Maybe someone of you made similar experiences and / or can give us suggestions how to solve this problem.

Thank you in advance :-)

Upvotes: 0

Views: 111

Answers (1)

Don McCurdy
Don McCurdy

Reputation: 11960

OBJ files are text-based, and unfortunately not a particularly efficient way to transfer 3D data. A-Frame has to parse that text to get your data uploaded to the GPU.

If you need to avoid that, I'd suggest trying to convert your OBJ files to a binary format like glTF (.glb). You can do that conversion with obj2gltf (CLI) or https://cesiumjs.org/convertmodel.html (web). A glTF file will load more quickly.

Upvotes: 3

Related Questions