我正试图从场景的左边投下一个很短的黑影。我的灯光设置如下:
func setupLights() {
// Create shadow
let spotLight = SCNLight()
spotLight.type = SCNLightTypeSpot
spotLight.spotInnerAngle = 30.0
spotLight.spotOuterAngle = 80.0
spotLight.castsShadow = true
let spotLightNode = SCNNode()
spotLightNode.light = spotLight
spotLightNode.position = SCNVector3(1.5, 1.5, 1.5)
rootNode.addChildNode(spotLightNode)
// Create ambient light
let ambientLight = SCNLight()
ambientLight.type = SCNLightTypeAmbient
ambientLight.color = UIColor.whiteColor()
let ambientLightNode = SCNNode()
ambientLightNode.name = "AmbientLight"
ambientLightNode.light = ambientLight
ambientLightNode.castsShadow = true
rootNode.addChildNode(ambientLightNode)
// Create an omni-directional light
let omniLight = SCNLight()
omniLight.type = SCNLightTypeOmni
omniLight.color = UIColor.whiteColor()
let omniLightNode = SCNNode()
omniLightNode.name = "OmniLight"
omniLightNode.light = omniLight
omniLightNode.position = SCNVector3(x: -10.0, y: 20, z: 10.0)
omniLightNode.castsShadow = true
rootNode.addChildNode(omniLightNode)
}有了这个代码,我有一个明亮的场景,一些非常轻和长的阴影不是从左边来的。我试图改变目前是SCNVector3(1.5,1.5,1.5)的位置,但是无论我放哪个位置,阴影都会消失。有什么想法吗?
发布于 2016-02-01 21:43:41
如果你想要在场景的所有部分的方向光,使用SCNLightTypeSpot为您的灯的type。也可能是SCNLightTypeDirectional。
SCNLight.castsShadow:的每个文档
只有当该属性的值为“是”且该光的类型属性为SCNLightTypeSpot时,由光投出的阴影所照亮的几何图形。默认值为否。
然而,@mnuages在SceneKit shadows on wall中指出,定向光可以投下阴影。
https://stackoverflow.com/questions/35140268
复制相似问题