# UV coordinates maaping in weird patterns

**URL:** https://discourse.threejs.org/t/uv-coordinates-maaping-in-weird-patterns/40821
**Category:** Questions
**Tags:** textures
**Created:** [July 28, 2022, 4:13pm UTC](https://discourse.threejs.org/t/uv-coordinates-maaping-in-weird-patterns/40821 "2022-07-28T16:13:22Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![HacksAndSlash](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/hacksandslash/32/28374_2.png) [@HacksAndSlash](https://discourse.threejs.org/u/HacksAndSlash)
#### Post date: [July 28, 2022, 4:13pm UTC](https://discourse.threejs.org/t/uv-coordinates-maaping-in-weird-patterns/40821/1 "2022-07-28T16:13:23Z")

</div>

Hello, I have a grid of 32\*32 quads each made of two triangles of the XY plane (or z-forward, not sure which is correct) even though each quad has the same uv mapping i get this monstrosity forming patterns on a macro scale but gibberish on a small scale my only guess is i messed up during getting the uv coordinates but other than that i have no other ideas

 ![image](https://canada1.discourse-cdn.com/flex035/uploads/threejs/original/3X/2/b/2b3d444092dee73b9d8bfec7d554218fa94cc5f8.jpeg)

---

<div class="post-metadata">

### Author: ![HacksAndSlash](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/hacksandslash/32/28374_2.png) [@HacksAndSlash](https://discourse.threejs.org/u/HacksAndSlash)
#### Post date: [July 28, 2022, 4:14pm UTC](https://discourse.threejs.org/t/uv-coordinates-maaping-in-weird-patterns/40821/2 "2022-07-28T16:14:16Z")

</div>

![test](https://canada1.discourse-cdn.com/flex035/uploads/threejs/original/3X/4/7/474c0ac3c4c4aceb67799702bd4b43c38db20e7b.png)  
forgot to mention this is what the texture should look like on each quad

---

<div class="post-metadata">

### Author: ![HacksAndSlash](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/hacksandslash/32/28374_2.png) [@HacksAndSlash](https://discourse.threejs.org/u/HacksAndSlash)
#### Post date: [July 28, 2022, 4:17pm UTC](https://discourse.threejs.org/t/uv-coordinates-maaping-in-weird-patterns/40821/3 "2022-07-28T16:17:17Z")

</div>

close-up:

 ![image](https://canada1.discourse-cdn.com/flex035/uploads/threejs/original/3X/f/7/f7fa4c98f4f0d10d6b91d6dfa195d34e85b4b651.jpeg)

---

<div class="post-metadata">

### Author: ![prisoner849](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/prisoner849/32/535_2.png) [@prisoner849](https://discourse.threejs.org/u/prisoner849)
#### Post date: [July 28, 2022, 4:21pm UTC](https://discourse.threejs.org/t/uv-coordinates-maaping-in-weird-patterns/40821/4 "2022-07-28T16:21:20Z")

</div>

Hi!  
Would be cool to provide a working live code example, that demonstrates the issue (jsfiddle, codepen, codesandbox etc.)  
Nobody, except you, knows the algorithm you set UV on quads.

---

<div class="post-metadata">

### Author: ![HacksAndSlash](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/hacksandslash/32/28374_2.png) [@HacksAndSlash](https://discourse.threejs.org/u/HacksAndSlash)
#### Post date: [July 28, 2022, 4:23pm UTC](https://discourse.threejs.org/t/uv-coordinates-maaping-in-weird-patterns/40821/5 "2022-07-28T16:23:39Z")

</div>

oh sorry about that, will get on it 🙂

---

<div class="post-metadata">

### Author: ![HacksAndSlash](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/hacksandslash/32/28374_2.png) [@HacksAndSlash](https://discourse.threejs.org/u/HacksAndSlash)
#### Post date: [July 28, 2022, 4:36pm UTC](https://discourse.threejs.org/t/uv-coordinates-maaping-in-weird-patterns/40821/6 "2022-07-28T16:36:13Z")

</div>

huh this is odd… jsfiddle is returning the error ’ \* “[209:16](#209:16) Uncaught TypeError: geometry.setAttribute is not a function”’

---

<div class="post-metadata">

### Author: ![Chaser\_Code](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/chaser_code/32/20199_2.png) [@Chaser\_Code](https://discourse.threejs.org/u/Chaser_Code)
#### Post date: [July 28, 2022, 4:49pm UTC](https://discourse.threejs.org/t/uv-coordinates-maaping-in-weird-patterns/40821/7 "2022-07-28T16:49:13Z")

</div>

BufferGeometry.addAttribute() has been renamed to BufferGeometry.setAttribute() version 110

---

<div class="post-metadata">

### Author: ![HacksAndSlash](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/hacksandslash/32/28374_2.png) [@HacksAndSlash](https://discourse.threejs.org/u/HacksAndSlash)
#### Post date: [July 28, 2022, 8:07pm UTC](https://discourse.threejs.org/t/uv-coordinates-maaping-in-weird-patterns/40821/8 "2022-07-28T20:07:56Z")

</div>

due to JSfiddle not being cooperative here is the code in question `indexes.push(vertexFromCoords(x+1,y,z+1),vertexFromCoords(x ,y ,z+1),vertexFromCoords(x,y+1,z+1));
indexes.push(vertexFromCoords(x+1,y+1,z+1),vertexFromCoords(x+1,y,z+1),vertexFromCoords(x,y+1,z+1));
uvs.push(1,0,0,0,0,1);
uvs.push(1,1,1,0,0,1);`

---

<div class="post-metadata">

### Author: ![HacksAndSlash](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/hacksandslash/32/28374_2.png) [@HacksAndSlash](https://discourse.threejs.org/u/HacksAndSlash)
#### Post date: [July 28, 2022, 8:08pm UTC](https://discourse.threejs.org/t/uv-coordinates-maaping-in-weird-patterns/40821/9 "2022-07-28T20:08:27Z")

</div>

note that this is for the Z+ face
