Forum

User posts Herod2k
08 June 2017 13:51
THank you very much Ivan!
07 June 2017 14:55
Hi Guys,

Is there a way to disable Blend4Web console log warnings and errors? I would like to hide them for the production website.



Thanks
H2K
07 June 2017 12:43
Thanks Ivan, it works.
06 June 2017 11:30
Thank you Roman!

It works

I have just realized that is written inside the documentation


It was in front of me and I didn't see it.

Thanks again.

H2K
05 June 2017 22:05
I have created another test file from scratch.

The file test contains a plane.

I have assigned a material to the object and to the data




I have loaded it inside the script


I can see the object but I can't see the materials


I have created it with Blender 2.78c on Linux and I have exported it with the add-on 17.04.1

I'm really stuck there, I don't know what else to try.

You can find the files attached.

H2K
04 June 2017 20:00
Hi Will,

thanks for the suggestion, but the code that I'm using is very minimal and it works with the stock files:
material_api.json
material_api.bin
(deploy/assets/code_snippets/material_api/)

I have also tried the same piece of code with others stock files and it works flawlessly.


I don't see the material list when I load a model made by me.

I have tested it with the standard Blender cube with a very simple material but blend4web doesn't return the material list.

Thanks
H2K
03 June 2017 14:21
Hi Will,

thanks for the reply.

I have added a console.log for the object

and I can see the cube inside the console:


I don't know why you can't

I have also tried my code and the file that you have suggested (material_api.json)


and it works


So it is not the API call get_materials_names, but probably it is something inside the exporter or Blender.

Any Ideas?

Thanks
H2K
02 June 2017 23:48
Hi guys,

I'm new with blend4web and I'm not 100% sure if it is a bug or not, but the command get_materials_names returns always an empty array, I have tried in different ways but I don't get the expected result.

I'm using Linux (Arch Linux)
I have tested it with:
Firefox 53.0.3 (64-bit) and Chromium 58.0.3029.110 (64-bit).

I have tried with blend4web 17.02.1 and 17.04.1
I have exported a cube (in json/bin) with 2 materials. I have made a simple script to load it inside the page and to read the materials, but it returns an empty array.

An example to replicate the problem:

HTML File:
<!DOCTYPE html>
<html>
<head>
    <script type="text/javascript" src="b4w.min.js"></script>
    <script type="text/javascript" src="main.js"></script>
    <style>
        body {
            margin: 0;
            overflow: hidden;
        }

        #container_id {
            position: absolute;
            width: 100%;
            height: 100%;
        }

    </style>
</head>

<body>
    <div id="container_id"></div>
</body>

</html>


Js file (main.js):
var app = b4w.require("app");
var data = b4w.require("data");
var scenes = b4w.require("scenes");
var material = b4w.require("material");

app.init({
	canvas_container_id: "container_id",
	physics_enabled: false,
	autoresize: true,
	callback: load_cb
});

function load_cb() {
    data.load("test.json", loaded_cb);
}

function loaded_cb() {
    app.enable_camera_controls();
    var cube = scenes.get_object_by_name("Cube");
    var material_list = material.get_materials_names(cube);
    console.log(material_list);
}


material_list is an empty array in Firefox


and Chromium


Attached you can find the entire example, with the blend, json and bin files.

Thanks
H2K
02 June 2017 12:17
Hi guys

first of all thanks for the help.

I'm stuck with the material list, I can't get it.

This:
var object = b4w_scenes.get_object_by_name('Zeta_0');
var material_list = b4w_materials.get_materials_names(object);
console.log(material_list);

returns an empty array but I have 3 materials assigned to Zeta_0, you can download my files here:
json: http://d1mr8g7ihxhxdy.cloudfront.net/0222d970708f9ec80886058e78a2343ba4805a19.json
bin: http://d1mr8g7ihxhxdy.cloudfront.net/0222d970708f9ec80886058e78a2343ba4805a19.bin

I have did a console.log of the b4w_scenes.get_object_by_name('Zeta_0'); and it seems ok, it is full of data.

Am I missing something? Reading the Json I can see the 3 materials assigned to the mesh:


Do I have to do check something inside Blender before the export?

Thanks again.

H2K
01 June 2017 14:37
Reply to post of user Will Welker
I am sometimes wrong on this stuff so one of the developer can correct me if needed but…
I believe you can change the texture but not the material. You can change the properties of the material, see the Material API
You can change the texture to a different image, see the Change Image API

Thank you Will, I supposed that, but I wasn't sure.

I was also thinking to a different approach. If I assign 3 different materials (for example) to the same object. Do you think that it would be possible to hide show the materials?

Thanks
H2K