# solved Vertices Position on cube

## Recommended Posts

Hi !,

I'm looking at how vertices work so that I can work with and transform my mesh later.
For that I started with a simple box to find the order and give a number on the vertices group.
Can someone explain to me why numbers 3 and 7 are in the same place?

Thank you !

##### Share on other sites

a cube has 6 sides

each side is composed with 2 triangular facets, so 4 vertices.

Side vertices aren't shared with other sides so they can hold different UVs and normals per side.

I total : 4 * 6 = 24 vertices... some are in the same location.

##### Share on other sites

thank you Jerome

I'm ok with you all 24 vertices match with  nbrVertices = cube.getTotalVertices ();

I follow you well on the 6 face with 4 vertices per face.
There are then 6 vertices of each face that have the same coordinates.

What I would like to do is group them ...  like this

##### Share on other sites

What do you mean by "to group them" ? To replace 3 vertices on the same location by only one ?

##### Share on other sites

Create an array with vertices that are the same coordinated in the same index
for example
myCubeVertices = [[all vertices with same coordinates xyz], [all vertices with same coordinates xyz], ...] ?
Does this seem to me easier to visualize and manipulate?

##### Share on other sites
27 minutes ago, Xav said:

Create an array with vertices that are the same coordinated in the same index
for example
myCubeVertices = [[all vertices with same coordinates xyz], [all vertices with same coordinates xyz], ...] ?
Does this seem to me easier to visualize and manipulate?

Hi @Xav

Group Vertices

##### Share on other sites

Hi Arte

Cool

I think I must not be good in my code because group returns only 7 differents positions while we should have 8 ?

##### Share on other sites

Ok it's good

I changed my loop

for (var i=0 ; i < nbrVertices ; i+=3){
with:
for (var i=0 ; i < nbrVertices ; i++){

Thanks You !

It's cood:

##### Share on other sites

I continued my research and I also found this post which helps to understand the function:

On the other side I haven't found information to adapt the uv according to the new position of vertices?

var uvs = mesh.getVerticesData(BABYLON.VertexBuffer.UVKind);

mesh.setVerticesData(BABYLON.VertexBuffer.UVKind, uvs);

What is the relationship between a vertex position vector3 and a UV position vector2 ?

Thanks

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.