Camera focus not working on OrbitCamera

Hi, today i tried to set initial position focused on a model.
That model is loaded from json file external, so after loading i call the focus function.

I tried to focus

app.root.findByName("Camera").script.orbitCamera.focus(app.root.findByName(*entity-id*));

I tried to pass the attribute by code

app.root.findByName("Camera").script.orbitCamera.__attributes.focusEntity=entity;

but nothing works… someone know how i can do to do that?

orbitCamera .focus should work. Do you have a public project to share?

Does app.root.findByName(*entity-id*) return a valid entity? Are you getting any error messages in the console?

Edit: Thinking about it, it also might be possible that the model or the model’s AABB isn’t generated in the same frame as the entity is created when you loaded the JSON. Try waiting a waiting or 2 before calling focus.

I solved the problem with a custom workaround.
I post it for someone that have the same problem.
Yes, the model load after 1 second or something similar, so the focus call have a entity without meshInstance and return error. There is no way to call focus when meshes are ok so i write this:

// my workaround
var active=false;
function f(){
    active=true;
    try{
    app.root.findByName("Camera").script.orbitCamera.focus(app.root.findByName("*entity_id*"));
    }catch(ex){
        setTimeout(f,200);
    }
}
function k(){
  if(active==false)f();
}

Then from code in Camera’s aabb function write :

k();

And inside your own code just write:

app.root.findByName("Camera").script.orbitCamera.focus(app.root.findByName("*entity_id*"));

If the aabb call works all ok, otherwise a timer re-call until the model is ok!
Yaustar thanks for the reply, good work.