entry point script breaks after first activation

22 June 2018 07:13
HI Guys,

I'm trying to control 3d from HTML
working from this topic

my goal is to have a number of "entry points" each running a sequence of actions and then a callback on each path to tell me when the sequence is finished.

for testing, I have created 3 entry points in the default cube blend file.

This is the code I added to default js (plus added var m_log_n = require("logic_nodes"); above)

 // place your code here
    document.getElementById("Btn_1").onclick = function() {button_1()}; // html button press
    document.getElementById("Btn_2").onclick = function() {button_2()};
    document.getElementById("Btn_3").onclick = function() {button_3()};    
    function button_1() { m_log_n.run_entrypoint("Scene", "Entry Node.006");} // entrypoint action 
    function button_2() { m_log_n.run_entrypoint("Scene", "Entry Node.007");}
    function button_3() { m_log_n.run_entrypoint("Scene", "Entry Node.008");}

My Blender node set up:

(Entry Node.006 ) —(move camera)—-(move camera)—-(move camera)
(Entry Node.007 ) —(play anim)———-(play anim)
(Entry Node.008 ) —(play anim)

when played:
I can click on each button and it works as expected.

And I can click on Entry Node.008 over and over without an issue
but if I click on Entry Node.006 or Entry Node.007 a second time.

I get an error like this (clicking on Node.006)

b4w.js:76013 Uncaught TypeError: Cannot read property 'func' of null
at process_logic_thread (b4w.js:76013)
at process_logic (b4w.js:74071)
at Object.Int_logic_nodes.exports.update (b4w.js:74003)
at frame (b4w.js:76710)
at loop (b4w.js:76690)

and then I can no longer press HTML buttons.

It seems that the error comes when a 2nd, 3rd or more nodes are added to the path.

I'm sure I'm doing something wrong here.. this is my first attempt at the json/javascript for blend4web.
Anyone have a clue as to what I'm doing wrong or how to get past this..
i included my blend file

Thanks for any help you may give.
22 June 2018 18:36

this is caused by a bug in the version you are using (v17.12) - see B4W manual release notes:

You can either update to v18.05 or have your buttons call API functions directly instead of going through logic nodes.
22 June 2018 18:43
Oh.. that makes sense.. Thanks. that helps a lot.
I will upgrade now
22 June 2018 19:35
IT Worked.. Thanks, Blend4Life !
22 June 2018 22:30
You can do something else:

Connect the js_callback nodes to the last node of each thread, respectively. Disconnected nodes cause console errors.

Fill in the name of your node tree under the scene tab -> Logic Editor (which must be checked) -> Active Node Tree. Not setting this will force the engine to pick a tree, cause console warnings and cause problems if you have more than one tree.

Also, use lowercase and use underscores instead of SPACE characters in your project names ("Button 1" -> "button_1"). Spaces are no good because they may get encoded (like in URLs etc.).
Please register or log in to leave a reply.