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 = this.vertices.length;

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

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

  // normals

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

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

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

  // uvs

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

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

    this.addUV(ia, ib, ic);

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

    this.addDefaultUV();
  }
}