PVector.angleBetween(PVector, PVector) returns 0 for 3D vectors whenever the x and y components of a parameter are both 0. For example:
PVector.angleBetween(new PVector(0,0,1), new PVector(1,0,0))
returns 0 instead of PI/2.
Looking at the source code, it seems clear what is wrong:
// We get NaN if we pass in a zero vector which can cause problems
// Zero seems like a reasonable angle between a (0,0) vector and something else
if (v1.x == 0 && v1.y == 0) return 0.0f;
if (v2.x == 0 && v2.y == 0) return 0.0f;