<p>There are many tutorials covering this - Google is your friend. Maybe <a href="https://jameshfisher.com/2017/10/21/webgl-cube.html" rel="nofollow noreferrer">this</a> covers your demands?</p>

CC BY-SA 4.0
2018-12-14T09:56:42.327Z
I'm not familiar with javascript, but it looks to me like that is using a separate transformation per face. It might be ok for a trivial example, but *please* don't try to scale that to larger models.
Simon F
CC BY-SA 4.0
2018-12-14T09:26:59.430Z
2018-12-14T09:26:59.430Z
beyond
<p>I have to draw cubes with faces of different colors (each per face), but I don't know how to accomplish this task: I draw cubes using CPU and GPU meshes (no vertexBuffer or three.js "style") and I don't know how to assign to each vertex different colors (I don't even know if this is possible).
I can upload my code to GitHub if my problem isn't clear enough, let me know.
All of this is coded in JavaScript and WebGL.</p>

CC BY-SA 4.0
2018-12-13T13:31:54.107Z
It's probably easier to do it with 3 copies of each vertex - with the appropriate colour on each copy.
Simon F
CC BY-SA 4.0
2018-12-14T14:23:27.103Z
Welcome to the site. Please elaborate on your specific problem and show what you have so far. A code dump is not a proper way to do this. Extract the minimal and meaningful parts and post them in the question.
bernie
CC BY-SA 4.0
2019-07-10T15:01:49.667Z
[This page](https://webglfundamentals.org/webgl/lessons/webgl-3d-orthographic.html) describes drawing faces in different colors.
gman
<webgl><javascript>
How can I make a cube with faces of different colors? Webgl
StormPooper
# How can I make a cube with faces of different colors? Webgl

(Asked by: username_0 on 2018-12-13)

I have to draw cubes with faces of different colors (each per face), but I don't know how to accomplish this task: I draw cubes using CPU and GPU meshes (no vertexBuffer or three.js "style") and I don't know how to assign to each vertex different colors (I don't even know if this is possible).
I can upload my code to GitHub if my problem isn't clear enough, let me know.
All of this is coded in JavaScript and WebGL.

**Tags:** webgl, javascript

> **Comments:**
> **username_1**: It's probably easier to do it with 3 copies of each vertex - with the appropriate colour on each copy.  
> **username_2**: Welcome to the site. Please elaborate on your specific problem and show what you have so far. A code dump is not a proper way to do this. Extract the minimal and meaningful parts and post them in the question.  
> **username_3**: [This page](https://webglfundamentals.org/webgl/lessons/webgl-3d-orthographic.html) describes drawing faces in different colors.  

---

## 1 answers

### Answer by username_4 on 2018-12-14. Score: -2

There are many tutorials covering this - Google is your friend. Maybe [this](https://jameshfisher.com/2017/10/21/webgl-cube.html) covers your demands?

> **Comments:**
> **username_1**: I'm not familiar with javascript, but it looks to me like that is using a separate transformation per face. It might be ok for a trivial example, but *please* don't try to scale that to larger models.  

---

