# How to generate uv attribute for buffer geometry (mesh)

**URL:** <https://discourse.threejs.org/t/how-to-generate-uv-attribute-for-buffer-geometry-mesh/35466>\
**Category:** Questions\
**Tags:** uv\
**Created:** [March 2, 2022, 3:40am UTC](https://discourse.threejs.org/t/how-to-generate-uv-attribute-for-buffer-geometry-mesh/35466 "2022-03-02T03:40:13Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![chloesun](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/chloesun/32/24587_2.png) [@chloesun](https://discourse.threejs.org/u/chloesun)\
**Post date:** [March 2, 2022, 3:40am UTC](https://discourse.threejs.org/t/how-to-generate-uv-attribute-for-buffer-geometry-mesh/35466/1 "2022-03-02T03:40:13Z")

</div>

I loaded a group of meshes (buffer geometry) in the threejs scene, and just noticed that they don’t have uv attribute at all. How to generate uvs for `geometry.attributes`

 ![Screen Shot 2022-03-01 at 10.24.59 PM](https://canada1.discourse-cdn.com/flex035/uploads/threejs/original/3X/b/e/be3d966ce30f2e1976533d15a6d8b97e721332b7.png)

---

<div class="post-metadata">

**Author:** ![timcastelijn1](https://avatars.discourse-cdn.com/v4/letter/t/cc9497/32.png) [@timcastelijn1](https://discourse.threejs.org/u/timcastelijn1)\
**Post date:** [November 17, 2022, 4:10pm UTC](https://discourse.threejs.org/t/how-to-generate-uv-attribute-for-buffer-geometry-mesh/35466/2 "2022-11-17T16:10:03Z")

</div>

hi @chloesun,

I have the same problem. Did you find a solution yet?

Thanks,  
Tim

---

<div class="post-metadata">

**Author:** ![drcmda](https://avatars.discourse-cdn.com/v4/letter/d/91b2a8/32.png) [@drcmda](https://discourse.threejs.org/u/drcmda)\
**Post date:** [November 17, 2022, 4:36pm UTC](https://discourse.threejs.org/t/how-to-generate-uv-attribute-for-buffer-geometry-mesh/35466/3 "2022-11-17T16:36:37Z")

</div>

you would typically unwrap a model in blender, and it’s rarely not a manual process. blender has auto unwrap but it’s looking pretty dodgy more often than not. even if there is a solution, doing any of that in the browser on the single cpu thread, it doesn’t inspire confidence.

---

<div class="post-metadata">

**Author:** ![donmccurdy](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/donmccurdy/32/33209_2.png) [@donmccurdy](https://discourse.threejs.org/u/donmccurdy)\
**Post date:** [November 17, 2022, 7:59pm UTC](https://discourse.threejs.org/t/how-to-generate-uv-attribute-for-buffer-geometry-mesh/35466/4 "2022-11-17T19:59:36Z")

</div>

I’d just also note that if you already have a texture, it’s probably designed for a _specific_ set of UVs. If the model is missing UVs, then you’re missing critical information, and generating new UVs won’t really help. Only in very simple cases (basic pattern texture, or basic quad/cube geometry) is that possible.

Otherwise it is necessary to do “UV unwrapping” in a tool like Blender as @drcmda mentions, there are many tutorials for this on youtube, but requires some important design/art choices.

---

<div class="post-metadata">

**Author:** ![trusktr](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/trusktr/32/13726_2.png) [@trusktr](https://discourse.threejs.org/u/trusktr)\
**Post date:** [March 30, 2025, 7:22pm UTC](https://discourse.threejs.org/t/how-to-generate-uv-attribute-for-buffer-geometry-mesh/35466/5 "2025-03-30T19:22:22Z")

</div>

Generating UVs can be useful for procedural/generated geometries (the same as with defining UVs for Three’s out-of-the-box geometries).

There isn’t quite enough documentation on what the rules are for the UV attribute (indexed vs non-indexed geometry), so I made a thread on that:

> [@Documentation: Do UVs need to match with position attribute? Or index attribute?](https://discourse.threejs.org/t/documentation-do-uvs-need-to-match-with-position-attribute-or-index-attribute/80408):
>
> Unless I missed it, I didn’t see the docs describing the rules for UV attributes. For example, does the uv attribute need to match with position or with index (indexed geometry vs non-indexed geometry)?
