private void calcTangents(Vertex[] vertices, int[] indices) {
        for (int i = 0; i < indices.length; i += 3) {
            int i0 = indices[i];
            int i1 = indices[i + 1];
            int i2 = indices[i + 2];

            Vector3f edge1 = vertices[i1].getPos().sub(vertices[i0].getPos());
            Vector3f edge2 = vertices[i2].getPos().sub(vertices[i0].getPos());

            float deltaU1 = vertices[i1].getTexCoord().getX() - vertices[i0].getTexCoord().getX();
            float deltaV1 = vertices[i1].getTexCoord().getY() - vertices[i0].getTexCoord().getY();
            float deltaU2 = vertices[i2].getTexCoord().getX() - vertices[i0].getTexCoord().getX();
            float deltaV2 = vertices[i2].getTexCoord().getY() - vertices[i0].getTexCoord().getY();

            float fDividend = (deltaU1 * deltaV2 - deltaU2 * deltaV1);
            float f = fDividend == 0 ? 0.1f : 1.0f / fDividend;

            Vector3f tangent = new Vector3f(0, 0, 0);
            tangent.setX(f * (deltaV2 * edge1.getX() - deltaV1 * edge2.getX()));
            tangent.setY(f * (deltaV2 * edge1.getY() - deltaV1 * edge2.getY()));
            tangent.setZ(f * (deltaV2 * edge1.getZ() - deltaV1 * edge2.getZ()));

            vertices[i0].getTangent().set(tangent);
            vertices[i1].getTangent().set(tangent);
            vertices[i2].getTangent().set(tangent);
        }

        for (int i = 0; i < vertices.length; i++)
            vertices[i].getTangent().set(vertices[i].getTangent().normalized());
    }