Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/developeracademy-postech/2024-nc2-m23-corehaptics
https://github.com/developeracademy-postech/2024-nc2-m23-corehaptics
Last synced: about 13 hours ago
JSON representation
- Host: GitHub
- URL: https://github.com/developeracademy-postech/2024-nc2-m23-corehaptics
- Owner: DeveloperAcademy-POSTECH
- Created: 2024-06-17T02:39:08.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2024-06-20T00:34:18.000Z (5 months ago)
- Last Synced: 2024-06-21T10:25:34.852Z (5 months ago)
- Language: Swift
- Size: 153 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 2024-NC2-M0-AugmentedReality
## π« Pair| μ΄λ¦ | μ΄μ§(μμ΄μ§) | λ΄μ€μ±(κΉμ€μ±) |
| ---- | ---- | ---- |
| **νλ‘ν μ¬μ§** | | |
| **μν ** | λμμΈ | ν ν¬ |
| **GitHub** | [@ez](https://github.com/izzy0426) | [@newJunsung](https://github.com/newJunsung) |
## π₯ Youtube Link
(μΆν λ§λ€μ΄μ§ μ νλΈ λ§ν¬ μΆκ°)## π‘ About Core Haptics
(ν΄λΉ κΈ°μ μ λν μ‘°μ¬ λ΄μ© μ 리)- μ΄λ²€νΈλ₯Ό κΈ°λ°μΌλ‘ ν μ€λμ€ / ν ν± λλλ§ API
- κΈ°λ³Έ ν ν±μ΄ μ¬λ¬ μΈν°νμ΄μ€ μμμ μλμΌλ‘ λ€μ΄κ° μμ§λ§, Core Haptics λ₯Ό μ¬μ©νλ©΄ κΈ°λ³Έμ μΈ ν¨ν΄μ λμ΄μ μ΄κ°(μ§λ)κ³Ό μ리 νΌλλ°±κ³Ό κ°μΒ **ν ν±μ 컀μ€ν **ν΄μ κΈ°λ₯μ νμ₯ν μ μλ€.
- ν ν±μ μΌκ΄μ± μκ² μ¬μ©ν΄μΌνλ©°, κ³Όλν μ¬μ©μ μ§μνλ€.
- μ¬μ©μμ λͺ°μ λλ₯Ό λμ¬μ€λ€.
- μ§μνλ νλμ¨μ΄ μΈμ§ νμΈμ΄ νμνλ€.- **CoreHaptics**μλ μ리μ μ§λμ μ€νμν¬ μ μλ κ²μ μκ² λ¨.
- `CHHapticEngineμ` μ΄μ©ν΄μ μ리 λ° μ§λμ κ΄λ¦¬νλ νλμ¨μ΄λ₯Ό μ μ΄ν μ μλ€λ κ²μ μκ² λ¨.
- `CHHapticPattern` μ리 λ° μ§λμ λν ν¨ν΄μ λ§λ€ μ μλ€λ κ²μ μκ² λ¨.
- `CHHapticPatternPlayer`μ μ΄μ©νμ¬ ν ν±μ λν ν¨ν΄μ μ¬μν μ μλ€λ κ²μ μκ² λ¨.## π― What we focus on?
보쑰μ μΈ μλ¨μ΄ μλ ν ν± μ체μμ μ¬λ―Έλ₯Ό μ°Ύκ³ μ νμ. **CoreHaptics**μ μ§λκ³Ό μ리 μ€, μ§λμ μ€μ μ λκΈ°λ‘ ν¨.
`CHHapticEventParameter`μ μ΄μ©νμ¬ νΉμ intensity, sharpness, durationμ κ°μ§ μ§λ μ΄λ²€νΈλ₯Ό λ§λ€κ³ , μ΄λ₯Ό `CHHapticPatternPlayerλ‘` λ§λ€κ³ μ€νμν€κ³ μ ν¨.
μ¬μ©μκ° λλ€ν(λλ μλλ°©μ΄ λ§λ€μ΄λΈ) μ§λμ λ§μΆλ©° μ¬λ―Έλ₯Ό λλΌκ² νκ³ μ ν¨.## πΌ Use Case
- CoreHaptics κΈ°μ μ μ΄μ©νμ¬ μ¬μ¬ν λ μ§λμ λ§μλλ‘ μ‘°μ νλ©° κ°μ§κ³ λ μ μκ² νλ μ±> π‘ **μ λμ§κ°**
- μμλ‘ μ£Όμ΄μ§λ μ§λμ intensityμ sharpness, durationμ μ‘°μ μ ν΅ν΄ λ§μΆλ€.
- intensityμ sharpness, durationμ μ‘°μ μΌλ‘ μλ‘μ΄ μ§λμ λ§λ€κ³ 곡μ νλ€.
- μΉκ΅¬κ° 곡μ ν μ§λμ intensityμ sharpness, durationμ μ‘°μ μΌλ‘ λ§μΆλ€.## πΌοΈ Prototype
(νλ‘ν νμ κ³Ό μ€λͺ μΆκ°)
![nc2 αα ³α α ©αα ©αα ‘αα ΅αΈ](https://github.com/DeveloperAcademy-POSTECH/2024-NC2-M23-CoreHaptics/assets/107932188/f58471cf-4bb3-4130-a233-c8aae348eb00)
1. **1μΈ λͺ¨λ**
1. μ»΄ν¨ν°κ° λλ€νκ² μ 곡νλ μ§λ λ£κΈ°
2. μ¬μ©μκ° μ»€μ€ν ν μ§λ λ£κΈ°
3. Intensity, Sharpeness, Duration μ€μ νκΈ°
4. 컀μ€ν ν μ§λμ μ μΆν ν κ²°κ³Ό νμΈνκΈ°
5. μ€ν¨ν κ²½μ° μ¬μλνκΈ°
2. **2μΈ λͺ¨λ**
1. νμ΄μ€νμμ ν΅ν΄ SharePlay μ°κ²°νκΈ°
2. Intensity, Sharpeness, Durationμ μ‘°μ νμ¬ λμ μ§λ 컀μ€ν νκΈ°
3. λμ μ§λμ μ΄λ¦μ λ°κΎΈκ³ μλμκ² κ³΅μ νκΈ°
4. μλκ° κ³΅μ ν μ§λμ λ°κ³ λ£κΈ°
5. Intensity, Sharpeness, Durationμ μ‘°μ νμ¬ μλμ μ§λ λ§μΆκΈ°
6. 컀μ€ν ν μ§λμ μ μΆν ν κ²°κ³Ό νμΈνκΈ°
7. μ€ν¨ν κ²½μ° μ¬μλνκΈ°## π±μ± μν
https://github.com/DeveloperAcademy-POSTECH/2024-NC2-M23-CoreHaptics/assets/107932188/0c2064a8-386a-40fa-b7be-92af2222b512
## π οΈ About Code
- ν ν±μ μ§μνμ§ μλ κΈ°μ’ λ±μ μ΄μ λ‘ `HapticManager`λ₯Ό λ§λ€ μ μλ μν©μ΄ λλ©΄, `nil`μ λ°ννκ²λ ν¨.
```swift
// HapticManager.swiftinit?() {
do {
let capablitity = CHHapticEngine.capabilitiesForHardware()
if capablitity.supportsHaptics {
let engine = try CHHapticEngine()
self.engine = engine
try engine.start()
print("haptic manager return.")
} else {
print("haptic manager nil.")
return nil
}
} catch {
print(error)
return nil
}
}
```- νλ‘ν μ½μ 맀κ°λ³μλ‘ λ°μμ λ€μν νμ μ λ°μ μ μκ² ν¨. (λ¬Όλ‘ , ν΄λΉ νλ‘ν μ½μ μ±νν΄μΌ ν¨.)
```swift
// HapticManager.swiftfunc haptic(
type: CHHapticEvent.EventType,
intensity: Float,
sharpness: Float,
duration: Float
) throws {
stop()
let eventParams = [
CHHapticEventParameter(parameterID: .hapticIntensity, value: intensity),
CHHapticEventParameter(parameterID: .hapticSharpness, value: sharpness)
]
let event = CHHapticEvent(eventType: .hapticContinuous, parameters: eventParams, relativeTime: 0, duration: TimeInterval(duration))
let pattern = try CHHapticPattern(events: [event], parameters: [])player = try engine.makePlayer(with: pattern)
start()
}func haptic(for param: HapticEventParameterable) throws {
try haptic(
type: .hapticContinuous,
intensity: param.intensity, sharpness: param.sharpness,
duration: param.duration
)
}
```### ν΄λμ€ λ€μ΄μ΄κ·Έλ¨
```mermaid
classDiagramclass ContentViewModel {
+ hapticsPublisher: AnyPublisher
- bind()
+ onAppear()
+ playHaptic()
+ resetHaptic()
+ send()
+ startSharing()
+ checkSubmit()
+ changeMode()
}class HapticManager {
- engine: CHHapticEngine
- player: CHHapticPatternPlayer?
+ haptic()
+ start()
+ stop()
}class GameTogetherManager {
+ session: GroupSession?
- messenger: GroupSessionMessenger?
+ hapticPublisher: AnyPublisher+ startSharing()
+ setSessions()
+ send()
- configureSession
- handle()
}ContentView --|> ContentViewModel
ContentViewModel --|> HapticManager
ContentViewModel --|> GameTogetherManager
```