Search the Community
Showing results for tags 'Mesh Dynamic Tile'.
-
Hi All! I am trying to build a simply terrain viewer using babylon.js. (I am new working with this kind of frameworks). I have several tile pieces and each one have information about altitude (height map). The idea is to let the javascript ask for new tiles when needed. So I have a tile manager that checking the position of the camera, select the tile where the camera is and ask for more tiles, if needed, to continue adding information to the map. I am using the WorldMonger terrain texture to see grass, rocks, etc.. on the terrain. I am creating a new Mesh for each tile and changing the position to locate it in the right place. This works great but because each tile is a new Mesh I can see the "jump" in the texture between two tiles and therefore it is not good enough. So my first idea was create only one mesh and update it everything I got new information. I would be applying the texture only once time and I would have only one mesh. It sounds like an improvement to me. The problem is that I cannot make it work. To test it I am loading only two tiles, to see if I can see the two tiles on the viewer. But I can only see one. I have tried different approach but at the end the result is always the same. This is a example of the "update" piece of my code: (any ideas? what is wrong?) if (this._singleMesh.getTotalVertices() == 0) { this._singleMesh.setVerticesData(BABYLON.VertexBuffer.PositionKind, positions, updatable); this._singleMesh.setVerticesData(BABYLON.VertexBuffer.NormalKind, normals, updatable); this._singleMesh.setVerticesData(BABYLON.VertexBuffer.UVKind, uvs, updatable); this._singleMesh.setIndices(indices); } else { positions = positions.concat(this._singleMesh.getVerticesData(BABYLON.VertexBuffer.PositionKind)); normals = normals.concat(this._singleMesh.getVerticesData(BABYLON.VertexBuffer.NormalKind)); uvs = uvs.concat(this._singleMesh.getVerticesData(BABYLON.VertexBuffer.UVKind)); indices = indices.concat(this._singleMesh.getIndices()); this._singleMesh.updateVerticesData(positions, BABYLON.VertexBuffer.PositionKind, updatable); this._singleMesh.updateVerticesData(normals, BABYLON.VertexBuffer.NormalKind, updatable); this._singleMesh.updateVerticesData(uvs, BABYLON.VertexBuffer.UVKind, updatable); this._singleMesh.setIndices(indices); }