Skip to content

Conversation

@ariankordi
Copy link

Currently, the output from cgltf is unminified and formatted. This is great for inspecting and debugging the output, but it'd also be nice to have minified JSON when not debugging.

In my testing, this can trim off a few KB. In practice, this lets me run a little snippet I made to view beautified GLB JSON that I couldn't use before:

> strings test.glb | awk -F'  ' '/JSON/ {print substr($1,5)}' | python3 -m json.tool
{
    "accessors": [
        {
            "bufferView": 0,
            "componentType": 5123,
            "type": "SCALAR",
            "count": 426
        },
...

What I chose to do in this PR is add a CGLTF_MINIFY option along with some other macros that get redefined when minifying. This required using find-and-replace to change, so there's a chance I missed a spot.
When I tested without defining the macro (default), my test GLB is byte-per-byte same as before. Then when enabling the new macro I can't find any remaining unminified JSON.

Let me know if there's improvements to make, or if this affects maintainability and whatnot. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant