[SOLVED] Strange camera setHpr() behavior

I’m encountering a bit of strangeness with controlling Panda3d’s camera using setHpr. Using the method:

camera.setHpr(h, 0, 0)

where h varies, the heading the camera is set to look at works as expected. With the code

camera.setHpr(h, 90, 0)

however, the heading converts into rotation, and any attempt to change h only rolls the camera around the global Z axis.

I know that I am almost certainly missing something very obvious here. Could someone point this n00b in the right direction?

EDIT: To use a better example of the behavior, imagine the camera as looking out the forward window of a space ship. When your pitch is zero degrees, when you change heading, you pan around the global Z axis. When you are at pitch up 90 degrees, and then attempt to change the heading, the ship (and camera view) should now change heading around the global X axis. Instead, it continues to pan along the global Z axis.

I found the solution to my problem. The problem was that I was experiencing gimbal lock when one of my axes was equal to 90 degrees, most noticeably with the pitch rotation. In my case, to get the camera to freely rotate around its axes, the solution was to rotate the camera using itself as its own relative rotation node. The code

	camera.setHpr(camera, h, p, r)

fixed the issue. If anyone else needs to create a freely rotatable model/camera without gimbal lock issues using Euler angles, this may be very useful.