$30 off During Our Annual Pro Sale. View Details »

Hapticをカスタマイズしてみよう / ZOZO Tech Talk #6 Customize Haptic

M"e
May 16, 2022

Hapticをカスタマイズしてみよう / ZOZO Tech Talk #6 Customize Haptic

M"e

May 16, 2022
Tweet

More Decks by M"e

Other Decks in Programming

Transcript

  1. HapticΛΧελϚΠζͯ͠ΈΑ͏ גࣜձࣾZOZO ZOZOTOWN։ൃຊ෦ ZOZOTOWNΞϓϦ෦ iOSϒϩοΫ ԕ౻ ສཬ Copyright © ZOZO,

    Inc. 1
  2. © ZOZO, Inc. גࣜձࣾZOZO ZOZOTOWN։ൃຊ෦ ZOZOTOWNΞϓϦ෦ iOSϒϩοΫ ԕ౻ ສཬ Twitter:@re___you

    #ZOZOTOWN iOSΞϓϦ։ൃ୲౰👩💻 #վળ׆ಈ΋ͯ͠·͢🛠 #࠷ۙങͬͯΑ͔ͬͨ΋ͷ͸Apple Watch⌚ 2
  3. © ZOZO, Inc. 3 ࠓ೔ͷςʔϚ

  4. © ZOZO, Inc. 4 HapticΛΧελϚΠζͯ͠ΈΑ͏

  5. © ZOZO, Inc. 5 Apple WatchΛ͚͍ͭͯͨΒHapticͷόϦΤʔγϣϯʹؾ͍ͮͨ ☀ ىচΞϥʔϜ ಓҊ಺ͷࠨӈͷ ਐߦํ޲

    ϚεΫ࣌ͷ iPhoneͷղআ 🔓 ώμϦɾɾɾώμϦɾɾɾώμϦ ϛΪϛΪϛΪϛΪϛΪϛΪ Χνο ͱͱΜɺͱͱΜɺͱͱΜ
  6. © ZOZO, Inc. 6 Core Hapticsొ৔Ͱ
 Hapticͷදݱ޲্

  7. © ZOZO, Inc. 7 Core Hapticsʹ͍ͭͯ

  8. © ZOZO, Inc. 8 UIFeedbackGeneratorͱCore Haptics UIFeedbackGenerator Core Haptics •

    iOS 10 ~ • ܾΊΒΕͨHapticύλʔϯͷΈ
 ࠶ੜՄೳ • ZOZOTOWN΋͓ؾʹೖΓͱ͔Ͱ ࢖ͬͯΔ • iOS 13 ~ • HapticύλʔϯΛΧελϚΠζͰ͖Δ
  9. © ZOZO, Inc. 9 Core HapticsͷΧελϚΠζཁૉ ԻΛ࠶ੜ(.wav) ৮֮

  10. © ZOZO, Inc. 10 Core HapticsͷΧελϚΠζͱ͸ ৮֮ɺԻΛ૊Έ߹Θͤͯ 1ͭͷύλʔϯΛ࡞Δ͜ͱ

  11. © ZOZO, Inc. Core Hapticsͷ໾ׂ • Haptic ίϯςϯπͷ࡞੒ • CHHapticEvent:

    ৮֮ɺԻ • CHHapticEventParameter: CHHapticEventͷύϥϝʔλʔ • CHHapticPattern: CHHapticEventΛ૊Έ߹Θͤͨ΋ͷ • Hapticͷ࠶ੜ • CHHapticPlayer: CHHapticPatternΛ࠶ੜ • CHHapticEngine: CHHapticPlayerΛ࡞੒ 11
  12. © ZOZO, Inc. 12 Core Hapticsͷίϯςϯπߏ੒ https://developer.apple.com/videos/play/wwdc2019/520 WWDC 2019 520

    Introducing Core HapticsΑΓ
  13. © ZOZO, Inc. 13 Core HapticsͰઃఆͰ͖Δ2छྨͷ৮֮ τϯο ϰΡʔʔʔʔʔʔʔʔ https://developer.apple.com/videos/play/wwdc2019/810 Designing

    Audio-Haptic ExperiencesΑΓ
  14. © ZOZO, Inc. 14 Core HapticsͰઃఆͰ͖Δ2छྨͷ৮֮ τϯο ϰΡʔʔʔʔʔʔʔʔ - durationΛઃఆͰ͖Δ

    - duration͕0ͩͱHaptic͕࠶ੜͰ͖ͳ͍ - durationͷઃఆ͸ͳ͍ Designing Audio-Haptic ExperiencesΑΓ
  15. © ZOZO, Inc. TransientͷCHHapticEventParameter 15 Haptic Intensity Haptic Sharpness 0

    1 1 ߗ͍ײ͡ ॊΒ͔͍ײ͡
  16. © ZOZO, Inc. ContinuousͷCHHapticEventParameter 16 Haptic Intensity Haptic Sharpness ;ΜΘΓৼಈΛײ͡Δ

    ͸͖ͬΓͱৼಈΛײ͡Δ
  17. © ZOZO, Inc. ԻͷCHHapticEventParameter 17 • audioVolume • audioPitch •

    audioPan • audioBrightness
  18. © ZOZO, Inc. Hapticͷ࠶ੜ https://developer.apple.com/documentation/corehaptics/chhapticengine HapticίϯςϯπΛ࡞੒ CHHapticEngineͷυΩϡϝϯτΑΓ

  19. © ZOZO, Inc. 19 Engine४උ class ViewController: UIViewController { //

    ࠶ੜதʹ։์͞Εͳ͍Α͏ʹϝϯόม਺ʹ͢Δ private let engine: CHHapticEngine! override func viewDidLoad() { super.viewDidLoad() // engine͸init΍viewDidLoad()ͳͲͷૣ͍λΠϛϯάͰ࡞੒ engine = try! CHHapticEngine(audioSession: AVAudioSession.sharedInstance()) try! engine.start() } }
  20. © ZOZO, Inc. 20 Hapticίϯςϯπ࡞੒ // Transient Event let transientEvent

    = CHHapticEvent(eventType: .hapticTransient, parameters: [ CHHapticEventParameter(parameterID: .hapticIntensity, value: 0.3), CHHapticEventParameter(parameterID: .hapticSharpness, value: 0.3)], relativeTime: 0.2) // Audio Event let audioResourceID = try! engine.registerAudioResource(resourceURL) let audioEvent = CHHapticEvent(audioResourceID: audioResourceID, parameters: [CHHapticEventParameter(parameterID: .audioVolume, value: 0.3)], relativeTime: 0) do { // ΠϕϯτΛ΋ͱʹHapticύλʔϯΛ࡞੒ let pattern = try CHHapticPattern(events: [transientEvent, audioEvent], parameters: []) } catch let error {ɾɾɾ}
  21. © ZOZO, Inc. 21 Haptic࠶ੜ do { let pattern =

    try CHHapticPattern(events: [event, audioEvent], parameters: []) let player = try engine.makePlayer(with: pattern) try player?.start(atTime: CHHapticTimeImmediate) } catch let error {ɾɾɾ}
  22. © ZOZO, Inc. 22

  23. © ZOZO, Inc. 23 ΧελϚΠζΛߟ͑ͯΈΔ

  24. © ZOZO, Inc. 24 ʮ঎඼ΛΧʔτʹೖΕΔʯ ࣌Λߟ͑ͯΈΔ ϦϦʔε͸͠ͳ͍Α ͋͘·Ͱ࣮ݧͶ 👆

  25. © ZOZO, Inc. 25 ʮ঎඼ΛΧʔτʹೖΕΔʯ ࣌Λߟ͑ͯΈΔ ϦϦʔε͸͠ͳ͍Α ͋͘·Ͱ࣮ݧͶ 👆

  26. © ZOZO, Inc. 26 Designing Audio-Haptic Experiences https://developer.apple.com/videos/play/wwdc2019/810/

  27. © ZOZO, Inc. 27 Appleͷࣄྫ https://developer.apple.com/videos/play/wwdc2019/810/

  28. © ZOZO, Inc. 28 Appleͷࣄྫ Apple Watch ཉ͍͠ɾɾɾ https://developer.apple.com/videos/play/wwdc2019/810/

  29. © ZOZO, Inc. 29 HapticsΛઃܭ͢Δͷʹॏཁͳ3ͭͷ͜ͱ ௐ࿨ੑ ҼՌؔ܎ ࣮༻ੑ

  30. © ZOZO, Inc. 30 ҼՌؔ܎ ඞཁͳ͜ͱ • ԿʹΑͬͯࣄ৅͕ى͖͔ͨ໌֬ʹ͢Δ ͳͥඞཁͳͷ͔ •

    ҼՌؔ܎͕߹Θͳ͍ͱҧ࿨ײΛײ͡Δ
  31. © ZOZO, Inc. 31 ҼՌؔ܎ Designing Audio-Haptic ExperiencesΑΓ ྫ) αοΧʔϘʔϧΛऽͬͨͱ͖ͷԻ͕ҧ͏ͱҧ࿨ײ͕͋Δ

    https://developer.apple.com/videos/play/wwdc2019/810/
  32. © ZOZO, Inc. 32 ௐ࿨ੑ ඞཁͳ͜ͱ • ࢹ֮(Ξχϝʔγϣϯ)ɺௌ֮(Ի)ɺ৮֮ΛҰகͤ͞Δ ͳͥඞཁͳͷ͔ •

    ௐ࿨่͕ΕΔͱମݧ͕ଛͳΘΕΔ • ྫ) αοΧʔϘʔϧΛऽΔલʹ৮͕֮ൃੜ͢Δ
  33. © ZOZO, Inc. 33 ࣮༻ੑ ඞཁͳ͜ͱ • ΞϓϦέʔγϣϯͷମݧ͕࣮֬ʹ޲্͢ΔՕॴʹಋೖ͢Δ ͳͥඞཁͳͷ͔ •

    HapticΛ௥Ճ͗͢͠Δͱཁ఺͕բΉ
  34. © ZOZO, Inc. 34 ·ͣΧελϚΠζΛߟ͑Δ্Ͱେࣄͳ͜ͱ https://developer.apple.com/videos/play/wwdc2019/810 ৮֮ɺԻ͕ ͦΕΒ͍͜͠ͱ

  35. © ZOZO, Inc. 35 ෰ΛΧʔτʹೖΕΔ࣌ͷ ৮֮ͷͦΕΒ͠͞ͱ͸ʁ

  36. © ZOZO, Inc. 36 https://developer.apple.com/videos/play/wwdc2019/810 ϙϯ ৮͕֮ͦΕΒ͍͠ͱ͸ʁ

  37. © ZOZO, Inc. 37 https://developer.apple.com/videos/play/wwdc2019/810 ϙϯ ৮͕֮ͦΕΒ͍͠ͱ͸ʁ ୯ൃతͳ৮͕֮1౓

  38. © ZOZO, Inc. 38 https://developer.apple.com/videos/play/wwdc2019/810 ৮͕֮ͦΕΒ͍͠ͱ͸ʁ βοβοβο

  39. © ZOZO, Inc. 39 https://developer.apple.com/videos/play/wwdc2019/810 ৮͕֮ͦΕΒ͍͠ͱ͸ʁ βοβοβο ܧଓతͳ৮֮ or ୯ൃతͳ৮͕֮ෳ਺ճ

  40. © ZOZO, Inc. 40 https://developer.apple.com/videos/play/wwdc2019/810 ৮͕֮ͦΕΒ͍͠ͱ͸ʁ Ψγϟʔϯ ͺΓʔΜ ऑ͍ ~

    த͘Β͍ͷ৮֮ ڧ͍৮֮
  41. © ZOZO, Inc. 41 https://developer.apple.com/videos/play/wwdc2019/810 ৮͕֮ͦΕΒ͍͠ͱ͸ʁ ΍ΘΒ͔͍৮֮ Ӷ͍৮֮ ΅;ͬ Ψπϯ

  42. © ZOZO, Inc. 42 ৮֮͸Ի΍ࡐ࣭ͱؔ࿈͕͋Γͦ͏

  43. © ZOZO, Inc. 43 ͕͜͜෼͔Ε͹৮֮Λ ܾΊ΍͘͢Γͦ͏ ৮֮͸Ի΍ࡐ࣭ͱؔ࿈͕͋Γͦ͏

  44. © ZOZO, Inc. 44 ෰ΛΧʔτʹೖΕΔ࣌͸ ͲΜͳԻ͕͢ΔͩΖ͏͔ʁ

  45. © ZOZO, Inc. 45 • ାʹٵ͍ࠐ·ΕΔγϡοͬͯԻ • ϋϯΨʔˠ෰ˠΧʔτ(͔͝?)ɺʹ͋ͨΔͱ͢Ε͹ɺΰοͱ͔ίϯ ʹͳΔ •

    Ϙϑοͯײ͡ • ෍ͷ͜͢ΕΔԻ͔ͳ͋ʮγϡοʯͬͯײ͡ • ෍͕མͪͨԻ͔ͳ • ϙϑͬײʢϘϑΑΓϙϑ೿ʣ • ચ୕ΧΰʹҥྨΛೖΕΔΑ͏ͳʮόαοʯͱ͍͏ײ͡ νʔϜϝϯόʔʹҙݟΛฉ͍ͯΈͨ
  46. © ZOZO, Inc. 46 • ାʹٵ͍ࠐ·ΕΔγϡοͬͯԻ • ϋϯΨʔˠ෰ˠΧʔτ(͔͝?)ɺʹ͋ͨΔͱ͢Ε͹ɺΰοͱ͔ίϯ ʹͳΔ •

    Ϙϑοͯײ͡ • ෍ͷ͜͢ΕΔԻ͔ͳ͋ʮγϡοʯͬͯײ͡ • ෍͕མͪͨԻ͔ͳ • ϙϑͬײʢϘϑΑΓϙϑ೿ʣ • ચ୕ΧΰʹҥྨΛೖΕΔΑ͏ͳʮόαοʯͱ͍͏ײ͡ νʔϜϝϯόʔʹҙݟΛฉ͍ͯΈͨ
  47. © ZOZO, Inc. 47 ୯ൃతͳ৮͕֮߹͍ͦ͏

  48. © ZOZO, Inc. 48 ΧʔτʹೖΕΔԻΛ࠶ݱͯ͠ΈΑ͏ • ϋϯΨʔʹ͔͔ͬͨγϟπ • ΧʔτʹೖΕΔಈ࡞ ؀ڥ

  49. © ZOZO, Inc. 49 ΧʔτʹೖΕΔԻΛ࠶ݱͯ͠ΈΑ͏ • ϋϯΨʔʹ͔͔ͬͨγϟπ • ΧʔτʹೖΕΔಈ࡞ ؀ڥ

    γϡοɺΧϯʁ Χϯʁ
  50. © ZOZO, Inc. 50 ԻΛݟͯΈΑ͏

  51. © ZOZO, Inc. 51

  52. © ZOZO, Inc. 52 • 2ͭͷԻ͕ͳ͍ͬͯΔ • খ͍͞Իͱେ͖ͳԻ • ҥࡲΕˠϋϯΨʔ

    ࿥Իͨ͠Իͷ೾ܗ
  53. © ZOZO, Inc. 53 ԻΛࢀߟʹߟ͑Δͱ • ୯ൃతͳ৮֮ • খ͘͞ॊΒ͔͍৮֮ →

    1ճ໨ΑΓ΋େ͖͘Ӷརͳ৮֮
  54. © ZOZO, Inc. 54

  55. © ZOZO, Inc. 55 Χʔτʹ෰͕ೖͬͨ ײ֮ͬΆ͍ؾ͕͢Δ

  56. © ZOZO, Inc. 56 ৮֮Λߟ͑Δͷʹ Ի͸ඇৗʹࢀߟʹͳΔ

  57. © ZOZO, Inc. 57 ·ͱΊ • ΧελϚΠζʹ͸Core HapticsΛ࢖͏ • Hapticͷઃܭʹ͸ʮҼՌؔ܎ʯʮௐ࿨ੑʯʮ࣮༻ੑʯ͕ॏཁ

    • ৮֮͸ԻΛࢀߟʹ͢ΔͱܾΊ΍͍͢
  58. © ZOZO, Inc. 58 HapticΛΧελϚΠζ͠Α͏ʂ

  59. None
  60. None
  61. None
  62. None
  63. None