Forum

Struggles figuring out how to make a interactive scene.

30 November 2016 17:52
Hello B4W users,

I have a question that has probably been asked before and im sorry for that.
For a project im trying to figure out how to create a scene with blend 4 web that allows me to have buttons in the scene that changes the color of the item visible in the scene.
myself im familliar with 3d modelling etc but i have never used blender before.

So im seeing some videos where people create the interactive elements in blender itself and when they export it to html everything works. Im also finding alot of suggestions that tell me i just need to export multiple scenes where the item has different collors. Create buttons in the css file, and link them to a blend4web exported html file when someone clicks them.

I hope im being clear in what i want to achieve. If anyone has any suggestions or maybe tutorials or anything that can help me that would be appreciated.

http://examples.viscircle.com/VWPolo/index.html
This link is sort of what i want to achieve. Whenever the buttons are pressed, the color of the car changes.

Thanks in advance!!
30 November 2016 18:24
Hi

It's very simple.
On your html page, just add a button
And with the method of your choice you have to catch the click and do action

Javascript in main blend4web function

function changeColor(){
m_mat.set_diffuse_color('objectName', 'materialName',0.047,0.047,0.047);
}



HTML

<p id="dfgdgdfgdf" onclick="changeColor()">Click to change color.</p>
<div id="main_canvas_container"></div>
30 November 2016 18:36
Thanks you for your quick reply Martial, im going to look into this!
01 December 2016 05:59
It is helpful to look at some of the example project that come with the SDK like Cartoon Interior.
blend4web/apps_dev/tutorials/cartoon_interior
You can see all the code.
I have a number of video on Youtube that show some of the basics in Blender:
https://www.youtube.com/channel/UCp6x8JP7oCiiTjbJorPPMsQ/videos
 
Please register or log in to leave a reply.