Skip to content

Documentation / scene / FunctionCallNode

Class: FunctionCallNode

Defined in: libs/scene/src/utility/blueprint/material/func.ts:45

Function call node for material blueprint functions

Remarks

Represents a call to a reusable material function (sub-graph) within the material node graph. Functions are defined in separate blueprint files and can be instantiated multiple times.

The node automatically:

  • Discovers function inputs (FunctionInputNode) and creates corresponding input slots
  • Discovers function outputs (FunctionOutputNode) and creates corresponding output slots
  • Validates input types match the function's parameter types

Benefits of using material functions:

  • Code reuse across multiple materials
  • Encapsulation of complex logic
  • Easier maintenance (update function once, affects all uses)
  • Better organization of large material graphs

Example

typescript
// Load and instantiate a custom noise function
const noiseIR = await manager.loadBluePrint('functions/noise.mtlfunc');
const noiseCall = new FunctionCallNode(
  'functions/noise.mtlfunc',
  'noise',
  noiseIR
);

// Connect inputs
noiseCall.connectInput(1, uvNode, 1); // UV coordinates
noiseCall.connectInput(2, scaleNode, 1); // Scale parameter

// Use outputs
colorNode.connectInput(1, noiseCall, 1); // Noise result

Extends

Constructors

Constructor

new FunctionCallNode(path, name, IR): FunctionCallNode

Defined in: libs/scene/src/utility/blueprint/material/func.ts:72

Creates a new function call node

Parameters

path

string

The file path to the function blueprint

name

string

The display name of the function

IR

MaterialBlueprintIR

The compiled intermediate representation of the function

Returns

FunctionCallNode

Remarks

The constructor scans the function's IR to:

  1. Find all FunctionInputNode instances and create input slots
  2. Find all FunctionOutputNode instances and create output slots
  3. Extract parameter names and types for validation

Input/output slots are created in the order they appear in the nodeMap, using either custom names or auto-generated names like 'arg_N' or 'out_N'.

Overrides

BaseGraphNode.constructor

Properties

_inputs

protected _inputs: GraphNodeInput[]

Defined in: libs/scene/src/utility/blueprint/node.ts:336

Internal storage for input slot definitions

Inherited from

BaseGraphNode._inputs


_outputs

protected _outputs: GraphNodeOutput[]

Defined in: libs/scene/src/utility/blueprint/node.ts:338

Internal storage for output slot definitions

Inherited from

BaseGraphNode._outputs


_error

protected _error: string

Defined in: libs/scene/src/utility/blueprint/node.ts:340

Internal storage for error message

Inherited from

BaseGraphNode._error

Accessors

path

Get Signature

get path(): string

Defined in: libs/scene/src/utility/blueprint/material/func.ts:113

Gets the file path to the function blueprint

Returns

string


name

Get Signature

get name(): string

Defined in: libs/scene/src/utility/blueprint/material/func.ts:119

Gets the function name

Returns

string


IR

Get Signature

get IR(): MaterialBlueprintIR

Defined in: libs/scene/src/utility/blueprint/material/func.ts:129

Gets the intermediate representation (IR) of the function

Remarks

The IR contains the compiled node graph that will be inlined or called during shader code generation.

Returns

MaterialBlueprintIR


args

Get Signature

get args(): object[]

Defined in: libs/scene/src/utility/blueprint/material/func.ts:137

Gets the function's input parameter definitions

Returns

object[]

Array of parameter descriptors with index, name, and type


outs

Get Signature

get outs(): object[]

Defined in: libs/scene/src/utility/blueprint/material/func.ts:145

Gets the function's output value definitions

Returns

object[]

Array of output descriptors with index, name, and type


isUniform

Get Signature

get isUniform(): boolean

Defined in: libs/scene/src/utility/blueprint/node.ts:357

Whether this node contains uniform value/texture

Returns

boolean

Whether this node has uniform value

Inherited from

BaseGraphNode.isUniform


paramName

Get Signature

get paramName(): string

Defined in: libs/scene/src/utility/blueprint/node.ts:363

Uniform parameter name

Returns

string

Uniform parameter name

Inherited from

BaseGraphNode.paramName


inputs

Get Signature

get inputs(): GraphNodeInput[]

Defined in: libs/scene/src/utility/blueprint/node.ts:380

Gets the input slot definitions array

Returns

GraphNodeInput[]

Array of input slot definitions

Inherited from

BaseGraphNode.inputs


outputs

Get Signature

get outputs(): GraphNodeOutput[]

Defined in: libs/scene/src/utility/blueprint/node.ts:384

Gets the output slot definitions array

Returns

GraphNodeOutput[]

Array of output slot definitions

Inherited from

BaseGraphNode.outputs


error

Get Signature

get error(): string

Defined in: libs/scene/src/utility/blueprint/node.ts:388

Gets the current error message

Returns

string

Set Signature

set error(str): void

Defined in: libs/scene/src/utility/blueprint/node.ts:391

Current error message, empty string if no error

Parameters
str

string

Returns

void

Current error message, empty string if no error

Inherited from

BaseGraphNode.error

Methods

on()

on<K>(type, listener, context?): void

Defined in: libs/base/dist/index.d.ts:594

IEventTarget.on

Type Parameters

K

K extends "changed"

Parameters

type

K

listener

EventListener<{ changed: []; }, K>

context?

unknown

Returns

void

Inherited from

BaseGraphNode.on


once()

once<K>(type, listener, context?): void

Defined in: libs/base/dist/index.d.ts:598

IEventTarget.once

Type Parameters

K

K extends "changed"

Parameters

type

K

listener

EventListener<{ changed: []; }, K>

context?

unknown

Returns

void

Inherited from

BaseGraphNode.once


off()

off<K>(type, listener?, context?): void

Defined in: libs/base/dist/index.d.ts:602

IEventTarget.off

Type Parameters

K

K extends "changed"

Parameters

type

K

listener?

EventListener<{ changed: []; }>

context?

unknown

Returns

void

Inherited from

BaseGraphNode.off


dispatchEvent()

dispatchEvent<K>(type, ...args): void

Defined in: libs/base/dist/index.d.ts:606

IEventTarget.dispatchEvent

Type Parameters

K

K extends "changed"

Parameters

type

K

args

...object[K]

Returns

void

Inherited from

BaseGraphNode.dispatchEvent


getSerializationCls()

static getSerializationCls(manager): object

Defined in: libs/scene/src/utility/blueprint/material/func.ts:158

Gets the serialization descriptor for this node type

Parameters

manager

ResourceManager

The serialization manager for loading blueprints

Returns

object

Serialization class descriptor

ctor

ctor: typeof FunctionCallNode = FunctionCallNode

name

name: string = 'FunctionCallNode'

createFunc()

createFunc(_, init): Promise<{ obj: FunctionCallNode; }>

Parameters
_

unknown

init

string

Returns

Promise<{ obj: FunctionCallNode; }>

getInitParams()

getInitParams(obj): string

Parameters
obj

FunctionCallNode

Returns

string

getProps()

getProps(): any[]

Returns

any[]

Remarks

Uses a custom createFunc to asynchronously load the function blueprint from the file system. The initialization parameter is the blueprint path.


toString()

toString(): string

Defined in: libs/scene/src/utility/blueprint/material/func.ts:180

Generates a string representation of this node

Returns

string

The function name

Overrides

BaseGraphNode.toString


validate()

protected validate(): string

Defined in: libs/scene/src/utility/blueprint/material/func.ts:194

Validates the node state and input types

Returns

string

Error message if invalid, empty string if valid

Remarks

Ensures:

  • All required inputs are connected
  • Input types can be determined
  • Input types match the function's parameter types

Overrides

BaseGraphNode.validate


getType()

protected getType(id): string

Defined in: libs/scene/src/utility/blueprint/material/func.ts:220

Gets the output type for a specific output slot

Parameters

id

number

The output slot ID (1-based)

Returns

string

The type of the output value

Remarks

Returns the type declared by the corresponding FunctionOutputNode in the function's blueprint.

Overrides

BaseGraphNode.getType


getOutputType()

getOutputType(id): string

Defined in: libs/scene/src/utility/blueprint/node.ts:376

Gets the output type for a specific output slot

Parameters

id

number

The output slot ID

Returns

string

The type name of the output

Remarks

Default implementation delegates to the abstract getType() method. Can be overridden for more complex type logic.

Inherited from

BaseGraphNode.getOutputType


check()

check(): void

Defined in: libs/scene/src/utility/blueprint/node.ts:413

Validates the node and updates error state

Returns

void

Remarks

Calls the validate() method and stores the result in _error. Emits a 'changed' event if the error state changes.

Inherited from

BaseGraphNode.check


reset()

reset(): void

Defined in: libs/scene/src/utility/blueprint/node.ts:422

Clears the error state

Returns

void

Remarks

Sets _error to an empty string.

Inherited from

BaseGraphNode.reset


setInput()

setInput(id, node, inputId): void

Defined in: libs/scene/src/utility/blueprint/node.ts:443

Connects an input slot to another node's output

Parameters

id

number

The input slot ID to connect

node

BaseGraphNode

The source node to connect from

inputId

number

The output slot ID of the source node

Returns

void

Throws

Error if the input slot with the given ID doesn't exist

Example

typescript
const addNode = new AddNode();
const constantNode = new ConstantNode(5.0);

// Connect constantNode's output 0 to addNode's input 0
addNode.setInput(0, constantNode, 0);

Inherited from

BaseGraphNode.setInput

Released under the MIT License.