大佬教程收集整理的这篇文章主要介绍了ios – SKVideoNode(嵌入在SKScene中)作为Scene Kit Node无法正常工作的纹理,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
import UIKit import SceneKit // for 3D mapping import SpriteKit // for SKVideoNode import QuartzCore // for basic animation import XCPlayground // for live preview import AVFoundation // for video playBACk ENGIne // create a scene view with an empty scene var sceneView = SCNView(frame: CGRect(x: 0,y: 0,width: 300,height: 300)) var scene = SCNScene() sceneView.scene = scene // start a live preview of that view XCPShowView("The Scene View",view: sceneView) // default lighTing sceneView.autoenablesDefaultLighTing = true // a geometry object var tube = SCNTube(innerRadius: 1.99,outerRadius: 2,height: 3) var tubeNode = SCNNode(geometry: tubE) scene.rootNode.addChildNode(tubeNodE) // video scene let urlStr = NSBundle.mainBundle().pathForresource("sample",ofType: "mp4") let url = NSURL(fileURLWithPath: urlStr!) let asset = AVURLAsset(URL: url,options: nil) let playerItem = AVPlayerItem(asset: asset) let player = AVPlayer(playerItem: playerItem) let videoNode = SKVideoNode(AVPlayer: player) let spritescene = SKScene(size: CGSize(width: 1211,height: 431)) videoNode.size.width=spritescene.size.width videoNode.size.height=spritescene.size.height spritescene.addChild(videoNodE) // configure the geometry object var myImage = UIImage.init(named: "BandImage.jpeg") tube.firstMaterial?.diffuse.contents = spritescene // set a rotation axis (no anglE) to be able to // use a nicer keypath below and avoid needing // to wrap it in an NSValue tubeNode.rotation = SCNVector4(x: 0.0,y: 1.0,z: 0.0,w: 0.0) // animate the rotation of the torus var spin = CABasicAnimation(keyPath: "rotation.w") // only animate the angle spin.toValue = 2.0*M_PI spin.duration = 3 spin.repeatCount = HUGE // for infinity tubeNode.addAnimation(spin,forKey: "spin around") // starts the video,solving the issue sceneView.playing = true
以上是大佬教程为你收集整理的ios – SKVideoNode(嵌入在SKScene中)作为Scene Kit Node无法正常工作的纹理全部内容,希望文章能够帮你解决ios – SKVideoNode(嵌入在SKScene中)作为Scene Kit Node无法正常工作的纹理所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。