I’ll download a js script from S3 and that script will have a JSON with objects like this:
this.s3Assets =
{
"S3-Assets":
{
'filename': 'Asset test',
'asset': 'https://3dsvent.s3.amazonaws.com/assets/Laughing.json',
'textureUrl': 'https://3dsvent.s3.amazonaws.com/assets/texture.jpg',
'posX': -74.379,
'posY': -1.581,
'posZ': -7.967,
'scaleX': '',
'scaleY': '',
'scaleZ': '',
'scale': 1.6,
'parent': '',
'entityName': 'Test'
}
}
I tried to load that object using this script but I got a HTTPS 403 forbidden warning, despite that error my model was successfully loaded without it’s texture. And just for the record, I already checked AWS CORS.
StartActions.prototype.loadAssets2 = function()
{
var assets = this.s3Assets;
for(var asset in assets)
{
var parent = this.app.root.findByName(asset);
var ent = new pc.Entity(assets[asset].entityName);
this.app.assets.loadFromUrl(assets[asset].asset, "model", function(err, model)
{
if (err) { console.log(err); }
ent.addComponent("model", {asset: model, material:assets[asset].textureUrl});
});
ent.setLocalPosition(assets[asset].posX, assets[asset].posY, assets[asset].posZ);
ent.setLocalScale(assets[asset].scale, assets[asset].scale, assets[asset].scale);
ent.enabled = true;
parent.addChild(ent);
}
console.log(parent.children, ent);
};