jurito Posted April 3, 2018 Share Posted April 3, 2018 Hello, I am quite a BabylonJS noob so sorry if it's a stupid question. After creating a GroundMesh and updating the vertices' positions with CreateGroundFromHeightMap, I'm trying to locate dinamically the height of the ground at defined positions, but using the getHeightAtCoordinates method results in the error: TypeError: Cannot read property 'slope' of undefined at i._getFacetAt... Am i missing something obvious? TIA Quote Link to comment Share on other sites More sharing options...
jerome Posted April 3, 2018 Share Posted April 3, 2018 http://doc.babylonjs.com/api/classes/babylon.groundmesh#updatecoordinateheights GameMonetize 1 Quote Link to comment Share on other sites More sharing options...
jurito Posted April 4, 2018 Author Share Posted April 4, 2018 Thanks for your answer (GREAT demos btw)! Still not working tho, same error (v3.2.0-beta.1) Im' gonna setup a playground that reproduces the problem asap.. Quote Link to comment Share on other sites More sharing options...
jurito Posted April 4, 2018 Author Share Posted April 4, 2018 here it is.. https://playground.babylonjs.com/#CPX1GV Quote Link to comment Share on other sites More sharing options...
JohnK Posted April 4, 2018 Share Posted April 4, 2018 @jurito welcome to the forum. Sorry I am not able to help with the getHeightAtCoordinates issue. I just wanted to point out to those checking out the PG that adjusting the position of the camera and taking out the problem line 'console.log(getHeightAtCoordinates)` does show that the code is working. With current position of camera mesh appears hidden. https://playground.babylonjs.com/#CPX1GV#1 Quote Link to comment Share on other sites More sharing options...
jerome Posted April 4, 2018 Share Posted April 4, 2018 The error comes from the fact you don't initially use MeshBuilder.CreateGroundFromHeightMap() as it's expected but directly VertexData.CreateGroundFromHeightMap() instead what is, like, a semi-public method. This means that some expected properties aren't initialized, in particular subdivisionsX and subdivisionsY. I would recommend either to call first MeshBuilder.CreateGroundFromHeightMap(), then to modify the vertices, then to update the heights if you're not sure about all the internals, either to check what's is required before calling directly VertexData.CreateGroundFromHeightMap() if you prefer it 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.