• Try this:

    var pirate=180.0/Math.PI;
    console.log("Level", pirate*Math.atan2(x,z]),pirate*Math.atanĀ­2(y,z));
    var heading; // if level
    heading=pirate*Math.atan2(-x,y);
    if(heading <0) heading+=360;
    console.log("heading",heading);
    
    
About