소스 검색

Merge pull request #6217 from repsac/bl_options

Added Preset Dropdown
Mr.doob 10 년 전
부모
커밋
62732a3428
1개의 변경된 파일8개의 추가작업 그리고 179개의 파일을 삭제
  1. 8 179
      utils/exporters/blender/addons/io_three/__init__.py

+ 8 - 179
utils/exporters/blender/addons/io_three/__init__.py

@@ -18,7 +18,6 @@
 
 import os
 import json
-import logging
 
 import bpy
 from bpy_extras.io_utils import ExportHelper
@@ -32,17 +31,10 @@ from bpy.props import (
 
 from . import constants
 
-logging.basicConfig(
-    format='%(levelname)s:THREE:%(message)s',
-    level=logging.DEBUG)
-
-SETTINGS_FILE_EXPORT = 'three_settings_export.js'
-
-
 bl_info = {
     'name': "Three.js Format",
-    'author': "repsac, mrdoob, yomotsu, mpk, jpweeks",
-    'version': (1, 3, 1),
+    'author': "repsac, mrdoob, yomotsu, mpk, jpweeks, rkusa",
+    'version': (1, 4, 0),
     'blender': (2, 7, 3),
     'location': "File > Export",
     'description': "Export Three.js formatted JSON files.",
@@ -53,6 +45,7 @@ bl_info = {
     'category': 'Import-Export'
 }
 
+
 def _geometry_types():
     """The valid geometry types that are supported by Three.js
 
@@ -257,17 +250,9 @@ class ThreeObject(bpy.types.Panel):
         row = layout.row()
         row.prop(obj, 'THREE_export', text='Export')
 
-def get_settings_fullpath():
-    """
-
-    :returns: Full path to the settings file (temp directory)
-
-    """
-    return os.path.join(bpy.app.tempdir, SETTINGS_FILE_EXPORT)
-
 
-def save_settings_export(properties):
-    """Save the current export settings to disk.
+def set_settings(properties):
+    """Set the export settings to the correct keys.
 
     :param properties:
     :returns: settings
@@ -312,166 +297,9 @@ def save_settings_export(properties):
         constants.INFLUENCES_PER_VERTEX: properties.option_influences
     }
 
-    fname = get_settings_fullpath()
-    logging.debug("Saving settings to %s", fname)
-    with open(fname, 'w') as stream:
-        json.dump(settings, stream)
-
     return settings
 
 
-def restore_settings_export(properties):
-    """Restore the settings (if settings file is found on disk)
-    If not found thend default to paramgers defined in
-    constants.EXPORT_OPTIONS
-
-    :param properties:
-
-    """
-
-    settings = {}
-
-    fname = get_settings_fullpath()
-    if os.path.exists(fname) and os.access(fname, os.R_OK):
-        logging.debug("Settings cache found %s", fname)
-        with open(fname, 'r') as fs:
-            settings = json.load(fs)
-    else:
-        logging.debug("No settings file found, using defaults.")
-
-    ## Geometry {
-    properties.option_vertices = settings.get(
-        constants.VERTICES,
-        constants.EXPORT_OPTIONS[constants.VERTICES])
-
-    properties.option_faces = settings.get(
-        constants.FACES,
-        constants.EXPORT_OPTIONS[constants.FACES])
-    properties.option_normals = settings.get(
-        constants.NORMALS,
-        constants.EXPORT_OPTIONS[constants.NORMALS])
-
-    properties.option_skinning = settings.get(
-        constants.SKINNING,
-        constants.EXPORT_OPTIONS[constants.SKINNING])
-
-    properties.option_bones = settings.get(
-        constants.BONES,
-        constants.EXPORT_OPTIONS[constants.BONES])
-
-    properties.option_influences = settings.get(
-        constants.INFLUENCES_PER_VERTEX,
-        constants.EXPORT_OPTIONS[constants.INFLUENCES_PER_VERTEX])
-
-    properties.option_geometry_type = settings.get(
-        constants.GEOMETRY_TYPE,
-        constants.EXPORT_OPTIONS[constants.GEOMETRY_TYPE])
-    ## }
-
-    ## Materials {
-    properties.option_materials = settings.get(
-        constants.MATERIALS,
-        constants.EXPORT_OPTIONS[constants.MATERIALS])
-
-    properties.option_uv_coords = settings.get(
-        constants.UVS,
-        constants.EXPORT_OPTIONS[constants.UVS])
-
-    properties.option_face_materials = settings.get(
-        constants.FACE_MATERIALS,
-        constants.EXPORT_OPTIONS[constants.FACE_MATERIALS])
-
-    properties.option_maps = settings.get(
-        constants.MAPS,
-        constants.EXPORT_OPTIONS[constants.MAPS])
-
-    properties.option_colors = settings.get(
-        constants.COLORS,
-        constants.EXPORT_OPTIONS[constants.COLORS])
-
-    properties.option_mix_colors = settings.get(
-        constants.MIX_COLORS,
-        constants.EXPORT_OPTIONS[constants.MIX_COLORS])
-    ## }
-
-    ## Settings {
-    properties.option_scale = settings.get(
-        constants.SCALE,
-        constants.EXPORT_OPTIONS[constants.SCALE])
-
-    properties.option_round_off = settings.get(
-        constants.ENABLE_PRECISION,
-        constants.EXPORT_OPTIONS[constants.ENABLE_PRECISION])
-
-    properties.option_round_value = settings.get(
-        constants.PRECISION,
-        constants.EXPORT_OPTIONS[constants.PRECISION])
-
-    properties.option_logging = settings.get(
-        constants.LOGGING,
-        constants.EXPORT_OPTIONS[constants.LOGGING])
-
-    properties.option_compression = settings.get(
-        constants.COMPRESSION,
-        constants.NONE)
-
-    properties.option_indent = settings.get(
-        constants.INDENT,
-        constants.EXPORT_OPTIONS[constants.INDENT])
-
-    properties.option_copy_textures = settings.get(
-        constants.COPY_TEXTURES,
-        constants.EXPORT_OPTIONS[constants.COPY_TEXTURES])
-
-    properties.option_texture_folder = settings.get(
-        constants.TEXTURE_FOLDER,
-        constants.EXPORT_OPTIONS[constants.TEXTURE_FOLDER])
-
-    properties.option_embed_animation = settings.get(
-        constants.EMBED_ANIMATION,
-        constants.EXPORT_OPTIONS[constants.EMBED_ANIMATION])
-    ## }
-
-    ## Scene {
-    properties.option_export_scene = settings.get(
-        constants.SCENE,
-        constants.EXPORT_OPTIONS[constants.SCENE])
-
-    #properties.option_embed_geometry = settings.get(
-    #    constants.EMBED_GEOMETRY,
-    #    constants.EXPORT_OPTIONS[constants.EMBED_GEOMETRY])
-
-    properties.option_lights = settings.get(
-        constants.LIGHTS,
-        constants.EXPORT_OPTIONS[constants.LIGHTS])
-
-    properties.option_cameras = settings.get(
-        constants.CAMERAS,
-        constants.EXPORT_OPTIONS[constants.CAMERAS])
-
-    properties.option_hierarchy = settings.get(
-        constants.HIERARCHY,
-        constants.EXPORT_OPTIONS[constants.HIERARCHY])
-    ## }
-
-    ## Animation {
-    properties.option_animation_morph = settings.get(
-        constants.MORPH_TARGETS,
-        constants.EXPORT_OPTIONS[constants.MORPH_TARGETS])
-
-    properties.option_animation_skeletal = settings.get(
-        constants.ANIMATION,
-        constants.EXPORT_OPTIONS[constants.ANIMATION])
-
-    properties.option_frame_step = settings.get(
-        constants.FRAME_STEP,
-        constants.EXPORT_OPTIONS[constants.FRAME_STEP])
-
-    properties.option_frame_index_as_time = settings.get(
-        constants.FRAME_INDEX_AS_TIME,
-        constants.EXPORT_OPTIONS[constants.FRAME_INDEX_AS_TIME])
-    ## }
-
 def compression_types():
     """Supported compression formats
 
@@ -489,6 +317,7 @@ def compression_types():
 
     return types
 
+
 def animation_options():
     """The supported skeletal animation types
 
@@ -508,6 +337,7 @@ class ExportThree(bpy.types.Operator, ExportHelper):
 
     bl_idname = 'export.three'
     bl_label = 'Export THREE'
+    bl_options = {'PRESET'}
 
     filename_ext = constants.EXTENSION
 
@@ -692,7 +522,6 @@ class ExportThree(bpy.types.Operator, ExportHelper):
         default=2)
 
     def invoke(self, context, event):
-        restore_settings_export(self.properties)
         return ExportHelper.invoke(self, context, event)
 
     @classmethod
@@ -713,7 +542,7 @@ class ExportThree(bpy.types.Operator, ExportHelper):
         if not self.properties.filepath:
             raise Exception("filename not set")
 
-        settings = save_settings_export(self.properties)
+        settings = set_settings(self.properties)
         settings['addon_version'] = bl_info['version']
 
         filepath = self.filepath