我正在尝试使用scenekit播放180个鱼眼视频,我发现其中一个示例是使用球体作为AVPlayers几何体来播放360度视频。
问题是我使用的视频是用180°鱼眼相机拍摄的,我需要用半球代表它。
我一直在摆弄代码2天但没有运气。
由于我没有这方面的经验,我试图将AVPlayer部分放到一个完整的球体上,或者将SCNSphere切成两半而没有成功。
以下代码用于播放360视频和simple360player_iOS GitHub repo,
var screenScale : CGFloat = 1.0
if PROCESSOR_64BITS {
screenScale = CGFloat(3.0)
}
player = AVPlayer(URL: fileURL!)
let videoSpriteKitNodeLeft = SKVideoNode(AVPlayer: player)
let videoNodeLeft = SCNNode()
let spriteKitScene1 = SKScene(size: CGSize(width: 1280 * screenScale, height: 1280 * screenScale))
spriteKitScene1.shouldRasterize = true
var spriteKitScenes = [spriteKitScene1]
videoNodeLeft.geometry = SCNSphere(radius: 30)
spriteKitScene1.scaleMode = .AspectFit
videoSpriteKitNodeLeft.position = CGPoint(x: spriteKitScene1.size.width / 2.0, y: spriteKitScene1.size.height / 2.0)
videoSpriteKitNodeLeft.size = spriteKitScene1.size
答案 0 :(得分:0)
Setting up a partial sphere, partial mapping, or another object that otherwise achieves that goal is probably the most noble path. However, depending on the context of the project, in cases where you have 180 degree videos it is often quicker to double the width of the video and fill the additional space with black or something of your choosing. This is especially useful if there is a likelihood you'll have 360 video in the future.