【问题标题】:SceneKit shows only partly a large rotated SCNPlaneSceneKit 仅显示部分旋转的大型 SCNPlane
【发布时间】:2018-01-13 07:39:03
【问题描述】:

我尝试创建一个大的 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)
}

【问题讨论】:

    标签: rotation scenekit


    【解决方案1】:

    您可能需要检查相机的zNear 属性以确保飞机没有被剪裁。你可以找到剪裁平面的解释here

    【讨论】:

    • 哇,谢谢。这是我错过的基本知识。有用。对于有同样问题的人,请尝试添加:cameraNode.camera?.zNear = 0.001(zNear 不接受零)
    猜你喜欢
    • 1970-01-01
    • 2014-12-07
    • 2016-12-16
    • 2014-08-16
    • 2020-06-04
    • 2018-06-05
    • 1970-01-01
    • 2018-01-31
    • 2017-07-31
    相关资源
    最近更新 更多