Skip to content

Commit e4a48bd

Browse files
Mugen87sunag
andauthored
LightsNode: Fix cache key. (#30045)
* LightsNode: Fix cache key. * Update LightsNode.js --------- Co-authored-by: sunag <[email protected]>
1 parent 58a9949 commit e4a48bd

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/nodes/lighting/LightsNode.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import Node from '../core/Node.js';
22
import { nodeObject, vec3 } from '../tsl/TSLBase.js';
3+
import { hashArray } from '../core/NodeUtils.js';
34

45
const sortLights = ( lights ) => {
56

@@ -51,6 +52,29 @@ class LightsNode extends Node {
5152

5253
}
5354

55+
getCacheKey( force ) {
56+
57+
force = force || this.version !== this._cacheKeyVersion;
58+
59+
if ( force === true || this._cacheKey === null ) {
60+
61+
const lightIDs = [];
62+
63+
for ( let i = 0; i < this._lights.length; i ++ ) {
64+
65+
lightIDs.push( this._lights[ i ].id );
66+
67+
}
68+
69+
this._cacheKey = hashArray( lightIDs );
70+
this._cacheKeyVersion = this.version;
71+
72+
}
73+
74+
return this._cacheKey;
75+
76+
}
77+
5478
getHash( builder ) {
5579

5680
if ( this._lightNodesHash === null ) {

0 commit comments

Comments
 (0)