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


I tried to pass the attribute by code


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(){
function k(){

Then from code in Camera’s aabb function write :


And inside your own code just write:


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