Forum

User posts Herod2k
01 June 2017 14:00
Hi guys,

I have just started to use Blend4Web and I have a problem with the materials and the API.

I have a blend file with 6 materials and 3 objects, these 3 objects have a material each (so I have 3 unassigned materials).

In Blender I can switch the material using this simple menu.

How can I do the same thing with Blend4web api?

First of all I have checked the Json file and inside there are only 3 materials (the assigned ones), is it possible to export all the material library?
Second I didn't find any api command to assign a material to an object, I have found only commands to edit the materials. The only command interesting is inherit_material but it moves a material from a object to another.

In the meanwhile I have also done also some tests, do you know why this command:
var object = b4w_scenes.get_object_by_name('test');
			var material_list = b4w_materials.get_materials_names(object);
			console.log(material_list);

return material_list an empty array? The object test has an assigned material.

Thanks.

H2K