答案 0 :(得分:0)
要完成您需要的内容,只需使用以下代码:
override func viewDidLoad() {
super.viewDidLoad()
let scene = SCNScene(named: "art.scnassets/myScene.scn")!
let sphereNode = SCNNode(geometry: SCNSphere(radius: 5))
let goldenMaterial = SCNMaterial()
goldenMaterial.lightingModel = .physicallyBased
goldenMaterial.metalness.contents = 1.0
goldenMaterial.roughness.contents = 0.0
goldenMaterial.diffuse.contents = UIColor(red: 0.95,
green: 0.75,
blue: 0.2,
alpha: 1.0)
sphereNode.geometry?.materials = [goldenMaterial]
scene.rootNode.addChildNode(sphereNode)
//......................................................
let scnView = self.view as! SCNView
scnView.scene = scene
scnView.autoenablesDefaultLighting = true
}