How to calculate the file size after three.js scene saves GLB

How to calculate the size of scene to GLB file? Including geometry and material
I can probably get the number of points and triangles in the scene, as well as the images used for texture.
How can I calculate the size of the GLB file after it is actually stored

If the glb file is represented as an instance of ArrayBuffer, you can get the size via the byteLength property.

Do I need to export every time I get the size?

Well, you need the ArrayBuffer representation to determine the size. I see no other way of doing this.

Can I pass the scene through worker, and then return the size of arraybuffer. In order to carry out multi-threaded hype, but I have tried many ways, and can’t directly deliver scene. Do you have any ways to deliver scene between different pages?

Transferring the scene to a Web Worker also requires converting it to an ArrayBuffer, or at least JSON.

You could get a rough estimate maybe by summing the sizes of all geometries, textures, and animations in the scene. But there’s no way to get an exact size of a GLB without creating the GLB.

But the scene conversion GLB or JSON will cause the scene to jam. I still want to deal with my calculation problem through multithreading. Is there any way to let multithreading join my calculation?

I would suggest trying to compute an estimate instead of an exact size, or else creating a parallel copy of the scene on the Web Worker in advance, so it’s already available there when you need to compute size.

1 Like

If you calculate the estimate every time, the scene will also get stuck. How to implement the other methods? How can I pass it to another scene every time I add a model or texture? Is the tojson method?

I don’t know English very well. I translate it with a translator. I’m sorry.