Forráskód Böngészése

LightsNode: Fix cache key. (#30045)

* LightsNode: Fix cache key.

* Update LightsNode.js

---------

Co-authored-by: sunag <sunagbrasil@gmail.com>
Michael Herzog 1 éve
szülő
commit
e4a48bd6bf
1 módosított fájl, 24 hozzáadás és 0 törlés
  1. 24 0
      src/nodes/lighting/LightsNode.js

+ 24 - 0
src/nodes/lighting/LightsNode.js

@@ -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 ) => {
 
@@ -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 ) {

粤ICP备19079148号