我正在为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)
}
答案 0 :(得分:0)
一件事是,模拟器使用OpenGL渲染器,而Xcode和iOS设备默认为Metal渲染器。
Xcode编辑器还具有多个选项,可自定义渲染场景的方式,“ default lighting”选项可能与应用程序使用的选项不匹配。