Forum

User posts stewet
29 December 2017 23:11
Interactive Bulb
Made in: blender - blend4web
Language: Hungarian

(in menu: ON OFF switch it does not work yet…)

thx b4w team
http://blender.hu Hungary Blender Community Site
24 November 2017 18:50
Sorry! I solved!
http://blender.hu Hungary Blender Community Site
22 November 2017 22:50
Hi!
My problem:
I would like to turn on/off a LED lamp depending on the checkbox status.

HTML Code:
<body>
  <div id="main_canvas_container"></div>

<!--SLIDER - OPACITY-->
  <div class="header">
  <center>
	<span>L.E.D. OPACITY</span><label id="demo"></label><br>
	<input type="range" id="myRange" style="width:180px" min="20" value="100"><p></p>
  </center>

<!--LIGHT-SWITCH & COLOR PICKER-->
  <div class="footer">
	<div class="glow"><span>LIGHT</span><input class="toggle" type="checkbox" id="light"></div>
	<div class="color"><span>COLOR</span><input type="color" id="color_input" value="#FF0000"></div>
	<div style="clear: both;"></div>
  </div>

	<script>
	   var slider = document.getElementById("myRange");
	   var output = document.getElementById("demo");
	   output.innerHTML = slider.value/100;

	   slider.oninput = function() {
  	   	output.innerHTML = this.value/100;
	   }
	</script>
	
  </div>
</body>

JS Code:
    // place your code here
    var lens = m_scenes.get_object_by_name("lens");
    var nodes = new Array("lens_mat", "RGB");

//OPACITY SLIDER
    var slider = document.getElementById("myRange");
    var output = document.getElementById("demo");
    output.innerHTML = slider.value/100;

	slider.oninput = function() {
   	   output.innerHTML = this.value/100;
	   m_mat.set_nodemat_value(lens, ["lens_mat", "Value"], output.innerHTML)
	}
//COLOR PICKER - HEX to RGB
    $('#color_input').change(function(){
        var rgb = hexToRgb($(this).val());
        $('#demo').text(rgb.r+', '+rgb.g+', '+rgb.b);
        m_objects.set_nodemat_rgb(lens, nodes, rgb.r, rgb.g, rgb.b);
    });

    m_objects.set_nodemat_rgb(lens, ["lens_mat", 'RGB'], 0.8, 0, 0);

//GLOW ON/OFF WITH CHECKBOX (does not work)
function main_canvas_click(e) {
    if (e.preventDefault)
        e.preventDefault();

    var x = e.clientX;
    var y = e.clientY;
    var glow = document.getElementById('light').checked;
    if (glow == false) {
	m_mat.set_nodemat_value(lens, ["lens_mat", "Value"], 0.0);
    }
    else
	m_mat.set_nodemat_value(lens, ["lens_mat", "Value"], 1.0);
}

}


function hexToRgb(hex) {
    var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
    return result ? {
        r: parseInt(result[1], 16)/255,
        g: parseInt(result[2], 16)/255,
        b: parseInt(result[3], 16)/255
    } : null;
}

Material Node:

Light ON (image):

but…
If you click the LIGHT checkbox, (ON status), GLOW will not be displayed. No console error. The transparency and color picker works. Can you help? Thanks
http://blender.hu Hungary Blender Community Site
25 October 2017 11:05
Which version do you use?
What does the console write onto your code?
http://blender.hu Hungary Blender Community Site
24 October 2017 19:42
Test it possibly so:
var scenes = m_scenes.get_all_scenes();
    var scene_names = [];
    for (var i = 0; i < scenes.length; i++)
        scene_names.push(scenes[i]["name"]);

It may be m_scenes.set_active() a name may be his parameter only. (I am not a programmer)
http://blender.hu Hungary Blender Community Site
23 October 2017 16:19
Did you try it on already with API?
var m_scenes = require("scenes");
m_scenes.set_active("Scene");
http://blender.hu Hungary Blender Community Site
11 October 2017 20:26
Thank you everyone
http://blender.hu Hungary Blender Community Site
23 September 2017 14:17
Hello everyone
A newer interactive show was ready. Asynchronous electric engine.
Elements Hide / Show (lower icons)
To click on the element - text information (Hungarian language)
Thank you b4w team
Interactive Electric Engine
http://blender.hu Hungary Blender Community Site
10 July 2017 15:30
Dear Olski!
Thank you for the acknowledgement.
How heavy? Good question… I read a lot and I was searching the blend4web his site.
I don't know on a what kind of level you handle it the blendert, but to take the words of worthy Will into consideration.
The size of the project depends on the structures (textures) and the models (lowpoly) - my project size: (full) 61MB.
The collection place of the site for us free.
http://blender.hu Hungary Blender Community Site
28 June 2017 22:34
I look at the new file if he will be upload
http://blender.hu Hungary Blender Community Site