Export a big scene to .babylon

i import a .glb model. then export scene to .babylon file.
It reported an error while serializing the scene:
Uncaught (in promise) RangeError: Invalid string length

I tried a few things, including shard serialization, but it didn’t work.

I wonder if babylon can provide a public method to export the big scene .babylon file for our use?Thanks very much!

this is my pg:

cc @alexchuber to check as this is related to serializer :slight_smile:

1 Like

Indeed, the serialization object is too big to be stringified in your PG. I’ll give our serializer a look to see if there’s anything we can improve, but this may just be a limitation of the .babylon format-- JSON isn’t ideal for storing tons of binary data.

Have you considered using our glTF exporter instead?

When I see such (quite) a big files which come from CAD tools like Solidworks, I always wonder how much it could be optimized without visual difference.
The size of your GLB is 343 Mb, no textures, mainly geometry (more than 10 000 000 indices).
The simplest and quickest optimization with gltf-transform

gltf-transform optimize ttt.glb ttt2.glb

reduces the file size to 2.9 Mb.
And, of course, this file is much better for serialization. Also, it loads a bit faster :slight_smile: Example - https://playground.babylonjs.com/#J6VHQZ#2
Note that the size of the exported .babylon file is around 136 Mb. I believe it is better to use GLB format in your case.
You may try to perform different optimizations online here - https://glb.babylonpress.org/ and check visual differences, but due to complexity of your files I would recommend to use GLTF-Transform CLI, it is just faster.

2 Likes

All I need is to export the .babylon file. Thank you for your reply. I will try it!