[SOLVED] Materials do not update


Im having an issue with updating my materials. its a bit weird because the last time everything worked fine.

 var meshes = this.entity.parent.model.meshInstances;   // get all materials assigned to the room
        for(var i = 0; i < meshes.length; i++) {        
            var material = meshes[i].material.clone();   
            material.useSkybox = false;     // make sure the material doesn't use the global skybox 
            material.cubeMap = this.cubeMaps[0]; 
            material.prefilteredCubeMap128 = this.cubeMaps[1];
            material.prefilteredCubeMap64  = this.cubeMaps[2];
            material.prefilteredCubeMap32  = this.cubeMaps[3];
            material.prefilteredCubeMap16  = this.cubeMaps[4];
            material.prefilteredCubeMap8   = this.cubeMaps[5];
            material.prefilteredCubeMap4   = this.cubeMaps[6];                 
            material.cubeMapProjection = pc.CUBEPROJ_BOX;
            //material.cubeMapProjectionBox = new pc.BoundingBox (new pc.Vec3(0,2,0), new pc.Vec3(2,2,2));

            material.update();  // update material  
            meshes[i].material = material;  // overwrite orignal material with the "new" (cloned) material
           // meshes[i].material.update();

in this example we can see that useSkybox is false but the material still renders it.

i am using


because the entity is a childrem of the room that renders the cubemap.

If anyone wants to take a look inside, i can add them to the project.

The skybox is referencing to the scene’s skybox, not the cubemap on the material.

if i set useSkybox = false the result should look like that:

The material has been given a cubemap so it’s using that over using the scene’s skybox

Yea but the changes are not applied, the cubemap dosent look like my skybox :slight_smile:

Can you share an example project please?

@yaustar added you to the project.

This is how it looks when i set the cubemap as the skybox:

which is fine, but i am just a bit confused why the material update isnt working anymore.

I’m not quite sure I understand.

To get this result, it seems like you just don’t set a cubemap

Am I missing something here?

Well i want the cubemap to get displayed. the issue is that if i am updaing the material from each Mesh in the MeshInstance and set the cubemap of the material, nothing really happens.

After calling update the material just looks the same. i also set useSkybox to false but the skybox is still visible on the material that sounds like my material didnt get updated for some reason.

Found the issue. I did set static = true on the Mesh. thats why my material did not update.

1 Like

Oh nice, good catch!