Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UsdGlTFFileFormat::Read fails to files with non-filesystem resolvedPaths. #24

Closed
expenses opened this issue Jan 13, 2024 · 4 comments
Closed

Comments

@expenses
Copy link
Contributor

Hi! I tried to get guc working with the custom resolver I've been working on but unfortunately it fails upon trying to load the file:
Failed to open "iroh://doc/pajzuzssv2l7wg7iruxixkbc7nfcm42gqfqbmzz5hux4im4v2yea/m5wfirrpirqw2ylhmvseqzlmnvsxilthnr2gmaa.gltf" - unable to parse glTF file: file not found

The problem is that this code assumes that resolvedPath is on the local filesystem:

bool UsdGlTFFileFormat::Read(SdfLayer* layer,
const std::string& resolvedPath,
bool metadataOnly) const
{
cgltf_data* gltf_data = nullptr;
if (!load_gltf(resolvedPath.c_str(), &gltf_data))
{
TF_RUNTIME_ERROR("unable to load glTF file %s", resolvedPath.c_str());
return false;
}

Ideally you'd call something like ArGetResolver().OpenAsset(resolvedPath) to get an ArAsset and then use the bytes from ArAsset::GetBuffer to load the glTF data. This is a bit of a hastle not gonna lie, but it would mean that assets using custom URI schemas (iroh:// for me, but also http://) would load perfectly.

@pablode
Copy link
Owner

pablode commented Jan 13, 2024

Thank you very much for this report! This is an oversight, and your proposed solution makes sense. Will implement it soon-ish!

@expenses
Copy link
Contributor Author

Additionally, I think you want to return relative paths for existing on-disk assets. At the moment you get absolute paths like @/home/ashley/projects/glTF-Sample-Models/2.0/DamagedHelmet/glTF/Default_normal.jpg@ which a HTTP resolver isn't going to be able to resolve if the anchor path looks like http://localhost:8000/DamagedHelmet.gltf. I haven't done a deep dive into how the internals work yet, so I'm not sure how the the images embedded in a binary file like http://localhost:8000/DamagedHelmet.glb should be resolved. Presumably just extracted to a temporary directory?

@pablode
Copy link
Owner

pablode commented Apr 20, 2024

Hi, I just implemented the feature in this branch. I have yet to test it with an actual custom resolver.

EDIT: it's now in dev and will be released soon.

@pablode
Copy link
Owner

pablode commented Jul 15, 2024

This is now implemented in v0.4, thanks for the patience!

@pablode pablode closed this as completed Jul 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants