Bitbybit Docs
    Preparing search index...

    Function computeVertexNormals

    • Smooth normals for a mesh that arrives without them: each point takes the sum of the normals of the triangles around it, each as long as twice its triangle's area, scaled to length 1, so a large triangle counts for more than a sliver and the mesh shades smoothly. A point that no triangle with an area touches keeps a normal of zero.

      Parameters

      • positions: ArrayLike<number>

        Flat array of vertex positions [x,y,z,x,y,z,...]

      • indices: ArrayLike<number>

        Triangle indices

      Returns number[]

      Flat array of normals [nx,ny,nz,nx,ny,nz,...]