Jump to content

Converting Plane to Ground mesh


Tableuraz
 Share

Recommended Posts

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 !  :)

Link to comment
Share on other sites

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...  :rolleyes: )

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...