diff --git a/examples/js/exporters/GLTFExporter.js b/examples/js/exporters/GLTFExporter.js index f98bd2c1e3533e..fcfc3e50b86c81 100644 --- a/examples/js/exporters/GLTFExporter.js +++ b/examples/js/exporters/GLTFExporter.js @@ -98,8 +98,8 @@ THREE.GLTFExporter.prototype = { var skins = []; var cachedData = { - images: {}, - materials: {} + materials: {}, + textures: {} }; @@ -448,11 +448,7 @@ THREE.GLTFExporter.prototype = { */ function processImage( map ) { - if ( cachedData.images[ map.uuid ] !== undefined ) { - - return cachedData.images[ map.uuid ]; - - } + // @TODO Cache if ( ! outputJSON.images ) { @@ -491,10 +487,7 @@ THREE.GLTFExporter.prototype = { outputJSON.images.push( gltfImage ); - var index = outputJSON.images.length - 1; - cachedData.images[ map.uuid ] = index; - - return index; + return outputJSON.images.length - 1; } @@ -533,6 +526,12 @@ THREE.GLTFExporter.prototype = { */ function processTexture( map ) { + if ( cachedData.textures[ map.uuid ] !== undefined ) { + + return cachedData.textures[ map.uuid ]; + + } + if ( ! outputJSON.textures ) { outputJSON.textures = []; @@ -548,7 +547,10 @@ THREE.GLTFExporter.prototype = { outputJSON.textures.push( gltfTexture ); - return outputJSON.textures.length - 1; + var index = outputJSON.textures.length - 1; + cachedData.textures[ map.uuid ] = index; + + return index; }