Forum

Load scene/models from remote server

14 October 2014 00:42
Hi there,

I wanted to know if there is a way to have the blend4web engine load the scene .json file from a remote server. The examples are given in a static html file with a script source declared.

Thanks in advance.
14 October 2014 11:07
Hi and welcome to the B4W forum!

Blend4Web apps load a pair of .json and binary files. In case of self-contained HTML files they are packed together with the engine and the web player.

You can load .json files within your app or using the standard web player. Note that loading resources into web apps is subject to the same-origin policy rule.

Please see this tutorial for available deploying options.
The Founder | Twitter | Facebook | Linkedin
15 October 2014 19:37
Hi yuri, thanks for your reply. I have the following usage scenario:

- I want to have the web player to work in a single page application (AngularJS). I have a set of scenes that need to be loaded from a server. When I select a scene, I need to load the resources from a remote server.

I know that I can load a .json file, the .json file has references to multiple assets. I don't know if the web player loads those resources when it parses the .json file?

Keep in mind that we're in separate domains. I may run the app in localhost and connect to a server in a different machine.

Thanks in advance.
16 October 2014 09:52
Hi,

You can place your json scenes + their textures on a remote server. In your local app when the user selects a scene to show you can insert/modify an iframe element to load that scene, e.g.


<iframe width=750 height=400 allowfullscreen src="http://www.blend4web.com/apps/embed/embed.html?load=../../assets/capri/vehicles/mi_34s1/mi_34s1_demo_scene_en.json"></iframe>
The Founder | Twitter | Facebook | Linkedin
19 October 2016 17:58
Reply to post of user SynapseR
Hi there,

I wanted to know if there is a way to have the blend4web engine load the scene .json file from a remote server. The examples are given in a static html file with a script source declared.

Thanks in advance.

Hi Mr SynapseR,

Cross Origin Resource Sharing (CORS) is a W3C standard that allows a server to relax but the same-origin policy Same-origin policy still remains for http request for years.

This takes JavaScript from making requests across domain boundaries, and has spawned various hacks for making cross-domain requests

but you may use CORS enabled or JSON P to do your payloads in a cross origin request, here its a tutorial for a webapi service Enabling Cross-Origin Requests in ASP.NET Web API 2

We use this technology to make many application that query the database from different web application with different domains.

as user interface and file manager you can use a technology such as angularjs to make the ajax easy in combination with the web service api application to handle the CORS request.

since B4W its javascript, it will be easy to make a simple http request the the json/bin pair of files
Hello VR-World!!
 
Please register or log in to leave a reply.