Ron Posted May 26, 2014 Share Posted May 26, 2014 This code :function getGroundHeight(x, z){x = new BABYLON.Vector3(x,50,z);height_of_ground=10;var rayPick = new BABYLON.Ray(x, new BABYLON.Vector3(0, -1, 0));var meshFound = scene.pickWithRay(rayPick, function (item) {if (item.id == 'ground'){return true;}});if (meshFound.pickedPoint != null) {height_of_ground = meshFound.pickedPoint.y;}return height_of_ground;}makes the 'ground' mesh disappearthe 'ground' mesh is built from a heightmapgroundMaterial = new BABYLON.StandardMaterial("ground", scene);groundMaterial.emissiveTexture = new BABYLON.Texture('world/'+zone_id+'_tex.png', scene);groundMaterial.emissiveTexture.uScale = 1;groundMaterial.emissiveTexture.vScale = 1;land = BABYLON.Mesh.CreateGroundFromHeightMap("ground", 'world/'+zone_id+'.jpg', 100, 100, 15, 0, 20, scene, false);land.material = groundMaterial;this didn't happen when the mesh was on smaller positions (x,z <~ 1000), but my positions range between 0 and 40000 for x or z values (0-50 for y) removing 'height_of_ground = meshFound.pickedPoint.y;' does not solve the problem. but removing `return true;` from `if (item.id == 'ground'){return true;}`does solve it ... but then i have no use !no errors in the console regarding this error. but still before starting to receive it sometimes i get "WebGL: INVALID_OPERATION: drawElements: no ELEMENT_ARRAY_BUFFER bound" any help would be aprreciated. i guess it's a bug in babylon js for large x,z values for positioning thanks Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted May 26, 2014 Share Posted May 26, 2014 Hello, could you share a complete repro case? A jsfiddle or a link to your project? Quote Link to comment Share on other sites More sharing options...
Ron Posted June 2, 2014 Author Share Posted June 2, 2014 I am not able to upload the content anywhere atm, nor even on jsfiddle (little bit complex and uses some external files and images). but when i replaced the heightmaps with planes, everything was working fine. on top of that some heightmaps are not rendering, and they break the webgl engine to show empty space (nothing is rendered), but sometimes they show when moving around the world!. i am attaching some of the heightmaps i am using, maybe there's something wrong with the image files?terrains.zip Quote Link to comment Share on other sites More sharing options...
Wingnut Posted June 2, 2014 Share Posted June 2, 2014 Hi Ron! I'm quite sure that the current webGL spec does not allow more than 65536 vertices on a single piece of ground. See http://stackoverflow.com/questions/4998278/is-there-a-limit-of-vertices-in-webgl . You can have more than one piece of ground, but then you will need to do some magic to "stitch the seams" so the ground sections smoothly integrate with each other (possibly by cutting your heightMap texture into multiple sections). Keep in mind that you can position mesh, cameras and lights in ANY location, with infinite granularity. But as far as vertices per mesh... 65536 is the maximum. MS Train Simulator - one of my favorite games, uses a topography sectioning system like that, and a technique called 'incremental loading'. I am not sure if this is the problem you are having, but maybe. Some other informative links: http://www.html5gamedevs.com/topic/6550-creategroundfromheightmap-subdivision-count-issue/ https://github.com/BabylonJS/Babylon.js/wiki/16-Height-map http://blogs.msdn.com/b/eternalcoding/archive/2013/08/06/babylon-js-creating-a-convincing-world-for-your-game-with-custom-shaders-height-maps-and-skyboxes.aspx At the main babylon.js website ... down in the Feature Tests section, there is a choice called 'heightmap' and I think that is the 100-subdivision heightMap ground from the 'convincing world' post (3rd link above). It is large and smooth, and if you keep the rest of your meshes small, it will provide a nice large scene area for any project. Take a look at http://www.babylonjs.com/playground/#RP6O4 I think THAT is the 250-subdivision heightMap ground from the heightMap tutorial (2nd link above). Click that 'fullscreen' button, and mousewheel in/out, and pan around. It is also quite a large play area. With a small character, it might take 3-4 LIFETIMES to explore all of that. (And lots of resources.) I don't know if any of this helps your problem, but I hope so. Keep us posted. Zip and attach your entire scene if you can, and want. We want to help, but we don't have enough information yet. Be well. Quote Link to comment Share on other sites More sharing options...
Ron Posted June 2, 2014 Author Share Posted June 2, 2014 Thanks for the information, but actually i am using maximum of 20 pieces per ground, and it even fails to load one. more info: i am building the ground of heightmap while moving the camera: engine.runRenderLoop(function () { move_camera(); mouse_functions(); scene.render(); }); move_camera function reads mouse inputs and moves the camera to positions, when moving outside of a ground mesh it loads the next ground mesh via the code i posted above. sometimes it works (5% of cases) sometimes it doesn't ... but the ground height returns the correct height underneath the camera, but it's kind of "invisible"! ... and sometimes everything in the scene just disappears with "too many errors" in console "on chromium/ubuntu" WebGL: INVALID_OPERATION: drawElements: no ELEMENT_ARRAY_BUFFER bound maybe you might reproduce this? i have attached the heightmaps i use! Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted June 2, 2014 Share Posted June 2, 2014 Could you try to reproduce the problem on playground ? Quote Link to comment Share on other sites More sharing options...
Ron Posted June 2, 2014 Author Share Posted June 2, 2014 I will upload the code to a server soon, it would be easier than to re-implement it. my problem now is with the tight time i have, maybe on weekend or tonight i will do it and post the link here Quote Link to comment Share on other sites More sharing options...
Ron Posted June 5, 2014 Author Share Posted June 5, 2014 here : http://war.3zezat.com/ Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted June 5, 2014 Share Posted June 5, 2014 Where should I look in your code? Quote Link to comment Share on other sites More sharing options...
Ron Posted June 5, 2014 Author Share Posted June 5, 2014 function 'getCameraHeight' in 'view/main/assets/js/core.js?ver=65' Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted June 5, 2014 Share Posted June 5, 2014 I do not see a bug, I can see an ocean and I can walk on it Quote Link to comment Share on other sites More sharing options...
Ron Posted June 5, 2014 Author Share Posted June 5, 2014 on top of the ocean there are heightmaps that become invisible when returning true if (item.id == 'ground'){ return true; }else{ return false; } Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted June 5, 2014 Share Posted June 5, 2014 Hum sounds like I had a race condition here Could you try with the latest bjs 1.12 beta? I think this issue is fixed Quote Link to comment Share on other sites More sharing options...
Ron Posted June 5, 2014 Author Share Posted June 5, 2014 Seems like it is working though sometimes the planes do not show, but i know this is a problem in my code. 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.