From 1bffd880b8f02d045e9647bd0e4235bd47055b34 Mon Sep 17 00:00:00 2001 From: Julien Duroure Date: Fri, 22 Apr 2022 21:14:28 +0200 Subject: glTF exporter: fix active scene export + option to use only active scene --- io_scene_gltf2/__init__.py | 11 ++++++++++- io_scene_gltf2/blender/exp/gltf2_blender_gather.py | 5 +++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/io_scene_gltf2/__init__.py b/io_scene_gltf2/__init__.py index dc80a1e1..e6653a5d 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 b3f4fd2a..6153bc33 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 -- cgit v1.2.3