glTF exporter: fix some rotation issue
This commit is contained in:
parent
fe05a06332
commit
76ca00772a
|
@ -102,13 +102,8 @@ def convert_swizzle_scale(scale, export_settings):
|
|||
return Vector((scale[0], scale[1], scale[2]))
|
||||
|
||||
|
||||
def decompose_transition(matrix, context, export_settings):
|
||||
def decompose_transition(matrix, export_settings):
|
||||
translation, rotation, scale = matrix.decompose()
|
||||
"""Decompose a matrix depending if it is associated to a joint or node."""
|
||||
if context == 'NODE':
|
||||
translation = convert_swizzle_location(translation, export_settings)
|
||||
rotation = convert_swizzle_rotation(rotation, export_settings)
|
||||
scale = convert_swizzle_scale(scale, export_settings)
|
||||
|
||||
# Put w at the end.
|
||||
rotation = Quaternion((rotation[1], rotation[2], rotation[3], rotation[0]))
|
||||
|
|
|
@ -48,7 +48,7 @@ def gather_joint(blender_bone, export_settings):
|
|||
# matrix_basis = blender_object.convert_space(blender_bone, blender_bone.matrix, from_space='POSE',
|
||||
# to_space='LOCAL')
|
||||
trans, rot, sca = gltf2_blender_extract.decompose_transition(
|
||||
gltf2_blender_math.multiply(correction_matrix_local, matrix_basis), 'JOINT', export_settings)
|
||||
gltf2_blender_math.multiply(correction_matrix_local, matrix_basis), export_settings)
|
||||
translation, rotation, scale = (None, None, None)
|
||||
if trans[0] != 0.0 or trans[1] != 0.0 or trans[2] != 0.0:
|
||||
translation = [trans[0], trans[1], trans[2]]
|
||||
|
|
|
@ -256,7 +256,20 @@ def __gather_name(blender_object, export_settings):
|
|||
|
||||
|
||||
def __gather_trans_rot_scale(blender_object, export_settings):
|
||||
trans, rot, sca = gltf2_blender_extract.decompose_transition(blender_object.matrix_local, 'NODE', export_settings)
|
||||
trans = gltf2_blender_extract.convert_swizzle_location(blender_object.location, export_settings)
|
||||
|
||||
if blender_object.rotation_mode in ['QUATERNION', 'AXIS_ANGLE']:
|
||||
rotation = blender_object.rotation_quaternion
|
||||
else:
|
||||
rotation = blender_object.rotation_euler.to_quaternion()
|
||||
|
||||
rotation = gltf2_blender_extract.convert_swizzle_rotation(rotation, export_settings)
|
||||
|
||||
# Put w at the end.
|
||||
rot = Quaternion((rotation[1], rotation[2], rotation[3], rotation[0]))
|
||||
|
||||
sca = gltf2_blender_extract.convert_swizzle_scale(blender_object.scale, export_settings)
|
||||
|
||||
if blender_object.instance_type == 'COLLECTION' and blender_object.instance_collection:
|
||||
trans = -gltf2_blender_extract.convert_swizzle_location(
|
||||
blender_object.instance_collection.instance_offset, export_settings)
|
||||
|
|
Loading…
Reference in New Issue