Added uv coordinates to cube
@@ -55,7 +55,7 @@ pub fn create_cube() -> Result<mesh::Mesh, Error>
glm::vec3(-1.0, 1.0, 1.0),
glm::vec3(-1.0, -1.0, 1.0),
glm::vec3(-1.0, 1.0, 1.0),
- glm::vec3(-1.0, -1.0, -1.0),
+ glm::vec3(-1.0, -1.0, -1.0)
];
let normals: Vec<glm::Vec3> = vec![
glm::vec3(0.0, 1.0, 0.0),
@@ -100,5 +100,52 @@ pub fn create_cube() -> Result<mesh::Mesh, Error>
glm::vec3(-1.0, 0.0, 0.0),
glm::vec3(-1.0, 0.0, 0.0)
];
- Ok(mesh::Mesh::create_with_normals(positions, normals)?)
+
+ let uvs: Vec<glm::Vec2> = vec![
+ glm::vec2(1.0, 0.0),
+ glm::vec2(0.0, 0.0),
+ glm::vec2(1.0, 1.0),
+ glm::vec2(0.0, 1.0),
+ glm::vec2(1.0, 1.0),
+ glm::vec2(0.0, 0.0),
+
+ glm::vec2(0.0, 0.0),
+ glm::vec2(0.0, 0.0),
+ glm::vec2(0.0, 0.0),
+ glm::vec2(0.0, 0.0),
+ glm::vec2(0.0, 0.0),
+ glm::vec2(0.0, 0.0),
+
+ glm::vec2(0.0, 0.0),
+ glm::vec2(0.0, 0.0),
+ glm::vec2(0.0, 0.0),
+ glm::vec2(0.0, 0.0),
+ glm::vec2(0.0, 0.0),
+ glm::vec2(0.0, 0.0),
+
+ glm::vec2(0.0, 0.0),
+ glm::vec2(0.0, 0.0),
+ glm::vec2(0.0, 0.0),
+ glm::vec2(0.0, 0.0),
+ glm::vec2(0.0, 0.0),
+ glm::vec2(0.0, 0.0),
+
+ glm::vec2(0.0, 0.0),
+ glm::vec2(0.0, 0.0),
+ glm::vec2(0.0, 0.0),
+ glm::vec2(0.0, 0.0),
+ glm::vec2(0.0, 0.0),
+ glm::vec2(0.0, 0.0),
+
+ glm::vec2(0.0, 0.0),
+ glm::vec2(0.0, 0.0),
+ glm::vec2(0.0, 0.0),
+ glm::vec2(0.0, 0.0),
+ glm::vec2(0.0, 0.0),
+ glm::vec2(0.0, 0.0)
+ ];
+
+ let mut mesh = mesh::Mesh::create_with_normals(positions, normals)?;
+ mesh.add_custom_vec2_attribute("uv_coordinate", uvs)?;
+ Ok(mesh)
}
\ No newline at end of file
