title: LiDAR | Swift | How to Export real texture 3d model using LiDAR Scanner
body: <p><strong>How to export same model with real world texture?</strong></p>
  <p>We used many demo and combine logic for export 3d model (usdz) with real texture. But, We get success in only export blank (white/gray) model.</p>
  <p>we used below code for export 3d model.</p>
  <pre><code>func exportModel() {
          
          guard let camera = sceneView.session.currentFrame?.camera else {return}
  
          
          func convertToAsset(meshAnchors: [ARMeshAnchor]) -&gt; MDLAsset? {
               
                  guard let device = MTLCreateSystemDefaultDevice() else {return nil}
                  
                  let asset = MDLAsset()
  
              
              guard let frame = sceneView.session.currentFrame else { return nil }
              guard let cameraImage = captureCamera() else { return nil }
  
              for anchor in meshAnchors {
                  
                  
                  // Below commented code help in showing preview model in sceneView
  //                guard let node = sceneView.node(for: anchor) else { continue }
  //                let geometry = scanGeometory(frame: frame, anchor: anchor, node: node, needTexture: true, cameraImage: cameraImage)
  //                node.geometry = geometry
                  
                  
                  let mdlMesh = anchor.geometry.toMDLMesh(device: device, camera: camera, modelMatrix: anchor.transform)
                  asset.add(mdlMesh)
              }
  
              return asset
          }
          func export(asset: MDLAsset) throws -&gt; URL {
              let directory = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first!
              let url = directory.appendingPathComponent(&quot;scaned.usdc&quot;)
  
              try asset.export(to: url)
  
              return url
          }
          func share(url: URL) {
              let vc = UIActivityViewController(activityItems: [url],applicationActivities: nil)
              // vc.popoverPresentationController?.sourceView = sender
              self.present(vc, animated: true, completion: nil)
          }
          if let meshAnchors = sceneView.session.currentFrame?.anchors.compactMap({ $0 as? ARMeshAnchor }),
             let asset = convertToAsset(meshAnchors: meshAnchors) {
              do {
                  let url = try export(asset: asset)
                  share(url: url)
              } catch {
                  print(&quot;export error&quot;)
              }
          }
      }
  </code></pre>