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!
 
Please register or log in to leave a reply.