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.

GLTFExporter: jpeg textures on export binary and embedImages=false cause validation error

See original GitHub issue

Heya,

when exporting a material with a jpeg texture as a .glb with these options:

{
    binary: true,
    embedImages: false
}

The resulting .glb has a validation error:

      {
        "code": "IMAGE_MIME_TYPE_INVALID",
        "message": "Recognized image format 'image/jpeg' does not match declared image format 'image/png'.",
        "severity": 0,
        "pointer": "/images/0"
      },

It seems three.js exports the texture with the image/png mime type, regardless of what type the image actually is: ...,"images":[{"mimeType":"image/png","uri":"data:image/jpeg;base64,....

I had a brief look around but couldn’t find a way to set the mime type manually (but maybe I missed something…).

Working example: https://framer.tz1and.com/ Source: https://github.com/tz1and/image-framer/blob/main/src/index.js

Thanks!

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:13 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
elalishcommented, May 2, 2022

I’m in favor of removing that option. Single-file GLBs are way more popular anyway, and if someone really wants to separate them they can always use gltf-pipeline or similar.

1reaction
852Kerfunklecommented, May 5, 2022

@Mugen87 Thank you for resolving this bug.

And just to leave a related comment: #23592 works great. I suppose it would be nice to have some way of preserving the source image. Quality loss on jpeg recompression and all that. Maybe something akin to #23592 can be done - store the original texture in userData. Just an idea, I’m certainly happy with the status quo.

Read more comments on GitHub >

github_iconTop Results From Across the Web

GLTFExporter – three.js docs
External files store textures (.jpg, .png) and additional binary data (.bin). A glTF asset may deliver one or more scenes, including meshes, materials,...
Read more >
glTF texture export error - Development - VTK Discourse
I have a .vtu file with scalardata that renders fine in VTK viewers but the texture doesn't export correctly to glTF format. I...
Read more >
class GLTFExporter | Simplygon 9 Documentation
class GLTFExporter. glTF geometry exporter capable of exporting both glTF and GLB files determined by output path extension. Textures and binary blob files ......
Read more >
Exporting Unreal Engine Content to glTF
Use the glTF exporter to export individual Assets or the current Level to one ... It can be difficult to troubleshoot errors caused...
Read more >
glTF 2.0 — Blender Manual
Menu: File ‣ Import/Export ‣ glTF 2.0 (.glb, .gltf) ... When image textures are used by materials, glTF requires that images be in...
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