我在实现ARKit / SceneKit时遇到一个问题。我只想向3D模型的某些部分添加纹理(例如,汽车的3D模型,我想在其中更改车轮和镜子的纹理)。
let dragonScene = SCNScene(named: "art.scnassets/Dragon_Baked_Actions_fbx_6.dae")!
let position = anchor.transform
for childNode in dragonScene.rootNode.childNodes {
self.dragonNode.addChildNode(childNode)
}
let scale:Float = 0.01
self.dragonNode.scale = SCNVector3(x: scale, y: scale, z: scale)
self.dragonNode.position = SCNVector3(x: position.columns.3.x, y: position.columns.3.y, z: position.columns.3.z)
self.sceneView.scene.rootNode.addChildNode(self.dragonNode)
let material = SCNMaterial()
material.diffuse.contents = UIImage(named: "Fire_A_2.png")
material.isDoubleSided = true
material.diffuse.wrapT = SCNWrapMode.repeat
material.diffuse.wrapS = SCNWrapMode.repeat
material.isDoubleSided = true
self.dragonNode.childNodes.first?.geometry!.replaceMaterial(at: 0, with: material)