How to write a 3d scene to a file format

I want to write out this scene i have created so that it can be loaded into a browser say COSMOS and then be viewed and navigated around by the user.
Anyone know any code that will write out the 3d scene to a file format??? or any other suggestions