I was recently reading a book about the mysteries of the cosmos, and a question came up. Lets say the human race is still around when the sun theoretically disintegrates the Earth in five billion years, or if we find a way to travel to other worlds in short time (wormholes); if these things happened before the day of judgement, to which direction would we be praying? Also, we as Muslims believe in other lifeforms, which worship Allah similar to us, as said in the Holy Qur'an. Is there any insight as to how they would pray and to what direction? Is there a "Mecca", or great holy city in each of these worlds?
You have asked hypothetical questions. I will attempt to answer what has been discussed by our `ulama.
1. In the light of the Islamic belief of the end of this world and the death of all living beings, the question of human beings surviving the disintergration of the earth does not arise at all.
2. It is true that the Qur'an talks about "praying/worship" by non-human creatures. However, as far as the concept of "worship -- ibadat" by other beings is concerned, their "worship" is not same as that done by human beings. "Ibadat" is more broader in meaning than the term "salat/namaz". "Ibadat" means the act of submission to the Almighty whereas "salat" means the ritual prayers done by Muslims. It is in salat that one has to face towards the direction of the Mecca as required by the specific order of the Qur'an (2:144). But for other prayers (du`as) you can face any direction you want. Wherever you turn, you will find Allah in that direction.
3. Our mujtahidin have also discussed the issue of qiblah for those who travel in space-crafts or visit other planets (e.g. the Moon). They say that when you are on the earth, your qiblah for salat is Mecca; but when you are in the space, your qiblah for salat is the planet earth.