我尝试创建一个大的 SCNPlane 来覆盖整个屏幕。测试代码如下所示,其中一个红色框(尺寸 1x1x1)位于蓝色平面(尺寸 200 x200)的中间。它们都在中心点 (0, 0, 0) 并且相机距离该点仅 +5。
当平面节点面向相机(大角度)时,效果很好(图1),左右两边都可以覆盖整个屏幕的左右两边。但是,当我将飞机旋转到一个小角度(使用相机)时,只显示了一小部分。在图 2 中,飞机的左侧更靠近相机。左侧应该足够宽(100 的一侧)以覆盖屏幕的所有左侧,但事实并非如此。将飞机的大小增加到 10 倍(到 2000 倍)并没有帮助。
关于问题和解决方案的任何想法?谢谢
override func viewDidLoad() {
super.viewDidLoad()
let scnView = self.view as! SCNView
scnView.backgroundColor = UIColor.darkGray
scnView.autoenablesDefaultLighting = true
scnView.allowsCameraControl = true
scnView.scene = SCNScene()
let cameraNode = SCNNode()
cameraNode.camera = SCNCamera()
scnView.scene?.rootNode.addChildNode(cameraNode)
cameraNode.position = SCNVector3(x: 0, y: 0, z: 5)
let theBox = SCNBox(width: 1, height: 1, length: 1, chamferRadius: 0)
theBox.firstMaterial?.diffuse.contents = UIColor.red
let theBoxNode = SCNNode(geometry: theBox)
theBoxNode.position = SCNVector3(0, 0, 0)
scnView.scene?.rootNode.addChildNode(theBoxNode)
let plane = SCNPlane(width: 200, height: 200)
plane.firstMaterial?.diffuse.contents = UIColor.blue
let planeNode = SCNNode(geometry: plane)
scnView.scene?.rootNode.addChildNode(planeNode)
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句