Reading glb with external resource uri (with absolute paths) #644
-
Hi, I see from #193 (comment) that it's not possible to resolve relative paths in In the source of Is there any way to handle this? I thought of replacing the external images with placeholder data URIs, but I guess from the source, that will not work either. Thanks. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
If you use a method that takes a URI or path, these external references can be resolved: const document = await io.readBinary('path/to/model.glb');
const jsonDocument = await io.readAsJSON('path/to/model.glb'); If the GLB is already in memory and that's not an option, then I think the only workaround the library currently supports would be to unpack the GLB container manually (example), append the resources you need to the Perhaps we could make that second method a bit easier by adding a second parameter to the const jsonDocument = io.binaryToJSON(binary, skipExternal = true); That option hasn't been added yet, and isn't the default behavior because I do think it's important to know that the JSONDocument returned is not actually self-contained. But adding the option would sound reasonable to me. |
Beta Was this translation helpful? Give feedback.
If you use a method that takes a URI or path, these external references can be resolved:
If the GLB is already in memory and that's not an option, then I think the only workaround the library currently supports would be to unpack the GLB container manually (example), append the resources you need to the
resources
map, and then parse it withio.readJSON(...)
.Perhaps we could make that second method a bit easier by adding a second parameter to the
binaryToJSON
method, allowing you to "opt out" of the checks for external resources: