# ExtrudePolygon position

Hi
I am creating a wall with ExtrudePolygonExtrudePolygon. It happens exactly as I want, but I can’t reach the real position of the formed wall. The resulting wall appears at (0,0,0) but the real (0,0,0) is where the box is. Can you help with this? How can I find the actual position of the object I created with ExtrudePolygon?

Extrusion with PolygonMeshBuilder | Babylon.js Playground (babylonjs.com)

Your polygon is built relative to the origin (0, 0, 0) s o that is its position within BJS. You can set various other ‘positions’ for your wall, bottom left corner, center of wall, etc as you seem fit.

You can use the construction data for the polygon to do this. Also the bounding box of the polygon is available to collect relevant data in the form of maximum and minimum sizes.

Once you have determined what position you want to allocate to your wall you can then uise a pivot to reset the position to where you want.

2 Likes

Thank you so much. This was definitely the answer I was looking for. I need to talk about one more thing. How can I get the rotation of the wall inside? Do you have an idea?

Sorry not clear, inside what?

Sorry, let me explain better. I can get the position of the wall. This is great. How can I get the rotation of the wall?

Trigonometry from the corners.

Do not know the full extent of your project.

Would it not be easier to build a wa;ll from a plane of known size at (0, 0, 0) and reposition and rotate as needed, you would then have known positional and rotational properties?

I need to draw a wall on PG. This is the scope of the project. If I can integrate the project into PG I will throw you an example. The Scaling and Rotation values ​​I need right now. Unfortunately I can’t access it.

As built your polygon will have scaling 1 and zero rotation.

You will need to describe your project in more detail as to why you need the scale and rotation.

You have the position of its corners of the polygonm therefore you can use mathematics to determine its actual rotation and its size in width and height. After that you can apply scale and rotation via the pivot.

Extrusion with PolygonMeshBuilder | Babylon.js Playground (babylonjs.com)

This is the part I used in the project.
I am creating a polygon with two different location information. For some reason in the project, I need to delete the polygony and replace it with the box. It should get rotation-position-length information of polygon in Box
If I could create a box with two different position information, I wouldn’t have a problem.

Please give an example of two positions and how a box should fits into these two positions. A diagram would help.

Have you seen this

Yes I did, but that didn’t work. A box will be created between the two positions. Width doesn’t matter. There will only be a box of the given length between the two positions. We actually achieve this with polygon, but for reasons you know it doesn’t work.

Sorry I cannot get an understanding of your issue, hopefully someone else might.

If you have already placed the wall where you want it to be why do you need to reposition, scale and rotate it?

Reason: After rendering I will move the formed wall using gizmo. Then I will save this position information to the db. While doing this, the resulting polygon takes the starting position as its own region, so it gives the position information incorrectly. Besides, I will have the same problem with the rotation scale properties.

Anyway, thank you for your help.

Ahh a little more insight. I would still say build your wall to size using a plane at position (0, 0, 0) and the apply the gizmo to move, rotate and scale as needed.

It might be worth asking a new question about using a gizmo on a wall built with polygonbuilder.

Also see