I found a way, but no shadow, how can i show the shadow.
func session(_ session: ARSession, didAdd anchors: [ARAnchor])
{
anchors.compactMap { $0 as? ARImageAnchor }.forEach {
rootAnchor = AnchorEntity()
rootAnchor.transform.matrix = $0.transform
arView.scene.addAnchor(rootAnchor)
add()
}
}
func session(_ session: ARSession, didUpdate anchors: [ARAnchor])
{
anchors.compactMap { $0 as? ARImageAnchor }.forEach {
rootAnchor.transform.matrix = $0.transform
}
}
fileprivate func add()
{
let audioPlane = MeshResource.generatePlane(width: 0.2, height: 0.2, cornerRadius: 0)
var audioMtl = SimpleMaterial()
do {
audioMtl.baseColor = try MaterialColorParameter.texture(TextureResource.load(named: "audio_play.png"))
} catch {
}
let audioEntity = ModelEntity(mesh: audioPlane, materials: [audioMtl])
audioEntity.position = [0, 0.1, 0]
rootAnchor.addChild(audioEntity)
}