Skip to content

Instantly share code, notes, and snippets.

@eospi
Last active December 8, 2021 22:17
Show Gist options
  • Save eospi/413c6b76f5683ac9831bf0e6c0e4f7ec to your computer and use it in GitHub Desktop.
Save eospi/413c6b76f5683ac9831bf0e6c0e4f7ec to your computer and use it in GitHub Desktop.
guard let query = arView.makeRaycastQuery(from: arView.center, allowing: .existingPlaneInfinite, alignment: .horizontal) else { return }
guard let raycastResult = arView.session.raycast(query).first else { return }
// set a transform to an existing entity
let transform = Transform(matrix: raycastResult.worldTransform)
entity.transform = transform
// or anchor an entity to an ARRaycastResult
let anchor = AnchorEntity(raycastResult: raycastResult)
anchor.addChild(entity)
self.arView.addAnchor(anchor)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment