How to Push Input Values from Page into B4W Custom Application?
21 June 2017 18:12
Hi,
I am new to Blend4Web. I am trying to create a combined solution that has a web page with a B4W custom application embedded within that page. The page has several ordinary HTML inputs in a form. I need the page and the B4W application to be able to communicate in both directions (the B4W app should be able to set values in the page and JavaScript in the page should be able to pass value into the B4W app). Through trial and error, I've been able to get something like this working, but I worry that my solution is not the best solution. I would appreciate some guidance.
To send data from the B4W app to the page I have used B4W logic. Specifically, I've used the JS Callback node to execute a custom JS function to read B4W logic parameters and write those values to HTML inputs on the page. This seems to work well.
My solution to send data from the page into the B4W app is a bit more convoluted:
1. A listener on the page observes a change to an HTML form value.
2. That listener executes an on page JS function that triggers an Entry Point node in a B4W logic flow.
3. That logic flow then uses a JS Callback node to read data from the HTML form in the page.
4. The logic flow then updates the scene
This works but it is indirect. Is there a better technique? Can input values from a page be pushed directly into the B4W app and have that push of values trigger an event in B4W?
Blend4Web is an amazing solution. Thanks for the hard work.
-jem
I am new to Blend4Web. I am trying to create a combined solution that has a web page with a B4W custom application embedded within that page. The page has several ordinary HTML inputs in a form. I need the page and the B4W application to be able to communicate in both directions (the B4W app should be able to set values in the page and JavaScript in the page should be able to pass value into the B4W app). Through trial and error, I've been able to get something like this working, but I worry that my solution is not the best solution. I would appreciate some guidance.
To send data from the B4W app to the page I have used B4W logic. Specifically, I've used the JS Callback node to execute a custom JS function to read B4W logic parameters and write those values to HTML inputs on the page. This seems to work well.
My solution to send data from the page into the B4W app is a bit more convoluted:
1. A listener on the page observes a change to an HTML form value.
2. That listener executes an on page JS function that triggers an Entry Point node in a B4W logic flow.
3. That logic flow then uses a JS Callback node to read data from the HTML form in the page.
4. The logic flow then updates the scene
This works but it is indirect. Is there a better technique? Can input values from a page be pushed directly into the B4W app and have that push of values trigger an event in B4W?
Blend4Web is an amazing solution. Thanks for the hard work.
-jem
21 June 2017 20:42
Hi jem,
I recommend this project for lots of things it seems like
Have a look at the Cartoon Interior Project
You can also find the full example files in your SDK: \blend4web_pro\apps_dev\tutorials\cartoon_interior
This project uses HTML/CSS buttons to affect the scene. It might help a little.
I recommend this project for lots of things it seems like
Have a look at the Cartoon Interior Project
You can also find the full example files in your SDK: \blend4web_pro\apps_dev\tutorials\cartoon_interior
This project uses HTML/CSS buttons to affect the scene. It might help a little.