首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法使用SCNLight显示阴影

无法使用SCNLight显示阴影
EN

Stack Overflow用户
提问于 2019-07-22 23:49:07
回答 1查看 59关注 0票数 1

我添加了一些环境光,平行光和地板,但仍然没有阴影出现!知道为什么吗?

代码语言:javascript
复制
// create and add ambient light to the scene
let ambientLightNode = SCNNode()
ambientLightNode.light = SCNLight()
ambientLightNode.light!.type = .ambient
ambientLightNode.light!.color = UIColor.init(hexString: "ececec")
ambientLightNode.light!.intensity = 100
ambientLightNode.light!.shadowColor = UIColor(white: 0, alpha: 0.5)
scene.rootNode.addChildNode(ambientLightNode)

//Main Light
let floor = SCNNode()
floor.geometry = SCNFloor()
floor.geometry?.firstMaterial!.diffuse.contents = UIColor.white
floor.geometry?.firstMaterial!.colorBufferWriteMask = SCNColorMask(rawValue: 0)
floor.castsShadow = false
scene.rootNode.addChildNode(floor)

// Create directional light
let directionalLight = SCNNode()
directionalLight.light = SCNLight()
directionalLight.castsShadow = true
directionalLight.light?.type = .directional
directionalLight.position = SCNVector3(2, 10, 2)

scene.rootNode.addChildNode(directionalLight)
EN

回答 1

Stack Overflow用户

发布于 2019-07-24 05:47:58

使用灯光的属性

代码语言:javascript
复制
directionalLight.light!.castsShadow = true

Not a node's castsShadow

代码语言:javascript
复制
directionalLight.castsShadow = true
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57149592

复制
相关文章

相似问题

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