Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 | 49x 6x 1x 5x 5x 3x 2x 2x 3x 24x 21x 3x 3x 3x 8x 1x 7x 7x 7x 3x 1x 2x 2x 2x 4x 1x 3x 3x 3x 3x 4x 4x 9x 9x 7x 6x 6x 2x 4x 4x | /**
* Haptic Feedback System for Combat UI
*
* Provides tactile feedback for mobile devices during combat interactions
* such as guard activation, stance changes, and guard breaks.
*
* Uses the Vibration API with fallback for unsupported devices.
*
* @module components/shared/three/indicators/HapticFeedback
* @category Combat UI
* @korean 햅틱피드백
*/
/**
* Haptic pattern type
* @korean 햅틱패턴타입
*/
export type HapticPattern = number | number[];
/**
* Check if haptic feedback is supported on this device
*
* @returns True if the Vibration API is available
*
* @example
* ```typescript
* if (isHapticSupported()) {
* triggerGuardHaptic('activate');
* }
* ```
*
* @public
* @korean 햅틱지원여부
*/
export function isHapticSupported(): boolean {
return (
typeof navigator !== "undefined" &&
"vibrate" in navigator &&
typeof navigator.vibrate === "function"
);
}
/**
* Trigger haptic feedback for guard activation or break
*
* Provides tactile feedback when a player activates their guard
* or when their guard is broken by an opponent.
*
* Patterns:
* - **activate**: Light single vibration (50ms) for guard activation
* - **break**: Strong triple-pulse pattern (100ms, 50ms pause, 100ms) for guard break
*
* @param type - Type of guard haptic feedback
*
* @example
* ```typescript
* // When player activates guard
* triggerGuardHaptic('activate');
*
* // When guard is broken
* triggerGuardHaptic('break');
* ```
*
* @public
* @korean 방어햅틱트리거
*/
export function triggerGuardHaptic(type: "activate" | "break"): void {
if (!isHapticSupported()) {
return;
}
try {
if (type === "activate") {
// Light haptic - single short vibration
navigator.vibrate(50);
E} else if (type === "break") {
// Strong haptic - triple pulse pattern for impact
// Pattern: vibrate 100ms, pause 50ms, vibrate 100ms
navigator.vibrate([100, 50, 100]);
}
} catch (error) {
// Silently fail if vibration fails
console.warn("Haptic feedback failed:", error);
}
}
/**
* Trigger haptic feedback for stance change
*
* Provides medium-strength tactile feedback when a player transitions
* between trigram stances (건→태→리→진→손→감→간→곤).
*
* @example
* ```typescript
* // When stance changes from Geon to Tae
* triggerStanceChangeHaptic();
* ```
*
* @public
* @korean 자세변경햅틱트리거
*/
export function triggerStanceChangeHaptic(): void {
if (!isHapticSupported()) {
return;
}
try {
// Medium haptic - single medium vibration
navigator.vibrate(75);
} catch (error) {
// Silently fail if vibration fails
console.warn("Haptic feedback failed:", error);
}
}
/**
* Trigger custom haptic pattern
*
* Allows for custom vibration patterns using the Vibration API.
* Can specify either a single duration or a pattern array.
*
* Pattern arrays alternate between vibration and pause:
* - [200, 100, 200] = vibrate 200ms, pause 100ms, vibrate 200ms
*
* @param pattern - Vibration duration in ms or pattern array
*
* @example
* ```typescript
* // Single vibration
* triggerCustomHaptic(200);
*
* // Complex pattern
* triggerCustomHaptic([100, 50, 100, 50, 100]);
* ```
*
* @public
* @korean 사용자정의햅틱트리거
*/
export function triggerCustomHaptic(pattern: HapticPattern): void {
if (!isHapticSupported()) {
return;
}
try {
navigator.vibrate(pattern);
} catch (error) {
// Silently fail if vibration fails
console.warn("Haptic feedback failed:", error);
}
}
/**
* Stop all haptic feedback
*
* Immediately stops any ongoing vibration. Useful for interrupting
* long or repeated patterns.
*
* @example
* ```typescript
* // Stop any ongoing haptic feedback
* stopHaptic();
* ```
*
* @public
* @korean 햅틱중지
*/
export function stopHaptic(): void {
if (!isHapticSupported()) {
return;
}
try {
// Passing 0 or empty array stops vibration
navigator.vibrate(0);
} catch (error) {
// Silently fail if vibration stop fails
console.warn("Haptic stop failed:", error);
}
}
/**
* Check if device is mobile
*
* Simple heuristic to detect mobile devices based on screen size,
* user agent, and touch support.
*
* @returns True if device is likely mobile
*
* @example
* ```typescript
* if (isMobileDevice() && isHapticSupported()) {
* triggerStanceChangeHaptic();
* }
* ```
*
* @public
* @korean 모바일기기여부
*/
export function isMobileDevice(): boolean {
if (typeof window === "undefined" || typeof navigator === "undefined") {
return false;
}
// Check screen size (mobile typically < 768px)
const isMobileSize = window.innerWidth < 768;
// Check user agent for mobile indicators
const mobileKeywords = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i;
const isMobileUA = mobileKeywords.test(navigator.userAgent);
// Check for touch support (modern browsers)
const hasTouch =
"ontouchstart" in window ||
navigator.maxTouchPoints > 0;
// Device is mobile if it meets size OR user agent criteria AND has touch
return (isMobileSize || isMobileUA) && hasTouch;
}
/**
* Haptic feedback settings
*
* Allows for global configuration of haptic feedback intensity
* and enable/disable state.
*
* @korean 햅틱설정
*/
export interface HapticSettings {
/** Whether haptic feedback is enabled */
readonly enabled: boolean;
/** Intensity multiplier (0.0 to 1.0) */
readonly intensity: number;
}
/**
* Default haptic settings
* @korean 기본햅틱설정
*/
export const DEFAULT_HAPTIC_SETTINGS: HapticSettings = {
enabled: true,
intensity: 1.0,
};
/**
* Apply intensity modifier to haptic pattern
*
* Scales vibration durations based on intensity setting.
*
* @param pattern - Original haptic pattern
* @param intensity - Intensity multiplier (0.0 to 1.0)
* @returns Scaled haptic pattern
*
* @internal
* @korean 햅틱강도적용
*/
export function applyIntensity(
pattern: HapticPattern,
intensity: number
): HapticPattern {
const clampedIntensity = Math.max(0, Math.min(1, intensity));
if (typeof pattern === "number") {
return Math.round(pattern * clampedIntensity);
}
return pattern.map((duration) => Math.round(duration * clampedIntensity));
}
/**
* Trigger haptic with settings
*
* Wrapper function that applies haptic settings before triggering.
*
* @param pattern - Haptic pattern to trigger
* @param settings - Haptic settings to apply
*
* @example
* ```typescript
* const settings = { enabled: true, intensity: 0.7 };
* triggerWithSettings(100, settings); // Triggers 70ms vibration
* ```
*
* @public
* @korean 설정포함햅틱트리거
*/
export function triggerWithSettings(
pattern: HapticPattern,
settings: HapticSettings = DEFAULT_HAPTIC_SETTINGS
): void {
if (!settings.enabled || !isHapticSupported()) {
return;
}
const scaledPattern = applyIntensity(pattern, settings.intensity);
triggerCustomHaptic(scaledPattern);
}
|