Capítulo 507 de 859

Chapter 507: VarNode

Core Idea

Class for representing shader variables as nodes. Variables are created from existing nodes like the following:

Key Concepts

  • global : boolean: VarNode sets this property to true by default.
  • intent : boolean: This flag is used to indicate that this node is used for intent.
  • isVarNode : boolean (readonly): This flag can be used for type testing.
  • name : string: The name of the variable in the shader. If no name is defined, the node system auto-generates one.
  • node : Node: The node for which a variable should be created.
  • parents : boolean: Add this flag to the node system to indicate that this node require parents.
  • readOnly : boolean: The read-only flag.

Code Examples

const depth = sampleDepth( uvNode ).toVar( 'depth' );
  • What it demonstrates: Typical usage of VarNode.

Reference Tables

Constructor

Signature
new VarNode( node : Node, name : string, readOnly : boolean )

Properties

PropertyDescription
.global : booleanVarNode sets this property to true by default.
.intent : booleanThis flag is used to indicate that this node is used for intent.
.isVarNode : boolean (readonly)This flag can be used for type testing.
.name : stringThe name of the variable in the shader. If no name is defined, the node system auto-generates one.
.node : NodeThe node for which a variable should be created.
.parents : booleanAdd this flag to the node system to indicate that this node require parents.
.readOnly : booleanThe read-only flag.

Methods

MethodDescription
.getIntent() : booleanReturns the intent flag of this node.
.isIntent( builder : NodeBuilder ) : booleanChecks if this node is used for intent.
.setIntent( value : boolean ) : VarNodeSets the intent flag for this node.

Key Takeaways

  1. VarNode extends: EventDispatcher → Node
  2. Most relevant properties: global, intent, isVarNode, name.
  3. Key methods: getIntent, isIntent, setIntent.

Connects To