djvs Posted September 4, 2017 Share Posted September 4, 2017 I'm completely in the dark when it comes to creating meshes from scratch. I figured it out as far as positions, indices, applying vertex data...I have this basic example, creating a barn-wall style pentagon from 5 x,y,z primitive vertex arrays - var v2pent = (v3s, mesh) => { // clockwise from tl, 0 1 4, 1 3 4, 1 2 3 var vtxdt = new BABYLON.VertexData vtxdt.positions = _.flatten(_.map([0,1,4,1,3,4,1,2,3], i => v3s[i])) vtxdt.indices = [0,1,2,3,4,5,6,7,8] // these two lines added to try to debug, no help // vtxdt.normals = [0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1] // vtxdt.uvs = _.flatten(_.map([0,1,4,1,3,4,1,2,3], i => [v3s[i][0],v3s[i][1]] )) var mesh = mesh || new BABYLON.Mesh('t1', scene) vtxdt.applyToMesh(mesh, true) return mesh } It sort of works, but the meshes are always dark gray to black (not picking up light?), and more importantly right now, not coming up when they're the foreground-most mesh when calling scene.pick - the other pentagon wall behind it will pick it up first! Help very much appreciated - I've read pretty much all the relevant docs and am totally confused. I don't know if its the uv and/or normal calculation, or if there's some helper function in the library to generate those for me (besides just ComputeNormals)? Is it something I could solve with BABYLON.Mesh.DOUBLESIDE, or an equivalent? The material used in this case is the following by the way: var wallMaterial = new BABYLON.TriPlanarMaterial("metal", scene); wallMaterial.tileSize = 12; wallMaterial.diffuseTextureX = metalTexture; wallMaterial.diffuseTextureZ = metalTexture; wallMaterial.backFaceCulling = false; (copy and pasted from my issue here https://github.com/BabylonJS/Babylon.js/issues/2735) Quote Link to comment Share on other sites More sharing options...
djvs Posted September 4, 2017 Author Share Posted September 4, 2017 Well, looks like the darkness came from trying to override the default uv/normals, and the issue with the wrong wall being selected was my own fault on an unrelated issue. GameMonetize 1 Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted September 4, 2017 Share Posted September 4, 2017 The important thing is that you are unblocked Quote Link to comment Share on other sites More sharing options...
djvs Posted September 4, 2017 Author Share Posted September 4, 2017 No kidding, I just completed that feature too. 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.