Last active
August 29, 2015 14:27
-
-
Save jeromeetienne/c462e23393f6a5acbdd3 to your computer and use it in GitHub Desktop.
lossy compression for 3d models in json - 10min compression algo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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