Applying rotation, location and scale to model bones I'm not an expert in 3D but I'm using Blender to change model's poses. I have a JSON object which describes how each bone will rotate, translate and scale:

{
  "name": "Soldier",
  "id": "TestId",
  "animMatrices": [
    {
      "name": "mixamorig:Spine",
      "position": [
        0.0,
        0.288420439,
        -0.027956875
      ],
      "rotation": [
        -0.0205147546,
        0.0105156591,
        0.0171466451,
        0.9995872
      ],
      "scale": [
        1.0,
        1.00000012,
        1.00000024
      ]
    },
    {
      "name": "mixamorig:Spine1",
      "position": [
        0.0,
        0.338067949,
        5.486072E-9
      ],
      "rotation": [
        0.0558569357,
        0.0207238179,
        0.0163610559,
        0.9980896
      ],
      "scale": [
        1.0,
        1.00000012,
        1.00000024
      ]
    }
  ]
} 


I tried to generate the 4x4 matrix and assign it to bone.matrix_basis as following:

pos = mathutils.Matrix.Translation((m['position'][0],m['position'][1], m['position'][2]))

rot1 = mathutils.Matrix.Rotation(math.radians(m['rotation'][0]), 4, 'X')
rot2 = mathutils.Matrix.Rotation(math.radians(m['rotation'][1]), 4, 'Y')
rot3 = mathutils.Matrix.Rotation(math.radians(m['rotation'][2]), 4, 'Z')
rot = rot1 * rot2 * rot3

scale1 = mathutils.Matrix.Scale(m['scale'][0], 4)
scale2 = mathutils.Matrix.Scale(m['scale'][1], 4)
scale3 = mathutils.Matrix.Scale(m['scale'][2], 4)
scale = scale1 * scale2 * scale3

bon_mat = pos * rot * scale
bone.matrix_basis = bon_mat


The model started to be having a very incorrect values, or I don't really know what happened.

I tried to to use bone.rotation_axis_angle but this did not effect anything, and by the way I always set:

bpy.ops.object.mode_set(mode="POSE")


and I got the JSON object from Unity.
You need the position for only loose bones. Instead of creating matrices assign the data where it belongs.

import bpy
if bpy.context.active_object.mode != 'POSE':
    bpy.ops.object.mode_set('POSE')

pbones = bpy.context.active_object.pose.bones

pbones['Spine'].location = m['position']
pbones['Spine'].scale = m['scale']

# I think your rotations are in quaternions, they are 4D
pbones['Spine'].rotation_quaternion = m['rotation']

# If not and you only use the first 3 values then:
#pbones['Spine'].rotation_mode = 'XYZ'
#pbones['Spine'].rotation_euler = m['rotation'][:3]


You can sure do this also by building the matrices, but check what your rotation data is in. You are building the rot_mat from Euler but I suspect your data being as quaternions.