Export data

12 February 2018 13:34
Hey there,

we are not able to export the data via the webplayer.

Isnt there any kind of documentation/example on the get request api? I mean it should be simple. We just need a possibility to export the scene with a button click. I don’t think this is the first time, that somebody is asking for that, or am i wrong? :D

For me as a web developer i would love to have something like a unique scene id which i can look up via an api.

Something like this:
exampleurl.com/example_scene.html?exportscenedata=123sceneid456&format=json

Is that possible?

Thanks for your time!
Patrick
12 February 2018 14:46
I'm not sure I got you. What should happen after clicking on exampleurl.com/example_scene.html?exportscenedata=123sceneid456&format=json ? The original Json should be downloaded? In this case this is not exporting, because there is no data convertion.

If you just want to save parameters, you can encode them in url like how it was implemented here

And just some info regarding data loading and its identification: you can load your data dynamically with load method. ID will be returned.
Alexander (Blend4Web Team)
twitter
13 February 2018 13:43
No, i do not want to export the original json. As you can see you are able to customize the scene with several buttons (colors).

I want to export those chosen colors after clicking an export button. Isnt that simply possible? Even in the example you have posted (the bag configurator) it is not able to export/share the configuration.
13 February 2018 14:02
(the bag configurator) it is not able to export/share the configuration.
It's able, just click "Customize" then change anything and click "save/share". This is how I shared my configuration with you.

Since your app is implemented with "Logic Nodes" you can interact with javascript using "JS Callback" node, just pass the configured params to this node every time when you changing some parameter. Then you can use this data in any way you want including sending this data with pure Javascript with native html button, or generating the link (like in bag configurator). In case of link you should add some code which will parse the url and initialize the configuration.
Alexander (Blend4Web Team)
twitter
28 March 2018 21:41
Hi Alexander,

That bag configurator example looks great, could i ask you how would you go about the generating the link ? Or as you mentioned previously just saving the color configuration ?

Generating the link would be great is there any sample files for that ?

I guess we need to add the Variable Store node and Jscallback node to each inherit material change branch but how do you get the data (variables) out of that ? Console print & send request nodes ?



Sorry i am struggling with this as i am just a 3d modeler and never touched any code properly.

cube_test.blend
26 April 2018 13:08
Hi Alexander,

could you please have a look again since we are still totally clouless :D

sorry for that….
26 April 2018 14:04
I will prepare an example for you, today, or tomorrow
Alexander (Blend4Web Team)
twitter
27 April 2018 14:04
Here is an example project.
The 17.12 release have a bug which causes incorrect behavior of Page Param node. Here is a simple patch. You can just manually modify src/intern/logic_nodes.js. The modification you should make is on 4th line ("vd"-> "id0"):
function pageparam_handler(node, logic, thread_state, timeline, elapsed, start_time) {
    switch (logic.state) {
    case RUNNING:
        set_var(node.vars["id0"], logic.variables, thread_state.variables,
            get_url_param(node.param_name, node.floats["ptp"], node.bools["hsh"]));
        thread_state.curr_node = node.slot_idx_order;
        break;
    }
}
Alexander (Blend4Web Team)
twitter
27 April 2018 23:12
Hello Alexander,

Thank you so much for that !!!!!! I managed to make it work on my sample file.

http://www.visual3d.co.nz/test/json5/json5.html

Can i ask you how would you go in the reverse way to initialize the configuration from the url with the json variables ?
http://www.visual3d.co.nz/test/json5/json5.html#bottom=red&top=orange
would it be be through the JS Callback node again or Send request node with the GET parameter ?

You created this updateURL function in the sample file which is called by the JS Callback

function updateURLHashParameter(url, param, paramVal){
    var newAdditionalURL = "";
    var tempArray = url.split("#");
    var baseURL = tempArray[0];
    var additionalURL = tempArray[1];
    var temp = "";
    if (additionalURL) {
        tempArray = additionalURL.split("&");
        for (var i=0; i<tempArray.length; i++){
            if(tempArray[i].split('=')[0] != param){
                newAdditionalURL += temp + tempArray[i];
                temp = "&";
            }
        }
    }

    var rows_txt = temp + "" + param + "=" + paramVal;
    return baseURL + "#" + newAdditionalURL + rows_txt;
}


I guess we need to create some function again which will get from the url just the json parameters #bottom=red&top=orange and assign them to variables which can be received by JS Callback and Send request node to be able to initialize the configuration. Or am i overthinking this and there is some other way to make it work in reverse ?

Thank you again for your help!!! And sorry for the noob questions, hopefully it make all sense :-)

BTW For some reason it is not working in chrome for me ..in firefox it loads fine but in chrome it hangs on 1% and there is a error message in the console
json5.min.js?v=27042018201625:3 B4W ERROR: 404 when trying to get http://www.visual3d.co.nz/test/json5/../assets/json5.json?v=_b4w_ver_17_12_0_
28 April 2018 11:26
http://www.visual3d.co.nz/test/json5/json5.html
It's not working, cant find json5.min.js
Can i ask you how would you go in the reverse way to initialize the configuration from the url with the json variables ?
It is done in the example which I've attachen in previous message. I used there "Page Param" nodes, but as I've already said, there are a bug and you should apply a patch to fix it.


I guess we need to create some function again which will get from the url just the json parameters #bottom=red&top=orange and assign them to variables which can be received by JS Callback and Send request node to be able to initialize the configuration. Or am i overthinking this and there is some other way to make it work in reverse ?
Yeah, you can, or you can use a patch and Page Param nodes.

json5.min.js?v=27042018201625:3 B4W ERROR: 404 when trying to get http://www.visual3d.co.nz/test/json5/../assets/json5.json?v=_b4w_ver_17_12_0_
It's not working for me at all, because of absence of json5.min.js on your server.
Alexander (Blend4Web Team)
twitter
 
Please register or log in to leave a reply.