SKVideoNode作为SCNSphere的纹理
我试图使用SKVideoNode作为我的SCNView中SCNSphere的video纹理源
我正在回答这个问题:
SKVideoNode(embedded在SKScene中)作为用于场景套件节点不起作用的纹理
和我的代码(粘贴在问题的最后),我得到一个video和audio播放。
问题是,映射只发生在球体的四分之一(全xy正四分之一)。
cameraNode在sphere(0,0,0)内,并且独立于sphereNode。
我将一个缩放应用于球体节点,只是为了扭转纹理的节点:
sphereNode.scale = SCNVector3Make(-1, 1, 1)
但是评论说这个没有效果。
这是所有在设备上testing(iphone 6 +,使用iOS 9.1):
let sphere = SCNSphere(radius: 1) . . . func setupView() { // setup the sphere sphere.segmentCount = 55 // sphere material sceneMaterial = SCNMaterial() // setup the sphereNode sphereNode = SCNNode(geometry: sphere) sphereNode.position = SCNVector3Make(0, 0, 0) sphereNode.scale = SCNVector3Make(-1, 1, 1) let apperture = 75.0 // setup the camera camera = SCNCamera() camera.xFov = apperture camera.zFar = 10000 camera.yFov = apperture camera.zNear = 0.5 camera.aperture = 1/10 cameraNode.position = SCNVector3Make(0, 0, 0) cameraNode.camera = camera // light node let lightNode = SCNNode() lightNode.position = SCNVector3Make(0, 0, 0) // light let ambientLight = SCNLight() ambientLight.type = SCNLightTypeAmbient ambientLight.color = UIColor(white: 0.7, alpha: 1) lightNode.light = ambientLight // add top sceneView topScene.scene = scene bottomScene.scene = scene // setup the sceneView scene.rootNode.addChildNode(sphereNode) scene.rootNode.addChildNode(cameraNode) // video reader let path = NSBundle.mainBundle().pathForResource("tb", ofType: "mp4") let url = NSURL(fileURLWithPath: path!) let asset = AVURLAsset(URL: url,options: nil) let playerItem = AVPlayerItem(asset: asset) let player = AVPlayer(playerItem: playerItem) let videoNode = SKVideoNode(AVPlayer: player) // check the sizes let size = CGFloat(1000.0) let spriteScene = SKScene(size: CGSizeMake(size,size)) videoNode.size.width = size videoNode.size.height = size spriteScene.addChild(videoNode) // the image sceneMaterial.specular.contents = UIColor.whiteColor() sceneMaterial.doubleSided = true sceneMaterial.shininess = 1 sceneMaterial.diffuse.contents = spriteScene sphere.materials = [sceneMaterial] videoNode.play() }