The center of the plane will be at (0, 0, 0) so that the easiest way to sort out the position for your polygon is to ensure the coordinates of its vertices are referenced to the center of the plane, i.e. the origin of the polygon is the center of the plane. This way setting the positions of the plane and the polygon to the same value will place the origin of the polygon at the center of the plane.
All vectors for shape and holes are Vector3 and should be in the xz plane, ie of the form BABYLON.Vector3(x, 0, z) and in counter clockwise order. You just list all the vertices of the polygon and CreatePolygon closes the shape.
Have you fully digested the order part of the information? When you create first, second, third, fourth and fifth points with the fifth point between say the first and second points you would need point order to be first, fifth, second, third, fourth and in correct direction to create a polygon.
For correct positioning have a look to see if you can find the screen coords of the center the of the plane and reference the picked points to this point as origin.
If I have more time I will have another look tomorrow.
Yup, I’ve seen the order part, but if you try to list them clockwisely, it works too.
For correct positioning have a look to see if you can find the screen coords of the center the of the plane and reference the picked points to this point as origin.
I’ve commented a section where I calculated the centerBox : the boundingBox of all points to align with the polygon boundindBox, but without success…
I think a solution is hidden in the Pivot part of the doc I haven’t read yet
But don’t you find it weird the polygon is correctly placed the fifth time you click on the plane ?
Which part of the code is doing this ? …
EDIT : just saw that polygon.position = plane.position moves the plane to a wrong position …