将360视频添加到SCNSphere时视频失真/扭曲

时间:2019-10-10 19:00:05

标签: ios swift scenekit scnsphere

我正在使用SpriteKit,SceneKit和CoreMotion构建一个简单的360视频播放器。在视频中,我看到了变形/扭曲。参见:image of video warping in scenekit

视频为3840 x1920。我知道视频很好,因为当我将其上传到youtube时没有失真。请参阅:image of video on youtube player no warping

有人曾经历过吗?也许我缺少什么?视频播放,音频很好,摄像机跟踪也很好,只是视频弯曲是问题所在。

这是我的玩家的基础:


        self.player = AVPlayer(url: url)
        let videoNode = SKVideoNode(avPlayer: player)

        // set size to 3840 x 1920 resolution
        let size = CGSize(width: videoWidth, height: videoHeight)

        videoNode.size = size
        videoNode.position = CGPoint(x: size.width/2.0, y: size.height/2.0)

        let spriteScene = SKScene(size: size)

        spriteScene.addChild(videoNode)

        let sphere = SCNSphere(radius: 30)
        sphere.firstMaterial?.isDoubleSided = true
        sphere.firstMaterial?.diffuse.contents = material

        let sphereNode = SCNNode(geometry: sphere)
        sphereNode.position = SCNVector3Make(0,0,0)
        sphereNode.rotation = SCNVector4Make(1, 0, 0, Float.pi)

        // Set the sceneView
        let scene = SCNScene()

        sceneView.scene = scene
        sceneView.showsStatistics = false
        sceneView.addGestureRecognizer(tap)

        // Camera
        cameraNode.camera = SCNCamera()
        cameraNode.camera?.automaticallyAdjustsZRange = true
        cameraNode.position = SCNVector3Make(0, 0, 0)

        // Add nodes to scene
        scene.rootNode.addChildNode(sphereNode)
        scene.rootNode.addChildNode(cameraNode)

        sceneView.play(self)

0 个答案:

没有答案