-
Notifications
You must be signed in to change notification settings - Fork 4
Saving your world
You can save your world anytime by clicking the "save" button in the menu.
When you click the "save" button, Vishva would popup a dialog box with a link to download your world file. 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 and lets you decide where and how you want to save the file.
You would normally right click the link and select "save as" and save the file under the "worlds" folder.
If you are editing an existing world you might want to save the file over the existing world file.
Here is Vishva's folder structure again
webapp
js
lib
vishva
assets
internal
worlds
demo.js
When you download Vishva, it comes with a small demo world. You can see that under the "worlds" folder.
These world files are just standard Babylon scene file with some additional Vishva specific data added to them. Vishva stores your settings and 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.
Further, 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 Notice no texture files in "worlds" fodler. 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 save your world file under the worlds folder. 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.