【发布时间】:2015-07-01 20:48:14
【问题描述】:
我的 SceneKit 应用程序中有一个立方体、一面墙和两个 lightNode,我想让立方体在墙上投射阴影。
我的 lightNode 在这里:
let lightNode = SCNNode()
lightNode.light = SCNLight()
lightNode.light!.type = SCNLightTypeSpot
lightNode.position = SCNVector3(x: 0, y: 0, z: 15)
lightNode.castsShadow = true
scene.rootNode.addChildNode(lightNode)
// create and add an ambient light to the scene
let ambientLightNode = SCNNode()
ambientLightNode.light = SCNLight()
ambientLightNode.light!.type = SCNLightTypeAmbient
ambientLightNode.light!.color = UIColor.darkGrayColor()
ambientLightNode.castsShadow = true
scene.rootNode.addChildNode(ambientLightNode)
这是我的墙:
var wall = SCNNode(geometry: SCNBox(width: 400, height: 100, length: 4, chamferRadius: 0))
wall.geometry?.firstMaterial!.emission.contents = UIColor.lightGrayColor()
wall.geometry?.firstMaterial!.doubleSided = false
wall.castsShadow = true
wall.position = SCNVector3Make(0, 0, -5)
wall.physicsBody = SCNPhysicsBody.staticBody()
scene.rootNode.addChildNode(wall)
如您所见,所有节点(包括立方体)都具有投射阴影的属性,因为它是true。
墙上怎么没有影子?
【问题讨论】:
标签: ios swift shadow scenekit lighting