【发布时间】:2015-04-07 18:57:34
【问题描述】:
我是 SceneKit 的新手...尝试让一些基本的东西正常工作,但到目前为止没有太大的成功。出于某种原因,当我尝试将 png 纹理应用于 CNBox 时,我最终只得到黑色。这是我在 viewDidLoad 中的简单代码 sn-p:
let sceneView = (view as SCNView)
let scene = SCNScene()
let boxGeometry = SCNBox(width: 10.0, height: 10.0, length: 10.0, chamferRadius: 1.0)
let mat = SCNMaterial()
mat.locksAmbientWithDiffuse = true
mat.diffuse.contents = ["sofb.png","sofb.png","sofb.png","sofb.png","sofb.png", "sofb.png"]
mat.specular.contents = UIColor.whiteColor()
boxGeometry.firstMaterial = mat
let boxNode = SCNNode(geometry: boxGeometry)
scene.rootNode.addChildNode(boxNode)
sceneView.scene = scene
sceneView.autoenablesDefaultLighting = true
sceneView.allowsCameraControl = true
它最终看起来像一个白色光源,从黑色立方体反射出黑色背景。我错过了什么?感谢所有回复
【问题讨论】:
标签: ios macos opengl swift scenekit