Skip to content

Commit

Permalink
PMREMGenerator: Correctly restore render target. (mrdoob#27013)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mugen87 committed Oct 19, 2023
1 parent 5377a02 commit 8428bb6
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/extras/PMREMGenerator.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ const MAX_SAMPLES = 20;
const _flatCamera = /*@__PURE__*/ new OrthographicCamera();
const _clearColor = /*@__PURE__*/ new Color();
let _oldTarget = null;
let _oldActiveCubeFace = 0;
let _oldActiveMipmapLevel = 0;

// Golden Ratio
const PHI = ( 1 + Math.sqrt( 5 ) ) / 2;
Expand Down Expand Up @@ -103,6 +105,8 @@ class PMREMGenerator {
fromScene( scene, sigma = 0, near = 0.1, far = 100 ) {

_oldTarget = this._renderer.getRenderTarget();
_oldActiveCubeFace = this._renderer.getActiveCubeFace();
_oldActiveMipmapLevel = this._renderer.getActiveMipmapLevel();

this._setSize( 256 );

Expand Down Expand Up @@ -215,7 +219,7 @@ class PMREMGenerator {

_cleanup( outputTarget ) {

this._renderer.setRenderTarget( _oldTarget );
this._renderer.setRenderTarget( _oldTarget, _oldActiveCubeFace, _oldActiveMipmapLevel );
outputTarget.scissorTest = false;
_setViewport( outputTarget, 0, 0, outputTarget.width, outputTarget.height );

Expand All @@ -234,6 +238,8 @@ class PMREMGenerator {
}

_oldTarget = this._renderer.getRenderTarget();
_oldActiveCubeFace = this._renderer.getActiveCubeFace();
_oldActiveMipmapLevel = this._renderer.getActiveMipmapLevel();

const cubeUVRenderTarget = renderTarget || this._allocateTargets();
this._textureToCubeUV( texture, cubeUVRenderTarget );
Expand Down

0 comments on commit 8428bb6

Please sign in to comment.