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

**URL:** <https://forum.babylonjs.com/t/are-you-able-to-change-the-color-of-an-stl-file-after-append-it/21960>\
**Category:** Questions\
**Created:** [June 29, 2021, 6:11am UTC](https://forum.babylonjs.com/t/are-you-able-to-change-the-color-of-an-stl-file-after-append-it/21960 "2021-06-29T06:11:23Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![hadecolliday](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/hadecolliday/32/17092_2.png) [@hadecolliday](https://forum.babylonjs.com/u/hadecolliday)\
**Post date:** [June 29, 2021, 6:11am UTC](https://forum.babylonjs.com/t/are-you-able-to-change-the-color-of-an-stl-file-after-append-it/21960/1 "2021-06-29T06:11:23Z")

</div>

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.

```auto
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.

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [June 29, 2021, 8:28am UTC](https://forum.babylonjs.com/t/are-you-able-to-change-the-color-of-an-stl-file-after-append-it/21960/2 "2021-06-29T08:28:30Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![hadecolliday](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/hadecolliday/32/17092_2.png) [@hadecolliday](https://forum.babylonjs.com/u/hadecolliday)\
**Post date:** [June 30, 2021, 5:57pm UTC](https://forum.babylonjs.com/t/are-you-able-to-change-the-color-of-an-stl-file-after-append-it/21960/3 "2021-06-30T17:57:57Z")

</div>

[Demo Bar | Babylon.js Playground (babylonjs.com)](https://playground.babylonjs.com/#1V9BAX)

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.

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [June 30, 2021, 6:29pm UTC](https://forum.babylonjs.com/t/are-you-able-to-change-the-color-of-an-stl-file-after-append-it/21960/4 "2021-06-30T18:29:00Z")

</div>

You can simply apply the material to your mesh:

[https://playground.babylonjs.com/#1V9BAX#1](https://playground.babylonjs.com/#1V9BAX#1)

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

---

<div class="post-metadata">

**Author:** ![hadecolliday](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/hadecolliday/32/17092_2.png) [@hadecolliday](https://forum.babylonjs.com/u/hadecolliday)\
**Post date:** [June 30, 2021, 7:40pm UTC](https://forum.babylonjs.com/t/are-you-able-to-change-the-color-of-an-stl-file-after-append-it/21960/5 "2021-06-30T19:40:03Z")

</div>

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 (babylonjs.com)](https://playground.babylonjs.com/#1V9BAX#2)

---

<div class="post-metadata">

**Author:** ![SahilTara](https://avatars.discourse-cdn.com/v4/letter/s/df788c/32.png) [@SahilTara](https://forum.babylonjs.com/u/SahilTara)\
**Post date:** [June 30, 2021, 9:18pm UTC](https://forum.babylonjs.com/t/are-you-able-to-change-the-color-of-an-stl-file-after-append-it/21960/6 "2021-06-30T21:18:42Z")

</div>

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 (babylonjs.com)](https://playground.babylonjs.com/#1V9BAX#6)

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 😃
