yokewang Posted February 5, 2018 Share Posted February 5, 2018 Hi, I want to create a ground mesh from a plane. let plane = new Plane(-0.4, -0.2, -0.6, 0.1); //normal and offset let planeMesh = Mesh.CreateGround("planeMesh", 100, 100, 2, scene); //to make the planeMesh to fit the plane, transformation should be added to the mesh planeMesh.rotation = ... planeMesh.positon = ... someone can help me out? Thanks. Quote Link to comment Share on other sites More sharing options...
Amarth2Estel Posted February 5, 2018 Share Posted February 5, 2018 Hello Yokewang ! When you do a new BABYLON.Plane, you create a "mathematical" plane in 3D-space. It is of course not rendered because it is infinite. When you do a BABYLON.MeshBuilder.CreateGround(..) you create a mesh which is coplanar to the XOZ Plane of your scene, with a given size, vertices number etc... To make your mesh fit your mathematical data, you need to align your mesh with your data's normal (the rotation) and change your mesh position to fit the offset of the math Plane. To do it, you can use : alignWithNormal method on AbstractMesh scale method on Vector3 Here is a simple playground showing this solution. Quote Link to comment Share on other sites More sharing options...
JohnK Posted February 5, 2018 Share Posted February 5, 2018 Hi @yokewang and welcome to the forum. @Amarth2Estel gave an excellent solution a little lost in the PG. Since you cannot change the sideOrientation to BABYLON.Mesh.DOUBLESIDE you cannot see the plane from the position of the camera. A change to camera type and position get you https://playground.babylonjs.com/#72YAXV#1 Quote Link to comment Share on other sites More sharing options...
yokewang Posted February 6, 2018 Author Share Posted February 6, 2018 Thanks for @Amarth2Estel's and @JohnK's help. It works. A new version with axes(verify the correctness): https://playground.babylonjs.com/#72YAXV#2 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.