problem solved
add:
modelEy = nil
Post
Replies
Boosts
Views
Activity
problem solved
add:
modelEy = nil
USDZ:https://sketchfab.com/3d-models/spartan-armour-mkv-halo-reach-57070b2fd9ff472c8988e76d8c5cbe66
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)
}
arView.automaticallyConfigureSession = false
configuration = ARWorldTrackingConfiguration()
if ARWorldTrackingConfiguration.supportsFrameSemantics(.personSegmentationWithDepth)
{
configuration.frameSemantics = .personSegmentationWithDepth
}
configuration.environmentTexturing = .automatic
guard let arAnchorCGImage = image.cgImage else { return }
let arReferenceImage = ARReferenceImage(arAnchorCGImage, orientation: .up, physicalWidth: CGFloat(0.1))
let arImages: SetARReferenceImage = [arReferenceImage]
configuration.detectionImages = arImages
configuration.maximumNumberOfTrackedImages = 1
arView.session.run(configuration)