diff --git a/io_scene_gltf2/__init__.py b/io_scene_gltf2/__init__.py index dc80a1e1bf25ac147761c5a88ffee33eaf4ac2bd..e6653a5d2354b283632777c002c47775cc182b34 100755 --- a/io_scene_gltf2/__init__.py +++ b/io_scene_gltf2/__init__.py @@ -4,7 +4,7 @@ bl_info = { 'name': 'glTF 2.0 format', 'author': 'Julien Duroure, Scurest, Norbert Nopper, Urs Hanselmann, Moritz Becher, Benjamin SchmithĂĽsen, Jim Eckerlein, and many external contributors', - "version": (3, 2, 26), + "version": (3, 2, 27), 'blender': (3, 1, 0), 'location': 'File > Import-Export', 'description': 'Import-Export as glTF 2.0', @@ -311,6 +311,12 @@ class ExportGLTF2_Base: default=False ) + use_active_scene: BoolProperty( + name='Active Scene', + description='Export active scene only', + default=False + ) + export_extras: BoolProperty( name='Custom Properties', description='Export custom properties as glTF extras', @@ -485,6 +491,7 @@ class ExportGLTF2_Base: 'use_active_collection', 'use_mesh_edges', 'use_mesh_vertices', + 'use_active_scene', ] all_props = self.properties export_props = { @@ -544,6 +551,7 @@ class ExportGLTF2_Base: export_settings['gltf_visible'] = self.use_visible export_settings['gltf_renderable'] = self.use_renderable export_settings['gltf_active_collection'] = self.use_active_collection + export_settings['gltf_active_scene'] = self.use_active_scene export_settings['gltf_selected'] = self.use_selection export_settings['gltf_layers'] = True # self.export_layers @@ -682,6 +690,7 @@ class GLTF_PT_export_include(bpy.types.Panel): col.prop(operator, 'use_visible') col.prop(operator, 'use_renderable') col.prop(operator, 'use_active_collection') + col.prop(operator, 'use_active_scene') col = layout.column(heading = "Data", align = True) col.prop(operator, 'export_extras') diff --git a/io_scene_gltf2/blender/exp/gltf2_blender_gather.py b/io_scene_gltf2/blender/exp/gltf2_blender_gather.py index b3f4fd2a33a2017ea5f267ff0312b731b3b12cb1..6153bc3369672a0186e3b49d8298dac58770d47b 100755 --- a/io_scene_gltf2/blender/exp/gltf2_blender_gather.py +++ b/io_scene_gltf2/blender/exp/gltf2_blender_gather.py @@ -25,13 +25,14 @@ def gather_gltf2(export_settings): animations = [] # unfortunately animations in gltf2 are just as 'root' as scenes. active_scene = None store_user_scene = bpy.context.scene - for blender_scene in bpy.data.scenes: + scenes_to_export = bpy.data.scenes if export_settings['gltf_active_scene'] is False else [scene for scene in bpy.data.scenes if scene.name == store_user_scene.name] + for blender_scene in scenes_to_export: scenes.append(__gather_scene(blender_scene, export_settings)) if export_settings[gltf2_blender_export_keys.ANIMATIONS]: # resetting object cache gltf2_blender_gather_animation_sampler_keyframes.get_object_matrix.reset_cache() animations += __gather_animations(blender_scene, export_settings) - if bpy.context.scene.name == blender_scene.name: + if bpy.context.scene.name == store_user_scene.name: active_scene = len(scenes) -1 # restore user scene