It's called a 'vasovagal response'..
Either your blood vessels were all dilated from the heat and pooling resulated to too little pressure for your brain, or your parasympathetic nervous system was overloaded resulting in the same effect.
This is not dangerous by itself and will resolve if you lie down and elevate the legs. HOWEVER, often people pass out and hit their heads, etc. A colleague of mine was taking a piss after biking, passed out and got a serious head injury as he hit the ground... micturition syncope.. same thing.
Weightlifters have a larger venous blood pool and are more susceptible to this.