Skip to content

Saving your world

Satguru P Srivastava edited this page Dec 28, 2016 · 19 revisions

You can save your world anytime by clicking the "save" button in the menu.

As we have mentioned before, in Vishva there are no server components,every thing runs in the browser. Because the browser does not have access to your disk it cannot save anything to the disk.

Instead it provides a link to download your world file and lets you decide where and how you want to save them.

You would normally right click the link and do a save as.

If you are editing an existing world you might want to save the file over the existing world file.

Few words about these world files

These world files are just standard Babylon scene file with some additional Vishva specific data in them. Vishva serializes and stores all your sensors and actuators data in these files. Because these are standard Babylon files they can be loaded directly by any other Babylon applications. Of course things like Vishva Sensors and Actuators will not work. The Babylon engine only uses data it recognizes and ignores the rest. Vishva when it loads the world, reads all its own data first and then passes the file to the engine for it, to do its own thing.

Secondly, Vishva modifies the texture path information in the file. Normally Babylon expects all the textures for a scene to be available in the same folder as your babylon scene file. Now in Vishva we add assets into the scene from different asset folders. All the asset textures are loaded from these asset folders. This means that when we save the the scene we would have to copy all the textures from various assets folder to the scene folder. Cumbersome ! and duplication of textures. To avoid this, before saving your scene, Vishva modifies the texture path information so that they point to your assets folder ! This makes it convenient but adds some limitations on how your world files are organized.

So now lets review how your world files are organized.

Here is Vishva's folder structure again

webapp
	js
	lib
	vishva
             assets
             internal
             worlds 

This time we will look at the worlds folder which is where your world file will be stored.

Like "assets" folder the "worlds" folder is two level deep.

The first level is, again, a category folder and the second is the world folder.

Both world category and world folder can be named anything you want.

Another way to think about them - category = a game, world = a scene/level in the game.

When you download Vishva, it comes with a small demo world.

The structure looks like this

             worlds 
                  demos
                      demo1
                          demo.js

So within worlds we have a category of worlds called demos and with in that we have one demo world called "demo1". Within "demo1" we have the BabylonJS scene file called "demo.js". Notice no texture files. All the textures will be loaded from various asset folders which of course means that you should be careful while moving your assets files around as that could break your scene.

Another thing you might be wondering about, is the filetype of the scene file. BabylonJS files usually have a filetype of ".babylon". Now we could have left it as ".babylon", as it is really just a babylon file but the reason we changed this to ".js" is to take advantage of http gzip compression. As most of you know all of the current browsers support gzip compression. In other words they tell the server that whenever possible, the server should compress a file before sending it to them thus saving bandwidth and making the download much faster. The server unfortunately does not compress each and every file. By default it only compresses those files which it knows to be textual in nature. ".js" - javascript files are known by the servers to be so. As such most servers will compress ".js" files by default.

Not so with ".babylon" files. For these files you have to specifically tell the server that it is ok to compress them. If you are using some web site provider you may not have an option to do so. Babylon scene files are usually very large, and compressing them do make a big difference, so we decided to go with ".js" filetype.

So in summary you should save your world file , under the worlds folder, 2 level deep. No need to store any texture files here, they will be picked up from the asset folders. While saving save your file as ".js" files.

While working on your world save your world often.