BabylonJS / Babylon.js

Babylon.js is a powerful, beautiful, simple, and open game and rendering engine packed into a friendly JavaScript framework.
http://www.babylonjs.com
Apache License 2.0
23.17k stars 3.42k forks source link

KTX2 with KHR_image_basisu fails to load when using .glb/.bin embedding #8394

Closed zeux closed 4 years ago

zeux commented 4 years ago

The attached file contains several variants of a model, exported with gltfpack using KHR_image_basisu with KTX2 containers.

The "separate" version loads fine in Babylon JS using latest sandbox; this is the version with separate files. Both "embedded" (textures inside .bin) and glb (single file) versions fail to load with a 2 MB error message along the lines of

Uncaught (in promise) Error: /textures/1: Error while trying to load image: 171,75,84,88,32,50,48,187,13,10,26,10,0,0,0,0,1,0,0,0,0,8,0,0,0,8,0,0,0,0,0,0,0,0,0,0,1,0,0,0,12,0,0,0,1,0,0,0,112,1,0,0,76,0,0,0,188,1,0,0,24,0,0,0,216,1,0,0,0,0,0,0,199,36,0,0,0,0,0,0,51,149,2,0,0,0,0,0,130,97,5,0,0,0,0,0,0,0,0,0,0,0,0,0,187,221,0,0,0,0,0,0,120,183,1,0,0,0,0,0,0,0,0,0,0,0,0,0,32,89,0,0,0,0,0,0,155,132,0,0,0,0,0,0,0,0,0,0,0...

  • Fallback texture was used

It would be nice to emit shorter error messages :) and also indicate the reason for the error. I'm reasonably sure that the file in question is correct, and it's a bug in Babylon.JS. Unsure what the problem is precisely, as the file header looks correct based on the error message (starts with "\xAB KTX 20"); maybe the MIME type isn't recognized correctly?

rubyrose.zip

bghgary commented 4 years ago

Thanks @zeux for the report! I fixed this issue and fixed a bunch of other error handling issues too.

That's a nice looking model. Where is it from?

zeux commented 4 years ago

gltfpack always preserves asset metadata to be fair to the creators :) https://sketchfab.com/3d-models/ruby-rose-2270ee59d38e409491a76451f6c6ef80