我正在尝试将SCNLight添加到SceneKit中的SCNSphere (SCNNode)。它的效果令人惊叹,唯一的问题是SCNLight所连接的源球体是完全黑色的,因为作为源,它根本得不到任何光。如何确保光源(即球体)完全亮起?
这是光源代码:
public func addLightSource(position: SCNVector3) -> SCNLight {
let light = SCNLight()
light.type = .omni
light.intensity = 5000
light.temperature = CGFloat(3500)
return light
}以及以后的
ParentNode.light = addLightSource(position: absolutePosition)这是可行的,但会使ParentNode变黑。
发布于 2019-04-28 20:51:37
为球体和灯光设置categoryBitMask实例属性以排除/包含它们:
func addLightSource(position: SCNVector3) -> SCNLight {
let light = SCNLight()
light.type = .omni
light.intensity = 5000
light.categoryBitMask = 1
light.temperature = CGFloat(2000)
return light
}
let sphereNode1 = SCNNode()
sphereNode1.geometry = SCNSphere(radius: 2)
sphereNode1.position = SCNVector3(x: 10, y: 0, z: 0)
sphereNode1.light = addLightSource(position: sphereNode1.position)
sphereNode1.categoryBitMask = 1
scene.rootNode.addChildNode(sphereNode1)https://stackoverflow.com/questions/55271885
复制相似问题