Closed gdagstn closed 2 years ago
glTF files aren't self contained. The data is in a separate file, and it needs to be available to the viewer as well. Unfortunately your viewer doesn't tell you the name that's missing, but if you run print(as.gltf(sc), verbose = "buffers")
it will be in the uri
field. It's probably test_withnames.bin
.
Thanks for the quick response!
Indeed I did think I was missing a .bin file, but there are none to be found in the folder I'm working at.
If I run print(as.gltf(sc), verbose = "buffers")
, here's my output:
asset fields:
GLtf version 2.0 file.
Generated by rgl2gltf version 0.1.12.
Scenes ( 1 )
Nodes ( 13 )
Buffers:
Buffer 0:
byteLength: 9912
Other buffer fields: bytes.
Bufferviews ( 30 )
Meshes ( 10 )
Accessors ( 30 )
Materials ( 6 )
Other fields: extras.
The uri
field is missing.
If I do the same with another glTF file downloaded from somewhere else, I do see it:
asset fields:
GLtf version 2.0 file.
Generated by Sketchfab-12.74.0.
extras Haider Al_Asady (https://sketchfab.com/haiderhabbeb313), CC-BY-4.0 (http://creativecommons.org/licenses/by/4.0/), https://sketchfab.com/3d-models/millitary-locker-cbe0943ab7dd4a2d907f6e77f4bee008, millitary locker
Scenes ( 1 )
Nodes ( 10 )
Buffers:
Buffer 0:
uri: scene.bin
byteLength: 169872
Bufferviews ( 4 )
Meshes ( 4 )
Accessors ( 20 )
Materials ( 4 )
Textures ( 12 )
Images ( 12 )
Other fields: samplers.
Sorry, the .bin
file gets created by writeglTF
. You need to write it out, read it back in, and then do the verbose print.
Sorry, still no luck:
sc_gltf = as.gltf(sc)
writeglTF(sc_gltf, path = "test.gltf")
sc_gltf_in = readglTF(path = "test.gltf")
print(sc_gltf_in, verbose = "buffers")
asset fields:
GLtf version 2.0 file.
Generated by rgl2gltf version 0.1.12.
Scenes ( 1 )
Nodes ( 18 )
Buffers:
Buffer 0:
byteLength: 14868
Other buffer fields: bytes.
Bufferviews ( 45 )
Meshes ( 15 )
Accessors ( 45 )
Materials ( 6 )
Other fields: extras.
And I still don't have any .bin
file in my directory... am I missing something?
You're right, that's a bug in the design of writeglTF
. It doesn't attempt to write the binary data.
Specs
Issue
Hi, I am using
rgl
to generatescene3d
objects to load as GLB files in a three.js renderer, usingrgl2gltf
for the conversion and writing.Somehow the glTF files do not display properly in an engine that displays glTF scenes (three.js or otherwise), while the GLB files do.
When I load the glTF files on a viewer such as this one (https://sandbox.babylonjs.com/) an error code pops up regarding "missing the Uri or the binary chunk". In fact while the glTF files I can download from the internet are structured as JSON objects (that come together with a .bin file), the ones coming from
rgl2gltf
are different - actually .GLB and .gltf files look remarkably similar when opened in a text editor.Reprex:
Then I go to the viewer and drag and drop the files; only the GLB files can be loaded.
Error message:
I wonder if there is anything I should be doing differently?
Thanks!