diff options
author | Julien Duroure <julien.duroure@gmail.com> | 2019-08-29 08:26:53 +0300 |
---|---|---|
committer | Julien Duroure <julien.duroure@gmail.com> | 2019-08-29 08:26:53 +0300 |
commit | ea5f0df783b6476d04a872e17357600ae8134351 (patch) | |
tree | f391325a5ea321a12071fbc1e8abfd5d4a6b05df /io_scene_gltf2/blender | |
parent | fe627477c2501c1e38311c97b3b5e3ffa731947e (diff) |
glTF exporter: Set blender active scene as main scene in glTF file
Diffstat (limited to 'io_scene_gltf2/blender')
-rwxr-xr-x | io_scene_gltf2/blender/exp/gltf2_blender_export.py | 6 | ||||
-rwxr-xr-x | io_scene_gltf2/blender/exp/gltf2_blender_gather.py | 6 | ||||
-rwxr-xr-x | io_scene_gltf2/blender/exp/gltf2_blender_gltf2_exporter.py | 2 |
3 files changed, 8 insertions, 6 deletions
diff --git a/io_scene_gltf2/blender/exp/gltf2_blender_export.py b/io_scene_gltf2/blender/exp/gltf2_blender_export.py index a41759a3..8c39cfdb 100755 --- a/io_scene_gltf2/blender/exp/gltf2_blender_export.py +++ b/io_scene_gltf2/blender/exp/gltf2_blender_export.py @@ -66,14 +66,14 @@ def __get_copyright(export_settings): def __gather_gltf(exporter, export_settings): - scenes, animations = gltf2_blender_gather.gather_gltf2(export_settings) + active_scene_idx, scenes, animations = gltf2_blender_gather.gather_gltf2(export_settings) if export_settings['gltf_draco_mesh_compression']: gltf2_io_draco_compression_extension.compress_scene_primitives(scenes, export_settings) exporter.add_draco_extension() - for scene in scenes: - exporter.add_scene(scene) + for idx, scene in enumerate(scenes): + exporter.add_scene(scene, idx==active_scene_idx) for animation in animations: exporter.add_animation(animation) diff --git a/io_scene_gltf2/blender/exp/gltf2_blender_gather.py b/io_scene_gltf2/blender/exp/gltf2_blender_gather.py index 013debdc..4d28a4bd 100755 --- a/io_scene_gltf2/blender/exp/gltf2_blender_gather.py +++ b/io_scene_gltf2/blender/exp/gltf2_blender_gather.py @@ -30,12 +30,14 @@ def gather_gltf2(export_settings): """ scenes = [] animations = [] # unfortunately animations in gltf2 are just as 'root' as scenes. + active_scene = None for blender_scene in bpy.data.scenes: scenes.append(__gather_scene(blender_scene, export_settings)) if export_settings[gltf2_blender_export_keys.ANIMATIONS]: animations += __gather_animations(blender_scene, export_settings) - - return scenes, animations + if bpy.context.scene.name == blender_scene.name: + active_scene = len(scenes) -1 + return active_scene, scenes, animations @cached diff --git a/io_scene_gltf2/blender/exp/gltf2_blender_gltf2_exporter.py b/io_scene_gltf2/blender/exp/gltf2_blender_gltf2_exporter.py index 19157c46..e97a30fd 100755 --- a/io_scene_gltf2/blender/exp/gltf2_blender_gltf2_exporter.py +++ b/io_scene_gltf2/blender/exp/gltf2_blender_gltf2_exporter.py @@ -156,7 +156,7 @@ class GlTF2Exporter: with open(dst_path, 'wb') as f: f.write(image.data) - def add_scene(self, scene: gltf2_io.Scene, active: bool = True): + def add_scene(self, scene: gltf2_io.Scene, active: bool = False): """ Add a scene to the glTF. |