Hello dear Community and PlayCanvas Team,
i would like to know if it is possible to download Assets during Runtime that haven´t been set up as Assets in the Project.
For Example:
- User Clicks a Button
- Application Downloads 3D-Model from www (CORS is considered)
- A Script ckecks its name and looks into a JSON File that Contains Information about what kind of Components should be added
- Components get added to the Model
- Model gets rendered
Is this possible or do all Assets have to be set up in the Editor before, with “Preload” unchecked?
Regards,
Markus
1 Like
dave
2
Yep. This is totally possible.
Something like this should work:
var asset = new Asset("Remote Model", "model", {
url: "http://example.com/remote-model.json"
});
app.assets.add(asset);
asset.on("load", function (err, model) {
//loaded
});
app.assets.load(asset);
Hey Dave,
thanks for the fast reply. I´ll give that a try 
Hi Dave,
is there some Tool to Convert 3D-Models into the JSON-format that PlayCanvas uses?
dave
5
You can download models from your scene in the Editor. Select the model and click “Download” in the right attribute panel.
This will give you a zip file containing the model .json
file.
1 Like
Hey, I have a question. Will this still work if i don’t have a file url?
In my project, we receive the JSON with a GET (so the info is transmitted from a web page), so we don’t actually have a file.
yaustar
7