Dad72 Posted March 6, 2017 Share Posted March 6, 2017 Hello, Is it normal that after serializing is the double weight of a model not serialized. I have a model with Skeleton and animation that 16 MB, but once serialize, the file is now 38 MB Why is not it the same weight. is there information duplicate add? I think the difference is huge. it has 22 MB add to the original file 16MB Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted March 6, 2017 Share Posted March 6, 2017 This is kind of expected as JSON serialization adds a lot of data when serializing numbers (instead of serializing "0", it will serialize "0.0000000") Quote Link to comment Share on other sites More sharing options...
Dad72 Posted March 6, 2017 Author Share Posted March 6, 2017 How can we remove it to reduce the final weight of the object to serialize? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted March 6, 2017 Share Posted March 6, 2017 I don't know This is a pure JS question actually. And I'm not sure we can control how JS serializes data. Perhaps something like that: https://github.com/tcorral/JSONC Quote Link to comment Share on other sites More sharing options...
Dad72 Posted March 6, 2017 Author Share Posted March 6, 2017 Yet when I look in the file, the numbers have no 0.0000., I see 0. By cons it is true that each number has a float number rise after the comma compare the original file. 4 decimal in the original file and 16 after the decimal point in the serialized file. (4 * 4) There is no possibility to reduce the number of decimal 4 or 6 at the time of serialization in Babylon. Quote Link to comment Share on other sites More sharing options...
adam Posted March 6, 2017 Share Posted March 6, 2017 http://stackoverflow.com/questions/9339870/how-to-reduce-numbers-significance-in-jsons-stringify Dad72 1 Quote Link to comment Share on other sites More sharing options...
Dad72 Posted March 6, 2017 Author Share Posted March 6, 2017 Thanks Adam. var str_serialized = JSON.stringify(serialization, function(key, val) { return val.toFixed ? Number(val.toFixed(4)) : val;}); Quote Link to comment Share on other sites More sharing options...
Dad72 Posted March 6, 2017 Author Share Posted March 6, 2017 Arf, in fact if I made it, the model not load. Quote Link to comment Share on other sites More sharing options...
Dad72 Posted March 6, 2017 Author Share Posted March 6, 2017 With PHP if I had done this instead of recording in gross, decreases the file is 26 MB rather that 38 MB I still fails to get closer to the initial weight of the file (before serialization 16 MB). There I +10MB. But the file babylon load after $json = json_decode($value, true); $json["meshes"][0]["scaling"][0] = (float)$_POST['scale']; $json["meshes"][0]["scaling"][1] = (float)$_POST['scale']; $json["meshes"][0]["scaling"][2] = (float)$_POST['scale']; $save = json_encode($json); @chmod($root, 0777); file_put_contents($root, $save); GameMonetize 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.