Ron Posted June 5, 2014 Share Posted June 5, 2014 How to apply a texture on a mesh created by the following function :function drawTriangle(scene) {var triangle = new BABYLON.Mesh('triangle', scene);var positions = [0, 1, 0,-1, -1, 0,1, -1, 0];var normals = [1, 1, 1,1, 1, 1,1, 1, 1];var indices = [];indices.push(0);indices.push(1);indices.push(2);triangle.setVerticesData(positions, BABYLON.VertexBuffer.PositionKind);triangle.setVerticesData(normals, BABYLON.VertexBuffer.NormalKind);triangle.setIndices(indices);return triangle;} Have tried the usual textures in the tutorial, but they don't work on this kind of objects Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted June 5, 2014 Share Posted June 5, 2014 You have to add uv (texture coordinates). Somethign like this:function drawTriangle(scene) {var triangle = new BABYLON.Mesh('triangle', scene);var positions = [0, 1, 0,-1, -1, 0,1, -1, 0];var normals = [1, 1, 1,1, 1, 1,1, 1, 1];var uv = [0, 0,1, 0,1, 1]var indices = [];indices.push(0);indices.push(1);indices.push(2);triangle.setVerticesData(positions, BABYLON.VertexBuffer.PositionKind);triangle.setVerticesData(normals, BABYLON.VertexBuffer.NormalKind);triangle.setVerticesData(uv , BABYLON.VertexBuffer.UVKind);triangle.setIndices(indices);return triangle;} 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.