Yeah,I have seen and forked your test,In your video, it shows that all the functions are working well,the skybox was changed succesfully,but I when running your test I saw the material.cubemap was not changed,and I add a log in forked project,it shows that the .ready function isn’t triggered, and when I adding these code in my demo(which you have it now),the .ready function isn’t triggered either,this is my code:
var mat = asset.resource;
entity.model.model.meshInstances[index].material = mat;
if (mat.name === "polesrar2_carpaint_white_mat.json") {
// The material with the problem in the door
var textureUrls = [
"./polestar2/47347304/Refl_0005s_0000.jpg",
"./polestar2/47347304/Refl_0005s_0000.jpg",
"./polestar2/47347307/Refl_0001s_0000.jpg",
"./polestar2/47347306/Refl_0002s_0000.jpg",
"./polestar2/47347304/Refl_0005s_0000.jpg",
"./polestar2/47347304/Refl_0005s_0000.jpg"
];
// Create assets from the texture URLs
var textures = textureUrls.map(function (url, i) {
var asset = new pc.Asset('skybox' + '-' + i,
'texture', {
url: url
});
app.assets.add(asset);
return asset.id;
});
var cubemap = new pc.Asset(
'skybox',
'cubemap',
'null', {
textures: textures
}
);
this.app.assets.add(cubemap);
// app.assets.load(cubemap);
// app.setSkybox(cubemap);
cubemap.ready(function (asset) {
console.log('triggered');
for (var i = 0; i < textures.length; ++i) {
var texture = app.assets.find(textures[i]);
texture.resource.addressU = pc.ADDRESS_CLAMP_TO_EDGE;
texture.resource.addressV = pc.ADDRESS_CLAMP_TO_EDGE;
}
mat.resource.useSkybox = false;
mat.cubeMap = asset.resource;
mat.update();
console.log(mat);
});
}
I was deeply confused.btw in my demo, you can find that the material of the car lamp is not loaded successfully,which also bothers me
Another question about loadding materials
In the demo,there is a car light model,and it also have loaded materials,but according the render effects,it shows that it lost some materials,I have checked the log,and didn’t find the reason because the log shows that all material was loaded successfully,so,I have to turn to you for help.
You can see there are two car lights(left and right),the left car light entity is just model in the scene,the right car light entity has model and perfect materials.
In fact,both of these car lights entity had perfect materials,and I have downloaded the assets(I put these assets on the server:https://arlive.sixeco.com/test ) through this way:
if you launch this project,you can get it too. so,I packaged this project and put it on my server,and the address is DynamicLoadMaterials ,So you can see the final effect,the left car light materials are not well rendered as the right car light,I don’t know why.please help,thank you!
Is this the only error you get? If so, it’s a server configuration issue rather than a PlayCanvas one. You will need to setup your server to allow sites from other domains to access the files.