Skip to content

Commit

Permalink
Merge pull request #528 from CesiumGS/clone-options
Browse files Browse the repository at this point in the history
Clone options before modifying options
  • Loading branch information
lilleyse committed Mar 4, 2020
2 parents 176827d + 7835ed0 commit 1e27e2b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/gltfToGlb.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const Cesium = require('cesium');
const getJsonBufferPadded = require('./getJsonBufferPadded');
const processGltf = require('./processGltf');

const defaultValue = Cesium.defaultValue;
const clone = Cesium.clone;
const defined = Cesium.defined;

module.exports = gltfToGlb;
Expand All @@ -16,7 +16,7 @@ module.exports = gltfToGlb;
* @returns {Promise} A promise that resolves to a buffer containing the glb contents.
*/
function gltfToGlb(gltf, options) {
options = defaultValue(options, {});
options = defined(options) ? clone(options) : {};
options.bufferStorage = {
buffer: undefined
};
Expand Down
3 changes: 2 additions & 1 deletion lib/processGltf.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const updateVersion = require('./updateVersion');
const writeResources = require('./writeResources');
const compressDracoMeshes = require('./compressDracoMeshes');

const clone = Cesium.clone;
const defaultValue = Cesium.defaultValue;
const defined = Cesium.defined;

Expand All @@ -35,7 +36,7 @@ module.exports = processGltf;
*/
function processGltf(gltf, options) {
const defaults = processGltf.defaults;
options = defaultValue(options, {});
options = defined(options) ? clone(options) : {};
options.separateBuffers = defaultValue(options.separate, defaults.separate);
options.separateShaders = defaultValue(options.separate, defaults.separate);
options.separateTextures = defaultValue(options.separateTextures, defaults.separateTextures) || options.separate;
Expand Down

0 comments on commit 1e27e2b

Please sign in to comment.