延迟将实时视图显示为球面几何体的SCNMaterial的漫反射内容

时间:2019-04-24 10:42:01

标签: ios swift scenekit arkit

我想使用SceneKit显示实时球面图像。我正在使用SCNMaterial的漫反射内容来显示它,但是实时显示时有些延迟。以下代码是我尝试实现的代码。如果遇到这种情况,请指导。

    @IBOutlet weak var sceneView: SCNView!
    let scene = SCNScene()


    sceneView.scene = scene
    sceneView.backgroundColor = UIColor.black

    let material = SCNMaterial()
    material.diffuse.mipFilter = .linear
    material.diffuse.magnificationFilter = .linear
    material.diffuse.contentsTransform = SCNMatrix4MakeScale(-1, 1, 1)
    material.diffuse.wrapS = .repeat
    material.cullMode = .front

    let sphere = SCNSphere(radius: 8)
    sphere.segmentCount = 300

    httpConnection.startLiveView { (data) in
        DispatchQueue.main.async {
           let image = UIImage(data: data!)
            material.diffuse.contents = image
        }
    }


    sphere.firstMaterial = material

    let sphereNode = SCNNode()
    sphereNode.geometry = sphere

    scene.rootNode.addChildNode(sphereNode)

httpConnection.startLiveView块中,我正在获取实时取景的图像数据。

0 个答案:

没有答案