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

arkit+animoji

mcz9mm
September 25, 2017
59

 arkit+animoji

mcz9mm

September 25, 2017
Tweet

Transcript

  1. A R K I T S W I F T

    S T U D Y
  2. A J E N D A • ARKitͰͰ͖Δ͜ͱ • SceneViewͱͷؔΘΓ߹͍

    • ݱ࣮ੈքͰͷ࠲ඪ • ݱ࣮ੈքͰͷεέʔϧ • Animoji
  3. ARKitͰͰ͖Δ͜ͱ • ϙδγϣϯτϥοΩϯά • ฏ໘ݕग़ • ݱ࣮ੈքͷ࠲ඪݕग़ • HitTest •

    Etc..
  4. SceneViewͱͷؔΘΓ߹͍ • 3D(Scenekit)ʴAR = ARSCNView ͷΑ͏ͳΠϝʔδ • ARͷಛ௃Ͱ͋Δݱ࣮ੈքͰͷฏ໘ͷೝࣝͱɺ࠲ඪΛ༻͍ͯSceneViewʹNode(ς Ωετ΍ΦϒδΣΫτ)Λ഑ஔ͢Δ •

    Χϝϥͷػೳͱಉ༷ʹsessionʹΑΓ؅ཧ͞Ε͓ͯΓɺsession͕੾ΕͨΓ͢Δͱೝ ͕ࣝͰ͖ͳ͘ͳΔ • AR্ۭؒʹ഑ஔ͢ΔΦϒδΣΫτ͸جຊతʹSceneKitΛ༻͍ͯੜ੒Λߦ͏
  5. ݱ࣮ੈքͰͷ࠲ඪ • ARSceneViewͰhitTestΛߦ͏
 hitTest: func hitTest(_ point: CGPoint, types: ARHitTestResult.ResultType)

    -> [ARHitTestResult] • ARSceneViewͷը໘্ʹදࣔ͞Ε͍ͯΔը૾͕࣮ࡍʹݱ࣮ੈքͰͲͷϙΠϯτʹ ౰ͨΔͷ͔൑ఆΛߦͬͯ͘ΕΔ • ͨͩɺೝࣝͨ͠ฏ໘ʹରͯ͠hitTestΛߦ͏ͷͰ·ͣ͸ೝࣝΛ͢Δඞཁ͕͋Δ • Returnʹ͸ೝࣝͨ͠ฏ໘ʹର͢Δ࠲ඪ͕݁Ռͱͯ͠ฦͬͯ͘Δ • SCNVector3ͱݺ͹ΕΔ̏࣍ݩͷ݁Ռͱͯ͠࠲ඪΛऔಘ͢Δ͜ͱ͕Ͱ͖Δ
  6. SCNVector3 var x: Float The first component in the vector.

    var y: Float The second component in the vector. var z: Float The third component in the vector. • ̎࣍ݩͰѻ͏ࡍ͸X࣠ͱZ࣠ͷΈΛར༻͢Δͱྑ͍ Z X Y
  7. ݱ࣮ੈքͰͷεέʔϧ • ࠲ඪͷεέʔϧ͸શͯϝʔτϧ׵ࢉ͞Ε͍ͯΔ? // ശΛੜ੒ let cube = SCNBox(width: 0.1,

    height: 0.1, length: 0.1, chamferRadius: 0) let cubeNode = SCNNode(geometry: cube) • 0.1 ͩͱ ݱ࣮ੈքͰͷ10cm ʹ૬౰͢Δ • ͍ͭ΋ͷΑ͏ʹview্ʹද͍ࣔͯ͠ΔαΠζͰ͸ඇৗʹେ͖ͳαΠζʹͳͬͯ͠ ·͏ͷͰ஫ҙ
  8. A N I M O J I

  9. W H AT • iPhone XͰͷCameraΛ༻͍ͯDepth(ਂ౓)Λݕग़ • ฏ໘͚ͩͰͳ͘إͷҐஔͱ޲͖Λݕग़͢Δ • ೝࣝͰ͖Δͷ͸̍ਓͷΈ(ෳ਺Χϝϥ಺ʹ͍ࣸͬͯΔ৔

    ߹͸࠷΋ਫ਼౓͕ྑ͍΋ͷ͕ݕग़͞ΕΔ)