我正在使用以.jpg为材料的3D模型。当我在Xcode中分配它时,一切正常:
现在,当我以编程方式添加scene
及其材料时,似乎会拉伸.jpg并将其弄乱。
代码:
override func viewDidLoad() {
super.viewDidLoad()
self.sceneView = ARSCNView(frame: self.view.frame)
self.view.addSubview(self.sceneView)
sceneView.delegate = self
let scene = SCNScene()
let baseScene = SCNScene(named: "art.scnassets/testing.scn")
let baseNode = baseScene?.rootNode.childNode(withName: "base", recursively: true)
baseNode?.position = SCNVector3(0, 0, 0)
let material = SCNMaterial()
material.diffuse.contents = UIImage(named: "art.scnassets/texture.jpg")
baseNode?.geometry?.materials = [material]
scene.rootNode.addChildNode(baseNode!)
sceneView.scene = scene
}
下面是它的样子: