Your code is mostly correct, you are missing two things:
the asset is added to the registry, but it has also to get downloaded (load). You can use the loadFromUrl method for that.
the model filetypes you are trying to load aren’t supported by the Playcanvas engine. Right now only the internal Playcanvas format can be used (as generated when uploading models in the editor) and there is work being done at the moment to support GLB (https://github.com/playcanvas/engine/pull/1904).
As a workaround, you can load a custom importer for OBJ files (which have their own restrictions though) which you can use to load remote OBJ files directly. Here is an example on how to do this:
Make sure you’ve loaded the obj loader in your app:
And then you can do something like this:
// OBJ Parser is not enabled by default in engine. Add the parser to the model resource handler
// set up obj parser
app.loader.getHandler("model").addParser(new pc.ObjModelParser(app.graphicsDevice), function (url, data) {
return (pc.path.getExtension(url) === '.obj');
});
var url = "../assets/models/monkey/monkey.obj";
app.assets.loadFromUrl(url, "model", function (err, asset) {
entity = new pc.Entity();
entity.addComponent("model");
entity.model.model = asset.resource;
app.root.addChild(entity);
});