MaterialX icon indicating copy to clipboard operation
MaterialX copied to clipboard

Web Viewer: Add support for drag-and-drop of materials with image references

Open kwokcb opened this issue 2 years ago • 6 comments

Issue

If you drag-drop a MTLX file with image dependencies the image dependencies cannot be found to be bound. Seems to be the case for

  1. Image files in same folder as MTLX file
  2. Image files in sub-folders of MTLX file
  3. Image files in sibling or parent folders

Perhaps this is due to the usage of relative file paths, though would think that 1 would work.

Diagnosis

Found while loading and examining the console log in a browser.

kwokcb avatar Jan 05 '24 19:01 kwokcb

Can I pick this issue for the dev day 2024 ?

Avgilles avatar Sep 24 '24 22:09 Avgilles

Absolutely, and welcome!

jstone-lucasfilm avatar Sep 24 '24 22:09 jstone-lucasfilm

As an FYI, AFAIK this could just not be feasible to do as you can't access local file paths due to security. Thus drag-and-drop supports zip files load. If there is a way @Avgilles, I'd be very interested in how to set this up :).

kwokcb avatar Sep 24 '24 23:09 kwokcb

Hello, is there is a way to have resolve path in material X (like asset resolver in USD ) ? I see here that the path is get in local when it's drag and drop, but the buffer store the blob url, maybe I can get the blob url and resolve it ? @kwokcb https://github.com/AcademySoftwareFoundation/MaterialX/blob/e6b96502e965392c8851bab9de847d3135a48396/javascript/MaterialXView/source/helper.js#L117

Avgilles avatar Sep 27 '24 12:09 Avgilles

When all the files are dropped together (or the folder containing them), then the references can indeed be resolved with a custom loader. (this is, for example, how all glTF viewers work when dropping .gltf + .bin + some textures).

I'll see if I find time to fix this :)

hybridherbst avatar Oct 04 '24 16:10 hybridherbst

Hi @hybridherbst,

Thanks for you comments on this.

Actually @Avgilles was trying to do this for ASWF dev days but if Gilles is still interested maybe just some pointers would be appreciated.

Also, the case I don't think is possible is drag-and-drop only the MaterialX file (not the folder or other with images files) and have the file references inside the MaterialX file parsed to load in associated images.

kwokcb avatar Oct 04 '24 18:10 kwokcb