简体   繁体   中英

iOS ARKit pointer to an anchor

I have an app that has a random ARKit anchor placed in the environment.

I want to make a simple arrow or pointer that would point to which direction the anchor is if it is currently off the screen.

Has anyone had to do anything similar? Or, do you know of any example code that I could take a look at to help me implement this feature?

Thanks!

If you use the pointer as a UIImage you can use: self.yourSceneView.projectPoint(yourNode.worldPosition) to get the position on screen for your node and than calculate where the pointer needs to point

if the pointer is another SCNNode than use yourPointerNode.look(at: yourAnchorNode) to change the orientation of the pointer to point towards the node on the anchor

in both cases update the locations in func session(_ session: ARSession, didUpdate frame: ARFrame) function

You could create a 3D arrow, add it to your camera node so that it's always visible and give it a lookAt(your random anchor world position) constraint.

If your anchor is visible (use visibleNodes) then hide the arrow.

Example video : https://twitter.com/londonrom/status/1060282275932372992?s=21

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM