Capítulo 129 de 859

Chapter 129: LightsNode

Core Idea

This node represents the scene's lighting and manages the lighting model's life cycle for the current build 3D object. It is responsible for computing the total outgoing light in a given lighting context.

Key Concepts

  • global : boolean: LightsNode sets this property to true by default.
  • hasLights : boolean: Whether the scene has lights or not.
  • outgoingLightNode : Node.<vec3>: A node representing the outgoing light.
  • totalDiffuseNode : Node.<vec3>: A node representing the total diffuse light.
  • totalSpecularNode : Node.<vec3>: A node representing the total specular light.

Reference Tables

Constructor

Signature
new LightsNode()

Properties

PropertyDescription
.global : booleanLightsNode sets this property to true by default.
.hasLights : booleanWhether the scene has lights or not.
.outgoingLightNode : Node.<vec3>A node representing the outgoing light.
.totalDiffuseNode : Node.<vec3>A node representing the total diffuse light.
.totalSpecularNode : Node.<vec3>A node representing the total specular light.

Methods

MethodDescription
.analyze( builder : NodeBuilder )Analyzes the node's dependencies by building all nested light nodes and the output node.
.customCacheKey() : numberOverwrites the default Node#customCacheKey implementation by including light data into the cache key.
.getHash( builder : NodeBuilder ) : stringComputes a hash value for identifying the current light nodes setup.
.getLights() : Array.<Light>Returns an array of the scene's lights.
.setLights( lights : Array.<Light> ) : LightsNodeConfigures this node with an array of lights.
.setup( builder : NodeBuilder ) : Node.<vec3>The implementation makes sure that for each light in the scene there is a corresponding light node. By building the light nodes and evaluating the lighting model the outgoing light is computed.
.setupDirectLight( builder : Object, lightNode : Object, lightData : Object )Sets up a direct light in the lighting model.
.setupDirectRectAreaLight( builder : Object, lightNode : Object, lightData : Object )Sets up a direct rect area light in the lighting model.
.setupLights( builder : NodeBuilder, lightNodes : Array.<LightingNode> )Setups the internal lights by building all respective light nodes.
.setupLightsNode( builder : NodeBuilder ) : Array.<LightingNode>Creates lighting nodes for each scene light. This makes it possible to further process lights in the node system.

Key Takeaways

  1. LightsNode extends: EventDispatcher → Node
  2. Most relevant properties: global, hasLights, outgoingLightNode, totalDiffuseNode.
  3. Key methods: analyze, customCacheKey, getHash, getLights.

Connects To