bakslash Posted September 5, 2015 Share Posted September 5, 2015 I want to build a cube (excluding the bottom). So I started to create a mesh with the following vertices (I'll just post the actual code since it's not much overhead) The problem I have is that all the 'sides' (but top) are only drawing one triangle. So my question is: What do I have to do to get the second triangle visible? geometry = new THREE.Geometry();// build top: alwaysgeometry.vertices.push(new THREE.Vector3(0, 0, 1));geometry.vertices.push(new THREE.Vector3(1, 0, 1));geometry.vertices.push(new THREE.Vector3(1, 1, 1));geometry.vertices.push(new THREE.Vector3(0, 0, 1));geometry.vertices.push(new THREE.Vector3(1, 1, 1));geometry.vertices.push(new THREE.Vector3(0, 1, 1));geometry.faces.push(new THREE.Face3(0, 1, 2));geometry.faces.push(new THREE.Face3(3, 4, 5));f = 5;// build left: (-x)if (!chunk.isSolid(x - 1, y)) {geometry.vertices.push(new THREE.Vector3(0, 0, 0));geometry.vertices.push(new THREE.Vector3(0, 0, 1));geometry.vertices.push(new THREE.Vector3(0, 1, 1));geometry.vertices.push(new THREE.Vector3(0, 0, 0));geometry.vertices.push(new THREE.Vector3(0, 1, 0));geometry.vertices.push(new THREE.Vector3(0, 1, 1));geometry.faces.push(new THREE.Face3(f + 1, f + 2, f + 3));geometry.faces.push(new THREE.Face3(f + 4, f + 5, f + 6));f += 6;}// build right: (+x)if (!chunk.isSolid(x + 1, y)) {geometry.vertices.push(new THREE.Vector3(1, 0, 0));geometry.vertices.push(new THREE.Vector3(1, 0, 1));geometry.vertices.push(new THREE.Vector3(1, 1, 1));geometry.vertices.push(new THREE.Vector3(1, 0, 0));geometry.vertices.push(new THREE.Vector3(1, 1, 0));geometry.vertices.push(new THREE.Vector3(1, 1, 1));geometry.faces.push(new THREE.Face3(f + 1, f + 2, f + 3));geometry.faces.push(new THREE.Face3(f + 4, f + 5, f + 6));f += 6;}//build front: (+y)if (!chunk.isSolid(x, y + 1)) {geometry.vertices.push(new THREE.Vector3(0, 1, 0));geometry.vertices.push(new THREE.Vector3(0, 1, 1));geometry.vertices.push(new THREE.Vector3(1, 1, 1));geometry.vertices.push(new THREE.Vector3(0, 1, 0));geometry.vertices.push(new THREE.Vector3(1, 1, 0));geometry.vertices.push(new THREE.Vector3(1, 1, 1));geometry.faces.push(new THREE.Face3(f + 1, f + 2, f + 3));geometry.faces.push(new THREE.Face3(f + 4, f + 5, f + 6));f += 6;}// build back: (-y)if (!chunk.isSolid(x, y - 1)) {geometry.vertices.push(new THREE.Vector3(0, 0, 0));geometry.vertices.push(new THREE.Vector3(0, 0, 1));geometry.vertices.push(new THREE.Vector3(1, 0, 1));geometry.vertices.push(new THREE.Vector3(0, 0, 0));geometry.vertices.push(new THREE.Vector3(1, 0, 1));geometry.vertices.push(new THREE.Vector3(1, 0, 0));geometry.faces.push(new THREE.Face3(f + 1, f + 2, f + 3));geometry.faces.push(new THREE.Face3(f + 4, f + 5, f + 6));f += 6;}cube = new THREE.Mesh(geometry, material);cube.position.x = x + (cx * Chunk.dimension);cube.position.y = y + (cy * Chunk.dimension);scene.add(cube);} Quote Link to comment Share on other sites More sharing options...

jacquesr Posted November 5, 2015 Share Posted November 5, 2015 identify which of the sides it is that is correct, then invert the order of the indices for the second triangle. So either invert the order of the first three or the last three. This is usually the problem since the faces are only drawn into one direction and as far as I know, that is due to the order of the vertices put into the geometry info Quote Link to comment Share on other sites More sharing options...

## Recommended Posts

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Note:Your post will require moderator approval before it will be visible.