繁体   English   中英

SceneKit的实例属性“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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM