question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support exporting embedded .gltf

See original GitHub issue

Is your feature request related to a problem? Please describe.

Currently (using WebIO in my case), you can use the writeBinary function to export as .glb, and the writeJSON function to export as .gltf with external resources.

It would be useful to have also the “.gltf embedded” option like blender does:

In my usecase, I need the json to be stored in another json file.

Describe the solution you’d like A function like writeJSONEmbedded or something that returns just the json object with the resources embedded in base64 in the object.

Describe alternatives you’ve considered Doing it myself (geometry only in this case):

const encodedBuffer = base64js.fromByteArray(new Uint8Array(resources['.bin']));
gltfCompressed.buffers[0].uri = `data:application/octet-stream;base64,${encodedBuffer}`;

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
lexaknyazevcommented, Oct 29, 2021

This adds a 25-30% size penalty

Nit: base64 encodes each 3 bytes as 4, so it adds 33% size penalty.

1reaction
donmccurdycommented, Oct 29, 2021

There are no Data URIs in a .glb file1 – it’s binary data with the JSON prepended, similar to a file header. A .gltf file cannot contain binary data and so encoding binary as Data URIs (base64 strings) is necessary instead. This adds a 25-30% size penalty compared to binary data in a .glb, and decoding the Data URI can sometimes block the main thread in web browsers. If the final assets were gzipped, the size penalty might be lower but additional parsing cost is the same.

<small>1 Technically you could combine them, but there’s no reason to and I’ve never seen it done.</small>

Read more comments on GitHub >

github_iconTop Results From Across the Web

Exporting gltf embedded - Questions
Hello, I am trying to export a gltf File but the goal is to have only one file without the .bin BABYLON.GLTF2Export.
Read more >
A Step-by-Step Guide to Exporting glTF Files From Blender
Run the Blender application. Go to Edit > Preferences > Add-ons; Search for 'glTF'; Enable Import-Export glTF 2.0 format.
Read more >
glTF 2.0 (GLTF/GLB) File
Select the menu/tool indicated in Location. → The Save File window opens. · Select the desired saving path and click Save. → The...
Read more >
glTF 2.0 — Blender Manual
The exporter supports Metal/Rough PBR (core glTF) and Shadeless ( KHR_materials_unlit ) materials. It will construct a glTF material based on the nodes...
Read more >
Best practices for .gltf / .glb · Issue #1117
Documentation for when to export/import .gltf / .glb for different types of apps, e.g., desktop vs. web, consumer vs. developer, etc.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found