📄 Lighting.js
¶
📊 Analysis Summary¶
Metric | Count |
---|---|
🔧 Functions | 2 |
🧱 Classes | 1 |
📦 Imports | 2 |
📊 Variables & Constants | 2 |
📚 Table of Contents¶
🛠️ File Location:¶
📂 src/renderers/common/Lighting.js
📦 Imports¶
Name | Source |
---|---|
LightsNode |
../../nodes/Nodes.js |
ChainMap |
./ChainMap.js |
Variables & Constants¶
Name | Type | Kind | Value | Exported |
---|---|---|---|---|
_defaultLights |
LightsNode |
let/var | new LightsNode() |
✗ |
_chainKeys |
any[] |
let/var | [] |
✗ |
Functions¶
Lighting.createNode(lights: Light[]): LightsNode
¶
JSDoc:
/**
* Creates a new lights node for the given array of lights.
*
* @param {Array<Light>} lights - The render object.
* @return {LightsNode} The lights node.
*/
Parameters:
lights
Light[]
Returns: LightsNode
Calls:
new LightsNode().setLights
Lighting.getNode(scene: Scene, camera: Camera): LightsNode
¶
JSDoc:
/**
* Returns a lights node for the given scene and camera.
*
* @param {Scene} scene - The scene.
* @param {Camera} camera - The camera.
* @return {LightsNode} The lights node.
*/
Parameters:
scene
Scene
camera
Camera
Returns: LightsNode
Calls:
this.get
this.createNode
this.set
Internal Comments:
Code
getNode( scene, camera ) {
// ignore post-processing
if ( scene.isQuadMesh ) return _defaultLights;
_chainKeys[ 0 ] = scene;
_chainKeys[ 1 ] = camera;
let node = this.get( _chainKeys );
if ( node === undefined ) {
node = this.createNode();
this.set( _chainKeys, node );
}
_chainKeys.length = 0;
return node;
}
Classes¶
Lighting
¶
Class Code
class Lighting extends ChainMap {
/**
* Constructs a lighting management component.
*/
constructor() {
super();
}
/**
* Creates a new lights node for the given array of lights.
*
* @param {Array<Light>} lights - The render object.
* @return {LightsNode} The lights node.
*/
createNode( lights = [] ) {
return new LightsNode().setLights( lights );
}
/**
* Returns a lights node for the given scene and camera.
*
* @param {Scene} scene - The scene.
* @param {Camera} camera - The camera.
* @return {LightsNode} The lights node.
*/
getNode( scene, camera ) {
// ignore post-processing
if ( scene.isQuadMesh ) return _defaultLights;
_chainKeys[ 0 ] = scene;
_chainKeys[ 1 ] = camera;
let node = this.get( _chainKeys );
if ( node === undefined ) {
node = this.createNode();
this.set( _chainKeys, node );
}
_chainKeys.length = 0;
return node;
}
}
Methods¶
createNode(lights: Light[]): LightsNode
¶
getNode(scene: Scene, camera: Camera): LightsNode
¶
Code
getNode( scene, camera ) {
// ignore post-processing
if ( scene.isQuadMesh ) return _defaultLights;
_chainKeys[ 0 ] = scene;
_chainKeys[ 1 ] = camera;
let node = this.get( _chainKeys );
if ( node === undefined ) {
node = this.createNode();
this.set( _chainKeys, node );
}
_chainKeys.length = 0;
return node;
}