Materials not working/ box won't change color

I run this and only get the default black for my box (I know that my variable is “blue color” but I’m trying white just to see if maybe I was doing something wrong. Thanks

        var blueColor = new BABYLON.StandardMaterial("blueColor", scene);
        blueColor.diffuseColor = new BABYLON.Color3(1, 1, 1);
        var box = BABYLON.Mesh.CreateBox("Box", 4.0, scene);
        box.material = blueColor;

Try to reproduce your scene in a playground. A standard material will be black if there is no lighting at all in your scene.

1 Like

Hi, @z_smith2019

as @Vinc3r mentioned you need light in scene to see any color from StandardMaterial (PBR you will see even without any on scene)

also small note Mesh.CreateBox is deprecated so MeshBuilder should be used

I created small Playground so you can test it

So the default playground code should be update, I will try to spot where it is on github.

[edit] [default playground] Mesh.CreateBox is deprecated by Vinc3r · Pull Request #6252 · BabylonJS/Babylon.js · GitHub

1 Like

@Vinc3r wrong post ? :slight_smile:

Rather wrong copy-paste :wink:

Thank you guys for everything and the fast reply! I thought I may need a light, but I tried a point light and I don’t understand why, but it didn’t change anything. I got it working now that you guys helped me with the hemispheric light. Again, I truly appreciate it.