Browse Source

Fix serialization error in Maya exporter

Chris Lewis 12 years ago
parent
commit
ddd0803d8a
1 changed files with 3 additions and 1 deletions
  1. 3 1
      utils/exporters/maya/plug-ins/threeJsFileTranslator.py

+ 3 - 1
utils/exporters/maya/plug-ins/threeJsFileTranlator.py → utils/exporters/maya/plug-ins/threeJsFileTranslator.py

@@ -24,7 +24,9 @@ class DecimalEncoder(json.JSONEncoder):
             if '.' in s and len(s[s.index('.'):]) > FLOAT_PRECISION - 1:
             if '.' in s and len(s[s.index('.'):]) > FLOAT_PRECISION - 1:
                 s = '%.{0}f'.format(FLOAT_PRECISION) % o
                 s = '%.{0}f'.format(FLOAT_PRECISION) % o
                 while '.' in s and s[-1] == '0':
                 while '.' in s and s[-1] == '0':
-                    s = s[-2]
+                    s = s[:-1] # this actually removes the last "0" from the string
+                if s[-1] == '.': # added this test to avoid leaving "0." instead of "0.0",
+                    s += '0'    # which would throw an error while loading the file
             return (s for s in [s])
             return (s for s in [s])
         return super(DecimalEncoder, self)._iterencode(o, markers)
         return super(DecimalEncoder, self)._iterencode(o, markers)