Forum

Web Player dependency?

08 December 2014 02:45 #655
My lack of coding knowledge and 'newbieness' shows again!

Is the exported Blend4Web .json file set in such a way as to make it dependent on the B4W web player or Javascript in general? If I read right, the tutorials using transparency do so by changing a setting in the player.

Also, if I wanted to give a transparent background to a B4W-generated .json file, where would I place the code given at Lighting, Shadows and Background:

You can use any HTML content behind the canvas element, to which the rendering is performed, as a background. To do this, activate the WebGL context transparency (the alpha parameter). For correct results, it’s recommended to set absolutely transparent black background color. Such the configuration is used by default in the scene viewer of Blend4Web SDK.

var m_cfg = b4w.require("config");
var m_main = b4w.require("main");

m_cfg.set("background_color", new Float32Array([0.0, 0.0, 0.0, 0.0]));
m_cfg.set("alpha", true);

m_main.init(…);



I was experimenting with putting the code in to the viewer for testing, but all I accomplished was to freeze the viewer.

Thank you!
08 December 2014 11:49 #664
Hi,

These all are good questions.

Is the exported Blend4Web .json file set in such a way as to make it dependent on the B4W web player or Javascript in general? If I read right, the tutorials using transparency do so by changing a setting in the player.
Exported .json can be read by any JSON-parser written in any language. But it contains lots of b4w specific information (additional parameters for objects, cameras, scenes, some rendering settings etc.), so I don't think you can get something really useful from it as a "raw data".

Web Player is an application written with the Blend4Web API. Such as our "Farm", "Island", "Fashion" demos. It would be more correctly to say about dependency on the whole Blend4Web framework.

I was experimenting with putting the code in to the viewer for testing, but all I accomplished was to freeze the viewer.
Where exactly did you put this code? If you did it just in console(F12) while Viewer was running nothing bad should have happened. And nothing should have changed as an application has already been initialized. The best way to give application some special parameters (including alpha transparency) is to use our app addon. Like it is done here. You can just change alpha to true in this call:
m_app.init({
    canvas_container_id: "canvas3d", 
    callback: init_cb,
    physics_enabled: false,
    alpha: false
});
Blend4Web developer
09 December 2014 22:52 #701
Thanks, going to work with this. Hopefully I can figure out how the app addon works without having to pick your brain again
09 December 2014 22:52 #702
Now I'm going to see if I can "reverse engineer" this without any prior knowledge of Javascript, and very little HTML. This will either be really cool or an amusing fail. Wish me luck…
10 December 2014 03:56 #704
Also, if I wanted to give a transparent background to a B4W-generated .json file, where would I place the code
Please check the balloons mini app for background transparency - it is enabled by setting the alpha initialization parameter to true.
Development Lead | Twitter
10 December 2014 03:59 #705
Well, that was easier than I expected. For what I was doing - a simple cyclic rotation animation - I didn't need to do any recoding, or even use the app.js file! Even the transparency was there by default - that made me want to do a "happy dance"! It was just a matter of uploading the "minified engine" along with an html file pointing to it and my accompanying .json content.

It'll be nice to learn how to code, but for now I'm all smiles
10 December 2014 21:02 #720
Nice to hear that worked!
Development Lead | Twitter
 
Please register or log in to leave a reply.