I have created a portal and attached it to a wall using the AnchorEntity. However, I am seeking guidance on how to determine the size of the wall so that the portal can fully occupy it. Initially, I attempted to locate relevant information within the demo code, but I encountered difficulties in comprehending certain sections. I would appreciate it if someone could provide a step-by-step explanation or a reference to the appropriate code. Thank you for your assistance.
Hello @lijiaxu
You should be able to use the extent
property of the anchor for the wall plane.
A small change to that sample code that demonstrates the basics:
@MainActor
func updatePlane(_ anchor: PlaneAnchor) {
if planeAnchors[anchor.id] == nil {
let width = anchor.geomerty.extent.width
let height = anchor.geomerty.extent.height
// use these two values to know the extent of the plane that has been detected
// Keep in mind that this anchor might be updated over time as
// more of the wall is discovered so it would make sense to have
// an update algorithm in addition to the creation algorithm
// demonstrated in the rest of this code.
// Add a new entity to represent this plane.
let entity = ModelEntity(mesh: .generateText(anchor.classification.description))
entityMap[anchor.id] = entity
rootEntity.addChild(entity)
}
entityMap[anchor.id]?.transform = Transform(matrix: anchor.originFromAnchorTransform)
}
Please let me know if this doesn't answer the question.