Skip to content

Commit 4d5a0d4

Browse files
authored
Make the 90 degree glb rotation optional (#347)
* Add option to not rotate 90 degrees for glb * Update blender.py with the new option
1 parent 63826f0 commit 4d5a0d4

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

kubric/core/objects.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,4 +302,10 @@ class FileBasedObject(PhysicalObject):
302302
# is used in a physics simulation.
303303
use_parenting_instead_of_join = tl.Bool(False)
304304

305+
# By default, the objects are rotated by 90 degrees around the X axis after
306+
# loading. This is to reproduce the behavior of Blender UI. If this is set to
307+
# True, the object will not be rotated by 90 degrees around the X axis after
308+
# loading.
309+
do_not_rotate_glb_90_degrees_after_import = tl.Bool(False)
310+
305311
# TODO: trigger error when changing filenames or asset-id after the fact

kubric/renderer/blender.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -476,9 +476,10 @@ def _add_asset(self, obj: core.FileBasedObject):
476476
bpy.ops.object.delete()
477477

478478
assert len(bpy.context.selected_objects) == 1
479-
blender_obj = bpy.context.selected_objects[0]
480-
blender_obj.rotation_quaternion = (0.707107, -0.707107, 0, 0)
481-
bpy.ops.object.transform_apply(location=False, rotation=True, scale=False)
479+
if not obj.do_not_rotate_glb_90_degrees_after_import:
480+
blender_obj = bpy.context.selected_objects[0]
481+
blender_obj.rotation_quaternion = (0.707107, -0.707107, 0, 0)
482+
bpy.ops.object.transform_apply(location=False, rotation=True, scale=False)
482483

483484
elif extension == "fbx":
484485
bpy.ops.import_scene.fbx(filepath=obj.render_filename,

0 commit comments

Comments
 (0)