How to compute the corners of a wall joint?

Hi all
I want to know if it is possible to adjust the vertices of the edge in each wall to correct the overlapping or gap between 2 walls. I have checked this doc: Developing Build a House from Plans | Babylon.js Documentation but I could not apply to the pg


Here is the PG:

Can someone help me with this?

The main difference is that you use only boxes whereas the doc is manipulating vertices to build walls doors windows and such. I would suggest to stick to the doc approach which will prevent having to reconcile edges like this.

Isn’t there a way to manipulate vertices of these boxes according to the angle?

You can get the vertex array by doing mesh.getVerticesData("position") but you will have to find which vertices correspond to the corner(s) and update their coordinates yourself, by applying some maths calculation. Once the array is updated, you can set the new vertices on the mesh by doing mesh.setVerticesData("position", newarray).

1 Like

To add to what Evgeni said-

The positions array of a mesh you make using .createBox will have 8 sets of 3 equal vector3 coordinates that correspond to each corner of the 6 faces. And you can move the corners by updating each all 3 coordinates.

If you want to have arbitrary angles to your walls and have the corners be clean it will be MUCH easier in my opinion to forget about transform (scaling rotation and position) and use world coordinates for the corners of all your walls and figure out what the world coordinate are using plane math.

If you’re curious about this approach let me know and I can make a playground to demo what this looks like.



Thanks a lot.Could you show me an example from the playground?

Something like this:

If someone wants to clean this up I’d be grateful. This is to get a normal then add scaling for the inside angle between to walls so the depth setback for the inside corners is correct:

const dot = BABYLON.Vector3.Dot(getNormal(previousWall),getNormal(wall));
const factor = 1/Math.cos(Math.acos(dot)/2);
leftNormal = getNormal(wall).add(getNormal(previousWall)).normalize().scale(factor);

Cool!! I am trying to figure out how to take this concept and dynamically create walls as I click on the ground. I should also consider creating outer walls and inner walls. Furthermore, I cannot see the top and bottom faces of the mesh.

Anyone know how to calculate the vector to offset the inside corner of 2 walls to the outside corner from the normals?

@carolhmj ?

If you are sure they are coplanar, I guess it is the intersection of both lines ?

I found one blog that talks about this issue: Drawing Polylines by Tessellation - CodeProject