Here is how my book goes about defining the moment of inertia.

Now here's how my book goes about deriving an expression for the angular momentum of a rigid body.

From this the book derives that L = Iw

My question is in regards to the bolded part. How come in one derivation we assume r_i is a measure of the perpendicular distance from the axis of rotation, and in the other we made no such distinction, but rather considered r_i a 3-D vector?