hiii,
trying to convert the files i get through html file input into playcanvas assets, images to be precise, here is what i get,
please guide me by example, thank you!
hiii,
trying to convert the files i get through html file input into playcanvas assets, images to be precise, here is what i get,
Test1Script.prototype.findFiles = function()
{
var fileInput = document.getElementById('file-input');
var context= this;
fileInput.addEventListener('change', (e) => {context.RecieveFiles(e.target.files);});
};
Test1Script.prototype.RecieveFiles = function(data)
{
this.assetsToLoad = data.length;
for(var i=0; i<data.length; i++)
{
// this.StoreFile(data[i]);
this.CreateSymbolMat(data[i].name,URL.createObjectURL(data[i]));
}
};}
};
Test1Script.prototype.CreateSymbolMat = function(matName,TextureUrl)
{
var newSymbol = this.symbolMat.resource.clone();
newSymbol.name = matName;
var context = this;
if(TextureUrl !== "")
{
var asset = new pc.Asset("ImageTexture", "texture", {url: TextureUrl});
this.app.assets.add(asset);
this.app.assets.load(asset);
asset.once("load", function ()
{
newSymbol.diffuseMap = asset.resource;
newSymbol.emissiveMap = asset.resource;
newSymbol.update();
context.loadedAssets++;
context.CheckIfAllAssetsReady();
},this);
}
this.mats.push(newSymbol);
};