如何在ARKit中的SCNPlane下面应用阴影?

时间:2017-10-01 15:46:37

标签: swift scenekit scene arkit

下面是我的代码,我试图在对象下添加阴影但不显示。

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)
    }

这是屏幕截图 enter image description here

0 个答案:

没有答案