下面是我的代码,我试图在对象下添加阴影但不显示。
public func addNode(locationNode:LocationNode) {
locationNode.position = SCNVector3Make(locationNode.x, locationNode.y,locationNode.z)
self.sceneNode?.scale = SCNVector3(x: 0.4, y: 0.4, z: 0.4)
let light = SCNLight()
light.type = .directional
light.castsShadow = true
light.shadowRadius = 200
light.shadowColor = UIColor(red: 0, green: 0, blue: 0, alpha: 1)
light.shadowMode = .deferred
let constraint = SCNLookAtConstraint(target: locationNode)
lightNode = SCNNode()
lightNode!.light = light
lightNode!.position = SCNVector3(locationNode.x + 0.5, locationNode.y + 0.5, locationNode.z)
lightNode!.constraints = [constraint]
self.sceneNode?.addChildNode(lightNode!)
self.sceneNode?.addChildNode(locationNode)
}