I am having issues creating a simple 2D scene with Three.js. I would like to create a 2D view on a colored triangle. I am not able to make the triangle colored (eg. red). I believe that I will need the following for that:
- THREE.OrthographicCamera
- simple triangle -> i.e. THREE.Geometry() colored in red
I do not want any shadows, just a simple red 2D triangle in the orthographic scene.Any suggestions on how to make it are welcome.
If you are going to use the base Geometry class you need to add all your own vertices to the scene. You can do this with the Vertex class like so
We then need to construct a face from our vertices, you pass in the indices of the vertices in the order they are pushed above..
[EDIT]: As mrdoob points out below, you also need to add them in counter clock-wise order.
This was the problem with my fiddle. You can view the fixed demo here.
Finally create a material and combine it with your geometry to create a Mesh. Even for 2D I believe you are required to create a mesh in order to display this.