I tap screen and get result hit point. from that point, I want to measure distance to a 3d object placed on ar view.
code is
*for placing 3dobject
let anchorEntity = AnchorEntity(anchor: anchor)
anchorEntity.addChild(modelEntityClone)
arView.scene.addAnchor(anchorEntity)
*for point to measure distance to 3dobject
guard let rayResult = self.view!.ray(through: normalizedIndexPoint)else {return}
let results = self.view!.scene.raycast(origin: rayResult.origin, direction: rayResult.direction)
if let firstResult = results.first {
var position = firstResult.position
var distanceing = distance(firstResult.position, self.me!.position)
}
I pointed very close to 3d object but it's a bit far saying 30 cm... or so, I found out that once I close to world origin, than it become almost 0...
how can I measure from 3d object not from world origin?