Vertex Normals - Babylon.js Documentation has a table with 24 rows and they probably should be 36

I am reading the documentation at Vertex Normals - Babylon.js Documentation

Looking at:

## Table of Indices, Positions and Normals for Flat Shaded Box

there is a table.

In the table there are 24 rows.
But when I run the playground example and add a few console logs it will produce a table with 36 rows.

Example -
I am not sure why the number of rows in the documentation is 24 and the number of rows produced from the code are 36? There could be something missing in the documentation?
I though it is because some of the points are redundant. The 36 rows returned from the code contain duplicates but the some of the same duplicates are also available in the documentation.

0 	( -1 , 1 , -1 ) 	( 0 , 0 , -1 )
3 	( -1 , 1 , -1 ) 	( 0 , 0 , -1 )

So it is not as simple as “The table with 24 rows does not have duplicates”

Yes it is :slight_smile:
Fancy doing a PR?

Yes. I was downloading the repo for this.
I will just finish my BoundingBoxRender with lineWidth and will prepare a PR :slight_smile:

1 Like

Much appreciated!

PR is here Improving documentation for Vertex Normals by thebravoman · Pull Request #65 · BabylonJS/Documentation · GitHub

@Deltakosh and @kmitov it is not the table that needs changing but the explanation. Each vertex for each face of the cube has a unique normal, 4 vertices per face, 6 faces on a cube so 24 unique normals. The 36 arises because because each face is split into two triangles and the two vertices at the end of each hypotenuse occur in both triangles adding an extra 12 normals which are repeats of existing normals. I will re-write the documentation to make it clear we are talking about the unique normals.

Thanks @JohnK. That would be really helpful.

It is done and live. Hopefully it makes sense.

Looking at the documentation.

The sentence is "There are 6 faces on a box and so 24 unique corner normals. "
At the same time row 0 and row 3 are the same
0 ( -1 , 1 , -1 ) ( 0 , 0 , -1 )
3 ( -1 , 1 , -1 ) ( 0 , 0 , -1 )

I started looking at this as some colleagues were looking at it and had some difficulties “understanding it”. I think and it might be helpful if the table includes and additional column with the “index of the side”.
If we have 8 corners of the box and 3 normals for each corner these are 24 unique normals. It is not clear why row 0 and 3 are the same and also 4 and 7 are the same, when the normals are unique?

  1. Look at the PG containing the flat shaded cube, you will count 24 normals. The table reflects these 24 normals, 4 per face
  2. The top left corner does in fact have two overlapping normals from where the triangle facets meet but only one unique norrmal.
  3. Actually indices 0, 1, 2, 3 have the same normal values because they all belong to the same face. As do 4, 5, 6, 7, and, 8, 9, 10, 11 etc
  4. There is a difference between corners and vertices which I will make clearer.

Thanks. I was thinking something along the lines of “index of the side” in the table. This will make it clear that some normals belong to one face and other normals belong to a different face.

Latest changes should be live.


Thanks John. It looks great.

1 Like