I can’t for the life of me find any documentation on UV mapping. I understand the concept, but there’s no docs on what’s the syntax to apply one. I found references to faceVertexUvs, but it was removed. In the repo there’s one file still mentioning it (three.js/threejs.js at 3daf128f34da9cdb1e339766a4aae21b5989f131 · mrdoob/three.js · GitHub) which is really confusing.
There’s a nice guide on this, but no code that helps:
I’m generating the mesh vertices with code, but I don’t know where to put the uv coordinates.
When I started programming uv coordinates I searched the net for a good tutorial.
Everything I found either referred to the general theory of what you need uv coordinates for and then modeling software like Blender was always used to explain it.
So I looked at three.js examples to see how the concept of uv coordinates is implemented. I tried until I could then do quite simple mappings piece by piece and later more complicated mappings.
I have now looked again on the net for uv tutorials, nothing has changed there. But maybe someone else knows a good source?
The examples above are not a tutorial, almost all just extracted from the collection to fit the topic. You can use them to experiment.
In the beginner’s example, you can easily understand the construction by the representation of the flower and the numbered representation of the arrangement of the vertices and faces on the quarter sphere.
More usefully, there is one uv coordinate per vertex coordinate.
If you have 10 vertices, you have 30 numbers for the vertices, and you have 10 uv coordinates or 20 numbers for the uvs, and 20 is twice 10 (hence “a.length is 2*number of vertices”)