alanz2223 Posted March 14, 2016 Share Posted March 14, 2016 I am creating a new ground from a height map and would like to convert it to a flat shaded mesh, however I am receiving an error when calling the mesh's convertToFlatShadedMesh(). Cannot read property 'slice' of undefined. and what is undefined is the mesh's subMeshes property. relevant code is simple var plane = new b.Mesh.CreateGroundFromHeightMap('plane', 'map.png', 100, 100, 50, -5, 5, scene); plane.convertToFlatShadedMesh(); Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted March 14, 2016 Share Posted March 14, 2016 Maybe try assigning a material before converting. Quote Link to comment Share on other sites More sharing options...
alanz2223 Posted March 14, 2016 Author Share Posted March 14, 2016 It does not work, I dont think that the material would be modifying with the subMeshes anyways. if you would like to see it for yourself the playground demo height map does the exact same thing when you call ground.convertToFlatShadedMesh(); Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted March 14, 2016 Share Posted March 14, 2016 This is because the ground mesh is created asynchronously (it needs to read the texture first). Just use the onready callback : http://doc.babylonjs.com/classes/2.3/Mesh#static-creategroundfromheightmap-name-url-width-height-subdivisions-minheight-maxheight-scene-updatable-onready-rarr-groundmesh-classes-2-3-groundmesh- Pryme8 1 Quote Link to comment Share on other sites More sharing options...
alanz2223 Posted March 14, 2016 Author Share Posted March 14, 2016 Yes this did the trick, thanks. Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted March 14, 2016 Share Posted March 14, 2016 Delta beat me to it yup, because the ground has to be constructed first for the uv to take effect the material has to be called on the onready call back, because otherwise it does not exsist yet or is fragmented. 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.