首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在所有节点上投下阴影SCNLight

在所有节点上投下阴影SCNLight
EN

Stack Overflow用户
提问于 2016-02-01 21:02:56
回答 1查看 2.5K关注 0票数 4

我正试图从场景的左边投下一个很短的黑影。我的灯光设置如下:

代码语言:javascript
复制
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)的位置,但是无论我放哪个位置,阴影都会消失。有什么想法吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-02-01 21:43:41

如果你想要在场景的所有部分的方向光,使用SCNLightTypeSpot为您的灯的type。也可能是SCNLightTypeDirectional

SCNLight.castsShadow:的每个文档

只有当该属性的值为“是”且该光的类型属性为SCNLightTypeSpot时,由光投出的阴影所照亮的几何图形。默认值为否。

然而,@mnuages在SceneKit shadows on wall中指出,定向光可以投下阴影。

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/35140268

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档