Cant access loaded obj

21 December 2015 23:37 #6029
So I load one json containing Cube1,
then I load another json containing Cube2.
Both cubes are visible and it works nice except I can access Cube1 but not Cube2.
B4W ERROR: get object Cube2: not found
What am I missing here?

//load scene one
function load_sc1() {m_data.load("scene1.json",sc1_loaded_cb);} //has Cube1

//load scene two
function load_sc2() {m_data.load("scene2.json");} //has Cube2

function sc1_loaded_cb(data_id) {

//test functions
function test_one(){ var obj_one = m_scenes.get_object_by_name("Cube1");} //works
function test_two(){ var obj_two = m_scenes.get_object_by_name("Cube2");} //fails..

22 December 2015 08:26 #6031
Hi Kristian,

The get_object_by_name() method accepts an optional second argument data_id which you should use to obtain objects from the second dynamically loaded scene. For example:
var obj_two = m_scenes.get_object_by_name("Cube2", 1); // scenes are indexed starting from 0

Hope this helps!
The Founder | Twitter
22 December 2015 09:49 #6032

Also we discussed it on this page.
Blend4Web developer
22 December 2015 11:55 #6036
Thanks alot! I can access it now.
I read the other post and trying out some things with external loading.
So how would the proper use of get_meta_tags(obj) be used? documentation confusing me bit, all I get returned is undefined or just object Object..

22 December 2015 12:15 #6037
Do you mean get_meta_tags from the "objects" module?

If yes, it returns the object metatags, that were set in Blender.

If you use the "get_meta_tags" function from the "scenes" module, it returns the metatags of the active scene.
Blend4Web developer
23 December 2015 18:20 #6068
Thanx alot! figured it out and updated my fish viewer!

23 December 2015 18:24 #6069
Glad we could help! Nice start with Blend4Web API
The Founder | Twitter
Please register or log in to leave a reply.