MaterialXLab API
0.0.1
APIs For MaterialXLab Libraries
|
This class extends the MxGraphHandler class to provide MaterialX-specific functionality for handling MaterialX graphs within the editor. More...
Public Member Functions | |
constructor (id, extension) | |
Constructor for the MxMaterialXHandler class. | |
loadMaterialX () | |
Load in the MaterialX library. | |
loadLibraryDocument (editor, materialFilename) | |
Load the MaterialX document from library into the editor. | |
initialize (editor, materialFilename) | |
Initialize the MaterialX handler for the given editor. | |
findRenderableItems (graph) | |
Find all MaterialX renderable items in a graph. | |
findRenderableItemsInDoc (mdoc) | |
Find all renderable items in the MaterialX document. | |
buildMetaData (colorSpace, unit, unitType, uiname, uimin, uimax, uifolder, _type) | |
Builds and returns metadata for a node based on the provided parameters. | |
createLiteGraphDefinitions (doc, debug, addInputOutputs, definitionsList, libraryPrefix='mtlx', editor, icon='') | |
Creates LiteGraph node definitions based on the MaterialX document. | |
validateDocument (doc) | |
Validates the provided MaterialX document. | |
saveGraphToDocument (graph, graphWriteOptions) | |
Saves the graph to a MaterialX document. | |
saveGraphToString (extension, graph, graphWriteOptions) | |
Saves the graph to a string in the specified format. | |
saveGraphToFile (extension, graph, graphWriteOptions) | |
Saves the graph to a file with the specified extension. | |
writeGraphToDocument (mltxgraph, graph, graphWriteOptions) | |
Writes the graph to the specified MaterialX document. | |
isArray (_type) | |
Determines if the specified type is an array type. | |
buildConnections (editor, node, lg_node, explicitInputs, graph, parentGraph) | |
Builds the connections between MaterialX nodes. | |
loadInputMetaData (node, input, property_info) | |
Set the meta-data for the specified input based on LiteGraph node property info. | |
buildGraphFromDoc (doc, editor, auto_arrange) | |
Builds the LiteGraph graph from the specified MaterialX document. | |
loadDefinitionsFromFile () | |
Load MaterialX document containing node definitions from a file. | |
loadFromString (extension, fileContents, fileName, auto_arrange) | |
Load graph editor from a string. | |
loadFromFile (extension, file, fileName, editor, auto_arrange) | |
Load graph editor from a file. | |
loadFromZip (extension, file, fileName, editor, auto_arrange) | |
loadMaterialXLibraries (stdlib) | |
Load MaterialX definition libraries. | |
createValidName (name, msg=null) | |
Create a valid MaterialX name within the context of the current graph. | |
Public Member Functions inherited from MxGraphHandler | |
constructor (id, extension) | |
addConverter (converter) | |
Add a converter to the handler. | |
setMonitor (monitor) | |
Set the monitor for the handler. | |
canExport (extension) | |
Return if the handler can export to the given extension / format. | |
getExporter (extension='') | |
Find the first exporter that can export to the given extension / format. | |
canImport (extension) | |
Return if the handler can import the given extension / format. | |
getImporter (extension='') | |
Find the first importer that can import the given extension / format. | |
setColorSpaces (colorSpaces) | |
Set the color spaces used by the handler. | |
getColorSpaces () | |
Get the color spaces used by the handler. | |
setUnits (units) | |
Set the units used by the handler. | |
getUnits () | |
Get the units used by the handler. | |
setSourceColorSpace (colorSpace) | |
Set the source color space for the handler. | |
setTargetDistanceUnit (unit) | |
Set the target distance unit for the handler. | |
getSourceColorSpace () | |
Get the source color space for the handler. | |
getTargetDistanceUnit () | |
Get the target distance unit for the handler. | |
getExtension () | |
Get the extension /format for the handler. | |
initialize (editor) | |
Initialize the handler for the given editor. | |
createValidName (name) | |
Create a valid name for the given name. | |
getDefaultValue (value, _type) | |
Get default value as a string for the given value and type. | |
This class extends the MxGraphHandler class to provide MaterialX-specific functionality for handling MaterialX graphs within the editor.
Definition at line 923 of file JsMaterialXNodeEditor.js.
MxMaterialXHandler::buildConnections | ( | editor, | |
node, | |||
lg_node, | |||
explicitInputs, | |||
graph, | |||
parentGraph ) |
Builds the connections between MaterialX nodes.
editor | - The graph editor. |
node | - The MaterialXnode to build connections for. |
lg_node | - The LiteGraph node |
explicitInputs | - The explicit inputs to the node. |
graph | - The LiteGraph parent. |
parentGraph | - The parent MaterialX graph. |
Definition at line 2240 of file JsMaterialXNodeEditor.js.
MxMaterialXHandler::buildGraphFromDoc | ( | doc, | |
editor, | |||
auto_arrange ) |
Builds the LiteGraph graph from the specified MaterialX document.
doc | - The MaterialX document to build the graph from. |
editor | - The graph editor. |
auto_arrange | - True to auto-arrange the graph, false otherwise. |
Definition at line 2439 of file JsMaterialXNodeEditor.js.
MxMaterialXHandler::buildMetaData | ( | colorSpace, | |
unit, | |||
unitType, | |||
uiname, | |||
uimin, | |||
uimax, | |||
uifolder, | |||
_type ) |
Builds and returns metadata for a node based on the provided parameters.
This metadata can be used to enhance the node's representation and interaction within the UI, specifying details like color space, unit, and UI properties.
colorSpace | - The color space of the node (e.g., 'sRGB', 'linear'). |
unit | - The unit of measurement for the node's value (e.g., 'meters', 'seconds'). |
unitType | - The type of unit measurement (e.g., 'distance', 'time'). |
uiname | - The name to display in the UI for this node. |
uimin | - The minimum value allowed for this node in the UI. |
uimax | - The maximum value allowed for this node in the UI. |
uifolder | - The folder/group in the UI where this node should be placed. |
_type | - The data type of the node (e.g., 'float', 'vector3'). |
Definition at line 1169 of file JsMaterialXNodeEditor.js.
MxMaterialXHandler::constructor | ( | id, | |
extension ) |
Constructor for the MxMaterialXHandler class.
id | - The identifier for the handler. |
extension | - The associated extension for the handler. |
Definition at line 931 of file JsMaterialXNodeEditor.js.
MxMaterialXHandler::createLiteGraphDefinitions | ( | doc, | |
debug, | |||
addInputOutputs, | |||
definitionsList, | |||
libraryPrefix = 'mtlx', | |||
editor, | |||
icon = '' ) |
Creates LiteGraph node definitions based on the MaterialX document.
This function parses the MaterialX document to extract node definitions and generates Javascript code for corresponding LiteGraph nodes that can be used within the editor.
doc | - The MaterialX document to parse. |
debug | - Flag to enable debug logging. |
addInputOutputs | - Flag to determine whether to add inputs and outputs to the LiteGraph nodes. |
definitionsList | - List to store the generated LiteGraph node definitions. |
libraryPrefix | - Prefix to use for the LiteGraph nodes, default is 'mtlx'. |
editor | - The instance of the editor where the nodes will be used. |
icon | - Icon to use for the LiteGraph nodes, default is an empty string. |
Definition at line 1206 of file JsMaterialXNodeEditor.js.
MxMaterialXHandler::createValidName | ( | name, | |
msg = null ) |
Create a valid MaterialX name within the context of the current graph.
name | - The name to validate. |
msg | - The message to display if the name is invalid. |
Definition at line 3097 of file JsMaterialXNodeEditor.js.
MxMaterialXHandler::findRenderableItems | ( | graph | ) |
Find all MaterialX renderable items in a graph.
graph | - The graph to scan. |
Definition at line 1085 of file JsMaterialXNodeEditor.js.
MxMaterialXHandler::findRenderableItemsInDoc | ( | mdoc | ) |
Find all renderable items in the MaterialX document.
mdoc | - The MaterialX document to scan. |
Definition at line 1102 of file JsMaterialXNodeEditor.js.
MxMaterialXHandler::initialize | ( | editor, | |
materialFilename ) |
Initialize the MaterialX handler for the given editor.
Initializes MaterialX and sets up the MaterialX document and standard libraries. If a default MaterialX document is provided, it will be loaded into the editor. The standard libraries are scanned for colorspaces and units, which are cached for later usage.
editor | - The editor instance |
materialFilename | - The filename of the default MaterialX document to graph |
Definition at line 991 of file JsMaterialXNodeEditor.js.
MxMaterialXHandler::isArray | ( | _type | ) |
Determines if the specified type is an array type.
_type | - The type to check. |
Definition at line 2222 of file JsMaterialXNodeEditor.js.
MxMaterialXHandler::loadDefinitionsFromFile | ( | ) |
Load MaterialX document containing node definitions from a file.
Definition at line 2757 of file JsMaterialXNodeEditor.js.
MxMaterialXHandler::loadFromFile | ( | extension, | |
file, | |||
fileName, | |||
editor, | |||
auto_arrange ) |
Load graph editor from a file.
extension | - The extension indicating the format of the file. |
file | - The file to load the graph from. |
fileName | - The identifier for the source file, or a arbitrary name. |
editor | - The graph editor. |
auto_arrange | - True to auto-arrange the graph, false otherwise. |
Definition at line 2989 of file JsMaterialXNodeEditor.js.
MxMaterialXHandler::loadFromString | ( | extension, | |
fileContents, | |||
fileName, | |||
auto_arrange ) |
Load graph editor from a string.
extension | - The extension indicating the format of the string. |
fileContents | - The document string. |
fileName | - The identifier for the source file, or a arbitrary name. |
auto_arrange | - True to auto-arrange the graph, false otherwise. |
Definition at line 2843 of file JsMaterialXNodeEditor.js.
MxMaterialXHandler::loadFromZip | ( | extension, | |
file, | |||
fileName, | |||
editor, | |||
auto_arrange ) |
Definition at line 3021 of file JsMaterialXNodeEditor.js.
MxMaterialXHandler::loadInputMetaData | ( | node, | |
input, | |||
property_info ) |
Set the meta-data for the specified input based on LiteGraph node property info.
node | - The MaterialX node parent of the input. If parent is a nodegraph then null is passed in. |
input | - The input to load the meta-data for. |
property_info | - The property info object to load the meta-data into. |
Definition at line 2365 of file JsMaterialXNodeEditor.js.
MxMaterialXHandler::loadLibraryDocument | ( | editor, | |
materialFilename ) |
Load the MaterialX document from library into the editor.
editor | - The editor instance. |
materialFilename | - The filename of the library MaterialX document to graph. |
Definition at line 959 of file JsMaterialXNodeEditor.js.
MxMaterialXHandler::loadMaterialX | ( | ) |
Load in the MaterialX library.
Sets the global ne_mx variable to the MaterialX instance.
Definition at line 941 of file JsMaterialXNodeEditor.js.
MxMaterialXHandler::loadMaterialXLibraries | ( | stdlib | ) |
Load MaterialX definition libraries.
Definition at line 3070 of file JsMaterialXNodeEditor.js.
MxMaterialXHandler::saveGraphToDocument | ( | graph, | |
graphWriteOptions ) |
Saves the graph to a MaterialX document.
graph | - The graph to save. |
graphWriteOptions | - Options to use when writing the graph. |
Definition at line 1790 of file JsMaterialXNodeEditor.js.
MxMaterialXHandler::saveGraphToFile | ( | extension, | |
graph, | |||
graphWriteOptions ) |
Saves the graph to a file with the specified extension.
extension | - The file extension to save the graph as. |
graph | - The graph to save. |
graphWriteOptions | - Options to use when writing the graph. |
Definition at line 1900 of file JsMaterialXNodeEditor.js.
MxMaterialXHandler::saveGraphToString | ( | extension, | |
graph, | |||
graphWriteOptions ) |
Saves the graph to a string in the specified format.
extension | - The file extension to save the graph as. |
graph | - The graph to save. |
graphWriteOptions | - Options to use when writing the graph. |
Definition at line 1847 of file JsMaterialXNodeEditor.js.
MxMaterialXHandler::validateDocument | ( | doc | ) |
Validates the provided MaterialX document.
doc | - The MaterialX document to validate. |
Definition at line 1764 of file JsMaterialXNodeEditor.js.
MxMaterialXHandler::writeGraphToDocument | ( | mltxgraph, | |
graph, | |||
graphWriteOptions ) |
Writes the graph to the specified MaterialX document.
mltxgraph | - The MaterialX document to write the graph to. |
graph | - The graph to write. |
graphWriteOptions | - Options to use when writing the graph. |
Definition at line 1923 of file JsMaterialXNodeEditor.js.