Code Monkey home page Code Monkey logo

arcorelocation's Introduction

ARCoreLocation

ARCoreLocation is a lightweight and configurable iOS framework for displaying AR content at real-world coordinates.

Features:

• Easily create AR scenes that place AR objects in the real world

• Place AR objects at any geographic location without worrying about ARKit's implementation details

• Receive tap events on your AR content

• Receive events when AR content overlaps on-screen

Installation

CocoaPods

Enter this in your Podfile:

pod 'ARCoreLocation', '~> 0.1.8'

Then run pod install. Remember to import ARCoreLocation in any file where you want to use it!

Usage

Setup

Create the ARLandmarker and add its view:

let landmarker = ARLandmarker(view: ARSKView(), scene: InteractiveScene(), locationManager: CLLocationManager())
landmarker.view.frame = self.view.bounds
landmarker.scene.size = self.view.bounds.size
self.view.addSubview(landmarker.view)

Add Landmarks to the scene:

let landmarkLabel = UILabel(frame: CGRect(x: 0, y: 0, width: 75, height: 20))
landmarkLabel.text = "Statue of Liberty"
let location = CLLocation(coordinate: CLLocationCoordinate2D(latitude: 40.689234, longitude: -74.044524), altitude: 30, horizontalAccuracy: 5, verticalAccuracy: 5, timestamp: Date())
landmarker.addLandmark(view: landmarkLabel, at: location, completion: nil)

User Interaction

Get User Interaction events:

landmarker.delegate = self

...

extension ViewController: ARLandmarkerDelegate {
    func landmarkDisplayer(_ landmarkDisplayer: ARLandmarker, didTap landmark: ARLandmark) {
        ...
    }
    
    func landmarkDisplayer(_ landmarkDisplayer: ARLandmarker, didFailWithError error: Error) -> Void {
        ...
    }
}

Overlapping Landmarks

Use different strategies for overlapping landmarks:

landmarker.overlappingLandmarksStrategy = .showAll
landmarker.overlappingLandmarksStrategy = .showNearest
landmarker.overlappingLandmarksStrategy = .showFarthest
landmarker.overlappingLandmarksStrategy = .custom(callback: { (overlappingLandmarkGroups, notOverlappingLandmarks) in
    // Check overlapping groups and react accordingly
})

Request the landmarker to check for overlapping landmarks at a given interval:

// Check for overlaps every second
landmarker.beginEvaluatingOverlappingLandmarks(atInterval: 1)
...
landmarker.stopEvaluatingOverlappingLandmarks()

Or check for overlapping landmarks immediately

// ... Or check immediately
landmarker.evaluateOverlappingLandmarks()

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.