如何增加场景中的照明?

问题描述 投票:0回答:1

我正在尝试阐明我从Mixamo下载的基本模型。

let scene = SCNScene(named: "art.scnassets/Ch45_nonPBR.dae")!

// create and add a camera to the scene
let cameraNode = SCNNode()
cameraNode.camera = SCNCamera()
scene.rootNode.addChildNode(cameraNode)

// place the camera
cameraNode.position = SCNVector3(x: 0, y: 40, z: 110)

// create and add a light to the scene
let lightNode = SCNNode()
lightNode.light = SCNLight()
lightNode.light!.type = .omni
lightNode.position = SCNVector3(x: 0, y: 50, z: 50)
scene.rootNode.addChildNode(lightNode)

// create and add an ambient light to the scene
let ambientLightNode = SCNNode()
ambientLightNode.light = SCNLight()
ambientLightNode.light!.type = .ambient
ambientLightNode.light!.color = UIColor.white
scene.rootNode.addChildNode(ambientLightNode)

目前,相机距离模型太近。但是,如果我将z值从110更改,则只能看到黑色。我想这与照明有关。我应该怎样设置照明才能让我看到我的模型,即使我将相机的z值更改为一个更高的值也可以看到很远的模型?

编辑:例如,现在您可以在此距离看到,腿的一部分不可见:

enter image description here

如果我走得更远,整个模型将不可见!

编辑:例如,如何编辑照明,使其看起来像在其网站上的Mixamo预览中一样:

enter image description here

我想将相机移得足够远,以便可以在屏幕上看到整个模型。

swift scenekit swift5
1个回答
1
投票

SCNCamera具有zFar属性,默认值为100,任何距离摄像机更远的表面都将被修剪以提高性能。在您的屏幕快照中,腿是模型中距离相机最远的部分,因此首先被裁剪,并且随着您移开更远,整个模型也将被裁剪。您可以将zFar增加到适合您的场景的数量。

© www.soinside.com 2019 - 2024. All rights reserved.