我正在为IOS开发一个基于3D SceneKit的基本游戏,我注意到我在编辑器中选择的颜色和模拟中显示的颜色不匹配(屏幕快照https://pasteboard.co/HVWdnnK.png)。
代码与默认的SceneKit游戏代码基本相同,只是我评论了配置灯和一切的部分,因为它们已经在编辑器中手动配置了(我觉得这里可能遗漏了什么)。
如果你能看一看就好了。
override func viewDidLoad() {
super.viewDidLoad()
// create a new scene
let scene = SCNScene(named: "art.scnassets/ship.scn")!
// create and add a camera to the scene
let cameraNode = scene.rootNode.childNode(withName: "corner-camera", recursively: true)!
// cameraNode.camera = SCNCamera()
// scene.rootNode.addChildNode(cameraNode)
// place the camera
// let camera = scene.rootNode.childNode(withName: "corner-camera", recursively: true)!
// cameraNode.position = SCNVector3(x: 0, y: 0, z: 15)
// create and add a light to the scene
// let lightNode = SCNNode()
// lightNode.light = SCNLight()
// lightNode.light!.type = .omni
// lightNode.position = SCNVector3(x: 0, y: 10, z: 10)
// scene.rootNode.addChildNode(lightNode)
// create and add an ambient light to the scene
// let ambientLightNode = SCNNode()
// ambientLightNode.light = SCNLight()
// ambientLightNode.light!.type = .ambient
// ambientLightNode.light!.color = UIColor.darkGray
// scene.rootNode.addChildNode(ambientLightNode)
// retrieve the ship node
// let ship = scene.rootNode.childNode(withName: "ship", recursively: true)!
// animate the 3d object
// ship.runAction(SCNAction.repeatForever(SCNAction.rotateBy(x: 0, y: 2, z: 0, duration: 1)))
// retrieve the SCNView
let scnView = self.view as! SCNView
// set the scene to the view
scnView.scene = scene
// set camera to corner-camera
scnView.pointOfView = cameraNode
// allows the user to manipulate the camera
// scnView.allowsCameraControl = true
// show statistics such as fps and timing information
// scnView.showsStatistics = true
// configure the view
scnView.backgroundColor = UIColor.white
// add a tap gesture recognizer
// let tapGesture = UITapGestureRecognizer(target: self, action: #selector(handleTap(_:)))
// scnView.addGestureRecognizer(tapGesture)
}发布于 2019-01-11 11:33:47
一件事是模拟器使用OpenGL渲染器,而Xcode和iOS设备默认使用金属渲染器。
此外,Xcode编辑器有几个选项可自定义渲染中的场景和"默认照明“选项可能与应用程序使用的选项不匹配。
https://stackoverflow.com/questions/54145079
复制相似问题