Skip to main content

index

Other​

getNodeCatalog()​

function getNodeCatalog(document?, registry?): MaterialXNodeSpec[];

Parameters​

ParameterType
document?MaterialXDocument
registry?MaterialXNodeSpec[]

Returns​

MaterialXNodeSpec[]


Point​

Persisted node coordinates; default placement belongs to the viewer.

Properties​

PropertyType
xnumber
ynumber

GraphConnection​

Extended by​

Properties​

PropertyType
sourcestring
sourceHandlestring
targetstring
targetHandlestring

GraphEdge​

Extends​

Properties​

PropertyTypeInherited from
sourcestringGraphConnection.source
sourceHandlestringGraphConnection.sourceHandle
targetstringGraphConnection.target
targetHandlestringGraphConnection.targetHandle
idstring-

graphScopes()​

function graphScopes(document): string[];

Parameters​

ParameterType
documentMaterialXDocument

Returns​

string[]


addNode()​

function addNode(
document,
spec,
position?,
scope?
): MaterialXDocument;

Parameters​

ParameterType
documentMaterialXDocument
specMaterialXNodeSpec
position?Point
scope?string

Returns​

MaterialXDocument


cloneNode()​

function cloneNode(
document,
id,
position?,
scope?
): MaterialXDocument;

Copy a node's values and incoming connections, leaving downstream connections unchanged.

Parameters​

ParameterType
documentMaterialXDocument
idstring
position?Point
scope?string

Returns​

MaterialXDocument


setInputValue()​

function setInputValue(
document,
node,
input,
value,
scope?,
catalog?,
valueType?
): MaterialXDocument;

Parameters​

ParameterType
documentMaterialXDocument
nodestring
inputstring
valuestring
scope?string
catalog?MaterialXNodeSpec[]
valueType?string

Returns​

MaterialXDocument


resetInput()​

function resetInput(
document,
node,
input,
scope?
): MaterialXDocument;

Parameters​

ParameterType
documentMaterialXDocument
nodestring
inputstring
scope?string

Returns​

MaterialXDocument


connectionError()​

function connectionError(
document,
connection,
scope?,
catalog?
): string | undefined;

Parameters​

ParameterType
documentMaterialXDocument
connectionGraphConnection
scope?string
catalog?MaterialXNodeSpec[]

Returns​

string | undefined


connectNodes()​

function connectNodes(
document,
connection,
scope?,
catalog?
): MaterialXDocument;

Parameters​

ParameterType
documentMaterialXDocument
connectionGraphConnection
scope?string
catalog?MaterialXNodeSpec[]

Returns​

MaterialXDocument


disconnectInput()​

function disconnectInput(
document,
target,
input,
scope?
): MaterialXDocument;

Parameters​

ParameterType
documentMaterialXDocument
targetstring
inputstring
scope?string

Returns​

MaterialXDocument


removeNodes()​

function removeNodes(
document,
ids,
scope?
): MaterialXDocument;

Parameters​

ParameterType
documentMaterialXDocument
idsstring[]
scope?string

Returns​

MaterialXDocument


moveNodes()​

function moveNodes(
document,
positions,
scope?
): MaterialXDocument;

Parameters​

ParameterType
documentMaterialXDocument
positionsRecord<string, Point>
scope?string

Returns​

MaterialXDocument


renameNode()​

function renameNode(
document,
id,
name,
scope?
): MaterialXDocument;

Rename a node and every reference to it: sibling wires, interface names, nested graph paths, and material assignments.

Parameters​

ParameterType
documentMaterialXDocument
idstring
namestring
scope?string

Returns​

MaterialXDocument


nodeType​

const nodeType: (spec) => string | undefined;

Parameters​

ParameterType
specMaterialXNodeSpec

Returns​

string | undefined


findNodeSpec()​

function findNodeSpec(element, catalog): MaterialXNodeSpec | undefined;

Parameters​

ParameterType
elementMaterialXElement
catalogMaterialXNodeSpec[]

Returns​

MaterialXNodeSpec | undefined


InputValue​

type InputValue = string | number | boolean | readonly number[];

OutputRef​

Properties​

PropertyType
nodestring
outputstring

InputRef​

Properties​

PropertyType
nodestring
inputstring

EditorDiagnostic​

Properties​

PropertyModifierType
codereadonlystring
messagereadonlystring
scope?readonlystring
node?readonlystring
input?readonlystring

EditorError​

Extends​

  • Error

Constructors​

Constructor​
new EditorError(diagnostic): EditorError;
Parameters​
ParameterType
diagnosticEditorDiagnostic
Returns​

EditorError

Overrides​

Error.constructor

Properties​

code​
readonly code: string;
scope?​
readonly scope?: string;
node?​
readonly node?: string;
input?​
readonly input?: string;

EditorSnapshot​

Properties​

PropertyModifierTypeDescription
documentreadonlyReadonlyMaterialXDocument-
canUndoreadonlyboolean-
canRedoreadonlyboolean-
dirtyreadonlybooleanWhether the document differs from the one last loaded or marked clean.
undoLabel?readonlystring-
redoLabel?readonlystring-
scopereadonlystringView state shared by every surface (canvas, toolbar, inspector); never part of undo history.
selectionreadonlyreadonly string[]Selected node ids in the current scope, in selection order. Ids of removed nodes drop out.
error?readonlystringMessage from the last failed command, until the next command succeeds or clears it.

EditorSessionOptions​

Properties​

PropertyTypeDescription
documentReadonlyMaterialXDocument-
catalog?readonly DeepReadonly<MaterialXNodeSpec>[]A complete catalog; otherwise derive it from the document and standard registry.
historyLimit?number-

EditorSession​

Headless editing state. Only successful commits publish immutable snapshots.

Constructors​

Constructor​
new EditorSession(options): EditorSession;
Parameters​
ParameterType
optionsEditorSessionOptions
Returns​

EditorSession

Methods​

getCatalog()​
getCatalog(): readonly DeepReadonly<MaterialXNodeSpec>[];
Returns​

readonly DeepReadonly<MaterialXNodeSpec>[]

markClean()​
markClean(): void;

Treat the current document as saved; dirty clears until the next edit.

Returns​

void

transaction()​
transaction<T>(label, operation): T;

Synchronous transactions support nested savepoints; an uncaught error rolls back the enclosing transaction.

Type Parameters​
Type Parameter
T
Parameters​
ParameterType
labelstring
operation() => T extends PromiseLike<unknown> ? never : T
Returns​

T

replaceDocument()​
replaceDocument(document): void;

Loading a document accepts existing diagnostics and clears undo/redo. Input ownership stays with the caller.

Parameters​
ParameterType
documentReadonlyMaterialXDocument
Returns​

void

getDiagnostics()​
getDiagnostics(): readonly EditorDiagnostic[];
Returns​

readonly EditorDiagnostic[]

listScopes()​
listScopes(): readonly string[];
Returns​

readonly string[]

graph()​
graph(scope?): Readonly<{
scope: string;
listNodes: () => DeepReadonly<GraphNode[]>;
getNode: (id) => DeepReadonly<GraphNode>;
getInputs: (id) => DeepReadonly<GraphNode["inputs"]>;
getOutputs: (id) => DeepReadonly<GraphNode["outputs"]>;
getConnection: (target) => Readonly<OutputRef> | undefined;
addNode: ({ definition }) => string;
cloneNode: (id) => string;
pasteNodes: (elements, offset?) => string[];
removeNodes: (ids) => void;
groupNodes: (ids) => string;
renameNode: (id, name) => void;
setInterfacePort: (id, changes) => void;
setInputValue: (id, input, value, options?) => void;
resetInput: (id, input) => void;
disconnectInput: (id, input) => void;
checkConnection: (source, target) => EditorDiagnostic | undefined;
connect: (source, target) => void;
}>;

Graph handles resolve against current state, so they remain useful across commits and undo.

Parameters​
ParameterType
scope?string
Returns​

Readonly<{ scope: string; listNodes: () => DeepReadonly<GraphNode[]>; getNode: (id) => DeepReadonly<GraphNode>; getInputs: (id) => DeepReadonly<GraphNode["inputs"]>; getOutputs: (id) => DeepReadonly<GraphNode["outputs"]>; getConnection: (target) => Readonly<OutputRef> | undefined; addNode: ({ definition }) => string; cloneNode: (id) => string; pasteNodes: (elements, offset?) => string[]; removeNodes: (ids) => void; groupNodes: (ids) => string; renameNode: (id, name) => void; setInterfacePort: (id, changes) => void; setInputValue: (id, input, value, options?) => void; resetInput: (id, input) => void; disconnectInput: (id, input) => void; checkConnection: (source, target) => EditorDiagnostic | undefined; connect: (source, target) => void; }>

Properties​

getDocument​
getDocument: () => ReadonlyMaterialXDocument;

Reads inside a transaction see its working snapshot. Subscribers see getSnapshot().

Returns​

ReadonlyMaterialXDocument

getSnapshot​
getSnapshot: () => EditorSnapshot;
Returns​

EditorSnapshot

toXml​
toXml: () => string;
Returns​

string

subscribe​
subscribe: (listener) => () => void;
Parameters​
ParameterType
listener() => void
Returns​

() => void

setScope​
setScope: (scope) => void;

Show the given scope; selection belongs to a scope, so it clears.

Parameters​
ParameterType
scopestring
Returns​

void

select​
select: (ids) => void;
Parameters​
ParameterType
idsreadonly string[]
Returns​

void

setError​
setError: (message?) => void;

Record a failed command for whichever surface shows errors; no argument clears it.

Parameters​
ParameterType
message?string
Returns​

void

undo​
undo: () => void;
Returns​

void

redo​
redo: () => void;
Returns​

void

layout​
readonly layout: object;

Positions remain a separate view operation, but share atomic commits and undo history.

moveNodes​
moveNodes: (positions, scope?) => void;
Parameters​
ParameterType
positionsReadonly<Record<string, Point>>
scope?string
Returns​

void


EditorGraph​

type EditorGraph = ReturnType<EditorSession["graph"]>;

createEditorSession​

const createEditorSession: (options) => EditorSession;

Parameters​

ParameterType
optionsEditorSessionOptions

Returns​

EditorSession


resolveTypes()​

function resolveTypes(document, catalog?): TypeResolution;

Parameters​

ParameterType
documentMaterialXDocument
catalog?MaterialXNodeSpec[]

Returns​

TypeResolution


materializeDocument()​

function materializeDocument(document, catalog?): MaterialXDocument;

Resolve a copy for consumers of concrete MaterialX. Never author defaults or pin inferred types.

Parameters​

ParameterType
documentMaterialXDocument
catalog?MaterialXNodeSpec[]

Returns​

MaterialXDocument


DeepReadonly​

type DeepReadonly<T> = { readonly [K in keyof T]: DeepReadonly<T[K]> };

A recursively read-only view, suitable for immutable editor snapshots.

Type Parameters​

Type Parameter
T

ReadonlyMaterialXDocument​

type ReadonlyMaterialXDocument = DeepReadonly<MaterialXDocument>;

MaterialXElement​

Properties​

PropertyType
namestring
attributesRecord<string, string>
text?string
childrenMaterialXElement[]

MaterialXNodePortSpec​

Properties​

PropertyTypeDescription
namestring-
type?string-
value?stringLiteral default; absent when the definition uses implicit geometry or a connection.
attributes?Readonly<Record<string, string>>Original definition metadata, including uiname, enum, ranges and defaultgeomprop.

GraphToolbar()​

function GraphToolbar(__namedParameters): Element;

Icon toolbar for the session's commands; in view mode only the canvas commands remain. Floats bottom-center of its parent by default.

Parameters​

ParameterType
__namedParameters{ session: EditorSession; editable?: boolean; entries?: readonly CommandEntry[]; className?: string; }
__namedParameters.sessionEditorSession
__namedParameters.editable?boolean
__namedParameters.entries?readonly CommandEntry[]
__namedParameters.className?string

Returns​

Element


MaterialXGraphView()​

function MaterialXGraphView(__namedParameters): Element;

Read-only inspection of a MaterialX file or archive, independent of 3D rendering.

Parameters​

ParameterType
__namedParameters{ data?: ArrayBuffer; fileName?: string; }
__namedParameters.data?ArrayBuffer
__namedParameters.fileName?string

Returns​

Element


MATERIALX_CLIPBOARD_TYPE​

Re-exports MATERIALX_CLIPBOARD_TYPE


MaterialXNodeGraphProps​

Properties​

PropertyTypeDescription
sessionEditorSessionShared editing state; create it with createEditorSession from mtlx-core/session.
fileName?stringMaterial file name or path, shown at the root of the breadcrumbs.
mode?EditorMode-
scope?stringControls the session's scope; without it the session owns navigation.
onScopeChange?(scope) => void-
className?string-
colorMode?ColorModeReact Flow chrome (controls, background) follows this; the editor's own colors follow CSS tokens.
children?ReactNodeRendered over the canvas, for example a material preview.

MaterialXNodeGraph()​

function MaterialXNodeGraph(props): Element;

Renders and edits one scope of the session's document; the ReactFlowProvider is created internally.

Parameters​

ParameterType
propsMaterialXNodeGraphProps

Returns​

Element


MATERIALX_NODE_MIME​

const MATERIALX_NODE_MIME: "application/x-materialx-nodedef" = 'application/x-materialx-nodedef';

MaterialXNodeListProps​

Properties​

PropertyType
nodesMaterialXNodeSpec[]
disabled?boolean
onAdd?(node) => void

MaterialXNodeList()​

function MaterialXNodeList(__namedParameters): Element;

Shared by the category column and search results; buttons also support keyboard insertion.

Parameters​

ParameterType
__namedParametersMaterialXNodeListProps

Returns​

Element


MaterialXNodeLibProps​

Properties​

PropertyType
catalog?MaterialXNodeSpec[]
disabled?boolean
onAdd?(node) => void
className?string

MaterialXNodeLib()​

function MaterialXNodeLib(__namedParameters): Element;

Parameters​

ParameterType
__namedParametersMaterialXNodeLibProps

Returns​

Element


NodeNameField()​

function NodeNameField(__namedParameters): Element;

The node's name as an inline field: Enter or blur renames, Escape reverts.

Parameters​

ParameterType
__namedParameters{ name: string; onRename: (name) => void; }
__namedParameters.namestring
__namedParameters.onRename(name) => void

Returns​

Element


NodeParameterEditorProps​

Properties​

PropertyTypeDescription
sessionEditorSession-
editable?boolean-
resources?ParameterResourcesPackage files offered by filename inputs, and an optional upload hook.
className?string-
placeholder?stringShown in place of the panel when no single node is selected; without it the panel unmounts.

NodeParameterEditor()​

function NodeParameterEditor(__namedParameters): Element | null;

The selected node's typed parameter editors, connections and reset actions. Follows the session's selection.

Parameters​

ParameterType
__namedParametersNodeParameterEditorProps

Returns​

Element | null


QuickAddMenuProps​

Properties​

PropertyTypeDescription
catalogMaterialXNodeSpec[]-
atobjectPosition inside the canvas element.
at.xnumber-
at.ynumber-
accept?(spec) => booleanNarrows the offered definitions, for example to those accepting a dragged wire.
placeholder?string-
onAdd(spec) => void-
onClose() => void-

QuickAddMenu()​

function QuickAddMenu(__namedParameters): Element;

Searchable, category-browsable node insertion at the cursor. Enter adds or drills in, Escape closes.

Parameters​

ParameterType
__namedParametersQuickAddMenuProps

Returns​

Element


visibleInputs()​

function visibleInputs(node): MaterialXNodePortSpec[];

Inputs shown on a collapsed node body: connected or authored ones.

Parameters​

ParameterType
nodePick<GraphNode, "element" | "inputs">

Returns​

MaterialXNodePortSpec[]


autoLayout()​

function autoLayout(nodes, edges): Record<string, Point>;

Layered left-to-right placement by data flow. Sources sit in the first column, sinks in the last.

Parameters​

ParameterType
nodesPick<GraphNode, "element" | "inputs" | "id" | "outputs">[]
edgesGraphEdge[]

Returns​

Record<string, Point>


WireTarget​

type WireTarget = object;

A right-clicked port, or the input end of a right-clicked wire.

Properties​

node​
node: string;
side​
side: "output" | "input";
name​
name: string;

CommandContext​

Everything a command may read or act on. Surfaces build it from the session; menus add where they opened.

Properties​

PropertyTypeDescription
sessionEditorSession-
snapshotEditorSnapshot-
projectionGraphProjection-
editableboolean-
targetsreadonly string[]Nodes the command applies to: the selection, or the right-clicked node.
at?PointCanvas point to paste or add at; without one, pasted nodes are nudged from the originals.
client?PointScreen point the command was invoked from, for menus that open at the pointer.
wire?WireTarget-
openQuickAdd?(client) => void-
canvas?CanvasActionsThe mounted canvas for this session, when one is showing it.

CanvasActions​

What a canvas offers commands that live outside it, such as the floating toolbar.

Properties​

PropertyTypeDescription
addNode() => void-
fitView(nodeIds?) => voidFrames the given nodes, or everything when none are given.
zoomIn() => void-
zoomOut() => void-

registerCanvas()​

function registerCanvas(session, actions): () => void;

A canvas announces itself while mounted; the returned function withdraws it.

Parameters​

ParameterType
sessionEditorSession
actionsCanvasActions

Returns​

() => void


CommandState​

Properties​

PropertyTypeDescription
visibleboolean-
enabledboolean-
titlestringMenu text and tooltip; defaults to the command's label.

Command​

A stateless action; state decides how a menu or toolbar shows it and run performs it.

Properties​

PropertyTypeDescription
idstring-
labelstring-
icon?LucideIcon-
shortcuts?readonly string[]mod is Cmd on macOS and Ctrl elsewhere, for example mod+shift+z.
variant?"destructive"-
state?(context) => Partial<CommandState>-
run(context) => unknown-

CommandEntry​

type CommandEntry = Command | "divider";

ResolvedCommand​

type ResolvedCommand = Command & CommandState;

resolveCommands()​

function resolveCommands(entries, context): ("divider" | ResolvedCommand)[];

Visible commands in order, with at most one divider between neighbours and none at the ends.

Parameters​

ParameterType
entriesreadonly CommandEntry[]
contextCommandContext

Returns​

("divider" | ResolvedCommand)[]


attempt()​

function attempt(session, operation): Promise<void> | undefined;

Run an edit and report its outcome on the session, so any surface can show the failure.

Parameters​

ParameterType
sessionEditorSession
operation() => unknown

Returns​

Promise<void> | undefined


execute()​

function execute(command, context): Promise<void> | undefined;

Parameters​

ParameterType
commandCommand
contextCommandContext

Returns​

Promise<void> | undefined


TOOLBAR_COMMANDS​

const TOOLBAR_COMMANDS: readonly CommandEntry[];

CONTEXT_MENU_COMMANDS​

const CONTEXT_MENU_COMMANDS: readonly CommandEntry[];

SHORTCUT_COMMANDS​

const SHORTCUT_COMMANDS: readonly Command[];

useCommandContext()​

function useCommandContext(session, options?): CommandContext;

The session's current graph as a command context. Each surface memoizes its own projection.

Parameters​

ParameterType
sessionEditorSession
options?{ editable?: boolean; }
options.editable?boolean

Returns​

CommandContext


useCommandShortcuts()​

function useCommandShortcuts(session, options?): void;

Window-level shortcuts for the session's commands, outside text fields. Mount once per page.

Parameters​

ParameterType
sessionEditorSession
options?{ editable?: boolean; commands?: readonly Command[]; }
options.editable?boolean
options.commands?readonly Command[]

Returns​

void


EditorMode​

Re-exports EditorMode


GraphNode​

Re-exports GraphNode


projectGraph​

Re-exports projectGraph


previewXml​

Re-exports previewXml


createDefaultDocument​

Re-exports createDefaultDocument


importMaterial​

Re-exports importMaterial


exportMaterial​

Re-exports exportMaterial


NodeDefinition​

type NodeDefinition = MaterialXNodeSpec & object;

A definition the editor can instantiate: core's structural placeholders have no nodedef.

Type Declaration​

NameType
nodeDefNamestring

isNodeDefinition()​

function isNodeDefinition(spec): spec is NodeDefinition;

Parameters​

ParameterType
specMaterialXNodeSpec

Returns​

spec is NodeDefinition


getNodeFamilies()​

function getNodeFamilies(catalog): NodeFamily[];

Supply menu labels for the shared semantic node families.

Parameters​

ParameterType
catalogMaterialXNodeSpec[]

Returns​

NodeFamily[]


ParameterEditorProps​

Properties​

PropertyTypeDescription
parameterMaterialXNodePortSpec-
valuestring-
ariaLabelstring-
disabled?boolean-
onChange(value, options?) => voidmerge identifies one continuous gesture (a drag, a typing session) so its changes share an undo entry.
onReset?() => void-

ParameterEditor​

type ParameterEditor = ComponentType<ParameterEditorProps>;

Implementations own their layout and use ParameterLabel for consistent labels.


ParameterLabel()​

function ParameterLabel(__namedParameters): Element;

Parameters​

ParameterType
__namedParameters{ parameter: MaterialXNodePortSpec; htmlFor: string; }
__namedParameters.parameterMaterialXNodePortSpec
__namedParameters.htmlForstring

Returns​

Element


parseParameterNumber()​

function parseParameterNumber(value, integer?): number | undefined;

Parameters​

ParameterTypeDefault value
valuestringundefined
integer?booleanfalse

Returns​

number | undefined


FloatParameterEditor​

const FloatParameterEditor: ParameterEditor;

IntegerParameterEditor​

const IntegerParameterEditor: ParameterEditor;

Vec2ParameterEditor​

const Vec2ParameterEditor: ParameterEditor;

Vec3ParameterEditor​

const Vec3ParameterEditor: ParameterEditor;

Vec4ParameterEditor​

const Vec4ParameterEditor: ParameterEditor;

MatrixParameterEditor​

const MatrixParameterEditor: ParameterEditor;

ColorParameterEditor​

const ColorParameterEditor: ParameterEditor;

BooleanParameterEditor​

const BooleanParameterEditor: ParameterEditor;

EnumParameterEditor​

const EnumParameterEditor: ParameterEditor;

TextParameterEditor​

const TextParameterEditor: ParameterEditor;

ReadOnlyParameterEditor​

const ReadOnlyParameterEditor: ParameterEditor;

ParameterResources​

Properties​

PropertyTypeDescription
filesreadonly string[]Document-relative paths of files already in the package, offered as completions.
addFile?(file) => Promise<string>Adds a file to the package and resolves to its document-relative path.

ParameterResourcesContext​

const ParameterResourcesContext: Context<ParameterResources>;

FilenameParameterEditor​

const FilenameParameterEditor: ParameterEditor;

Filename inputs complete against package resources and accept uploads through the host.


parameterEditors​

const parameterEditors: Readonly<Record<string, ParameterEditor>>;

getParameterEditor()​

function getParameterEditor(parameter): ParameterEditor;

Parameters​

ParameterType
parameterMaterialXNodePortSpec

Returns​

ParameterEditor


ConnectedParameterEditorProps​

type ConnectedParameterEditorProps = ParameterEditorProps & object;

Type Declaration​

NameType
sourcestring
onDisconnect()() => void

ConnectedParameterEditor()​

function ConnectedParameterEditor(props): Element;

Parameters​

ParameterType
propsConnectedParameterEditorProps

Returns​

Element


GeometryParameterEditor​

const GeometryParameterEditor: ParameterEditor;

An implicit geometry input, before a literal or connection overrides it.


useEditorSession()​

function useEditorSession(session): EditorSnapshot;

Subscribe to committed document and history changes with stable snapshot identities.

Parameters​

ParameterType
sessionEditorSession

Returns​

EditorSnapshot

Parsing​

MaterialXDocument​

The in-memory form of a .mtlx file, mirroring its XML structure.

nodes and nodeGraphs are derived read-only snapshots; elements is the canonical tree that serializeMaterialX writes back out.

Properties​

PropertyModifierType
attributespublicRecord<string, string>
nodesreadonlyreadonly MaterialXNode[]
nodeGraphsreadonlyreadonly MaterialXNodeGraph[]
elementspublicMaterialXElement[]

Validation​

MaterialXNodeSpec​

A node definition entry in the materialXNodeRegistry.

Properties​

PropertyType
categorystring
nodeDefName?string
type?string
nodeGroup?string
attributes?Readonly<Record<string, string>>
inputsMaterialXNodePortSpec[]
outputsMaterialXNodePortSpec[]
parametersMaterialXNodePortSpec[]