Skip to content

Instantly share code, notes, and snippets.

@jeromeetienne
Last active August 29, 2015 14:27
Show Gist options
  • Save jeromeetienne/c462e23393f6a5acbdd3 to your computer and use it in GitHub Desktop.
Save jeromeetienne/c462e23393f6a5acbdd3 to your computer and use it in GitHub Desktop.
lossy compression for 3d models in json - 10min compression algo
var data = {
foobar : 1234.56789 // NOTE: see the number
}
data = JSON.parse(JSON.stringify(data, function(key, value){
if( typeof(value) !== 'number' ) return value;
// for number, keep at most 6 digits after dot
return Number( value.toFixed(6) )
}))
console.log(data)
// {
// foobar : 1234.56
// }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment