[Bf-extensions-cvs] [ea5f0df7] master: glTF exporter: Set blender active scene as main scene in glTF file
Julien Duroure
noreply at git.blender.org
Thu Aug 29 07:27:22 CEST 2019
Commit: ea5f0df783b6476d04a872e17357600ae8134351
Author: Julien Duroure
Date: Thu Aug 29 07:26:53 2019 +0200
Branches: master
https://developer.blender.org/rBAea5f0df783b6476d04a872e17357600ae8134351
glTF exporter: Set blender active scene as main scene in glTF file
===================================================================
M io_scene_gltf2/__init__.py
M io_scene_gltf2/blender/exp/gltf2_blender_export.py
M io_scene_gltf2/blender/exp/gltf2_blender_gather.py
M io_scene_gltf2/blender/exp/gltf2_blender_gltf2_exporter.py
===================================================================
diff --git a/io_scene_gltf2/__init__.py b/io_scene_gltf2/__init__.py
index 7c81f830..f64224ce 100755
--- a/io_scene_gltf2/__init__.py
+++ b/io_scene_gltf2/__init__.py
@@ -15,7 +15,7 @@
bl_info = {
'name': 'glTF 2.0 format',
'author': 'Julien Duroure, Norbert Nopper, Urs Hanselmann, Moritz Becher, Benjamin Schmithüsen, Jim Eckerlein, and many external contributors',
- "version": (0, 9, 52),
+ "version": (0, 9, 53),
'blender': (2, 80, 0),
'location': 'File > Import-Export',
'description': 'Import-Export as glTF 2.0',
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.
More information about the Bf-extensions-cvs
mailing list