There is a direct way to acquire .obj file of environment scans by using Device Portal without coding, you could refer to - Spatial object mesh observer - MRTK 2 | Microsoft Learn.