Hi Josh33357,
regarding to question 1, it is considered in the camera coordinate system, where X is pointing to the plane nose (or north), Y is pointing to right wing and Z is pointing down. Then heading/yaw is around Z axis, pitch is around Y axis and roll is around X axis.
Default direction looks like this (in a local world coordinate system, where Y is pointing to north):
Yaw = 0, image is oriented to Y (upper side of image is oriented that way)
Pitch = 0, image is looking down
Roll = 0, image is parallel with X axis
Regarding to question 2 and 3, the YPR are considered in camera coordinate system, as I mentioned in previous answer (X to north, Y to east and Z down).
Regarding to question 4, this is how you can compute the rotation matrix in JavaScript:
EulerRotation: function (y, p, r) {
var cx = Math.cos(LA.Deg2Rad * r);
var cy = Math.cos(LA.Deg2Rad * p);
var cz = Math.cos(LA.Deg2Rad * y);
var sx = Math.sin(LA.Deg2Rad * r);
var sy = Math.sin(LA.Deg2Rad * p);
var sz = Math.sin(LA.Deg2Rad * y);
return [cx * cz + sx * sy * sz, -cx * sz + cz * sx * sy, -cy * sx,
-cy * sz, -cy * cz, -sy,
cx * sy * sz - cz * sx, cx * cz * sy + sx * sz, -cx * cy];
},