Search the Community
Showing results for tags 'getHeightAtCoordinates'.
-
Hello good day team from babylon , i am really glad to have known babylon as well, it is a great tool , i am currently having some issues when using : ground.getHeightAtCoordinates(x, z) , i am currently using the export Toolkit that exports from Unity to Babylon js . i have imported the meshes to my scene using the "assetsManager" this way : var stones = assetsManager.addMeshTask("stones", "", "assets/stones/", "stones.babylon"); stones.onSuccess = function(task) { task.loadedMeshes.forEach(function(mesh) { mesh.isVisible = false; var range = 1024; var count = 40; for (var index = 0; index < count; index++) { var newInstance = mesh.createInstance("j" + index); var x = range / 2 - Math.random() * range; var z = range / 2 - Math.random() * range; var y = ground.getHeightAtCoordinates(x, z) ; // Getting height from ground object newInstance.position = new BABYLON.Vector3(x, y, z); } }); } The idea of using : ground.getHeightAtCoordinates(x, z) was to set each of my meshes in this case "stones" to the ground level on a random location on my scene . The problem starts when i import 1 or more meshes for example a "Palm.babylon or Plant.babylon" that i want to set it in random locations on my scene as well on ground level, then i instanciate and use "var y = ground.getHeightAtCoordinates(x, z) ;" the same way as the stones , but when i load the scene all the meshes doesn't load and i have to reload multiple times so it can appear all the meshes , and sometimes all the meshes never appear . Surprisingly when i replace : ground.getHeightAtCoordinates(x, z) to another high for example : 40 or another number , all the meshes appears correctly , that's why i suspect of getHeightAtCoordinates(x, z) function , Not sure if i am doing the correct importing ? , or it has to be something to Unity exporter? or getHeightAtCoordinates() ? , Anyone have an idea of what could be ocurring ? I wanted to add that if i increment the range of the meshes to be on the scene for example my ground is 1024*1024 and the range of my sheshes is 2048*2048 , all the meshes that are outside the ground appears correctly and the meshes inside the ground doesn't appear , any ideas? maybe it has to be something about memory?
-
http://www.babylonjs-playground.com/#1LEGTP#1 Commented code : each rolling ball has a tiny line on its top, normal to terrain.
- 7 replies
-
- heightmap
- getHeightAtCoordinates
-
(and 1 more)
Tagged with: