To get a point in 3D world coordinates for use with project(_:), use Entity's convert(position:from:) instance method. The description of convert(position:from:)'s referenceEntity says "Set this to nil to indicate world space.".
In the example above, the code:
// convert position into anchor's space
let modelPos = model.convert(position: model.position, to: anchor)
Should be changed to:
// convert position into world coordinate space
let modelPos = model.convert(position: model.position, to: nil)
Topic:
Spatial Computing
SubTopic:
ARKit
Tags: