this is a project using Apple Vision Pro.how can i crop detected image ,
so my code basically is this it generate a sphere that track the detected image
i wanna update it so it will crop the detected image so it can be a sign of click me mesh
private func updateImage(_ anchor: ImageAnchor) {
if let existingEntity = entityMap[anchor.id] {
existingEntity.removeFromParent()
}
let imageID = anchor.referenceImage.name
detectedImageID = imageID
print("Recognized image with ID: (imageID)")
let entity = ModelEntity(mesh: .generateSphere(radius: 0.05))
entity.components.set(InputTargetComponent())
entity.collision = CollisionComponent(shapes: [.generateSphere(radius: 0.05)])
let material = UnlitMaterial(color: UIColor.blue.withAlphaComponent(0.65))
entity.model?.materials = [material]
entity.generateCollisionShapes(recursive: true)
entity.components[CollisionComponent.self] = CollisionComponent(shapes: [.generateSphere(radius: 0.05)])
entityMap[anchor.id] = entity
contentEntity.addChild(entity)
animateMesh(entity)
if anchor.isTracked {
entity.transform = Transform(matrix: anchor.originFromAnchorTransform)
entity.isEnabled = true
}
}