@@ -7,10 +7,10 @@ import {
77 Scene ,
88 WebGLRenderer ,
99 Texture ,
10- sRGBEncoding
10+ SRGBColorSpace
1111} from 'three' ;
1212
13- let temporaryRenderer ;
13+ let _renderer ;
1414let fullscreenQuadGeometry ;
1515let fullscreenQuadMaterial ;
1616let fullscreenQuad ;
@@ -47,7 +47,7 @@ export function decompress( texture, maxTextureSize, renderer = null ) {
4747 } ) ;
4848
4949 fullscreenQuadMaterial . uniforms . blitTexture . value = texture ;
50- fullscreenQuadMaterial . defines . IS_SRGB = texture . encoding == sRGBEncoding ;
50+ fullscreenQuadMaterial . defines . IS_SRGB = texture . colorSpace == SRGBColorSpace ;
5151 fullscreenQuadMaterial . needsUpdate = true ;
5252
5353 if ( ! fullscreenQuad ) {
@@ -57,22 +57,19 @@ export function decompress( texture, maxTextureSize, renderer = null ) {
5757
5858 }
5959
60- const temporaryCam = new PerspectiveCamera ( ) ;
61- const temporaryScene = new Scene ( ) ;
62- temporaryScene . add ( fullscreenQuad ) ;
60+ const _camera = new PerspectiveCamera ( ) ;
61+ const _scene = new Scene ( ) ;
62+ _scene . add ( fullscreenQuad ) ;
6363
6464 if ( ! renderer ) {
6565
66- if ( ! temporaryRenderer )
67- temporaryRenderer = new WebGLRenderer ( { antialias : false } ) ;
68-
69- renderer = temporaryRenderer ;
66+ renderer = _renderer = new WebGLRenderer ( { antialias : false } ) ;
7067
7168 }
7269
7370 renderer . setSize ( Math . min ( texture . image . width , maxTextureSize ) , Math . min ( texture . image . height , maxTextureSize ) ) ;
7471 renderer . clear ( ) ;
75- renderer . render ( temporaryScene , temporaryCam ) ;
72+ renderer . render ( _scene , _camera ) ;
7673
7774 const readableTexture = new Texture ( renderer . domElement ) ;
7875
@@ -82,11 +79,10 @@ export function decompress( texture, maxTextureSize, renderer = null ) {
8279 readableTexture . wrapT = texture . wrapT ;
8380 readableTexture . name = texture . name ;
8481
85- readableTexture . userData . mimeType = 'image/png' ;
86-
87- if ( temporaryRenderer ) {
82+ if ( _renderer ) {
8883
89- temporaryRenderer . dispose ( ) ;
84+ _renderer . dispose ( ) ;
85+ _renderer = null ;
9086
9187 }
9288
0 commit comments