The three-dimensional structure and kinematics of protostellar envelopes