我正在试验 SceneKit 并尝试用它制作迷宫风格的游戏。但是,其中一个问题是当您在一个盒子( pipe 、球体等)内移动时,盒子的投影会消失。
我已经多次阅读文档,但我要么没有匹配正确的措辞,要么就是没有。
你会如何填充一个盒子的内容,以便当你穿过它时你会在黑暗中?
谢谢!
最佳答案
SCNMaterial
有一个 isDoubleSided
属性,它是:
A Boolean value that determines whether SceneKit should render both front and back faces of a surface.
默认设置为 false
意味着您的内容只会显示在一侧,例如外面。
If you change this property’s value to YES, SceneKit renders both the front and back surfaces of every polygon.
因此,两侧渲染的示例可以这样实现:
func createBoxNode(){
//1. Create An SCNNode With An SCNBox Geometry
let boxNode = SCNNode(geometry: SCNBox(width: 0.1, height: 0.1, length: 0.1, chamferRadius: 0))
//2. Set The Colour Of All Sides To Cyan
boxNode.geometry?.firstMaterial?.diffuse.contents = UIColor.cyan
//3. Enusre That Both Sides Are Rendered
boxNode.geometry?.firstMaterial?.isDoubleSided = true
//4. Place Our BoxNode & Add It To The Hierachy
boxNode.position = SCNVector3(0, 0, -1.5)
self.augmentedRealityView?.scene.rootNode.addChildNode(boxNode)
}
希望对你有帮助
关于ios - 如何填充 SCNBox 的内部,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51096638/