Are you able to Change the color of an STL file after .Append it

I have a basic scene, at least what I consider to be basic. And I was wondering if it was possible to change the color of the STL file after it was loaded using babylon.js.

var createScene = function () {
                // This creates a basic Babylon Scene object (non-mesh)
                var scene = new BABYLON.Scene(engine);

                // This creates and positions a free camera (non-mesh)
                var camera = new BABYLON.ArcRotateCamera("camera", BABYLON.Tools.ToRadians(90), BABYLON.Tools.ToRadians(90), 100, new BABYLON.Vector3(0, 1, 0), scene)

                // This attaches the camera to the canvas
                camera.attachControl(canvas, true);

                // This creates a light, aiming 0,1,0 - to the sky (non-mesh)
                var light = new BABYLON.HemisphericLight("light", new BABYLON.Vector3(0, 1, 0), scene);

                // Default intensity is 1. Let's dim the light a small amount
                light.intensity = 0.7;

                var stl = BABYLON.SceneLoader.Append("{% static '/stl/' %}", "DEMO STONE STL.stl", scene)
                return scene;

If this has been asked somewhere before please point me in the right direction cause I am generally lost.

You can retrieve the material of the mesh(es) and change the diffuse color. Providing a repro in the Playground would help, as I’m not sure I have totally understood your question.

1 Like

Demo Bar | Babylon.js Playground (

I would like to change the color from grey to red or black or any color, and maybe be able to alter the transparency @Evgeni_Popov.

You can simply apply the material to your mesh:

Update the alpha property of the material to change the transparency.


Thank you for your help and your quick reply, my last inquiry if you can help point me in the right way is how do i go about doing the same but with multiple imports of different shades and values.

here is a playground for an example:
Demo Bar | Babylon.js Playground (

Hey @hadecolliday it seems like the names of your meshes may be the same, causing a conflict when you call scene.getMeshByName(“stlmesh”).

Demo Bar | Babylon.js Playground (

In the playground I simply change the name to get rid of such conflict. It is possible there is a better way to do this but this should resolve your issue for now :smiley: