Generating indexed from non-indexed Geometry issue [SOLVED]

The answer to this has been posted here:

Summary below:
Freystar has written a code that can be used to convert non-indexed to indexed geometry, BUT three.js has later implemented a method that can help with this called BufferGeometryUtils.mergeVertices() which is the recommended approach right now.

import * as BufferGeometryUtils from "three/examples/jsm/utils/BufferGeometryUtils.js";

documentation link:
https://threejs.org/docs/?q=buffergeom#examples/en/utils/BufferGeometryUtils.mergeVertices