Sfoglia il codice sorgente

Added checkbox for scene/html base type

Jhonny Göransson 14 anni fa
parent
commit
acae6714c9

+ 7 - 1
utils/exporters/blender/2.57/scripts/addons/io_mesh_threejs/__init__.py

@@ -178,6 +178,7 @@ def save_settings_export(properties):
     
     "option_lights" : properties.option_lights,
     "option_cameras" : properties.option_cameras,
+    "option_url_base_type" : properties.option_url_base_type,
 
     "option_flip_yz"      : properties.option_flip_yz,
 
@@ -225,6 +226,7 @@ def restore_settings_export(properties):
 
     properties.option_export_scene = settings.get("option_export_scene", False)
     properties.option_embed_meshes = settings.get("option_embed_meshes", True)
+    properties.option_url_base_type = settings.get("option_url_base_type", True)
 
     properties.option_lights = settings.get("option_lights", False)
     properties.option_cameras = settings.get("option_cameras", False)
@@ -263,7 +265,8 @@ class ExportTHREEJS(bpy.types.Operator, ExportHelper):
 
     option_export_scene = BoolProperty(name = "Scene", description = "Export scene", default = False)
     option_embed_meshes = BoolProperty(name = "Embed", description = "Embed meshes", default = True)
-    
+    option_url_base_type = BoolProperty(name = "Url Base Type", description = "Url base type", default=True)
+
     option_lights = BoolProperty(name = "Lights", description = "Export default scene lights", default = False)
     option_cameras = BoolProperty(name = "Cameras", description = "Export default scene cameras", default = False)
 
@@ -284,6 +287,7 @@ class ExportTHREEJS(bpy.types.Operator, ExportHelper):
         save_settings_export(self.properties)
 
         filepath = self.filepath
+
         import io_mesh_threejs.export_threejs
         return io_mesh_threejs.export_threejs.save(self, context, **self.properties)
 
@@ -341,8 +345,10 @@ class ExportTHREEJS(bpy.types.Operator, ExportHelper):
 
         row = layout.row()
         row.prop(self.properties, "option_export_scene")
+
         row.prop(self.properties, "option_lights")
         row.prop(self.properties, "option_cameras")
+        row.prop(self.properties, "option_url_base_type")
 
         row = layout.row()
         row.prop(self.properties, "option_embed_meshes")

+ 17 - 5
utils/exporters/blender/2.57/scripts/addons/io_mesh_threejs/export_threejs.py

@@ -91,7 +91,7 @@ TEMPLATE_SCENE_ASCII = """\
 var scene = {
 
 "type" : "scene",
-"urlBaseType" : "relativeToScene",
+"urlBaseType" : %(basetype)s,
 
 %(sections)s
 
@@ -1473,6 +1473,13 @@ def generate_ascii_scene(data):
 
     embeds = generate_embeds(data)
 
+    basetype = "RelativeTo"
+
+    if data["base_type"]:
+        basetype += "HTML"
+    else:
+        basetype += "Scene"
+
     sections = [
     ["objects",    objects],
     ["geometries", geometries],
@@ -1506,6 +1513,7 @@ def generate_ascii_scene(data):
     "nobjects"      : nobjects,
     "ngeometries"   : ngeometries,
     "ntextures"     : ntextures,
+    "basetype"      : generate_string(basetype),
     "nmaterials"    : nmaterials,
 
     "position"      : generate_vec3(DEFAULTS["position"]),
@@ -1517,7 +1525,7 @@ def generate_ascii_scene(data):
 
     return text
 
-def export_scene(scene, filepath, flipyz, option_colors, option_lights, option_cameras, option_embed_meshes, embeds):
+def export_scene(scene, filepath, flipyz, option_colors, option_lights, option_cameras, option_embed_meshes, embeds,option_url_base_type):
 
     source_file = os.path.basename(bpy.data.filepath)
 
@@ -1532,7 +1540,8 @@ def export_scene(scene, filepath, flipyz, option_colors, option_lights, option_c
     "use_colors"  : option_colors,
     "use_lights"  : option_lights, 
     "use_cameras" : option_cameras,
-    "embed_meshes": option_embed_meshes
+    "embed_meshes": option_embed_meshes,
+    "base_type"   : option_url_base_type
     }
     scene_text += generate_ascii_scene(data)
 
@@ -1557,7 +1566,10 @@ def save(operator, context, filepath = "",
          option_lights = False,
          option_cameras = False,
          option_scale = 1.0,
-         option_embed_meshes = True):
+         option_embed_meshes = True,
+         option_url_base_type = True):
+
+    print("URL TYPE",option_url_base_type)
 
     filepath = ensure_extension(filepath, '.js')
 
@@ -1624,7 +1636,7 @@ def save(operator, context, filepath = "",
 
                     geo_set.add(name)
 
-        export_scene(scene, filepath, option_flip_yz, option_colors, option_lights, option_cameras, option_embed_meshes, embeds)
+        export_scene(scene, filepath, option_flip_yz, option_colors, option_lights, option_cameras, option_embed_meshes, embeds,option_url_base_type)
 
     else: