Skip to content

Commit 3f1307e

Browse files
committed
addressing PR feedback and updating to colorSpace
1 parent 706e9cf commit 3f1307e

File tree

2 files changed

+15
-21
lines changed

2 files changed

+15
-21
lines changed

examples/jsm/exporters/GLTFExporter.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -841,8 +841,8 @@ class GLTFWriter {
841841

842842
}
843843

844-
const metalness = metalnessMap?.image;
845-
const roughness = roughnessMap?.image;
844+
const metalness = metalnessMap ? metalnessMap.image : null;
845+
const roughness = roughnessMap ? roughnessMap.image : null;
846846

847847
const width = Math.max( metalness ? metalness.width : 0, roughness ? roughness.width : 0 );
848848
const height = Math.max( metalness ? metalness.height : 0, roughness ? roughness.height : 0 );
@@ -1160,7 +1160,7 @@ class GLTFWriter {
11601160

11611161
} else {
11621162

1163-
throw new Error( 'THREE.GLTFExporter: Unsupported bufferAttribute component type: ' + attribute.array.constructor );
1163+
throw new Error( 'THREE.GLTFExporter: Unsupported bufferAttribute component type: ' + attribute.array.constructor.name );
11641164

11651165
}
11661166

@@ -1250,7 +1250,7 @@ class GLTFWriter {
12501250

12511251
if ( format !== RGBAFormat ) {
12521252

1253-
console.error( 'GLTFExporter: Only RGBAFormat is supported.', image );
1253+
console.error( 'GLTFExporter: Only RGBAFormat is supported.', format );
12541254

12551255
}
12561256

@@ -1371,8 +1371,6 @@ class GLTFWriter {
13711371
if ( map instanceof CompressedTexture ) {
13721372

13731373
map = decompress( map, options.maxTextureSize );
1374-
// remove from cache, as the underlaying canvas is always the same between decompressed textures
1375-
cache.images.delete( map.image );
13761374

13771375
}
13781376

examples/jsm/utils/TextureUtils.js

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -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;
1414
let fullscreenQuadGeometry;
1515
let fullscreenQuadMaterial;
1616
let 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

Comments
 (0)