In example position is 0,0,0. I thought that triangle should be on the middle of the screen. Could u explain this moment for me.
Hi @n0t2day and welcome to the forums
In the starter code, the position of the gray triangle is (0, 0, 0) where (0, 0, 0) is the middle of the screen, as you rightly state.
However, each vertex of the gray triangle is not at (0, 0, 0).
struct Triangle {
var vertices: [Float] = [
-0.7, 0.8, 0,
-0.7, -0.5, 0,
0.4, 0.1, 0
]
// ....
}
So if you add the position to each vertex, that will be the position of the triangle.
The red triangle has position (0.3, -0.4, 0), and when you add that to each vertex, you get the result you see.
2 Likes
Oh… god, how did i miss this. Thx a lot.
1 Like