| ▸isCacheable | () => boolean |
Whether this node allows caching its result in a temporary variable.
Caching is enabled by default. Override this method to disable it. |
| ▸toAssignable | () => Node |
Makes this node assignable and adds it to the current stack,
so it can be declared where it was created if it is assigned later.
Only use it with nodes that are not shared, see Node#assignable. |
| ▸isAssignable | (builder: NodeBuilder) => boolean |
Checks if this node is assignable without a forced declaration. |
| ▸isAssign | (builder: NodeBuilder) => boolean |
Checks if this node is the target of an assignment. |
| ▸_updateAssignable | (builder: NodeBuilder, data: Object, valueNode?: Node) => void |
Declares the assignable node before the loops where it is used if it has no stack, and
decides if a value that cannot be cached must be evaluated once at its declaration. |
| builder | NodeBuilder | — | | data | Object | — | | valueNode? | Node | this |
|
| ▸_declaresAssignable | () => boolean |
Whether build() declares this assignable node as a variable when it is assigned.
Nodes that wrap an assignable value, like VarNode, declare it themselves. |
| ▸_declareVariable | (builder: NodeBuilder, snippet: string, type: string, readOnly: boolean, property: string) => string |
Declares a variable for this node in the current flow, initialized with the given snippet. |
| builder | NodeBuilder | — | | snippet | string | — | | type | string | — | | readOnly | boolean | — | | property | string | — |
|
| ▸_isVariable | (builder: NodeBuilder, nodeData: Object) => boolean |
Whether this assignable node must be declared as a variable, because it is assigned
or must be evaluated once at its declaration. |
| builder | NodeBuilder | — | | nodeData | Object | — |
|
| ▸_buildVariable | (builder: NodeBuilder, nodeData: Object, output: null | string) => string |
Generates an assignable node as a variable. The variable is declared the first
time it is generated, which is its stack position, and then referenced by name. |
| builder | NodeBuilder | — | | nodeData | Object | — | | output | null | string | — |
|
| ▸_isFunctionScope | () => boolean |
Whether the generated value is a variable declared in the scope of the function,
so it keeps its value after the block where it was generated, e.g. a VarNode. |
| ▸_checkFlowBlock | (builder: NodeBuilder, nodeData: Object) => void |
A generated value is only visible in the block where it was declared and in its inner blocks.
A variable of the function scope is also visible in a later block of the same parent and guard,
e.g. a second if ( c ) of an immutable condition c, since that block only runs if its block ran.
This method discards the generated value if it is not visible in the current block. |
| builder | NodeBuilder | — | | nodeData | Object | — |
|
| ▸_setFlowBlock | (builder: NodeBuilder, nodeData: Object, isCached: boolean, flowCodeLength: number) => void |
Keeps the block where a value was generated, so it is only reused where it is visible.
A global node is a declaration visible in any block, unless it emitted code in this block. |
| builder | NodeBuilder | — | | nodeData | Object | — | | isCached | boolean | — | | flowCodeLength | number | — |
|
| ▸onUpdate | (callback: Function, updateType: string) => Node |
|
| callback | Function | — | | updateType | string | — |
|
| ▸onFrameUpdate | (callback: Function) => Node |
Convenient method for defining Node#update. Similar to Node#onUpdate, but
this method automatically sets the update type to FRAME. |
| ▸onRenderUpdate | (callback: Function) => Node |
Convenient method for defining Node#update. Similar to Node#onUpdate, but
this method automatically sets the update type to RENDER. |
| ▸onObjectUpdate | (callback: Function) => Node |
Convenient method for defining Node#update. Similar to Node#onUpdate, but
this method automatically sets the update type to OBJECT. |
| ▸onReference | (callback: Function) => Node |
|
| ▸updateReference | () => any |
Nodes might refer to other objects like materials. This method allows to dynamically update the reference
to such objects based on a given state (e.g. the current node frame or builder). |
| ▸isGlobal | () => boolean |
By default this method returns the value of the Node#global flag. This method
can be overwritten in derived classes if an analytical way is required to determine the
global cache referring to the current shader-stage. |
| ▸getChildren | () => Array<…> |
Returns the child nodes of this node. |
| ▸dispose | () => void |
Calling this method dispatches the dispose event. This event can be used
to register event listeners for clean up tasks. |
| ▸traverse | (callback: traverseCallback) => void |
Callback for Node#traverse.
Can be used to traverse through the node’s hierarchy. |
| callback | traverseCallback | — |
|
| ▸_getChildren | (ignores?: Set<…>) => Array<…> |
Returns the child nodes of this node. |
| ignores? | Set<Node> | new Set() |
|
| ▸getCacheKey | (force?: boolean, ignores?: Set<…>) => number |
Returns the cache key for this node. |
| force? | boolean | false | | ignores? | Set<Node> | null |
|
| ▸customCacheKey | () => number |
Generate a custom cache key for this node. |
| ▸getScope | () => Node |
Returns the references to this node which is by default this. |
| ▸getHash | () => string |
Returns the hash of the node which is used to identify the node. By default it’s
the Node#uuid however derived node classes might have to overwrite this method
depending on their implementation. |
| ▸getUpdateType | () => { NONE: string; FRAME: string; RENDER: string; OBJECT: string; } |
Returns |
| NONE | string | — | | FRAME | string | — | | RENDER | string | — | | OBJECT | string | — |
|
| ▸getUpdateBeforeType | () => { NONE: string; FRAME: string; RENDER: string; OBJECT: string; } |
Returns |
| NONE | string | — | | FRAME | string | — | | RENDER | string | — | | OBJECT | string | — |
|
| ▸getUpdateAfterType | () => { NONE: string; FRAME: string; RENDER: string; OBJECT: string; } |
Returns |
| NONE | string | — | | FRAME | string | — | | RENDER | string | — | | OBJECT | string | — |
|
| ▸getElementType | (builder: NodeBuilder) => string |
Certain types are composed of multiple elements. For example a vec3
is composed of three float values. This method returns the type of
these elements. |
| ▸getMemberType | () => string |
Returns the node member type for the given name. |
| ▸getNodeType | (builder: NodeBuilder, output?: string) => string |
|
| builder | NodeBuilder | — | | output? | string | null |
|
| ▸generateNodeType | (builder: NodeBuilder, output?: string) => string |
|
| builder | NodeBuilder | — | | output? | string | null |
|
| ▸getShared | (builder: NodeBuilder) => Node |
This method is used during the build process of a node and ensures
equal nodes are not built multiple times but just once. For example if
attribute( 'uv' ) is used multiple times by the user, the build
process makes sure to process just the first node. It also handles
node overrides if an override context is set. |
| ▸getArrayCount | () => null | number |
Returns the number of elements in the node array. |
| ▸setup | (builder: NodeBuilder) => null | Node |
Represents the setup stage which is the first step of the build process, see Node#build method.
This method is often overwritten in derived modules to prepare the node which is used as a node’s output/result.
If an output node is prepared, then it must be returned in the return statement of the derived module’s setup function. |
| ▸analyze | (builder: NodeBuilder, output?: null | Node) => void |
Represents the analyze stage which is the second step of the build process, see Node#build method.
This stage analyzes the node hierarchy and ensures descendent nodes are built. |
| builder | NodeBuilder | — | | output? | null | Node | null |
|
| ▸generate | (builder: NodeBuilder, output?: null | string) => null | string |
Represents the generate stage which is the third step of the build process, see Node#build method.
This state builds the output node and returns the resulting shader string. |
| builder | NodeBuilder | — | | output? | null | string | — |
|
| ▸updateBefore | () => null | boolean |
The method can be implemented to update the node’s internal state before it is used to render an object.
The Node#updateBeforeType property defines how often the update is executed. |
| ▸updateAfter | () => null | boolean |
The method can be implemented to update the node’s internal state after it was used to render an object.
The Node#updateAfterType property defines how often the update is executed. |
| ▸update | () => null | boolean |
The method can be implemented to update the node’s internal state when it is used to render an object.
The Node#updateType property defines how often the update is executed. |
| ▸_setupInspector | (builder: NodeBuilder) => void |
Registers the inspector node added with toInspector() in the builder, so it is updated every frame.
Nodes that override build() without always calling super.build() must call this method. |
| ▸build | (builder: NodeBuilder, output?: null | string | Node) => null | string | Node |
This method performs the build of a node. The behavior and return value depend on the current build stage:
-
setup
: Prepares the node and its children for the build process. This process can also create new nodes. Returns the node itself or a variant.
-
analyze
: Analyzes the node hierarchy for optimizations in the code generation stage. Returns
null
.
-
generate
: Generates the shader code for the node. Returns the generated shader string.
|
| builder | NodeBuilder | — | | output? | null | string | Node | null |
Returns null | string | Node |
| ▸getSerializeChildren | () => Generator<…> |
Returns the child nodes as a JSON object. Returns Generator<Object, any, any> |
| ▸serialize | (json: Object) => void |
Serializes the node to JSON. |
| ▸deserialize | (json: Object) => void |
Deserializes the node from the given JSON. |
| ▸toJSON | (meta: null | Object) => Object |
Serializes the node into the three.js JSON Object/Scene format. |