Upgrade to Pro — share decks privately, control downloads, hide ads and more …

ARKit + CoreLocation - Bonfire iOS #4 -

totomo
May 15, 2018

ARKit + CoreLocation - Bonfire iOS #4 -

Talked about ARKit + CoreLocation.
This session was focused to the UI.

totomo

May 15, 2018
Tweet

More Decks by totomo

Other Decks in Technology

Transcript

  1. Copyright (C) 2018 Yahoo Japan Corporation. All Rights Reserved. Bonfire

    iOS #4 2018೥5݄15೔ Kenta Tokumoto ARKit+CoreLocation
  2. Copyright (C) 2018 Yahoo Japan Corporation. All Rights Reserved. 2

    Outline • ࣗݾ঺հ • ARϞʔυʹ͍ͭͯ • ARKitͷ֓ཁ • ARKit+CoreLocation • ΦϒδΣΫτͷ഑ஔํ๏ʹ͍ͭͯ • ϧʔτϥΠϯ • ؃൘ • ଍੻ • ͚Μ͘͞+ΰʔϧϐϯ • ۭؒิਖ਼ • ARͱ஍ਤͰͷUIͷҧ͍ʹ͍ͭͯ
  3. Copyright (C) 2018 Yahoo Japan Corporation. All Rights Reserved. 6

    Schedule 2017೥9݄ʙ 12݄ 1݄ 2݄ 3݄ ϧʔτϥΠϯɺ଍੻ ࣮ݧ ؃൘ɺ͚Μ͘͞ QAɺਃ੥ ۭؒิਖ਼ ϦϦʔε
  4. Copyright (C) 2018 Yahoo Japan Corporation. All Rights Reserved. 7

    ARKit • iOS 11Ҏ߱Ͱ࢖͑ΔARػೳΛ࣮૷͢Δͷʹศ རͳFramework • AR mode͸Position TrackingΛඞཁͱ͢ΔͨΊ A9νοϓ͕౥ࡌ͞Εͨ୺຤ͷΈαϙʔτ • Android → ARCore
  5. Copyright (C) 2018 Yahoo Japan Corporation. All Rights Reserved. 8

    ARKit+CoreLocation • ARConfiguration.worldAlignment.gravit yAndHeadingΛࢦఆ͢Δ • ݪ఺ͷҐஔ৘ใͱARKitʹΑΓߏங͞Ε ͨੈքۭؒͷݪ఺͸૬ޓม׵Մೳ AR ࣮ۭؒ N N (x n , z n ) (lat n , lon n )
  6. Copyright (C) 2018 Yahoo Japan Corporation. All Rights Reserved. 9

    ARKit+CoreLocation (0, 0) d [m] (x 1 , z 1 ) (lat 0 , lon 0 ) d [m] (lat 1 , lon 1 )
  7. Copyright (C) 2018 Yahoo Japan Corporation. All Rights Reserved. 10

    SCNNodeͷ഑ஔ • ϧʔτϥΠϯ (SCNPlane) • ؃൘ (3D) • ͚Μ͘͞+ΰʔϧϐϯ(3D) • ଍੻ (SCNPlane)
  8. Copyright (C) 2018 Yahoo Japan Corporation. All Rights Reserved. 16

    ؃൘ position • ϚʔδϯΛઃ͚ͯݟ΍͍͢ํ޲ʹճస • ౦੢ͲͪΒʹ഑ஔ͢Δ͔͸ɺਐߦํ޲ ͱ࣍ͷํ޲ͱͷࠩ෼͔Β൑அ͍ͯ͠Δ
  9. Copyright (C) 2018 Yahoo Japan Corporation. All Rights Reserved. 19

    ଍੻ position • ARSCNView͔ΒऔΕΔ pointOfViewͷpositionΛऔಘ • ݱࡏҐஔͷ࠲ඪΛ΋ͱʹҠಈڑ཭ ͱ֯౓Λܭࢉ • ଍੻͸ϥϯμϜͰग़͢Α͏ʹ materialʹઃఆ͍ͯ͠ΔUIImageΛ ಈతʹઃఆ͍ͯ͠Δ
  10. Copyright (C) 2018 Yahoo Japan Corporation. All Rights Reserved. 20

    ͚Μ͘͞+ΰʔϧϐϯ position SCNBillboardConstrain t
  11. Copyright (C) 2018 Yahoo Japan Corporation. All Rights Reserved. 21

    SCNNodeͷ௥Ճ locationInfoProvider.location { [weak self] location in guard let origin = location else { self?.displayError() return } self?.addObjects(origin: origin) }
  12. Copyright (C) 2018 Yahoo Japan Corporation. All Rights Reserved. 22

    ஞ࣍తͳSCNNodeͷ௥Ճ func renderer(_ renderer: SCNSceneRenderer, updateAtTime time: TimeInterval) { // 5ͭͣͭ௥Ճ͢Δ } self.navigationView.worldNode.addScheduledNodes(quantity: 5) func addObjects(origin: CLLocation) { self.navigationView.origin = origin let routeLineNodes = routeNodes(withCoordinates: self.coordinates) self.navigationView.scheduleNodes(routeLineNodes, priority: .high) } // ARSCNViewDelegate
  13. Copyright (C) 2018 Yahoo Japan Corporation. All Rights Reserved. 23

    ۭؒิਖ਼ Correctable Space Fixed Space Root Space
  14. Copyright (C) 2018 Yahoo Japan Corporation. All Rights Reserved. ۭؒิਖ਼

    24 • Fixed Space • ଍੻ • Correctable Space • ϧʔτϥΠϯ • ͚Μ͘͞&ΰʔϧϐϯ • ؃൘
  15. Copyright (C) 2018 Yahoo Japan Corporation. All Rights Reserved. ۭؒิਖ਼

    25 GPSʹΑΔݱࡏ஍ (CoreLocation) AR্ۭؒͷΧϝϥͷݱࡏ஍ (ARKit) GPSʹΑΔޡࠩͷ൒ܘ
  16. Copyright (C) 2018 Yahoo Japan Corporation. All Rights Reserved. ۭؒิਖ਼

    26 GPSʹΑΔݱࡏ஍ (CoreLocation) AR্ۭؒͷΧϝϥͷݱࡏ஍ (ARKit) GPSʹΑΔޡࠩͷ൒ܘ ޡࠩͷԁ͔Β͸Έग़ͯ͠ ͍Δ
  17. Copyright (C) 2018 Yahoo Japan Corporation. All Rights Reserved. 27

    LocationInfoProvider public protocol LocationInfoProvidable { func location(completion: @escaping (CLLocation?)->()) func nearbyRoutePoint(from origin: SCNVector3) -> SCNVector3? var delegate: LocationInfoProviderDelegate? { get set }
 } protocol LocationInfoProviderDelegate: class { // ֯౓ิਖ਼ (ిࢠίϯύε·ͨ͸Ґஔ৘ใͷਫ਼౓͕޲্ͨ͠λΠϛϯάͰ௨஌) // ਫ਼౓: heading.headingAccuracy func locationInfoProvider(_ provider: LocationInfoProvidable, requestUpdateHeading heading: CLHeading) // Ґஔิਖ਼ (Ґஔ৘ใͷਫ਼౓͕޲্ͨ͠λΠϛϯάͰ௨஌ // ਫ਼౓: location.horizontalAccuracy func locationInfoProvider(_ provider: LocationInfoProvidable, requestUpdateLocation location: CLLocation, oldLocation: CLLocation?)
 }
  18. Copyright (C) 2018 Yahoo Japan Corporation. All Rights Reserved. ۭؒิਖ਼

    28 extension ARRouteNavigationViewController: ARLocationInfoProviderDelegate { public func arLocationInfoProvider(_ provider: ARLocationInfoProvidable, requestUpdateLocation location: CLLocation, oldLocation: CLLocation?) { guard let origin = navigationView.origin, let currentPosition = navigationView.pointOfView?.worldPosition else { return } 
 ɹɹɹɹɹ// GPS͔Βܭࢉͨ͠ARۭؒʹ͓͚Δ࠲ඪ ɹɹɹɹɹlet gpsPosition = location.coordinate.relativeVector3(to: origin.coordinate) + ɹɹɹɹɹ navigationView.worldNode.correctableNode.worldPosition ɹɹɹɹɹ// GPSͷޡࠩΛ௒͑ͯͣΕ͍ͯͳ͍৔߹͸Կ΋͠ͳ͍ ɹɹɹɹɹguard idealPosition.length(between: currentPosition) > location.horizontalAccuracy else { ɹɹ return ɹɹɹɹɹ} 
 ɹɹɹɹɹ// ޡࠩΛܭࢉ ɹɹɹɹɹlet positionDifference = gpsPosition – currentPosition 
 ɹɹɹɹɹ// ิਖ਼ ɹɹɹɹɹnavigationView.worldNode.correctableNode.worldPosition -= SCNVector3(positionDifference.x, 0, positionDifference.z) } }
  19. Copyright (C) 2018 Yahoo Japan Corporation. All Rights Reserved. ՄࢹྖҬͷҧ͍

    30 • ՄࢹྖҬ • ஍ਤɹ →ɹશମΛ၆ᛌͯ͠ݟΕΔ • ARɹ →ɹपลʹϑΥʔΧεͯ͠ݟΔ
  20. Copyright (C) 2018 Yahoo Japan Corporation. All Rights Reserved. ՄࢹྖҬͷҧ͍΁ͷରࡦ

    31 ํ޲ࢦࣔΛࡉ͔͘දࣔ ؃൘Ͱํ޲ͱ࢒Γͷڑ཭Λࡉ͔͘දࣔ
  21. Copyright (C) 2018 Yahoo Japan Corporation. All Rights Reserved. ۭؒͱ࣍ݩͷҧ͍

    32 • ۭؒͱ࣍ݩ • ஍ਤɹ →ɹ஍ਤʹΑΔ2࣍ݩۭؒ ɹɹɹɹɹ (ݱ࣮Λ2Dʹͯ͠Ճ޻ͨ͠΋ͷ) • ARɹ →ɹݱ࣮ۭؒ (3D)
  22. Copyright (C) 2018 Yahoo Japan Corporation. All Rights Reserved. ࣍ݩͷҧ͍΁ͷରࡦ

    33 • ي੻ɹɹɹ →ɹ଍੻ • ਧ͖ग़͠ɹ →ɹ؃൘ • ΰʔϧϐϯ →ɹ͚Μ͘͞(ͱΰʔϧϐϯ)
  23. Copyright (C) 2018 Yahoo Japan Corporation. All Rights Reserved. 35

    ·ͱΊ • ARKit + CoreLocation Ͱ࣮ࡍͷ෩ܠΛݟͳ͕ΒಓҊ಺͕Ͱ͖Δ • ARKit͕ߏ੒͢Δۭؒ࠲ඪͱ࣮ۭؒͷҢ౓ܦ౓͸૬ޓʹม׵͢Δ͜ ͱ͕Ͱ͖Δ • 3DΦϒδΣΫτͷ഑ஔʹ͸SceneKitͷ஌͕ࣝඞཁ • GPS΍ిࢠίϯύεͷਫ਼౓ΛݟͭͭΧϝϥͷ࠲ඪ͔ΒҐஔ΍ํ޲ Λิਖ਼Մೳ • ARͱ஍ਤͰ͸ಛੑ͕ҧ͏ͨΊUI΋ͦΕͧΕʹ߹ΘͤΔඞཁ͕͋Δ