Create triangles and push the data for each polygon for the pattern 2
In this pattern we get vertice positions and uvsu
@param face
@param v
328755
function (face, v) {
                //Get the indices of triangles for each polygon
                getTriangles(face, v);
                for (var k = 0; k < triangles.length; k++) {
                    //triangle[k] = "1/1"
                    //Split the data for getting position and uv
                    var point = triangles[k].split("/"); // ["1", "1"]
                    //Set position indice
                    var indicePositionFromObj = parseInt(point[0]) - 1;
                    //Set uv indice
                    var indiceUvsFromObj = parseInt(point[1]) - 1;
                    setData(indicePositionFromObj, indiceUvsFromObj, 0, //Default value for normals
                    positions[indicePositionFromObj], //Get the values for each element
                    uvs[indiceUvsFromObj], BABYLON.Vector3.Up() //Default value for normals
                    );
                }
                //Reset variable for the next line
                triangles = [];
            }
861413
def all_faces_with_verts(self, v_indices, as_boolean=False):
        '''
        
        '''
        import numpy as np
        included_vertices = np.zeros(self.v.shape[0], dtype=bool)
        included_vertices[np.array(v_indices, dtype=np.uint32)] = True
        faces_with_verts = included_vertices[self.f].all(axis=1)
        if as_boolean:
            return faces_with_verts
        return np.nonzero(faces_with_verts)[0]
180462
function (options) {
  options = options || {}
  if (('points' in options) !== ('faces' in options)) {
    throw new Error("polyhedron needs 'points' and 'faces' arrays")
  }
  let vertices = parseOptionAs3DVectorList(options, 'points', [
            [1, 1, 0],
            [1, -1, 0],
            [-1, -1, 0],
            [-1, 1, 0],
            [0, 0, 1]
  ])
        .map(function (pt) {
          return new Vertex3(pt)
        })
  let faces = parseOption(options, 'faces', [
            [0, 1, 4],
            [1, 2, 4],
            [2, 3, 4],
            [3, 0, 4],
            [1, 0, 3],
            [2, 1, 3]
  ])
    // Openscad convention defines inward normals - so we have to invert here
  faces.forEach(function (face) {
    face.reverse()
  })
  let polygons = faces.map(function (face) {
    return new Polygon3(face.map(function (idx) {
      return vertices[idx]
    }))
  })

    // TODO: facecenters as connectors? probably overkill. Maybe centroid
    // the re-tesselation here happens because it's so easy for a user to
    // create parametrized polyhedrons that end up with 1-2 dimensional polygons.
    // These will create infinite loops at CSG.Tree()
  return fromPolygons(polygons).reTesselated()
}
95972
def polygon(self, vertexes, attr=0, row=None):
        ''
        self.polylines.append((vertexes + [vertexes[0]], attr, row))
184707
public static Face createTriangle(Vertex v0, Vertex v1, Vertex v2, double minArea) {
        Face face = new Face();
        HalfEdge he0 = new HalfEdge(v0, face);
        HalfEdge he1 = new HalfEdge(v1, face);
        HalfEdge he2 = new HalfEdge(v2, face);

        he0.prev = he2;
        he0.next = he1;
        he1.prev = he0;
        he1.next = he2;
        he2.prev = he1;
        he2.next = he0;

        face.he0 = he0;

        // compute the normal and offset
        face.computeNormalAndCentroid(minArea);
        return face;
    }
860108
def _fill_vao(self):
        """"""
        with self.vao:
            self.vbos = []
            for loc, verts in enumerate(self.arrays):
                vbo = VBO(verts)
                self.vbos.append(vbo)
                self.vao.assign_vertex_attrib_location(vbo, loc)
499833
public void cross(Vector v)
	{
		x = (y * v.z) - (z * v.y);
		y = (z * v.x) - (x * v.z);
		z = (x * v.y) - (y * v.x);
	}
139863
private void addFace(String data)
	{
		matcher = facePattern.matcher(data);

		List<Vertex> faceVertex = new ArrayList<>();
		List<Vector> faceNormals = new ArrayList<>();
		int v = 0, t = 0, n = 0;
		String strV, strT, strN;
		Vertex vertex, vertexCopy;
		UV uv = null;
		Vector normal;
		while (matcher.find())
		{
			normal = null;
			uv = null;

			strV = matcher.group("v");
			strT = matcher.group("t");
			strN = matcher.group("n");

			v = Integer.parseInt(strV);
			vertex = vertexes.get(v > 0 ? v - 1 : vertexes.size() - v - 1);

			if (vertex != null)
			{
				vertexCopy = new Vertex(vertex);
				if (strT != null)
				{
					t = Integer.parseInt(strT);
					uv = uvs.get(t > 0 ? t - 1 : uvs.size() - t - 1);
					if (uv != null)
						vertexCopy.setUV(uv.u, uv.v);
				}
				faceVertex.add(vertexCopy);

				if (strN != null)
				{
					n = Integer.parseInt(strN);
					n = n > 0 ? n - 1 : normals.size() - n - 1;
					if (n >= 0 && n < normals.size())
						normal = normals.get(n);
					if (normal != null)
						faceNormals.add(new Vector(normal.x, normal.y, normal.z));
				}
			}
			else
			{
				MalisisCore.log.error("[ObjFileImporter] Wrong vertex reference {} for face at line {} :\n{}", v, lineNumber, currentLine);
			}
		}

		Face f = new Face(faceVertex);
		f.deductParameters(faceNormals.toArray(new Vector[0]));
		RenderParameters params = f.getParameters();
		if (params.direction.get() == EnumFacing.NORTH || params.direction.get() == EnumFacing.EAST)
			params.flipU.set(true);
		params.renderAllFaces.set(true);
		params.interpolateUV.set(false);
		params.calculateAOColor.set(false);
		//params.useEnvironmentBrightness.set(false);

		faces.add(f);
	}
720057
public void setPosition(Vector3D v) {
		this.x = v.getX();
		this.y = v.getY();
		this.z = v.getZ();
	}
101320
public void vertex(double x, double y, double z) {
        MODE = LINES_3D;
        this.x.add(x);
        this.y.add(y);
        this.z.add(z);
        colors.add(this.strokeColor);
        calcG();
    }
94166
function prepare( vector ) {

		var vertex = vector.normalize().clone();
		vertex.index = that.vertices.push( vertex ) - 1;

		// Texture coords are equivalent to map coords, calculate angle and convert to fraction of a circle.

		var u = azimuth( vector ) / 2 / Math.PI + 0.5;
		var v = inclination( vector ) / Math.PI + 0.5;
		vertex.uv = new THREE.UV( u, 1 - v );

		return vertex;

	}
112974
function makePlane(u, v, w, su, sv, nu, nv, pw, flipu, flipv) {
    var vertShift = vertexIndex;
    for (var j=0; j<=nv; j++) {
      for (var i=0; i<=nu; i++) {
        vert = vertices[vertexIndex] = Vec3.create();
        vert[u] = (-su / 2 + i * su / nu) * flipu;
        vert[v] = (-sv / 2 + j * sv / nv) * flipv;
        vert[w] = pw;
        normal = normals[vertexIndex] = Vec3.create();
        normal[u] = 0;
        normal[v] = 0;
        normal[w] = pw / Math.abs(pw);
        texCoord = texCoords[vertexIndex] = Vec2.create();
        texCoord.x = i / nu;
        texCoord.y = 1.0 - j / nv;
        ++vertexIndex;
      }
    }
    for (var j=0; j<=nv-1; j++) {
      for (var i=0; i<=nu-1; i++) {
        var n = vertShift + j * (nu + 1) + i;
        faces.push([n, n + nu + 1, n + nu + 2, n + 1]);
      }
    }
  }
451663
function processMesh(mesh) {
      var geometry = mesh.geometry;

      var mode;

      // Use the correct mode
      if (mesh.isLineSegments) {
        mode = WEBGL_CONSTANTS.LINES;
      } else if (mesh.isLineLoop) {
        mode = WEBGL_CONSTANTS.LINE_LOOP;
      } else if (mesh.isLine) {
        mode = WEBGL_CONSTANTS.LINE_STRIP;
      } else if (mesh.isPoints) {
        mode = WEBGL_CONSTANTS.POINTS;
      } else {
        if (!geometry.isBufferGeometry) {
          var geometryTemp = new THREE.BufferGeometry();
          geometryTemp.fromGeometry(geometry);
          geometry = geometryTemp;
        }

        if (mesh.drawMode === THREE.TriangleFanDrawMode) {
          console.warn(
            'GLTFExporter: TriangleFanDrawMode and wireframe incompatible.'
          );
          mode = WEBGL_CONSTANTS.TRIANGLE_FAN;
        } else if (mesh.drawMode === THREE.TriangleStripDrawMode) {
          mode = mesh.material.wireframe
            ? WEBGL_CONSTANTS.LINE_STRIP
            : WEBGL_CONSTANTS.TRIANGLE_STRIP;
        } else {
          mode = mesh.material.wireframe
            ? WEBGL_CONSTANTS.LINES
            : WEBGL_CONSTANTS.TRIANGLES;
        }
      }

      var gltfMesh = {};

      var attributes = {};
      var primitives = [];
      var targets = [];

      // Conversion between attributes names in threejs and gltf spec
      var nameConversion = {
        uv: 'TEXCOORD_0',
        uv2: 'TEXCOORD_1',
        color: 'COLOR_0',
        skinWeight: 'WEIGHTS_0',
        skinIndex: 'JOINTS_0'
      };

      var originalNormal = geometry.getAttribute('normal');

      if (
        originalNormal !== undefined &&
        !isNormalizedNormalAttribute(originalNormal)
      ) {
        console.warn(
          'THREE.GLTFExporter: Creating normalized normal attribute from the non-normalized one.'
        );

        geometry.addAttribute(
          'normal',
          createNormalizedNormalAttribute(originalNormal)
        );
      }

      // @QUESTION Detect if .vertexColors = THREE.VertexColors?
      // For every attribute create an accessor
      for (var attributeName in geometry.attributes) {
        var attribute = geometry.attributes[attributeName];
        attributeName =
          nameConversion[attributeName] || attributeName.toUpperCase();

        // JOINTS_0 must be UNSIGNED_BYTE or UNSIGNED_SHORT.
        var array = attribute.array;
        if (
          attributeName === 'JOINTS_0' &&
          !(array instanceof Uint16Array) &&
          !(array instanceof Uint8Array)
        ) {
          console.warn(
            'GLTFExporter: Attribute "skinIndex" converted to type UNSIGNED_SHORT.'
          );
          attribute = new THREE.BufferAttribute(
            new Uint16Array(array),
            attribute.itemSize,
            attribute.normalized
          );
        }

        if (attributeName.substr(0, 5) !== 'MORPH') {
          var accessor = processAccessor(attribute, geometry);
          if (accessor !== null) {
            attributes[attributeName] = accessor;
          }
        }
      }

      if (originalNormal !== undefined)
        geometry.addAttribute('normal', originalNormal);

      // Skip if no exportable attributes found
      if (Object.keys(attributes).length === 0) {
        return null;
      }

      // Morph targets
      if (
        mesh.morphTargetInfluences !== undefined &&
        mesh.morphTargetInfluences.length > 0
      ) {
        var weights = [];
        var targetNames = [];
        var reverseDictionary = {};

        if (mesh.morphTargetDictionary !== undefined) {
          for (var key in mesh.morphTargetDictionary) {
            reverseDictionary[mesh.morphTargetDictionary[key]] = key;
          }
        }

        for (var i = 0; i < mesh.morphTargetInfluences.length; ++i) {
          var target = {};

          var warned = false;

          for (var attributeName in geometry.morphAttributes) {
            // glTF 2.0 morph supports only POSITION/NORMAL/TANGENT.
            // Three.js doesn't support TANGENT yet.

            if (attributeName !== 'position' && attributeName !== 'normal') {
              if (!warned) {
                console.warn(
                  'GLTFExporter: Only POSITION and NORMAL morph are supported.'
                );
                warned = true;
              }

              continue;
            }

            var attribute = geometry.morphAttributes[attributeName][i];

            // Three.js morph attribute has absolute values while the one of glTF has relative values.
            //
            // glTF 2.0 Specification:
            // https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#morph-targets

            var baseAttribute = geometry.attributes[attributeName];
            // Clones attribute not to override
            var relativeAttribute = attribute.clone();

            for (var j = 0, jl = attribute.count; j < jl; j++) {
              relativeAttribute.setXYZ(
                j,
                attribute.getX(j) - baseAttribute.getX(j),
                attribute.getY(j) - baseAttribute.getY(j),
                attribute.getZ(j) - baseAttribute.getZ(j)
              );
            }

            target[attributeName.toUpperCase()] = processAccessor(
              relativeAttribute,
              geometry
            );
          }

          targets.push(target);

          weights.push(mesh.morphTargetInfluences[i]);
          if (mesh.morphTargetDictionary !== undefined)
            targetNames.push(reverseDictionary[i]);
        }

        gltfMesh.weights = weights;

        if (targetNames.length > 0) {
          gltfMesh.extras = {};
          gltfMesh.extras.targetNames = targetNames;
        }
      }

      var extras =
        Object.keys(geometry.userData).length > 0
          ? serializeUserData(geometry)
          : undefined;

      var forceIndices = options.forceIndices;
      var isMultiMaterial = Array.isArray(mesh.material);

      if (isMultiMaterial && geometry.groups.length === 0) return null;

      if (!forceIndices && geometry.index === null && isMultiMaterial) {
        // temporal workaround.
        console.warn(
          'THREE.GLTFExporter: Creating index for non-indexed multi-material mesh.'
        );
        forceIndices = true;
      }

      var didForceIndices = false;

      if (geometry.index === null && forceIndices) {
        var indices = [];

        for (var i = 0, il = geometry.attributes.position.count; i < il; i++) {
          indices[i] = i;
        }

        geometry.setIndex(indices);

        didForceIndices = true;
      }

      var materials = isMultiMaterial ? mesh.material : [mesh.material];
      var groups = isMultiMaterial
        ? geometry.groups
        : [{ materialIndex: 0, start: undefined, count: undefined }];

      for (var i = 0, il = groups.length; i < il; i++) {
        var primitive = {
          mode: mode,
          attributes: attributes
        };

        if (extras) primitive.extras = extras;

        if (targets.length > 0) primitive.targets = targets;

        if (geometry.index !== null) {
          primitive.indices = processAccessor(
            geometry.index,
            geometry,
            groups[i].start,
            groups[i].count
          );
        }

        var material = processMaterial(materials[groups[i].materialIndex]);

        if (material !== null) {
          primitive.material = material;
        }

        primitives.push(primitive);
      }

      if (didForceIndices) {
        geometry.setIndex(null);
      }

      gltfMesh.primitives = primitives;

      if (!outputJSON.meshes) {
        outputJSON.meshes = [];
      }

      outputJSON.meshes.push(gltfMesh);

      return outputJSON.meshes.length - 1;
    }
92612
private EdgeSet<T> addIfAbsent(int v) {
        S edges = getEdgeSet(v);
        if (edges == null) {
            edges = createEdgeSet(v);
            vertexToEdges.put(v, edges);
        }
        return edges;
    }
627811
function(v) {
            var v0 = v.x;
            var v1 = v.y;
            var v2 = 0;
            var v3 = 1;
            var x = v0 * this.elements[0] + v1 * this.elements[1] + v2 * this.elements[2] + v3 * this.elements[3];
            var y = v0 * this.elements[4] + v1 * this.elements[5] + v2 * this.elements[6] + v3 * this.elements[7];
            var z = v0 * this.elements[8] + v1 * this.elements[9] + v2 * this.elements[10] + v3 * this.elements[11];
            var w = v0 * this.elements[12] + v1 * this.elements[13] + v2 * this.elements[14] + v3 * this.elements[15];
            // scale such that fourth element becomes 1:
            if (w != 1) {
                var invw = 1.0 / w;
                x *= invw;
                y *= invw;
                z *= invw;
            }
            return new CSG.Vector2D(x, y);
        }
316019
public static VertexData generatePlane(Vector2f size) {
        final VertexData destination = new VertexData();
        final VertexAttribute positionsAttribute = new VertexAttribute("positions", DataType.FLOAT, 3);
        destination.addAttribute(0, positionsAttribute);
        final TFloatList positions = new TFloatArrayList();
        final VertexAttribute normalsAttribute = new VertexAttribute("normals", DataType.FLOAT, 3);
        destination.addAttribute(1, normalsAttribute);
        final TFloatList normals = new TFloatArrayList();
        final VertexAttribute textureCoordsAttribute = new VertexAttribute("textureCoords", DataType.FLOAT, 2);
        destination.addAttribute(2, textureCoordsAttribute);
        final TFloatList textureCoords = new TFloatArrayList();
        final TIntList indices = destination.getIndices();
        // Generate the mesh
        generatePlane(positions, normals, textureCoords, indices, size);
        // Put the mesh in the vertex data
        positionsAttribute.setData(positions);
        normalsAttribute.setData(normals);
        textureCoordsAttribute.setData(textureCoords);
        return destination;
    }
917770
function buildLidFaces() {

			var start = verticesArray.length / 3;

			if ( bevelEnabled ) {

				var layer = 0; // steps + 1
				var offset = vlen * layer;

				// Bottom faces

				for ( i = 0; i < flen; i ++ ) {

					face = faces[ i ];
					f3( face[ 2 ] + offset, face[ 1 ] + offset, face[ 0 ] + offset );

				}

				layer = steps + bevelSegments * 2;
				offset = vlen * layer;

				// Top faces

				for ( i = 0; i < flen; i ++ ) {

					face = faces[ i ];
					f3( face[ 0 ] + offset, face[ 1 ] + offset, face[ 2 ] + offset );

				}

			} else {

				// Bottom faces

				for ( i = 0; i < flen; i ++ ) {

					face = faces[ i ];
					f3( face[ 2 ], face[ 1 ], face[ 0 ] );

				}

				// Top faces

				for ( i = 0; i < flen; i ++ ) {

					face = faces[ i ];
					f3( face[ 0 ] + vlen * steps, face[ 1 ] + vlen * steps, face[ 2 ] + vlen * steps );

				}

			}

			scope.addGroup( start, verticesArray.length / 3 - start, 0 );

		}