Last active
February 3, 2020 08:26
-
-
Save lukas-ruzicka/686f1e9ac9c5814366286d458595c934 to your computer and use it in GitHub Desktop.
Implementace metody `ARSessionDelegate`, která je volána pokaždé, když je detekována nová kotva. Pokud chcete přidat obsah Reality Composer projektu do scény, stačí jen ověřit jestli je nalezená kotva typu `ARObjectAnchor` a pak jen přidat obsah RC projektu do scény se změněnou kotvou. Toto je je jednoduchá implementace k demonstraci použití.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func session(_ session: ARSession, didAdd anchors: [ARAnchor]) { | |
// `ARObjectAnchor` je kotva definovaného referenčního objektu | |
guard let objectAnchor = (anchors.first(where: { $0 is ARObjectAnchor })) as? ARObjectAnchor else { return } | |
let entity = try! Entity.loadScene() | |
// Následujícím přiřazením `AnchoringComponent` (s identifikátorem nalezené kotvy) definujeme pozici přidané entity | |
entity.anchoring = AnchoringComponent(.anchor(identifier: objectAnchor.identifier)) | |
arView.scene.addAnchor(entity) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment