Why Use Web Player + JSON


Instantaneous scene export from Blender to HTML is an outstanding feature of the Blend4Web engine that catches one's attention from the start. You might get used to it and later find out that creating web applications is a struggle without this fast and convenient method. However, I have frequently heard suggestions from the framework developers to use the combination of Web Player + JSON. So, what's the secret?

Stereotypical Thinking

When we hear the word "player", we usually imagine a separate program for playing back certain files; this is correct! Blend4Web's Web Player is an application for viewing Blender 3D scenes exported in JSON format.

If we think about a player in the context of a web browser, something like Flash or Unity plug-ins come to mind, but this is incorrect. The Web Player is not an add-on for the browser, but simply scripts loaded by a web page.

Regardless of how we choose to use the Web Player (HTML export vs. Web Player + JSON), it always uses the same application. Only, in the first case the application and all the data are packed into a single file, and in the second, you yourself specify the data for the player to load.

So, why might you need additional steps if you can get a ready-to-use HTML file right away?

Fact #1. File Size and Loading Time

At first glance, it might not seem so evident and clear, but try exporting your scene using two methods, and measure the size of files they produce (don't forget to add the player files to the JSON file!). I've been experimenting with the default Blender scene and have found that the difference is trivial, only several dozens of kilobytes. But when I compared more complex scenes, the difference was significant. For example, the fairly simple Solar System app turned out to be smaller by more than a megabyte when using the Web Player + JSON option. Then I became interested in why this is, and talked it over with the developers of the framework. As it turned out, while exporting to an HTML file, all the resources, including models and textures, are base64-encoded. This approach, of course, does affect the final size of the file.

Because of this, not only does an HTML file load slower than Web Player + JSON, but it also doesn't start as quickly. The reason for this is that an application has to spend some additional time unpacking the resources after loading them.

Fact #2. Customization

Sometimes, while working on a project, you discover that the features that the Web Player provides out-of-the-box don't quite meet your needs. For example, you might need to alter the loading screen or to add custom buttons to the program interface.

What you need to know is that the Web Player is just a web page with linked scripts and resources, which you can edit without any restrictions. In essence, it is a ready-made construction set for creating applications of any complexity.

So, the fact is that you can do all these things only with the separate Web Player. There is no (convenient) way for you to modify the application obtained through HTML export.

Fact #3. Physics

The framework developers haven't "taught" the HTML exporter to work with physics. Not every scene uses the physics engine, and including it upon each export would consume additional space.

But when you are working with Web Player + JSON, you are not limited by anything. Just use the Project Manager to automatically copy the physics module to your application directory.


Let's try to combine all these facts into one whole picture and to understand how and in which cases each of the export methods offered to us by the developers is most suitable.

Blend4Web HTML is perfectly suitable for showing a 3D model you've created or a presentation prototype. A single file doesn't have any dependencies and can easily be sent by e-mail or placed on a website..

The Web Player + JSON method is specifically good for final deployment to a server. It is faster, more compact and scalable. Don't forget that is also saves some disk space on the server, as you don't have to use a separate copy of the player for every JSON file. Furthermore, you can also use shared assets for multiple projects. And, what's of no small importance, the whole might of the Project Manager will be at your service. Using this unique tool, you can control the development process: conveniently adjust scene parameters in the viewer application, convert media resources, backup projects and building them by pressing a single button.

As you can see, Blend4Web HTML and Web Player + JSON simply belong to different weight classes. The decision what to choose should depend on the situation, but for a major project, you should use the whole might of the Blend4Web framework.

23 sep. 2016 12:33
Yes, the way I like
Please register or log in to leave a reply.