# MeshBuilder Last Poly Out Render Oddness?

I have been building a 2d/3d arc / circle / polar math based library for a project I am working on using meshBuilder.

However, I am having an issue where the last poly drawn using MeshBuilder, always renders white…

https://www.babylonjs-playground.com/#UD7RJE#1

Every material applied does it. I think it is some sort of geometry normal oddness. It’s got me head scratching for most of today. So I figured I would call in reinforcements. Thoughts on a fix?

It seems some normals are missing:

The white vertical lines are the normals. As you can see, the first triangle as a proper normal for each of its 3 vertices, so the shading is ok, but the other triangles have only a single normal for one of its vertex, so the shading can’t work.

Don’t know why it happens, if it’s a bug in the `MeshBuilder.ExtrudeShape` class or if there is something wrong with your parameters when calling this function…

1 Like

Adding @jerome and @JohnK who might be able to help here

First of all lets exaggerate the shape you are extruding, i.e. majorLine. In your case your shape is essentially two lines forming a 0 angle. Lets make that angle none zero (lines 69 - 71)

https://www.babylonjs-playground.com/#UD7RJE#2

Since by default only front sides are drawn as you move the camera, depending on the angle, only some of the front sides of the upper or lower planes can be seen at any one time.

Now narrow the angle

https://www.babylonjs-playground.com/#UD7RJE#3

Since the planes are flatter you can see more of the upper and lower planes at any point but with an overlap at some views.

Now make the angle 0 and the arrangement gives you that overlap on the last segment

https://www.babylonjs-playground.com/#UD7RJE#4

The issue is your shape (majorLine) being open and zero angled.

Solution make the shape a closed shape (a zero volume rectangle)

https://www.babylonjs-playground.com/#UD7RJE#5

Also note line 39 from Tools - Babylon.js Documentation

other tools are also already available.

You may also be interested in Line2D of Given Width - Babylon.js Documentation

https://www.babylonjs-playground.com/#FA2H7X#41

4 Likes

Beautiful, thanks all. That did the trick.
@JohnK, thanks for the explanation of what was happening. That was driving me crazy.