Skip to content

Commit

Permalink
Use removeUnusedElements in writeResources
Browse files Browse the repository at this point in the history
  • Loading branch information
lilleyse committed Apr 27, 2018
1 parent ed74d1b commit f51e4fe
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions lib/writeResources.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ var Promise = require('bluebird');
var ForEach = require('./ForEach');
var getImageExtension = require('./getImageExtension');
var mergeBuffers = require('./mergeBuffers');
var removeUnusedElements = require('./removeUnusedElements');

Jimp.prototype.getBufferAsync = Promise.promisify(Jimp.prototype.getBuffer);

Expand Down Expand Up @@ -61,6 +62,7 @@ function writeResources(gltf, options) {
return Promise.all(promises)
.then(function() {
mergeBuffers(gltf);
removeUnusedElements(gltf);
return writeBuffer(gltf, gltf.buffers[0], 0, options);
})
.then(function() {
Expand Down Expand Up @@ -98,15 +100,12 @@ function writeResource(gltf, object, index, separate, dataUris, extension, optio
if (separate) {
return writeFile(gltf, object, index, extension, options);
} else if (dataUris) {
return Promise.resolve(writeDataUri(gltf, object, extension));
return Promise.resolve(writeDataUri(object, extension));
}
return Promise.resolve(writeBufferView(gltf, object));
}

function writeDataUri(gltf, object, extension) {
if (defined(object.bufferView)) {
gltf.bufferViews.splice(object.bufferView, 1);
}
function writeDataUri(object, extension) {
delete object.bufferView;
var source = object.extras._pipeline.source;
var mimeType = mime.getType(extension);
Expand Down Expand Up @@ -205,9 +204,6 @@ function getRelativePath(gltf, object, index, extension, options) {
}

function writeFile(gltf, object, index, extension, options) {
if (defined(object.bufferView)) {
gltf.bufferViews.splice(object.bufferView, 1);
}
delete object.bufferView;
var source = object.extras._pipeline.source;
var relativePath = getRelativePath(gltf, object, index, extension, options);
Expand Down

0 comments on commit f51e4fe

Please sign in to comment.