Bitbybit Docs
    Preparing search index...

    Function computeVertexNormals

    • Compute smooth vertex normals for a mesh that arrives without them. Accumulates each triangle's cross product onto its three vertices, then normalizes, so a vertex shared by several triangles ends up with their average and the mesh shades smoothly.

      Parameters

      • positions: number[]

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

      • indices: number[]

        Triangle indices

      Returns number[]

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