Forum

Entry Point - Run from Script?

08 March 2017 19:27
ktk
hi

i try to run a specific node tree entry point from a html button - i see there is an option to check 'Run from Script' in the entry point node, but i didn't found any useful tutorial.

here's my scene: Project Link

so the close (X) button of the html overlay should reset the camera as it already does with the yellow cam reset button - but this button is in the 3d scene. i want it to call the node tree's entry point just for resetting the camera via the html (X) button

i actually want to stay with the 'move camera' node as i don't want to go to deep into blend4web api

calling a specific node tree entry point seems to be the simplest option - or is there a simpler way?

thanks in advance
kay
08 March 2017 20:47
ktk
according to https://www.blend4web.com/api_doc/module-logic_nodes.html#.run_entrypoint

i did :

a) include logic nodes

var m_logic_n   = require("logic_nodes");


b) write my function to be called from html

function resetCamera() {
    m_logic_n.run_entrypoint(Scene, ResetCamera);
}


node name is clear but i'm not sure about the scene name - is this the name of my blender file, like
abc.blend then it would be 'abc' otherwise a Scene is called Scene….


c) call my function from html
<div class="btn"><a onClick="resetCamera()">Reset Cam</a></div>


DOESN'T WORK! ;(
08 March 2017 21:02
ktk
any help on this?
09 March 2017 04:34
I think you just need quotes
m_logic_n.run_entrypoint("Scene", "ResetCamera")
09 March 2017 14:57
ktk
ahhh … thx a lot v3ny!

my final solution below & the scene name is definitely the name of the Scene in Blender not the .json or .blend name, i was just confused about that.



function load_cb(data_id, success) {

    if (!success) {
        console.log("b4w load failure");
        return;
    }

    m_app.enable_camera_controls();

    // place your code here
    
    document.getElementById("camBtn").onclick = function() {resetCamera()};

}
    
function resetCamera() {    
    m_logic_n.run_entrypoint("Scene", "camera");
    console.log("Camera is resetting");
}
09 March 2017 19:48
ktk
this can bring a really cool 2D - 3D bidirectional workflow in general! i'm really looking forward to test b4w more intensely.
this was about controlling stuff from outside of the 3d canvas - the other way round is featured in this post:
https://www.blend4web.com/en/forums/topic/3076/

have fun!
19 May 2017 11:47
Hi Guys, I am following this as above but it is not working and I keep getting this message in my console:

TypeError: m_logic_n is undefined[Learn More]

I am sure I have done something wrong somewhere but I can not figure it out and it is driving me nuts.

Thank you in advance for any help you can offer.
19 May 2017 11:55
Hi Guys, I am following this as above but it is not working and I keep getting this message in my console:

TypeError: m_logic_n is undefined[Learn More]

I am sure I have done something wrong somewhere but I can not figure it out and it is driving me nuts.

Thank you in advance for any help you can offer.
Hello,

could you please attach exported example project reproducing the issue
Blend4Web Team - developer
19 May 2017 13:09
Thank you for the swift response.
Please find the wip here:

link

When the user clicks on the AR in the middle, the colour wheel starts to spin which is fine but I want to be able to do this (and many more exciting things) from a html menu UI like the SPIN AR button.

I have set up the SPIN AR button as directed i the thread above. When clicked, it should rotate the AR in the middle of the logo.

Thank you so much for any help you are able to offer.
19 May 2017 13:20
Do you need the blend file too?
link
 
Please register or log in to leave a reply.