OK i try to change the environment cubemap of a material from an external javascript file, this is my code :
var data = {
"name": "sejour_vide2",
"cubemap": app.assets.findAll("sejour_vide")[0].getFileUrl(),
"textures": [
app.assets.findAll("1.png")[1].getFileUrl(),
app.assets.findAll("2.png")[1].getFileUrl(),
app.assets.findAll("3.png")[1].getFileUrl(),
app.assets.findAll("4.png")[1].getFileUrl(),
app.assets.findAll("5.png")[1].getFileUrl(),
app.assets.findAll("6.png")[1].getFileUrl(),
]
};
var textures = data.textures.map(function(v, i) {
var asset = new pc.Asset(data.name + '-' + i, 'texture', { url: v });
app.assets.add(asset);
return asset.id;
});
//console.log(textures);
sejour_vide = new pc.Asset(
data.name,
'cubemap',
{ url: data.cubemap },
{
anisotropy: 1,
magFilter: 1,
minFilter: 5,
rgbm: true,
textures: textures,
prefiltered: app.assets.findAll("sejour_vide")[0].id
}
);
and then
if(app.root.findByName("MeshBaker (0)-mesh-mesh").model.model.meshInstances[i].material.cubeMap.name=="sejour_deco"){
console.log("okdeco");
app.root.findByName("MeshBaker (0)-mesh-mesh").model.model.meshInstances[i].material.cubeMap=sejour_vide;
}
app.root.findByName("MeshBaker (0)-mesh-mesh").model.model.meshInstances[i].material.lightMap=app.assets.findAll("Lightmap-1_comp_light_vide.png")[0].resource;
app.root.findByName("MeshBaker (0)-mesh-mesh").model.model.meshInstances[i].material.update();
console.log(app.root.findByName("MeshBaker (0)-mesh-mesh").model.model.meshInstances[i].material.cubeMap);
if I console log the material object, i can see than the correct cubeMap is assigned but nothing change visually, any ideas?
btw i tried this with no success
app.root.findByName("MeshBaker (0)-mesh-mesh").model.model.meshInstances[i].material.cubeMap=app.assets.findAll("sejour_vide")[0].resource;
Is the prefiltered cubemap may be a problem ?
after testing, the problem is not there when the original material have a no filtered cubemap, still investigating
do i have to assign prefilteredCubeMap4, prefilteredCubeMap8 etc; ?
edit : ok it works now, you need to assign all prefilteredCubeMap, I creatde a storage material for get it back from it, kind of a hack⦠there is a function for assign all cubemap correctly?