kazuhiro4949/ARPlaneTracker
Fork: 0 Star: 8 (更新于 2024-11-27 15:29:04)
license: MIT
Language: Swift .
最后发布版本: 0.2 ( 2019-07-24 15:04:44)
ARPlaneTracker
easy to place a guide on AR environment
What's this?
Feature
- easy to coach detected area
- easy to associate with your ARSCNView
- custumizable coaching object
Requirements
- iOS 12.0+
- Xcode 10.0+
- Swift 5.0
Installation
CocoaPods
- Install CocoaPods
> gem install cocoapods
> pod setup
- Create Podfile
> pod init
- Edit Podfile
target 'YourProject' do
use_frameworks!
pod "ARPlaneTracker" # add
target 'YourProject' do
inherit! :search_paths
end
target 'YourProject' do
inherit! :search_paths
end
end
- Install
> pod install
open .xcworkspace
Carthage
- Install Carthage from Homebrew
> ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
> brew update
> brew install carthage
- Move your project dir and create Cartfile
> touch Cartfile
- add the following line to Cartfile
github "kazuhiro4949/ARPlaneTracker"
- Create framework
> carthage update --platform iOS
- In Xcode, move to "Genera > Build Phase > Linked Frameworks and Library"
- Add the framework to your project
- Add a new run script and put the following code
/usr/local/bin/carthage copy-frameworks
- Click "+" at Input file and Add the framework path
$(SRCROOT)/Carthage/Build/iOS/ARPlaneTracker.framework
- Write Import statement on your source file
import ARPlaneTracker
Getting Started
1. Instanciate ARPlaneTracker
class ViewController: UIViewController, ARSCNViewDelegate {
@IBOutlet var sceneView: ARSCNView!
let arPlaneTracker = ARPlaneTracker()
//...
}
2. Add ARPlaneTracker object to the root scene node
override func viewDidLoad() {
// ...
arPlaneTracker.sceneView = sceneView
arPlaneTracker.delegate = self
sceneView.scene.rootNode.addChildNode(arPlaneTracker)
}
3. Add a coaching node to ARPlaneTracker object
let coachingNode = SCNNode()
override func viewDidLoad() {
// ...
arPlaneTracker.addChildNode(coachingNode)
}
4. Update the state of ARPlaneTrack object in ARSCNViewDelegate
extension ViewController: ARSCNViewDelegate {
func renderer(_ renderer: SCNSceneRenderer, updateAtTime time: TimeInterval) {
DispatchQueue.main.async {
self.arPlaneTracker.updateTracker()
}
}
}
5. Animate coaching node in ARPlaneTrackerDelegate
extension ViewController: ARPlaneTrackerDelegate {
func planeTracker(_ planeTracker: ARPlaneTracker, didDetect horizontalPlaneAnchor: ARPlaneAnchor, hitTestResult: ARHitTestResult, camera: ARCamera?) {
// add activate animation to coachingNode
activateAnimation()
}
func planeTracker(_ planeTracker: ARPlaneTracker, failToDetectHorizontalAnchorWith hitTestResult: ARHitTestResult, camera: ARCamera?) {
// add deactivate animation to coachingNode
deactivateAnimation()
}
}
6. Implement Fade animation to coaching node
// Fade in
func activateAnimation() {
guard positioningNode.hasActions else { return }
positioningNode.removeAllActions()
let fadeInAction = SCNAction.fadeIn(duration: 0.2)
fadeInAction.timingMode = .easeInEaseOut
positioningNode.runAction(fadeInAction)
}
// Fade out
func deactivateAnimation() {
guard !positioningNode.hasActions else { return }
let fadeOutAction = SCNAction.fadeOut(duration: 0.2)
fadeOutAction.timingMode = .easeInEaseOut
let fadeInAction = SCNAction.fadeIn(duration: 0.2)
fadeInAction.timingMode = .easeInEaseOut
let sequence = SCNAction.sequence([fadeOutAction, fadeInAction])
let repeatForever = SCNAction.repeatForever(sequence)
positioningNode.runAction(repeatForever)
}
kazuhiro4949/ARPlaneTracker同语言 Swift最近更新仓库
2024-12-21 13:48:53 argmaxinc/WhisperKit
2024-12-19 06:06:30 stripe/stripe-ios
2024-12-16 23:43:56 wordpress-mobile/WordPress-iOS
2024-12-04 20:33:05 Artificial-Pancreas/iAPS
2024-12-03 10:12:09 utmapp/UTM
2024-11-25 23:11:48 Alamofire/Alamofire