Forum

Accesing objects in the scene from the browser console

19 September 2017 21:57
Hello there:

I've been trying some things inside the browser console to access the b4w objects, for example I can access the camera and change the field of view while the app is running with
b4w.camera.set_fov(b4w.scenes.get_active_camera(), 0.26)


This code is written in the console of the browser, F12>console>etc… and the app changes the config in real time. I have tried witn several functions, hour of day, wind parameters, etc. But…

How can I access the objects themselves? If I want to see the position of an object for example. Can I get it from the console? Or, can I change the position of an object from the console? It would be very handy for developing to access the properties of the object from the console.

Does anybody knows where are the 3dobjects inside the browser DOM?

Ah, I have tried with b4w.scenes.get_object_by_dupli_name(object) but doesn't seem to work…

I'll keep trying and if I found it I'll post it here so anybody can do it….
19 September 2017 22:13
Hi, again, if it is of some interest I've been able to get some of the objects:

    The sun for example, and I think any other objects in the scene that are not dupli-objects can be debugged with:
    b4w.scenes.get_object_by_name("Sun");
    
    The character object, if you have it can be retrieved with
    b4w.scenes.get_first_character()
    
I still don't understand the dupli-groups naming, 'Group*Object' is not working for me so I don't know how to get it but for now the get_first_character thing is going to do the trick.

I think understanding this is pretty fun, not so easy for me….
21 September 2017 11:06
I still don't understand the dupli-groups naming, 'Group*Object' is not working for me so I don't know how to get it but for now the get_first_character thing is going to do the trick.

I think understanding this is pretty fun, not so easy for me….
Hello,

all available API methods and their descriptions (including parameters) can be found in the docs
To access object from the dupli group you can use get_object_by_dupli_name method:
https://www.blend4web.com/api_doc/module-scenes.html#.get_object_by_dupli_name
Blend4Web Team - developer
 
Please register or log in to leave a reply.