Forum

Changing camera from the html

03 February 2017 09:39
E21
Hello B4W!

I have looked at the Camera Animation example (https://www.blend4web.com/apps/code_snippets/code_snippets.html?scene=camera_animation) and I know how to make the camera change target and positionning. The animation trigger is in the canvas managed by B4W.

What I want to learn is how to make a link (the javascript link) located in the html page (not just in the canvas) trigger the animation.

DOM Tree:
html
body
<div id="B4W_Container"></div>

<div>Some text <a id="B4W_Trigger">go to Camera 01</a></div>

Programatically, what do I need to do this?

Best regards,


Eric
03 February 2017 17:35
hi!
you can do it something like
var mylink=document.getElementById("B4W_Trigger");

// replace the code in the example with the following:
mylink.addEventListener("mouseup", main_canvas_up);
mylink.addEventListener("mousedown", main_canvas_down);

should work!
The Founder | Twitter | Facebook | Linkedin
04 February 2017 14:01
Hello,

Programatically, what do I need to do this?

You should add the listeners of user's action (mouse click) on your button. And then start the camera animation.

I can help with code lines if you attach your project
05 February 2017 16:50
E21
That's really easy, thank you!
 
Please register or log in to leave a reply.