For very limited cases, you can hack 3D rotation using PVector and hope that you don’t run into gimbal lock.
As soon as you need something general-purpose, though, representing rotation state in terms of xyz has lots of known problems. Instead, use quaternions. They are complicated and it is a pain – but they actually work. The PeasyCam library has a great reference implementation.