Skip to main content

Function: resolveMaterialXResources()

resolveMaterialXResources(document, readResource, options?): Promise<MaterialXResource[]>

Collects every file referenced by a document and rewrites the references to archive paths.

Walks file/filename/href/uri/source attributes and any type="filename" value, rejects external (http:), absolute, or root-escaping references, reads each unique file via readResource, assigns it an archive path under textures/, libraries/, or resources/, and rewrites the document's attributes in place to those paths.

Example:

const resources = await resolveMaterialXResources(document, (rel) => readFile(path.join(rootDir, rel)));

Parameters​

document​

MaterialXDocument

readResource​

ResourceReader

options?​

limits?​

Partial<MaterialXReadLimits>

rootPath?​

string

Returns​

Promise<MaterialXResource[]>