Hi everyone, in our project we want to load multiple assets from S3 but I got an error while running the script, it says :
No resource handler found for: function( modelAsset )
Can anyone suggest me a way to add a resource handler in this case? Here is the script I’m using:
var StartActions = pc.createScript('startActions');
// initialize code called once per entity
StartActions.prototype.initialize = function()
{
//this.setAssetSizes();
this.s3Assets = [
/*
EntityName:
{ url/json:, filename:, position:, size-x:, size-y:, size-z:, entityName:, fatherEntity:, scaleX}
*
*/
{
'filename': 'Pantalla.json',
'url': ' https://3dsvent.s3.amazonaws.com/assets/Pantalla.json',
'posX': -71,
'posY': 0,
'posZ': 0,
'scaleX': '',
'scaleY': '',
'scaleZ': '',
'scale': 4.68,
'fatherEntity': 'Decoracion',
'entityName': 'PantalaTest'
}
];
this.loadAssets();
};
/* Set size of all objects by tag */
StartActions.prototype.setAssetSizes = function()
{
var models = this.app.root.findByTag("modelSize");
for (var i = 0; i < models.length; i++)
{
models[i].setLocalScale(0.9, 0.9, 0.9);
}
};
StartActions.prototype.loadAssets = function()
{
var assets = this.s3Assets;
for (var asset in assets)
{
var fatherEnt = this.app.root.findByName(asset.fatherEntity);
var file = { url: asset.url, filename: asset.filename };
var assetS3 = new pc.Asset('load', function( modelAsset )
{
var entity = new pc.Entity(asset.entityName);
entity.addComponent("model");
entity.model.asset = modelAsset;
entity.collision.asset = modelAsset;
entity.collision.enabled = true;
entity.setPosition(asset.posX, asset.posY, asset.posZ);
if (!asset.scale !== null || !asset.scale !== undefined) { entity.setLocalScale(asset.scale, asset.scale, asset.scale); } else { entity.setLocalScale(asset.scaleX, asset.scaleY, asset.scaleZ); }
fatherEnt.addChild(entity);
});
this.app.assets.add(assetS3);
this.app.assets.load(assetS3);
}
};