diff --git a/examples/jsm/exporters/GLTFExporter.js b/examples/jsm/exporters/GLTFExporter.js index 3accb80fb1a1ed..e201b7c9d376c9 100644 --- a/examples/jsm/exporters/GLTFExporter.js +++ b/examples/jsm/exporters/GLTFExporter.js @@ -841,8 +841,8 @@ class GLTFWriter { } - const metalness = metalnessMap?.image; - const roughness = roughnessMap?.image; + const metalness = metalnessMap ? metalnessMap.image : null; + const roughness = roughnessMap ? roughnessMap.image : null; const width = Math.max( metalness ? metalness.width : 0, roughness ? roughness.width : 0 ); const height = Math.max( metalness ? metalness.height : 0, roughness ? roughness.height : 0 ); @@ -1160,7 +1160,7 @@ class GLTFWriter { } else { - throw new Error( 'THREE.GLTFExporter: Unsupported bufferAttribute component type: ' + attribute.array.constructor ); + throw new Error( 'THREE.GLTFExporter: Unsupported bufferAttribute component type: ' + attribute.array.constructor.name ); } @@ -1250,7 +1250,7 @@ class GLTFWriter { if ( format !== RGBAFormat ) { - console.error( 'GLTFExporter: Only RGBAFormat is supported.', image ); + console.error( 'GLTFExporter: Only RGBAFormat is supported.', format ); } @@ -1371,8 +1371,6 @@ class GLTFWriter { if ( map instanceof CompressedTexture ) { map = decompress( map, options.maxTextureSize ); - // remove from cache, as the underlaying canvas is always the same between decompressed textures - cache.images.delete( map.image ); } diff --git a/examples/jsm/utils/TextureUtils.js b/examples/jsm/utils/TextureUtils.js index 8b727da3be217e..67dba09ad2b4c9 100644 --- a/examples/jsm/utils/TextureUtils.js +++ b/examples/jsm/utils/TextureUtils.js @@ -7,10 +7,10 @@ import { Scene, WebGLRenderer, Texture, - sRGBEncoding + SRGBColorSpace } from 'three'; -let temporaryRenderer; +let _renderer; let fullscreenQuadGeometry; let fullscreenQuadMaterial; let fullscreenQuad; @@ -47,7 +47,7 @@ export function decompress( texture, maxTextureSize, renderer = null ) { } ); fullscreenQuadMaterial.uniforms.blitTexture.value = texture; - fullscreenQuadMaterial.defines.IS_SRGB = texture.encoding == sRGBEncoding; + fullscreenQuadMaterial.defines.IS_SRGB = texture.colorSpace == SRGBColorSpace; fullscreenQuadMaterial.needsUpdate = true; if ( ! fullscreenQuad ) { @@ -57,22 +57,19 @@ export function decompress( texture, maxTextureSize, renderer = null ) { } - const temporaryCam = new PerspectiveCamera(); - const temporaryScene = new Scene(); - temporaryScene.add( fullscreenQuad ); + const _camera = new PerspectiveCamera(); + const _scene = new Scene(); + _scene.add( fullscreenQuad ); if ( ! renderer ) { - if ( ! temporaryRenderer ) - temporaryRenderer = new WebGLRenderer( { antialias: false } ); - - renderer = temporaryRenderer; + renderer = _renderer = new WebGLRenderer( { antialias: false } ); } renderer.setSize( Math.min( texture.image.width, maxTextureSize ), Math.min( texture.image.height, maxTextureSize ) ); renderer.clear(); - renderer.render( temporaryScene, temporaryCam ); + renderer.render( _scene, _camera ); const readableTexture = new Texture( renderer.domElement ); @@ -82,11 +79,10 @@ export function decompress( texture, maxTextureSize, renderer = null ) { readableTexture.wrapT = texture.wrapT; readableTexture.name = texture.name; - readableTexture.userData.mimeType = 'image/png'; - - if ( temporaryRenderer ) { + if ( _renderer ) { - temporaryRenderer.dispose(); + _renderer.dispose(); + _renderer = null; }