From what I gather, the uv coords ("texels") of each vertex in a mesh can be accessed using:
geometry.faceVertexUvs[ materialIndex ][ faceIndex ][ vertexIndex ]
The issue I'm facing is that the vertexIndex
seems to have a different mapping order compared to
geometry.vertices[ vertexIndex ]
An example showcasing this problem has been created:
Source:
The provided code carries out the following actions:
- Generates a plane
Displays a sphere at the position of the plane's vertex with index
1
using a utility function calleddot
:dot( floor.localToWorld( floor.geometry.vertices[1].clone() ) );
Alters the texel at
faceVertexUvs[0][0][1]
to visualize the location of texel1
floor.geometry.faceVertexUvs[0][0][1].add( new THREE.Vector2( 0.4, 0 ) );
In the example page, it can be observed that the sphere is drawn on the top right of the plane (vertex 1), while the texel being manipulated is situated on the bottom left of the plane. The vertex indices do not align! Is this an issue with three.js, or am I overlooking something regarding texels?
I've noticed that the vertices seem to correspond as follows:
texel index | vertex index
0 | 3
1 | 1
2 | 0
3 | 2
However, some unexpected behavior arises when attempting a related uv mapping task, which leads me to question if the mapping is indeed the root cause of my error.