Skip to content

Commit

Permalink
LightsNode: Fix cache key. (#30045)
Browse files Browse the repository at this point in the history
* LightsNode: Fix cache key.

* Update LightsNode.js

---------

Co-authored-by: sunag <[email protected]>
  • Loading branch information
Mugen87 and sunag authored Dec 7, 2024
1 parent 58a9949 commit e4a48bd
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/nodes/lighting/LightsNode.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Node from '../core/Node.js';
import { nodeObject, vec3 } from '../tsl/TSLBase.js';
import { hashArray } from '../core/NodeUtils.js';

const sortLights = ( lights ) => {

Expand Down Expand Up @@ -51,6 +52,29 @@ class LightsNode extends Node {

}

getCacheKey( force ) {

force = force || this.version !== this._cacheKeyVersion;

if ( force === true || this._cacheKey === null ) {

const lightIDs = [];

for ( let i = 0; i < this._lights.length; i ++ ) {

lightIDs.push( this._lights[ i ].id );

}

this._cacheKey = hashArray( lightIDs );
this._cacheKeyVersion = this.version;

}

return this._cacheKey;

}

getHash( builder ) {

if ( this._lightNodesHash === null ) {
Expand Down

0 comments on commit e4a48bd

Please sign in to comment.