Capítulo 461 de 859

Chapter 461: ReferenceNode

Core Idea

This type of node establishes a reference to a property of another object. In this way, the value of the node is automatically linked to the value of referenced object. Reference nodes internally represent the linked value as a uniform.

Key Concepts

  • count : number: When the linked property is an array, this parameter defines its length.
  • group : UniformGroupNode: The uniform group of the internal uniform.
  • name : string: An optional label of the internal uniform node.
  • node : UniformNode: The uniform node that holds the value of the reference node.
  • object : Object: The object the property belongs to.
  • properties : Array.<string>: The property name might have dots so nested properties can be referred. The hierarchy of the names is stored inside this array.
  • property : string: The name of the property the node refers to.
  • reference : Object: Points to the current referred object. This property exists next to ReferenceNode#object since the final refer…
  • uniformType : string: The uniform type that should be used to represent the property value.
  • updateType : string: Overwritten since reference nodes are updated per object.

Reference Tables

Constructor

Signature
new ReferenceNode( property : string, uniformType : string, object : Object, count : number )

Properties

PropertyDescription
.count : numberWhen the linked property is an array, this parameter defines its length.
.group : UniformGroupNodeThe uniform group of the internal uniform.
.name : stringAn optional label of the internal uniform node.
.node : UniformNodeThe uniform node that holds the value of the reference node.
.object : ObjectThe object the property belongs to.
.properties : Array.<string>The property name might have dots so nested properties can be referred. The hierarchy of the names is stored inside this array.
.property : stringThe name of the property the node refers to.
.reference : ObjectPoints to the current referred object. This property exists next to ReferenceNode#object since the final reference might be updated from calling code.
.uniformType : stringThe uniform type that should be used to represent the property value.
.updateType : stringOverwritten since reference nodes are updated per object.

Methods

MethodDescription
.element( indexNode : IndexNode ) : ReferenceElementNodeWhen the referred property is array-like, this method can be used to access elements via an index node.
.generateNodeType( builder : NodeBuilder ) : stringThis method is overwritten since the node type is inferred from the type of the reference node.
.getValueFromReference( object : Object ) : anyReturns the property value from the given referred object.
.label( name : string ) : ReferenceNodeSets the label for the internal uniform.
.setGroup( group : UniformGroupNode ) : ReferenceNodeSets the uniform group for this reference node.
.setName( name : string ) : ReferenceNodeSets the name for the internal uniform.
.setNodeType( uniformType : string )Sets the node type which automatically defines the internal uniform type.
.setup( builder : NodeBuilder ) : UniformNodeThe output of the reference node is the internal uniform node.
.update( frame : NodeFrame )Overwritten to update the internal uniform value.
`.updateReference( state : NodeFrameNodeBuilder ) : Object`
.updateValue()Retrieves the value from the referred object property and uses it to updated the internal uniform.

Key Takeaways

  1. ReferenceNode extends: EventDispatcher → Node
  2. Most relevant properties: count, group, name, node.
  3. Key methods: element, generateNodeType, getValueFromReference, label.

Connects To