Skip to content

Commit

Permalink
WebGPURenderer: Reuse LightNode when available (#29480)
Browse files Browse the repository at this point in the history
* WebGPURenderer: Reuse LightNode when available

* cleanup
  • Loading branch information
RenaudRohlinger authored Sep 24, 2024
1 parent f97d930 commit 12bcf60
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/nodes/lighting/LightsNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ const getLightNodeById = ( id, lightNodes ) => {

};

const _lightsNodeRef = /*@__PURE__*/ new WeakMap();

class LightsNode extends Node {

static get type() {
Expand Down Expand Up @@ -119,7 +121,20 @@ class LightsNode extends Node {

}

lightNodes.push( nodeObject( new lightNodeClass( light ) ) );
let lightNode = null;

if ( ! _lightsNodeRef.has( light ) ) {

lightNode = new lightNodeClass( light );
_lightsNodeRef.set( light, lightNode );

} else {

lightNode = _lightsNodeRef.get( light );

}

lightNodes.push( lightNode );

}

Expand Down

0 comments on commit 12bcf60

Please sign in to comment.