我使用SCNScene在SwiftUI中加载一个3D模型,我的对象在lambert或phong阴影中看起来更好。我试图像这样改变照明模式:
var scene: SCNScene? {
let scene = SCNScene(named: "model.usdz")
scene?.rootNode.geometry?.firstMaterial?.lightingModel = .lambert
scene?.rootNode.scale = SCNVector3(scale, scale, scale)
return scene
}然后把场景装进身体:
var body: some View {
SceneView(
scene: scene,
pointOfView: cameraNode,
options: [.allowsCameraControl, .autoenablesDefaultLighting]
)
}但是,改变照明模式并不影响模型,甚至在场景工具包编辑器中手动尝试,但仍然没有运气,任何解决方案都将是伟大的。

发布于 2022-06-30 17:12:59
据我所见,您的代码更改了RootNode的照明模型(这没有改变什么,因为根节点本身是不可见的)。要更改the模型的照明模型,必须获取包含该模型的几何形状的精确节点,该模型通常是childNode或childNode的子节点。这样就行了。
https://stackoverflow.com/questions/72817915
复制相似问题