Tableuraz Posted July 12, 2015 Share Posted July 12, 2015 Hi there, I just started learning BabylonJS some days ago (and I love it so far), but I'm having an issue.I am loading scenes, with a plane called WaterPlane, which is... The water plane. I am using some shaders to simulate water surface on it, however, as it only has 4 vertices, the vertex shader is not really useful...So I decided to convert it to a GroundMesh (which has more vertices), the only issue I am getting is regarding the size of the WaterPlane, I can't use the scaling data as it makes a huge water surface...I've spent some time looking on the internet, how I could get the scale of a plane after importing it from a scene, but I can't find a way to do it...I can't set the Ground mesh manually as the water plane will change size over different scenes, and I can't modify the plane to add more vertices before importing...Thanls in advance for your help guys ! Quote Link to comment Share on other sites More sharing options...
Tableuraz Posted July 12, 2015 Author Share Posted July 12, 2015 Well, I found the solution, by using the bounding box of the original WaterPlane. If someone is having the same issue, the easiest way to get the Plane size in order to create an other Plane or a groundMesh is the following (if the Plane is horizontal).var Water = new BABYLON.Mesh.CreateGround("Water", Math.abs(WaterPlane.getBoundingInfo().boundingBox.maximumWorld.x - WaterPlane.getBoundingInfo().boundingBox.minimumWorld.x),Math.abs(WaterPlane.getBoundingInfo().boundingBox.maximumWorld.z - WaterPlane.getBoundingInfo().boundingBox.minimumWorld.z), 1, scene, false);Also, think about setting the newly created groundMesh parent to the same Plane parent before setting the location (I spent some time trying to set the groundMesh position before understanding that... ) Quote Link to comment Share on other sites More sharing options...
jahow Posted July 12, 2015 Share Posted July 12, 2015 Well done bounding info does seem like the perfect way to solve this, clean and foolproof. 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.