# Always getting STL surface color as black

**URL:** https://discourse.vtk.org/t/always-getting-stl-surface-color-as-black/10413
**Category:** Web
**Created:** [January 10, 2023, 7:35am UTC](https://discourse.vtk.org/t/always-getting-stl-surface-color-as-black/10413 "2023-01-10T07:35:48Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![patiludayv](https://discourse.vtk.org/user_avatar/discourse.vtk.org/patiludayv/32/6386_2.png) [@patiludayv](https://discourse.vtk.org/u/patiludayv)
#### Post date: [January 10, 2023, 7:35am UTC](https://discourse.vtk.org/t/always-getting-stl-surface-color-as-black/10413/1 "2023-01-10T07:35:48Z")

</div>

Hi all,

I have an STL file. When I open it in STLReader live example ([vtk.js](https://kitware.github.io/vtk-js/examples/STLReader.html)), It always shows in black color. Because of which, I am not able to apply color on that surface.

Is there is any VTK function is available which will return it’s actual color (which is black). So that I will pop up warning message to the users.

Any help is highly appreciated.  
Thanks

# STL file content:

solid xmax  
facet normal -1 0 0  
outer loop  
vertex 11.5 -4.5 1  
vertex 11.5 -4.5 0  
vertex 11.5 4.5 1  
endloop  
endfacet  
facet normal -1 0 0  
outer loop  
vertex 11.5 4.5 0  
vertex 11.5 4.5 1  
vertex 11.5 -4.5 0  
endloop  
endfacet  
endsolid xmax

---

<div class="post-metadata">

### Author: ![finetjul](https://discourse.vtk.org/user_avatar/discourse.vtk.org/finetjul/32/154_2.png) [@finetjul](https://discourse.vtk.org/u/finetjul)
#### Post date: [January 10, 2023, 7:46am UTC](https://discourse.vtk.org/t/always-getting-stl-surface-color-as-black/10413/2 "2023-01-10T07:46:07Z")

</div>

You can flip the normals, e.g. `facet normal -1 0 0` → `facet normal 1 0 0`

---

<div class="post-metadata">

### Author: ![patiludayv](https://discourse.vtk.org/user_avatar/discourse.vtk.org/patiludayv/32/6386_2.png) [@patiludayv](https://discourse.vtk.org/u/patiludayv)
#### Post date: [January 10, 2023, 9:31am UTC](https://discourse.vtk.org/t/always-getting-stl-surface-color-as-black/10413/3 "2023-01-10T09:31:35Z")

</div>

Thanks for the reply.

But what is the decision criteria? How do I know whether I need to flip the normal or not?

---

<div class="post-metadata">

### Author: ![finetjul](https://discourse.vtk.org/user_avatar/discourse.vtk.org/finetjul/32/154_2.png) [@finetjul](https://discourse.vtk.org/u/finetjul)
#### Post date: [January 10, 2023, 9:46am UTC](https://discourse.vtk.org/t/always-getting-stl-surface-color-as-black/10413/4 "2023-01-10T09:46:51Z")

</div>

It depends on your point ordering, the normal should follow trigonometric ordering of the points.  
So:

```auto
vertex 11.5 -4.5 1
vertex 11.5 -4.5 0
vertex 11.5 4.5 1

```

→ normal = [1, 0, 0]

But

```auto
vertex 11.5 -4.5 1
vertex 11.5 4.5 1
vertex 11.5 -4.5 0

```

→ normal = [-1, 0, 0]
