iOS基于SceneKit的3D汽车改色
基于SceneKit的汽車改色,需要修改模型文件可以去?3D Models for Professionals :: TurboSquid自行下載,免費資源還挺多的。
先上個效果圖吧:
?
核心代碼:
? ? ? ? let path = Bundle.main.path(forResource: "ks_car", ofType: "dae")!
? ? ? ? let source = SCNSceneSource.init(url: URL(fileURLWithPath: path), options: nil)
? ? ? ? let scene = source?.scene(options: nil)
?? ? ? ?
? ? ? ? //添加燈光效果 omni:點光源、方向360度,可衰減
? ? ? ? let lightNode = SCNNode.init()
? ? ? ? lightNode.light = SCNLight()
? ? ? ? lightNode.light?.type = SCNLight.LightType.omni
? ? ? ? lightNode.position = SCNVector3Make(0, 0, 300)
? ? ? ? scene?.rootNode.addChildNode(lightNode)
?? ? ? ?
? ? ? ? scnView = SCNView.init(frame: CGRect(x: 0, y: 0, width: kswidth, height: 500))
? ? ? ? scnView.allowsCameraControl = true
? ? ? ? scnView.showsStatistics = true
? ? ? ? scnView.backgroundColor = UIColor.white
? ? ? ? scnView.scene = scene
? ? ? ? self.view.addSubview(scnView)
demo地址:?GitHub - Turboks/3DCar
總結
以上是生活随笔為你收集整理的iOS基于SceneKit的3D汽车改色的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 正则表达式验证手机号 身份证号 银行卡号
- 下一篇: 中国雷山苗年简介