![](/img/trans.png)
[英]SceneKit. How to achieve default scene light behavior without autoenablesDefaultLighting?
[英]SceneKit's instance property “autoenablesDefaultLighting” doesn't work
我尝试通过.autoenablesDefaultLighting
实例属性在SCNView中打开和关闭默认光照但是不起作用(既不在UI中也不在编程上)。
当没有光线时,我需要所有物体都是黑色的。
如何关闭默认照明 ?
这是一个代码:
import SceneKit
import QuartzCore
class GameViewController: NSViewController {
override func viewDidLoad() {
super.viewDidLoad()
let scnView = SCNView(frame: NSRect(x: 0,
y: 0,
width: 450,
height: 300))
view.addSubview(scnView)
scnView.autoenablesDefaultLighting = false // DOESN'T WORK
scnView.allowsCameraControl = true
scnView.backgroundColor = NSColor.blue
let scene = SCNScene()
scnView.scene = scene
let sphereGeo = SCNSphere(radius: 2)
sphereGeo.segmentCount = 4
sphereGeo.materials.first?.diffuse.contents = NSColor.lightGray
let sphereNode = SCNNode(geometry: sphereGeo)
sphereNode.name = "Sphere Node"
scene.rootNode.addChildNode(sphereNode)
}
}
它似乎只有在我使用Physically Based Rendering
着色模型时才有效。
let material = SCNMaterial()
material.lightingModel = SCNMaterial.LightingModel.physicallyBased
sceneView.autoenablesDefaultLighting = false
如果我使用.physicallyBased
类型属性来着色我的模型,那么照明就像假设一样。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.