diff --git a/examples/jsm/nodes/core/NodeBuilder.js b/examples/jsm/nodes/core/NodeBuilder.js index 75e560e01436b8..96b2af785c3bdc 100644 --- a/examples/jsm/nodes/core/NodeBuilder.js +++ b/examples/jsm/nodes/core/NodeBuilder.js @@ -30,7 +30,7 @@ import ChainMap from '../../renderers/common/ChainMap.js'; import PMREMGenerator from '../../renderers/common/extras/PMREMGenerator.js'; -const bindGroupsCache = new ChainMap(); +const rendererCache = new WeakMap(); const typeFromLength = new Map( [ [ 2, 'vec2' ], @@ -123,6 +123,22 @@ class NodeBuilder { } + getBingGroupsCache() { + + let bindGroupsCache = rendererCache.get( this.renderer ); + + if ( bindGroupsCache === undefined ) { + + bindGroupsCache = new ChainMap(); + + rendererCache.set( this.renderer, bindGroupsCache ); + + } + + return bindGroupsCache; + + } + createRenderTarget( width, height, options ) { return new RenderTarget( width, height, options ); @@ -151,6 +167,8 @@ class NodeBuilder { _getBindGroup( groupName, bindings ) { + const bindGroupsCache = this.getBingGroupsCache(); + // cache individual uniforms group const bindingsArray = [];