Skip to content

Commit 5a7ef84

Browse files
Mugen87RuthySheffi
authored andcommitted
LightsNode: Honor spotlight maps in cache key. (mrdoob#30940)
* LightsNode: Honor spotlight maps in cache key. * LightsNode: Make spot light hash more robust.
1 parent 3b18198 commit 5a7ef84

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

src/nodes/lighting/LightsNode.js

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,23 +107,33 @@ class LightsNode extends Node {
107107
}
108108

109109
/**
110-
* Overwrites the default {@link Node#customCacheKey} implementation by including the
111-
* light IDs into the cache key.
110+
* Overwrites the default {@link Node#customCacheKey} implementation by including
111+
* light data into the cache key.
112112
*
113113
* @return {number} The custom cache key.
114114
*/
115115
customCacheKey() {
116116

117-
const lightIDs = [];
117+
const hashData = [];
118118
const lights = this._lights;
119119

120120
for ( let i = 0; i < lights.length; i ++ ) {
121121

122-
lightIDs.push( lights[ i ].id );
122+
const light = lights[ i ];
123+
124+
hashData.push( light.id );
125+
126+
if ( light.isSpotLight === true ) {
127+
128+
const hashValue = ( light.map !== null ) ? light.map.id : - 1;
129+
130+
hashData.push( hashValue );
131+
132+
}
123133

124134
}
125135

126-
return hashArray( lightIDs );
136+
return hashArray( hashData );
127137

128138
}
129139

0 commit comments

Comments
 (0)