diff --git a/src/extras/PMREMGenerator.js b/src/extras/PMREMGenerator.js index f5231d660469f2..2fd04d65c44f2c 100644 --- a/src/extras/PMREMGenerator.js +++ b/src/extras/PMREMGenerator.js @@ -54,13 +54,6 @@ const ENCODINGS = { [ GammaEncoding ]: 6 }; -const backgroundMaterial = new MeshBasicMaterial( { - side: BackSide, - depthWrite: false, - depthTest: false, -} ); -const backgroundBox = new Mesh( new BoxGeometry(), backgroundMaterial ); - const _flatCamera = /*@__PURE__*/ new OrthographicCamera(); const { _lodPlanes, _sizeLods, _sigmas } = /*@__PURE__*/ _createPlanes(); const _clearColor = /*@__PURE__*/ new Color(); @@ -279,8 +272,18 @@ class PMREMGenerator { renderer.outputEncoding = LinearEncoding; renderer.autoClear = false; + const backgroundMaterial = new MeshBasicMaterial( { + name: 'PMREM.Background', + side: BackSide, + depthWrite: false, + depthTest: false, + } ); + + const backgroundBox = new Mesh( new BoxGeometry(), backgroundMaterial ); + let useSolidColor = false; const background = scene.background; + if ( background ) { if ( background.isColor ) { @@ -298,7 +301,6 @@ class PMREMGenerator { } - for ( let i = 0; i < 6; i ++ ) { const col = i % 3; @@ -333,6 +335,9 @@ class PMREMGenerator { } + backgroundBox.geometry.dispose(); + backgroundBox.material.dispose(); + renderer.toneMapping = toneMapping; renderer.outputEncoding = outputEncoding; renderer.autoClear = originalAutoClear;