Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GLTFExporter: Texture cache #13417

Merged
merged 4 commits into from
Feb 24, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 14 additions & 12 deletions examples/js/exporters/GLTFExporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ THREE.GLTFExporter.prototype = {
var skins = [];
var cachedData = {

images: {},
materials: {}
materials: {},
textures: {}

};

Expand Down Expand Up @@ -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 ) {

Expand Down Expand Up @@ -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;

}

Expand Down Expand Up @@ -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 = [];
Expand All @@ -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;

}

Expand Down