addFace method

dynamic addFace(
  1. dynamic a,
  2. dynamic b,
  3. dynamic c,
  4. dynamic ua,
  5. dynamic ub,
  6. dynamic uc,
  7. dynamic na,
  8. dynamic nb,
  9. dynamic nc,
)

Implementation

addFace(a, b, c, ua, ub, uc, na, nb, nc) {
  var vLen = vertices.length;

  var ia = parseVertexIndex(a, vLen);
  var ib = parseVertexIndex(b, vLen);
  var ic = parseVertexIndex(c, vLen);

  addVertex(ia, ib, ic);
  addColor(ia, ib, ic);

  // normals

  if (na != null && na != '') {
    var nLen = normals.length;

    ia = parseNormalIndex(na, nLen);
    ib = parseNormalIndex(nb, nLen);
    ic = parseNormalIndex(nc, nLen);

    addNormal(ia, ib, ic);
  } else {
    addFaceNormal(ia, ib, ic);
  }

  // uvs

  if (ua != null && ua != '') {
    var uvLen = uvs.length;

    ia = parseUVIndex(ua, uvLen);
    ib = parseUVIndex(ub, uvLen);
    ic = parseUVIndex(uc, uvLen);

    addUV(ia, ib, ic);

    object!.geometry["hasUVIndices"] = true;
  } else {
    // add placeholder values (for inconsistent face definitions)

    addDefaultUV();
  }
}