上QQ阅读APP看书,第一时间看更新
Defining a Geometry Using JavaScript Arrays
To practice using the preceding steps, let's use a trapezoid to see how we can define its vertices and indices. We need two JavaScript arrays – one for the vertices and one for the indices:
As you can see from the preceding illustration, we have placed the coordinates sequentially in the vertex array and then indicated how these coordinates are used to draw the trapezoid in the index array. So, the first triangle is formed with the vertices having the indices 0, 2, and 1; the second, with the vertices having the indices 1, 2, and 3; and finally, the third, with the vertices having the indices 2, 4, and 3. We will follow the same procedure for all possible geometries.
Index Array Order
Triangles in the index array are usually, but not necessarily, defined in counter-clockwise order. It's important to pick one approach and keep it consistent to help you determine the front and back sides of geometry primitives. Consistency is important, because programs may use the clockwise/counter-clockwise order to determine whether a face is facing forward or backward for culling and rendering purposes.
Triangles in the index array are usually, but not necessarily, defined in counter-clockwise order. It's important to pick one approach and keep it consistent to help you determine the front and back sides of geometry primitives. Consistency is important, because programs may use the clockwise/counter-clockwise order to determine whether a face is facing forward or backward for culling and rendering purposes.
Culling
In computer graphics , back-face culling determines whether a polygon of a graphical object is visible. It is a step in the graphical pipeline that tests whether the points in the polygon appear in clockwise or counter-clockwise order when projected onto the screen. For more information, visit https://en.wikipedia.org/wiki/Back-face_culling.
In computer graphics , back-face culling determines whether a polygon of a graphical object is visible. It is a step in the graphical pipeline that tests whether the points in the polygon appear in clockwise or counter-clockwise order when projected onto the screen. For more information, visit https://en.wikipedia.org/wiki/Back-face_culling.