Capítulo 400 de 859

Chapter 400: ContextNode

Core Idea

This node can be used as a context management component for another node. NodeBuilder performs its node building process in a specific context and this node allows the modify the context. A typical use case is to overwrite getUV() e.g.:

Key Concepts

  • isContextNode : boolean (readonly): This flag can be used for type testing.
  • node : Node: The node whose context should be modified.
  • value : Object: The modified context data.

Code Examples

node.context( { getUV: () => customCoord } );
\// or
material.contextNode = context( { getUV: () => customCoord } );
\// or
renderer.contextNode = context( { getUV: () => customCoord } );
\// or
scenePass.contextNode = context( { getUV: () => customCoord } );
  • What it demonstrates: Typical usage of ContextNode.

Reference Tables

Constructor

Signature
new ContextNode( node : Node, value : Object )

Properties

PropertyDescription
.isContextNode : boolean (readonly)This flag can be used for type testing.
.node : NodeThe node whose context should be modified.
.value : ObjectThe modified context data.

Methods

MethodDescription
.generateNodeType( builder : NodeBuilder ) : stringThis method is overwritten to ensure it returns the type of ContextNode#node.
.getFlowContextData() : ObjectGathers the context data from all parent context nodes.
.getMemberType( builder : NodeBuilder, name : string ) : stringThis method is overwritten to ensure it returns the member type of ContextNode#node.
.getScope() : NodeThis method is overwritten to ensure it returns the reference to ContextNode#node.

Key Takeaways

  1. ContextNode extends: EventDispatcher → Node
  2. Most relevant properties: isContextNode, node, value.
  3. Key methods: generateNodeType, getFlowContextData, getMemberType, getScope.

Connects To