Facebook sees the future — a 3-D virtual world where you feel as if you are hanging out with your friends rather than staring at their pictures.

To fulfill that vision, the company announced on Tuesday that it had reached a $2 billion agreement to buy Oculus VR, the maker of a virtual reality headset. It’s a bet that a technology commonly associated with science fiction can help eventually turn social networking into an immersive, 3-D experience.

Virtual reality technologies give people the illusion that they are physically present in a digital world.

Mark Zuckerberg, a co-founder and the chief executive of Facebook, said the deal reflected his belief that virtual reality could be the next big computing platform after mobile, a technology the company has spent most of the last several years adapting to, for the most part successfully. Facebook’s deal came as a surprise, because Oculus, a small start-up that has not yet shipped a product to the broader public, is working on what some view as a niche technology aimed at hard-core video game players.