Capítulo 440 de 859

Chapter 440: Object3DNode

Core Idea

This node can be used to access transformation related metrics of 3D objects. Depending on the selected scope, a different metric is represented as a uniform in the shader. The following scopes are supported:

  • POSITION: The object's position in world space.
  • VIEW_POSITION: The object's position in view/camera space.
  • DIRECTION: The object's direction in world space.
  • SCALE: The object's scale in world space.
  • WORLD_MATRIX: The object's matrix in world space.

Key Concepts

  • object3d : Object3D: The 3D object.
  • scope : 'position' | 'viewPosition' | 'direction' | 'scale' | 'worldMatrix': The node reports a different type of transformation depending on the scope.
  • uniformNode : UniformNode: Holds the value of the node as a uniform.
  • updateType : string: Overwritten since this type of node is updated per object.

Reference Tables

Constructor

Signature
`new Object3DNode( scope : 'position'

Properties

PropertyDescription
.object3d : Object3DThe 3D object.
`.scope : 'position''viewPosition'
.uniformNode : UniformNodeHolds the value of the node as a uniform.
.updateType : stringOverwritten since this type of node is updated per object.

Methods

MethodDescription
.generate( builder : NodeBuilder ) : stringGenerates the code snippet of the uniform node. The node type of the uniform node also depends on the selected scope.
`.generateNodeType() : 'mat4''vec3'
.update( frame : NodeFrame )Updates the uniform value depending on the scope.

Key Takeaways

  1. Object3DNode extends: EventDispatcher → Node
  2. Most relevant properties: object3d, scope, uniformNode, updateType.
  3. Key methods: generate, generateNodeType, update.

Connects To