LoadFromUrl Issue

Hello everyone,
I am new to playcanvas, i am loading an asset from the url in which inside the loadfromurl() i am trying to add the entity to the hierarchy which is giving error and also if i try to access the entity variavle outside that method it is promting me with undefined. please help.

project link : https://playcanvas.com/editor/scene/606071

var temp = new pc.Entity();
var entity = new pc.Entity();
this.app.assets.loadFromUrl(“https://s3-us-west-2.amazonaws.com/cubedots/PlayCanvas/ACR_I_00_S.FBX","model”,function (err, temp)
{
// window.alert(err);
if(temp!==null)
{
entity = temp;

            window.alert("first" + entity.name);
            **this.app.root.addChild(entity);**
           }
        
     });
     window.alert("second" + entity.name);

Either use ECMA6 arrow function

this.app.assets.loadFromUrl("https://s3-us-west-2.amazonaws.com/cubedots/PlayCanvas/ACR_I_00_S.FBX","model", (err, temp) =>  {
     // window.alert(err);
     if(temp!==null)
     {
          entity = temp;
                
          window.alert("first" + entity.name);
          this.app.root.addChild(entity);   
     }
            
});

Or store your context before scope

var self = this;

this.app.assets.loadFromUrl("https://s3-us-west-2.amazonaws.com/cubedots/PlayCanvas/ACR_I_00_S.FBX","model",function (err, temp)
{
     // window.alert(err);
     if(temp!==null)
     {
          entity = temp;
                
          window.alert("first" + entity.name);
          self.app.root.addChild(entity);   
       }
            
});

Are you trying to import a model? In that case, download the model, and import the .fbx file into the assets panel.

Oh yes, I didn’t notice that.

@karan_sengar you have to specify url to .json

Yes that’s true, otherwise the asset won’t be imported as a model.