Skip to main content
api link
Source Link
p2or
  • 16.1k
  • 10
  • 87
  • 146

There is indeed a straightforward python method using mathutils.

from mathutils import Vector
direction = Vector(your_tuple)
your_object.rotation_mode = 'QUATERNION'
your_object.rotation_quaternion = direction.to_track_quat('Z','Y')

You can see the doc herehere for more details.

Edit: As the sun direction is negative on the z axis, you may have to change 'Z' to '-Z'

There is indeed a straightforward python method using mathutils.

from mathutils import Vector
direction = Vector(your_tuple)
your_object.rotation_mode = 'QUATERNION'
your_object.rotation_quaternion = direction.to_track_quat('Z','Y')

You can see the doc here for more details.

Edit: As the sun direction is negative on the z axis, you may have to change 'Z' to '-Z'

There is indeed a straightforward python method using mathutils.

from mathutils import Vector
direction = Vector(your_tuple)
your_object.rotation_mode = 'QUATERNION'
your_object.rotation_quaternion = direction.to_track_quat('Z','Y')

You can see the doc here for more details.

Edit: As the sun direction is negative on the z axis, you may have to change 'Z' to '-Z'

added 94 characters in body
Source Link
Vanitat
  • 281
  • 3
  • 7

There is indeed a straightforward python method using mathutils.

from mathutils import Vector
direction = Vector(your_tuple)
your_object.rotation_mode = 'QUATERNION'
your_object.rotation_quaternion = direction.to_track_quat('Z','Y')

You can see the doc here for more details.

Edit: As the sun direction is negative on the z axis, you may have to change 'Z' to '-Z'

There is indeed a straightforward python method using mathutils.

from mathutils import Vector
direction = Vector(your_tuple)
your_object.rotation_mode = 'QUATERNION'
your_object.rotation_quaternion = direction.to_track_quat('Z','Y')

You can see the doc here for more details.

There is indeed a straightforward python method using mathutils.

from mathutils import Vector
direction = Vector(your_tuple)
your_object.rotation_mode = 'QUATERNION'
your_object.rotation_quaternion = direction.to_track_quat('Z','Y')

You can see the doc here for more details.

Edit: As the sun direction is negative on the z axis, you may have to change 'Z' to '-Z'

Source Link
Vanitat
  • 281
  • 3
  • 7

There is indeed a straightforward python method using mathutils.

from mathutils import Vector
direction = Vector(your_tuple)
your_object.rotation_mode = 'QUATERNION'
your_object.rotation_quaternion = direction.to_track_quat('Z','Y')

You can see the doc here for more details.