Browse Source

(alteredq fix)
Changed mesh JS class name generator in Blender exporter to use cross-platform path parsing.
Old version was generating broken class names on Windows (full path was included).

Mr.doob 15 years ago
parent
commit
bd2dc37e50

+ 5 - 4
utils/exporters/blender/2.54/scripts/op/io_mesh_threejs/export_threejs.py

@@ -17,7 +17,7 @@
 # ##### END GPL LICENSE BLOCK #####
 # ##### END GPL LICENSE BLOCK #####
 
 
 # Based on export_ply.py
 # Based on export_ply.py
-# Contributors: Mr.doob, Kikko
+# Contributors: Mr.doob, Kikko, alteredq
 
 
 """
 """
 This script exports the selected object for the three.js engine.
 This script exports the selected object for the three.js engine.
@@ -25,22 +25,23 @@ This script exports the selected object for the three.js engine.
 
 
 import bpy
 import bpy
 import os
 import os
+import os.path
 
 
 def save(operator, context, filepath="", use_modifiers=True, use_normals=True, use_uv_coords=True, use_colors=True):
 def save(operator, context, filepath="", use_modifiers=True, use_normals=True, use_uv_coords=True, use_colors=True):
-    
+
     def rvec3d(v):
     def rvec3d(v):
         return round(v[0], 6), round(v[1], 6), round(v[2], 6)
         return round(v[0], 6), round(v[1], 6), round(v[2], 6)
 
 
     def rvec2d(v):
     def rvec2d(v):
         return round(v[0], 6), round(v[1], 6)
         return round(v[0], 6), round(v[1], 6)
-    
+
     scene = context.scene
     scene = context.scene
     obj = context.object
     obj = context.object
 
 
     if not filepath.lower().endswith('.js'):
     if not filepath.lower().endswith('.js'):
         filepath += '.js'
         filepath += '.js'
 
 
-    classname = filepath.split('/')[-1].replace('.js','')
+    classname = os.path.basename(filepath).split(".")[0]
 
 
     if not obj:
     if not obj:
         raise Exception("Error, Select 1 active object")
         raise Exception("Error, Select 1 active object")