2017-10-10 6 views

Répondre

0

Vous devez convertir la partie de rotation de la matrice en angles d'Euler. Ce n'est pas une opération triviale. Je ne sais pas si "glm" a une fonction pour cela, mais il y a un code (d'autres méthodes peuvent exister) pour convertir la rotation d'une matrice 4x4 en angles X, Y et Z Euler:

function Matrix4ToEuler(OutEuler, InMatrix4) 
{ 
    let cy = Math.sqrt(InMatrix4[0] * InMatrix4[0] + InMatrix4[1] * InMatrix4[1]); 

    if(cy > 0.001) { 

    OutEuler.x = Math.atan2(InMatrix4[6], InMatrix4[10]); 
    OutEuler.y = Math.atan2(-InMatrix4[2], cy); 
    OutEuler.z = Math.atan2(InMatrix4[1], InMatrix4[0]); 

    } else { 

    OutEuler.x = Math.atan2(-InMatrix4[9], InMatrix4[5]); 
    OutEuler.y = Math.atan2(-InMatrix4[2], cy); 
    OutEuler.z = 0; 

    } 
}