我遇到一个问题,我的屏幕上显示的scnode中有浮动蒙版。但是,我不想显示该浮动蒙版,而是希望显示以下图像。谁能帮我解决这个问题。
图片:https://imgur.com/a/sUkRcv2
这是我的代码:
var maskNode: Mask?
override func viewDidLoad() {
super.viewDidLoad()
self.sceneView.backgroundColor = .clear
self.sceneView.scene = SCNScene()
self.sceneView.rendersContinuously = true
if let device = MTLCreateSystemDefaultDevice(),
let geo = ARSCNFaceGeometry(device: device) {
self.maskNode = Mask(geometry: geo)
self.sceneView.scene?.rootNode.addChildNode(self.maskNode!)
self.maskNode?.position = SCNVector3(x: 0.0, y: 0.0, z: 0.0)
}
面具:
import ARKit
import SceneKit
class Mask: SCNNode, VirtualFaceContent {
init(geometry: ARSCNFaceGeometry) {
let material = SCNMaterial()
material.diffuse.contents = #colorLiteral(red: 1, green: 1, blue: 1, alpha: 1)
geometry.firstMaterial = material
super.init()
self.geometry = geometry
}
required init?(coder aDecoder: NSCoder) {
fatalError("\(#function) has not been implemented")
}
func update(withFaceAnchor anchor: ARFaceAnchor) {
let faceGeometry = geometry as! ARSCNFaceGeometry
faceGeometry.update(from: anchor.geometry)
}
}