Cant access loaded obj
21 December 2015 23:37
Hi!
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?
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) {
m_app.enable_controls();
m_app.enable_camera_controls();
}
//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
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:
Hope this helps!
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!
22 December 2015 11:55
22 December 2015 12:15