Which technique do you use to compress scene json file?

When we download a scene from playcanvas studio, the scene json file is quite compressed with unreadable format if I select “optimize scene format” enabled.

Sometimes I want to go through a post process with scene file. Then I have to disable the option.

But I still need a compressed version when it goes to production.

So, I just wonder if I can do the same action by myself.
compress-json - npm (npmjs.com)

this opensource project seems doing the similar task,but somehow the output looks little different.

Can anyone tried this without studio export?

It replaces long IDs by short ids, and does some compression (don’t remember the details) to transform storage, and possibly few others, but it was a pretty simple compression.

The decompression code is here: https://github.com/playcanvas/engine/tree/main/src/scene/compress

It’s called on an array of entity data in the scene:

So you’d have a to write a custom compressor here, as that is not part of the engine.

1 Like