Save 37% off PRO during our Black Friday Sale! »

ARKit + CoreLocation - Bonfire iOS #4 -

ARKit + CoreLocation - Bonfire iOS #4 -

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

15d09153e7d56f8d73e8d9e519501a92?s=128

totomo

May 15, 2018
Tweet

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. About me ,FOUB5PLVNPUP 5XJUUFSUPUPNP (JUIVCUPUPNP 2JJUBUPUPNP ໊ݹ԰ۈ຿ɺೖࣾ̒೥໨ :BIPP."1ͷJ04 8FC"1*։ൃ୲౰ 3

  4. AR mode? 4 • Yahoo! MAPΞϓϦ(iOS)Ͱఏڙ͍ͯ͠ΔARΛ࢖ͬͨ ెาφϏࢧԉػೳ • iOS 11͔Βར༻ՄೳͳARKitΛ࢖༻

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

    Team Product Manager Designer Engineer
  6. Copyright (C) 2018 Yahoo Japan Corporation. All Rights Reserved. 6

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

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

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

    ϧʔτϥΠϯ
  12. Copyright (C) 2018 Yahoo Japan Corporation. All Rights Reserved. 12

    ϧʔτϥΠϯ position eulerAngles.y
  13. Copyright (C) 2018 Yahoo Japan Corporation. All Rights Reserved. 13

    ؃൘
  14. Copyright (C) 2018 Yahoo Japan Corporation. All Rights Reserved. 14

    ؃൘ position
  15. Copyright (C) 2018 Yahoo Japan Corporation. All Rights Reserved. 15

    ؃൘ position
  16. Copyright (C) 2018 Yahoo Japan Corporation. All Rights Reserved. 16

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

    ଍੻
  18. Copyright (C) 2018 Yahoo Japan Corporation. All Rights Reserved. 18

    ଍੻ position
  19. Copyright (C) 2018 Yahoo Japan Corporation. All Rights Reserved. 19

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

    ͚Μ͘͞+ΰʔϧϐϯ position SCNBillboardConstrain t
  21. 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) }
  22. 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
  23. Copyright (C) 2018 Yahoo Japan Corporation. All Rights Reserved. 23

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

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

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

    26 GPSʹΑΔݱࡏ஍ (CoreLocation) AR্ۭؒͷΧϝϥͷݱࡏ஍ (ARKit) GPSʹΑΔޡࠩͷ൒ܘ ޡࠩͷԁ͔Β͸Έग़ͯ͠ ͍Δ
  27. 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?)
 }
  28. 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) } }
  29. Copyright (C) 2018 Yahoo Japan Corporation. All Rights Reserved. ARͱ஍ਤͰͷφϏήʔγϣϯͷҧ͍

    29 • ՄࢹྖҬ • ۭؒͱ࣍ݩ
  30. Copyright (C) 2018 Yahoo Japan Corporation. All Rights Reserved. ՄࢹྖҬͷҧ͍

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

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

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

    33 • ي੻ɹɹɹ →ɹ଍੻ • ਧ͖ग़͠ɹ →ɹ؃൘ • ΰʔϧϐϯ →ɹ͚Μ͘͞(ͱΰʔϧϐϯ)
  34. Copyright (C) 2018 Yahoo Japan Corporation. All Rights Reserved. ஍ਤͱARΛγʔϜϨεʹซ༻͢Δ

    34 1λοϓͰ͙͢੾Γସ͑ΒΕΔΑ͏ʹ
  35. Copyright (C) 2018 Yahoo Japan Corporation. All Rights Reserved. 35

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