Polygon mesh normal_at

Hi,

It seems that mesh.normal_at returns the normal at the points of the mesh and not the normal of the polygons. Is this correct?

How is this normal calculated? I know I could calculate the normal of the face given the points, but it would be probably very slow in Ruby.

Thanks

Does it not return the normal of the polygon at the given index?

Yes, but it seems to be the index of a point. For example for a four sided face it returns four normals.

They are all the same,

You may be right, but I am not sure it matters.

I do not think the normal is calculated when using a PolygonMesh. It is only available when getting the mesh from a face entity, and so any mesh normal will just be the face normal.

Edit - I checked how the SketchUp STL project is using normal_at and we are giving a point index as an argument to normal_at[1], so maybe the documentation is totally incorrect. It could use clarified at the least.

[1] sketchup-stl/exporter.rb at main · SketchUp/sketchup-stl · GitHub

I think you are right and actually the Ruby API doc says

‘This only works for meshes retrieved from Sketchup::Face.mesh.’