How to get selected usdz model thumbnail image with material apply in vision os?

I want to get thumbnail image from USDZ model from vision os, But it will get image without material apply. Here is my code

import Foundation
import SceneKit
import SceneKit.ModelIO


class ARQLThumbnailGenerator {
    private let device = MTLCreateSystemDefaultDevice()!

    /// Create a thumbnail image of the asset with the specified URL at the specified
    /// animation time. Supports loading of .scn, .usd, .usdz, .obj, and .abc files,
    /// and other formats supported by ModelIO.
    /// - Parameters:
    ///     - url: The file URL of the asset.
    ///     - size: The size (in points) at which to render the asset.
    ///     - time: The animation time to which the asset should be advanced before snapshotting.
    func thumbnail(for url: URL, size: CGSize, time: TimeInterval = 0) -> UIImage? {
        let renderer = SCNRenderer(device: device, options: [:])
        renderer.autoenablesDefaultLighting = true

        if (url.pathExtension == "scn") {
            let scene = try? SCNScene(url: url, options: nil)
            renderer.scene = scene
        } else {
            let asset = MDLAsset(url: url)
            let scene = SCNScene(mdlAsset: asset)
            renderer.scene = scene
        }

        let image = renderer.snapshot(atTime: time, with: size, antialiasingMode: .multisampling4X)
        
        self.saveImageFileInDocumentDirectory(imageData: image.pngData()!)
        
        return image
    }
    
    func saveImageFileInDocumentDirectory(imageData : Data){
        
        
        var uniqueID = UUID().uuidString
        let tempPath = NSSearchPathForDirectoriesInDomains(FileManager.SearchPathDirectory.documentDirectory, FileManager.SearchPathDomainMask.userDomainMask, true)
        let tempDocumentsDirectory: AnyObject = tempPath[0] as AnyObject
        let uniqueVideoID = uniqueID  + "image.png"
        let tempDataPath = tempDocumentsDirectory.appendingPathComponent(uniqueVideoID) as String
            try? imageData.write(to: URL(fileURLWithPath: tempDataPath), options: [])
    }
}

only blank scene show.

You can directly load the scene using a URL, no need to set up model:

let scene = try SCNScene(url: url)
let renderer = SCNRenderer(device:MTLCreateSystemDefaultDevice())
renderer.scene = scene
let image = renderer.snapshot(atTime: 0, with: AppStyle.ImageSize.thumbnail.size, antialiasingMode: .multisampling4X)

Meanwhile, as for now, the QuickLookThumbnailing framework can't generate thumbnails for usdz files on visionOS, we should wait for it to be available.

How to get selected usdz model thumbnail image with material apply in vision os?
 
 
Q