blacktrigram 0.7.8 โ 0.7.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ARCHITECTURE.md +2404 -0
- package/COMBAT_ARCHITECTURE.md +3322 -0
- package/CONTROLS.md +639 -0
- package/CRA-ASSESSMENT.md +508 -0
- package/DATA_MODEL.md +675 -0
- package/ISMS_REFERENCE_MAPPING.md +513 -0
- package/SECURITY_ARCHITECTURE.md +1160 -0
- package/THREAT_MODEL.md +1163 -0
- package/lib/components/screens/intro/IntroScreen3D.js +1 -1
- package/lib/components/shared/ui/SplashScreen.js +2 -2
- package/lib/data/archetypeClothing.js +1 -1
- package/lib/data/archetypePhysicalAttributes.js +158 -1
- package/lib/data/archetypePhysicalAttributes.js.map +1 -1
- package/lib/data/index.d.ts +14 -0
- package/lib/data/index.d.ts.map +1 -0
- package/lib/data/index.js +43 -0
- package/lib/data/index.js.map +1 -0
- package/lib/data/techniqueMappings.js +47 -2
- package/lib/data/techniqueMappings.js.map +1 -1
- package/lib/data/techniques.js +1 -1
- package/lib/hooks/index.d.ts +29 -0
- package/lib/hooks/index.d.ts.map +1 -0
- package/lib/hooks/index.js +53 -0
- package/lib/hooks/index.js.map +1 -0
- package/lib/hooks/useDebounce.js +52 -0
- package/lib/hooks/useDebounce.js.map +1 -0
- package/lib/hooks/usePauseMenu.js +60 -0
- package/lib/hooks/usePauseMenu.js.map +1 -0
- package/lib/hooks/useResponsiveLayout.js +160 -0
- package/lib/hooks/useResponsiveLayout.js.map +1 -0
- package/lib/hooks/useWebGLContextLossHandler.js +36 -1
- package/lib/hooks/useWebGLContextLossHandler.js.map +1 -1
- package/lib/hooks/useWindowSize.js +19 -1
- package/lib/hooks/useWindowSize.js.map +1 -1
- package/lib/index.d.ts +2 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +3 -1
- package/package.json +19 -3
package/ARCHITECTURE.md
ADDED
|
@@ -0,0 +1,2404 @@
|
|
|
1
|
+
# ๐ฎ Black Trigram (ํ๊ด) โ Technical Architecture (Q1 2026)
|
|
2
|
+
|
|
3
|
+
**Last Updated**: March 2026
|
|
4
|
+
**Architecture Version**: 2.0 (Three.js Complete Migration)
|
|
5
|
+
**Status**: Beta Stage (8.4/10) - Combat Realism Production-Ready
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## ๐ Architecture Documentation Map
|
|
10
|
+
|
|
11
|
+
| Document | Focus | Description |
|
|
12
|
+
| --------------------------------------------------------------------- | ---------------- | ---------------------------------------------------------------------------------------------------------- |
|
|
13
|
+
| **[๐ System Context](#-system-context)** | C4 Model | High-level view showing actors (Player, CDNs) and the entirely front-end application |
|
|
14
|
+
| **[๐ข Container View](#-container-view)** | C4 Model | Frontend-only architecture: UI Layer, Game Logic, Three.js Renderer, Animation System, State Management |
|
|
15
|
+
| **[๐งฉ Component View](#-component-view)** | C4 Model | Detailed breakdown: Combat System, Trigram System (8 stances), Vital Point System (70 points), Skeletal Animation (28 bones) |
|
|
16
|
+
| **[๐ง File Structure](#-file-structure-q1-2026)** | Organization | Q1 2026 project structure with systems/, components/, data/, types/ layout |
|
|
17
|
+
| **[๐ Combat Flow Sequence](#-combat-flow-sequence)** | Sequence Diagram | Input โ Trigram โ Vital Point โ Damage โ Three.js rendering with skeletal animation |
|
|
18
|
+
| **[๐ฌ Skeletal Animation](#-skeletal-animation-architecture)** | Animation System | 28-bone hierarchy, 7 hand poses, muscle tension visualization |
|
|
19
|
+
| **[โก Performance Architecture](#-performance-architecture-q1-2026)** | Performance | Three.js optimization, 60fps targets, instancing, LOD, benchmarks |
|
|
20
|
+
| **[๐ SWOT Analysis](#-swot-analysis)** | Strategy | Q1 2026 status: Strengths (70/70 vital points), Weaknesses (67% combat realism), Opportunities, Threats |
|
|
21
|
+
| **[๐ Game Status Report](game-status.md)** | Current Progress | Comprehensive status (current test coverage and metrics from docs/coverage/coverage-summary.json, 8/12 combat realism systems, 8/8 trigram stances) |
|
|
22
|
+
| **[๐ฎ Future Architecture](FUTURE_ARCHITECTURE.md)** | Roadmap | Q2 2026+ evolution: Combat realism completion, VR/AR integration, advanced features |
|
|
23
|
+
| **[๐ฏ Core Game Concepts](#-core-game-concepts)** | Game Design | Player archetypes (5), trigram system (8), resources & mechanics |
|
|
24
|
+
| **[๐๏ธ Architecture Concepts](#-architecture-concepts)** | Technical Design | Mindmap of system architecture layers and components |
|
|
25
|
+
| **[๐ UX Flow](#-ux-flow)** | User Experience | User journey through screens and interactions |
|
|
26
|
+
| **[๐ Combat Mechanics](#-combat-mechanics--data-relationships)** | Game Mechanics | Detailed combat system data flow and relationships |
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## ๐ System Context
|
|
31
|
+
|
|
32
|
+
```mermaid
|
|
33
|
+
C4Context
|
|
34
|
+
title System Context - Black Trigram (ํ๊ด) Web Application (Q1 2026)
|
|
35
|
+
|
|
36
|
+
Person(player, "๐งโ๐คโ๐ง Martial Arts Student", "Learns Korean vital point targeting with 70 anatomical points and 28-bone skeletal animation")
|
|
37
|
+
Person(instructor, "๐ฅ Martial Arts Instructor", "Uses for teaching traditional Korean techniques and I Ching philosophy")
|
|
38
|
+
|
|
39
|
+
System(blackTrigram, "๐ Black Trigram (ํ๊ด)", "Korean martial arts combat simulator with 70 vital points, 8 trigram stances, 28-bone skeletal animation, 60fps performance")
|
|
40
|
+
|
|
41
|
+
System_Ext(cloudfront, "โ๏ธ AWS CloudFront CDN", "Global content delivery with 400+ edge locations, DDoS protection")
|
|
42
|
+
System_Ext(s3Storage, "๐พ AWS S3 Multi-Region", "Primary (us-east-1) + backup region storage with versioning")
|
|
43
|
+
System_Ext(route53, "๐ก AWS Route53", "DNS with DNSSEC, health checks, automatic DR failover")
|
|
44
|
+
System_Ext(ghPages, "๐ GitHub Pages DR", "Disaster recovery hosting with independent infrastructure")
|
|
45
|
+
System_Ext(culturalDB, "๐๏ธ Korean Cultural Database", "Authentic martial arts terminology, I Ching philosophy, TCM meridians")
|
|
46
|
+
|
|
47
|
+
Rel(player, route53, "Resolves DNS", "DNS/DNSSEC")
|
|
48
|
+
Rel(route53, cloudfront, "Primary route", "DNS")
|
|
49
|
+
Rel(route53, ghPages, "DR failover", "DNS")
|
|
50
|
+
Rel(player, blackTrigram, "Practices combat techniques", "HTTPS/TLS 1.3 via CloudFront CDN")
|
|
51
|
+
Rel(instructor, blackTrigram, "Demonstrates vital points", "HTTPS/TLS 1.3 via CloudFront CDN")
|
|
52
|
+
Rel(blackTrigram, culturalDB, "References authentic terminology", "HTTPS/JSON")
|
|
53
|
+
|
|
54
|
+
UpdateLayoutConfig($c4ShapeInRow="2", $c4BoundaryInRow="1")
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
> **Legend (Q1 2026)**
|
|
58
|
+
>
|
|
59
|
+
> - ๐งโ๐คโ๐ง **Player**: End-user interacting with Black Trigram through desktop (60fps) or mobile (30-45fps) browser.
|
|
60
|
+
> - ๐ **Black Trigram Web App**: Entirely front-end, built with React 19 + Three.js (TypeScript). All game logic, state, skeletal animation, & 3D rendering occur in-browserโno backend.
|
|
61
|
+
> - โ๏ธ **CloudFront CDN**: AWS global CDN with 400+ edge locations, DDoS protection (AWS Shield Standard), TLS 1.3 encryption, and aggressive caching.
|
|
62
|
+
> - ๐พ **S3 Multi-Region**: Primary storage in us-east-1 with server-side encryption (SSE-S3), versioning, and multi-region replication for redundancy.
|
|
63
|
+
> - ๐ก **Route53**: AWS DNS service with DNSSEC, active health checks monitoring CloudFront, automatic failover to GitHub Pages DR.
|
|
64
|
+
> - ๐ **GitHub Pages DR**: Independent disaster recovery infrastructure, activated automatically via Route53 health checks when AWS unavailable.
|
|
65
|
+
> - ๐ฅ **Key Capabilities**: 70 vital points with Korean names (100% complete), 8 trigram stances, 28-bone skeletal animation system, 7 hand poses, muscle tension visualization, 8 body part health tracking, 60fps desktop performance.
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
## ๐ข Container View
|
|
70
|
+
|
|
71
|
+
```mermaid
|
|
72
|
+
C4Container
|
|
73
|
+
title Container View - Black Trigram Performance Architecture (Q1 2026)
|
|
74
|
+
|
|
75
|
+
Person(user, "๐งโ๐คโ๐ง User", "Practices Korean martial arts")
|
|
76
|
+
|
|
77
|
+
System_Boundary(browserApp, "๐ Black Trigram Browser Application") {
|
|
78
|
+
Container(ui, "๐ฅ๏ธ React UI Layer", "React 19 + TypeScript", "Korean-themed components, responsive design, Html overlays")
|
|
79
|
+
Container(gameEngine, "โ๏ธ Game Logic Engine", "TypeScript Modules", "Combat calculations, trigram system (8 stances), vital points (70)")
|
|
80
|
+
Container(renderer, "๐จ Three.js Renderer", "@react-three/fiber + drei", "60fps 3D graphics, skeletal animation (28 bones), particle systems")
|
|
81
|
+
Container(audioEngine, "๐ต Audio Engine", "Web Audio API", "Damage-based sound feedback, Korean traditional + cyberpunk audio")
|
|
82
|
+
Container(stateManager, "๐๏ธ State Manager", "Zustand + React Context", "Combat state, player archetypes (5), trigram stances")
|
|
83
|
+
Container(animationSystem, "๐ฌ Animation System", "Skeletal Animation + Hand Poses", "28-bone system, muscle tension, 70 vital point mapping")
|
|
84
|
+
Container(perfMonitor, "๐ Performance Monitor", "PerformanceOverlay3D", "60fps tracking, memory usage, optimization")
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
Rel(user, ui, "Interacts via input", "Touch/Mouse/Keyboard")
|
|
88
|
+
Rel(ui, gameEngine, "Dispatches actions", "Function calls")
|
|
89
|
+
Rel(gameEngine, renderer, "Updates visuals", "Three.js API")
|
|
90
|
+
Rel(gameEngine, audioEngine, "Triggers sounds", "Web Audio API")
|
|
91
|
+
Rel(gameEngine, stateManager, "Updates state", "Zustand actions")
|
|
92
|
+
Rel(gameEngine, animationSystem, "Execute techniques", "Animation API")
|
|
93
|
+
Rel(animationSystem, renderer, "Bone transforms", "Three.js Skeleton")
|
|
94
|
+
Rel(perfMonitor, stateManager, "Reports metrics", "Performance data")
|
|
95
|
+
|
|
96
|
+
UpdateLayoutConfig($c4ShapeInRow="3", $c4BoundaryInRow="1")
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
> **Containers Overview**
|
|
100
|
+
>
|
|
101
|
+
> - **๐ฅ๏ธ UI Layer**:
|
|
102
|
+
>
|
|
103
|
+
> - React 19 + TypeScript functional components.
|
|
104
|
+
> - Screens: `CombatScreen3D`, `TrainingScreen3D`, `IntroScreen3D`, `ControlsScreen3D`, `PhilosophyScreen3D`.
|
|
105
|
+
> - Common UI: Html overlays from `@react-three/drei` for HUD elements, health bars, stance indicators.
|
|
106
|
+
> - Base modules: Korean-themed UI components with bilingual support (Korean | English).
|
|
107
|
+
> - CSS: App.css, component-specific styling for overlays.
|
|
108
|
+
>
|
|
109
|
+
> - **โ๏ธ Game Logic Layer**:
|
|
110
|
+
>
|
|
111
|
+
> - Under `src/systems/*`, `src/types/*`, `src/data/*`.
|
|
112
|
+
> - **CombatSystem (`src/systems/CombatSystem.ts`)**: Orchestrates input โ trigram โ vital-point โ damage โ audio/visual.
|
|
113
|
+
> - **TrigramSystem (`src/systems/trigram/*`):**
|
|
114
|
+
>
|
|
115
|
+
> - `StanceManager.ts`: Tracks current stance, validates Ki/Stamina, handles transition cost.
|
|
116
|
+
> - `TransitionCalculator.ts`: Computes validity of stance switches.
|
|
117
|
+
> - `TrigramCalculator.ts`: Provides technique data & advantage multipliers.
|
|
118
|
+
> - `KoreanCulture.ts`: Supplies I Ching lore, Korean labels/descriptions.
|
|
119
|
+
>
|
|
120
|
+
> - **VitalPointSystem (`src/systems/vitalpoint/*`):**
|
|
121
|
+
>
|
|
122
|
+
> - 70 vital points database with Korean names (๋ฐฑํํ, ์ธ์, ๋ช
๋ฌธ, etc.)
|
|
123
|
+
> - Enhanced anatomical zones with polygon-based hit detection.
|
|
124
|
+
> - 5 severity levels (Lethal, Critical, Major, Moderate, Minor).
|
|
125
|
+
> - 7 anatomical categories (Neurological, Skeletal, Joint, Organ, Muscular, Vascular, Respiratory).
|
|
126
|
+
>
|
|
127
|
+
> - **AudioManager (`src/audio/*`):**
|
|
128
|
+
>
|
|
129
|
+
> - `AudioAssetRegistry.ts`, `AudioManager.ts`, `AudioUtils.ts`: Load & play SFX/music via Web Audio API.
|
|
130
|
+
> - Damage-based audio scaling (combat impact sounds scaled by effectiveness).
|
|
131
|
+
>
|
|
132
|
+
> - **Animation System (`src/systems/animation/*`):**
|
|
133
|
+
>
|
|
134
|
+
> - 28-bone skeletal system (PELVIS โ SPINE (3) โ NECK/HEAD (2) โ ARMS (6 each) โ LEGS (5 each)).
|
|
135
|
+
> - Hand pose system (fist_vertical, fist_horizontal, open_hand_knife, etc.).
|
|
136
|
+
> - Muscle tension visualization (0.0-1.0 mapped to bone visual intensity).
|
|
137
|
+
>
|
|
138
|
+
> - **AI System (`src/systems/ai/*`):** Tactical combat behaviors, archetype-specific AI.
|
|
139
|
+
>
|
|
140
|
+
> - **๐จ Rendering Engine**:
|
|
141
|
+
>
|
|
142
|
+
> - Three.js via `@react-three/fiber` (React renderer for Three.js).
|
|
143
|
+
> - Manages 3D scene with WebGL rendering via `Canvas` component.
|
|
144
|
+
> - Renders: Character 3D models with skeletal animation, environment, particles, and visual effects.
|
|
145
|
+
> - UI overlays via `Html` component from `@react-three/drei` for HUD, health bars, Ki meters, stance indicators.
|
|
146
|
+
> - Korean cyberpunk aesthetic with traditional ์ค๋ฐฉ์ (Five Directional Colors).
|
|
147
|
+
>
|
|
148
|
+
> - **๐ฌ Animation System**:
|
|
149
|
+
>
|
|
150
|
+
> - 28-bone skeletal hierarchy (`src/types/skeletal.ts`).
|
|
151
|
+
> - Hand pose management (`src/types/hand-animation.ts`) for martial arts techniques.
|
|
152
|
+
> - Muscle activation visualization (`src/types/muscle.ts`) with tension mapping.
|
|
153
|
+
> - Technique animation (`src/types/technique.ts`) with keyframe interpolation.
|
|
154
|
+
>
|
|
155
|
+
> - **๐๏ธ State Management**:
|
|
156
|
+
>
|
|
157
|
+
> - In-browser only (no backend). Uses **Zustand** (or React Context fallback) under hooks.
|
|
158
|
+
> - Combat state: Health, stamina, Ki, current stance (8 trigrams), body part health (8 parts), consciousness levels.
|
|
159
|
+
> - Player archetypes: 5 distinct fighter types (๋ฌด์ฌ, ์์ด์, ํด์ปค, ์ ๋ณด์์, ์กฐ์งํญ๋ ฅ๋ฐฐ).
|
|
160
|
+
> - **No Persistence**: Refresh resets all state / progress.
|
|
161
|
+
|
|
162
|
+
---
|
|
163
|
+
|
|
164
|
+
## ๐งฉ Component View
|
|
165
|
+
|
|
166
|
+
```mermaid
|
|
167
|
+
C4Component
|
|
168
|
+
title Combat System Components - Korean Martial Arts Engine (Q1 2026)
|
|
169
|
+
|
|
170
|
+
Container_Boundary(combatSystem, "โ๏ธ Combat System") {
|
|
171
|
+
Component(combatController, "๐ฅ CombatController", "TypeScript", "Orchestrates combat interactions (CombatSystem.ts - 36KB)")
|
|
172
|
+
Component(inputHandler, "๐ฎ InputHandler", "TypeScript", "Processes keyboard/mouse/touch input")
|
|
173
|
+
Component(trigramEngine, "โฏ๏ธ TrigramEngine", "TypeScript", "Manages 8 trigram stances and transitions")
|
|
174
|
+
Component(vitalPointEngine, "๐ฏ VitalPointEngine", "TypeScript", "70 vital points with polygon hit detection (<0.01ms)")
|
|
175
|
+
Component(damageCalculator, "๐ฅ DamageCalculator", "TypeScript", "Base ร trigram ร vital point multipliers")
|
|
176
|
+
Component(effectsProcessor, "โจ EffectsProcessor", "TypeScript", "Visual and audio effect coordination")
|
|
177
|
+
Component(animationSystem, "๐ฌ AnimationSystem", "TypeScript", "28-bone skeletal animation + hand poses")
|
|
178
|
+
Component(bodyPartHealth, "๐ฉน BodyPartHealth", "TypeScript", "8-part health tracking system")
|
|
179
|
+
Component(painSystem, "๐ฅ PainResponseSystem", "TypeScript", "Pain accumulation and response (90% complete)")
|
|
180
|
+
Component(consciousnessSystem, "๐ค ConsciousnessSystem", "TypeScript", "4-level consciousness degradation (90% complete)")
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
Container_Boundary(dataLayer, "๐ Data Layer") {
|
|
184
|
+
Component(koreanTerminology, "๐ฐ๐ท KoreanTerminology", "JSON/TypeScript", "Bilingual Korean-English terms")
|
|
185
|
+
Component(anatomyData, "๐ซ AnatomyData", "JSON/TypeScript", "70 vital points (5 severity, 7 categories, 14 meridians)")
|
|
186
|
+
Component(trigramData, "๐ TrigramData", "JSON/TypeScript", "8 I Ching trigrams + techniques")
|
|
187
|
+
Component(audioAssets, "๐ต AudioAssets", "WebM/OGG", "Damage-scaled audio + Korean traditional")
|
|
188
|
+
Component(archetypeData, "๐ค ArchetypeData", "JSON/TypeScript", "5 player archetypes (๋ฌด์ฌ, ์์ด์, ํด์ปค, ์ ๋ณด์์, ์กฐ์งํญ๋ ฅ๋ฐฐ)")
|
|
189
|
+
Component(skeletalData, "๐ฆด SkeletalData", "TypeScript", "28-bone hierarchy + 7 hand poses + muscle tension")
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
Container_Boundary(rendering, "๐จ Rendering Layer") {
|
|
193
|
+
Component(threeScene, "โ๏ธ ThreeScene", "Three.js", "3D combat scene with WebGL 2.0 where available (WebGL 1 fallback)")
|
|
194
|
+
Component(particleSystem, "โจ ParticleSystem", "Three.js Instances", "Ki energy, hit effects, impact particles (1000+)")
|
|
195
|
+
Component(hudOverlay, "๐ HUDOverlay", "Html (drei)", "Health bars, stance indicators, damage numbers, combo counter")
|
|
196
|
+
Component(skeletalRenderer, "๐ญ SkeletalRenderer", "Three.js Skeleton", "28-bone character animation @ 60fps")
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
Rel(inputHandler, combatController, "Sends input events")
|
|
200
|
+
Rel(combatController, trigramEngine, "Requests stance changes (8 stances)")
|
|
201
|
+
Rel(combatController, vitalPointEngine, "Checks hit targets (70 points)")
|
|
202
|
+
Rel(combatController, damageCalculator, "Calculates damage")
|
|
203
|
+
Rel(combatController, bodyPartHealth, "Updates 8 body parts")
|
|
204
|
+
Rel(combatController, painSystem, "Tracks pain accumulation")
|
|
205
|
+
Rel(combatController, consciousnessSystem, "Manages consciousness levels")
|
|
206
|
+
Rel(damageCalculator, effectsProcessor, "Triggers effects")
|
|
207
|
+
Rel(effectsProcessor, animationSystem, "Execute technique animations")
|
|
208
|
+
|
|
209
|
+
Rel(trigramEngine, trigramData, "Loads 8 stance data")
|
|
210
|
+
Rel(vitalPointEngine, anatomyData, "References 70 vital points + meridians")
|
|
211
|
+
Rel(combatController, koreanTerminology, "Gets Korean terms")
|
|
212
|
+
Rel(effectsProcessor, audioAssets, "Plays damage-scaled sounds")
|
|
213
|
+
Rel(animationSystem, skeletalData, "Loads bone hierarchy + hand poses")
|
|
214
|
+
Rel(combatController, archetypeData, "Loads 5 archetype data")
|
|
215
|
+
|
|
216
|
+
Rel(effectsProcessor, threeScene, "Updates 3D visuals")
|
|
217
|
+
Rel(effectsProcessor, particleSystem, "Spawns particle effects")
|
|
218
|
+
Rel(combatController, hudOverlay, "Updates HUD overlays")
|
|
219
|
+
Rel(animationSystem, skeletalRenderer, "Updates bone transforms @ 60fps")
|
|
220
|
+
|
|
221
|
+
UpdateLayoutConfig($c4ShapeInRow="4", $c4BoundaryInRow="1")
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
### ๐งฉ Component Implementation Status (Q1 2026)
|
|
225
|
+
|
|
226
|
+
#### Combat System (8.3/10 - Production-Ready)
|
|
227
|
+
- **Combat Realism**: 8/12 systems complete or near-complete (67%)
|
|
228
|
+
- โ
**Body Part Health**: 100% (8 parts tracked with Korean/English labels)
|
|
229
|
+
- โ
**Vital Point Targeting**: 100% (70/70 points with TCM meridian mapping)
|
|
230
|
+
- โ
**Enhanced Anatomy**: 95% (polygon-based detection, 13 zones, <0.01ms)
|
|
231
|
+
- โ
**Visual Feedback**: 90% (damage numbers, hit effects, combo counter)
|
|
232
|
+
- โ
**Pain Response**: 90% (production-ready with 37 tests)
|
|
233
|
+
- โ
**Consciousness Levels**: 90% (production-ready with 36 tests, 4-level gradation)
|
|
234
|
+
- โ
**Breathing Disruption**: 75% (near-complete, CombatSystem integration ongoing)
|
|
235
|
+
- โ ๏ธ **Trauma Visualization**: 65% (in progress, injury tracking integration)
|
|
236
|
+
- โ ๏ธ **Balance/Vulnerability**: 70% (refinement needed)
|
|
237
|
+
- โ ๏ธ **Combat Readiness HUD**: 60% (integration ongoing)
|
|
238
|
+
- โ ๏ธ **Injury-Based Movement**: 10% (planned, basic framework)
|
|
239
|
+
- โ ๏ธ **Bone Impact Audio**: 60% (BoneImpactAudioMap + useCombatAudio integration complete; asset coverage/final mix & tuning pending)
|
|
240
|
+
|
|
241
|
+
#### Vital Point System (9.5/10 - Excellent)
|
|
242
|
+
- 70/70 vital points with Korean names (100% complete)
|
|
243
|
+
- **4 regions**: Head (12), Torso (24), Arms (17), Legs (17)
|
|
244
|
+
- **5 severity levels**: Lethal (4), Critical (18), Major (28), Moderate (16), Minor (4)
|
|
245
|
+
- **7 categories**: Neurological (22), Skeletal (15), Joint (12), Organ (9), Muscular (7), Vascular (3), Respiratory (2)
|
|
246
|
+
- **14 TCM Meridians** mapped to vital points
|
|
247
|
+
- **127 Medical References** cited
|
|
248
|
+
- Visual overlay controls with filtering (severity, region, search)
|
|
249
|
+
- Comprehensive documentation in `docs/vital-points/`
|
|
250
|
+
|
|
251
|
+
#### Trigram System (10/10 - Complete)
|
|
252
|
+
- 8/8 stances fully functional with I Ching philosophy
|
|
253
|
+
- Korean cultural integration: โฐ ๊ฑด Geon, โฑ ํ Tae, โฒ ๋ฆฌ Li, โณ ์ง Jin, โด ์ Son, โต ๊ฐ Gam, โถ ๊ฐ Gan, โท ๊ณค Gon
|
|
254
|
+
- Stance-specific techniques with trigram advantage matrix
|
|
255
|
+
- Transition cost calculation (Ki/Stamina)
|
|
256
|
+
|
|
257
|
+
#### Skeletal Animation System (8.5/10 - Production-Ready, Q1 2026)
|
|
258
|
+
- **28-bone hierarchy** with realistic human proportions
|
|
259
|
+
- Core: PELVIS (root)
|
|
260
|
+
- Spine: SPINE_LOWER, SPINE_MIDDLE, SPINE_UPPER (3 bones)
|
|
261
|
+
- Head: NECK, HEAD (2 bones)
|
|
262
|
+
- Arms: SHOULDER, UPPER_ARM, ELBOW, FOREARM, WRIST, HAND (6 bones each ร 2 = 12 bones)
|
|
263
|
+
- Legs: HIP, THIGH, KNEE, SHIN, FOOT (5 bones each ร 2 = 10 bones)
|
|
264
|
+
- **7 hand poses** for martial arts techniques
|
|
265
|
+
- fist_vertical (์์ง์ฃผ๋จน) - Vertical punch
|
|
266
|
+
- fist_horizontal (์ํ์ฃผ๋จน) - Horizontal punch
|
|
267
|
+
- open_hand_knife (์๋) - Knife hand strike
|
|
268
|
+
- spear_hand (๊ด์) - Spear hand
|
|
269
|
+
- grasping (์ก๊ธฐ) - Grappling
|
|
270
|
+
- open_palm (ํด๊ธฐ) - Palm strike
|
|
271
|
+
- relaxed (ํด์) - Neutral/rest
|
|
272
|
+
- **Muscle tension visualization** (0.0-1.0 intensity mapping to bone visual intensity)
|
|
273
|
+
- **Technique animation** with keyframe interpolation for smooth 60fps playback
|
|
274
|
+
- Located in `src/systems/animation/`, `src/types/skeletal.ts`, `src/types/hand-animation.ts`, `src/types/muscle.ts`
|
|
275
|
+
|
|
276
|
+
#### Player Archetypes (10/10 - Complete)
|
|
277
|
+
- 5/5 archetypes balanced with distinct combat styles:
|
|
278
|
+
- **๋ฌด์ฌ (Musa)** - Traditional Warrior: Honor-bound, balanced techniques
|
|
279
|
+
- **์์ด์ (Amsalja)** - Shadow Assassin: Precision strikes, critical damage focus
|
|
280
|
+
- **ํด์ปค (Hacker)** - Cyber Warrior: Tech-enhanced, digital disruption
|
|
281
|
+
- **์ ๋ณด์์ (Jeongbo Yowon)** - Intelligence Operative: Analytical, tactical advantage
|
|
282
|
+
- **์กฐ์งํญ๋ ฅ๋ฐฐ (Jojik Pokryeokbae)** - Organized Crime: Brutal efficiency, overwhelming force
|
|
283
|
+
|
|
284
|
+
## Enhanced Icon Categories
|
|
285
|
+
|
|
286
|
+
### ๐ฅ๏ธ UI Layer Icons
|
|
287
|
+
|
|
288
|
+
- **๐ฑ App** - Mobile-first application root
|
|
289
|
+
- **๐ฎ IntroScreen** - Traditional Korean lantern for welcome
|
|
290
|
+
- **โ๏ธ CombatScreen** - Crossed swords for combat
|
|
291
|
+
- **๐ฏ TrainingScreen** - Target for practice mode
|
|
292
|
+
- **๐ฎ GameUI** - Game controller for interface
|
|
293
|
+
- **๐ CombatHUD** - Chart/dashboard for HUD
|
|
294
|
+
- **โฏ๏ธ TrigramWheel** - Yin-yang for Korean philosophy
|
|
295
|
+
- **๐ EndScreen** - Checkered flag for completion
|
|
296
|
+
- **๐ BaseButton** - Button for reusable component
|
|
297
|
+
- **๐ฐ๐ท KoreanText** - Korean flag for Korean text
|
|
298
|
+
- **โ BackgroundGrid** - Grid pattern for overlay
|
|
299
|
+
|
|
300
|
+
### โ๏ธ Game Logic Icons
|
|
301
|
+
|
|
302
|
+
- **๐ฅ CombatSystem** - Boxing glove for combat orchestration
|
|
303
|
+
- **๐ถ TrigramSystem** - Diamond for trigram system
|
|
304
|
+
- **๐ฅ StanceManager** - Martial arts uniform for stance
|
|
305
|
+
- **๐ TransitionCalculator** - Refresh for transitions
|
|
306
|
+
- **๐งฎ TrigramCalculator** - Abacus for calculations
|
|
307
|
+
- **๐๏ธ KoreanCulture** - Classical building for culture
|
|
308
|
+
- **๐ฏ VitalPointSystem** - Bullseye for targeting
|
|
309
|
+
- **๐ซ AnatomicalRegions** - Heart for anatomy
|
|
310
|
+
- **๐ฅ HitDetection** - Explosion for collision
|
|
311
|
+
- **๐ฉธ DamageCalculator** - Blood drop for damage
|
|
312
|
+
- **๐ต AudioManager** - Musical note for audio
|
|
313
|
+
- **๐น DefaultSoundGenerator** - Piano for sound generation
|
|
314
|
+
- **๐ฒ VariantSelector** - Dice for randomization
|
|
315
|
+
|
|
316
|
+
### ๐ฆ Asset Loader Icons
|
|
317
|
+
|
|
318
|
+
- **๐ผ๏ธ TextureLoader** - Framed picture for textures
|
|
319
|
+
- **๐ง AudioLoader** - Headphones for audio assets
|
|
320
|
+
- **๐ TrigramDataLoader** - Clipboard for data
|
|
321
|
+
- **๐งฌ VitalPointsDataLoader** - DNA for anatomical data
|
|
322
|
+
|
|
323
|
+
### ๐๏ธ State Management Icons
|
|
324
|
+
|
|
325
|
+
- **๐ฎ useGameState** - Game controller for game state
|
|
326
|
+
- **๐ฑ๏ธ useUIState** - Computer mouse for UI state
|
|
327
|
+
- **๐น useEnemyState** - Ogre for enemy state
|
|
328
|
+
|
|
329
|
+
### ๐จ Rendering Engine Icons
|
|
330
|
+
|
|
331
|
+
- **๐ญ ThreeScene** - Theater masks for 3D scene
|
|
332
|
+
- **๐ค PlayerVisuals** - Bust silhouette for player
|
|
333
|
+
- **๐บ EnemyVisuals** - Goblin for enemy
|
|
334
|
+
- **โจ ParticlesLayer** - Sparkles for effects
|
|
335
|
+
- **๐
DojangBackground** - Sunrise for environment
|
|
336
|
+
|
|
337
|
+
---
|
|
338
|
+
|
|
339
|
+
## ๐ฎ Three.js 3D Rendering Architecture
|
|
340
|
+
|
|
341
|
+
Black Trigram uses Three.js for 3D rendering, achieving enhanced visual capabilities with authentic Korean martial arts theming and maintaining 60fps performance targets.
|
|
342
|
+
|
|
343
|
+
### ๐ฆ Three.js Dependencies
|
|
344
|
+
|
|
345
|
+
The following Three.js packages are now installed and configured:
|
|
346
|
+
|
|
347
|
+
- **three@0.181.2** - Core Three.js 3D engine with WebGL rendering
|
|
348
|
+
- **@react-three/fiber@9.4.0** - React renderer for Three.js (declarative 3D in React)
|
|
349
|
+
- **@react-three/drei@10.7.7** - Useful helpers and abstractions (@react-three/fiber)
|
|
350
|
+
- **@types/three@0.181.0** - TypeScript type definitions for Three.js
|
|
351
|
+
|
|
352
|
+
### ๐๏ธ Architecture Integration
|
|
353
|
+
|
|
354
|
+
```mermaid
|
|
355
|
+
graph TD
|
|
356
|
+
subgraph "React 19 Application Layer"
|
|
357
|
+
A[React Components]
|
|
358
|
+
B[State Management - Zustand]
|
|
359
|
+
C[Korean Theming - KOREAN_COLORS]
|
|
360
|
+
end
|
|
361
|
+
|
|
362
|
+
subgraph "Rendering Layer"
|
|
363
|
+
D[@react-three/fiber Canvas]
|
|
364
|
+
end
|
|
365
|
+
|
|
366
|
+
subgraph "Three.js 3D Scene"
|
|
367
|
+
F[Scene Graph]
|
|
368
|
+
G[3D Characters]
|
|
369
|
+
H[Vital Point Markers]
|
|
370
|
+
I[Particle Systems]
|
|
371
|
+
J[Korean-Themed Materials]
|
|
372
|
+
K[Lighting Setup]
|
|
373
|
+
end
|
|
374
|
+
|
|
375
|
+
subgraph "UI Overlay Layer"
|
|
376
|
+
L[Html Components]
|
|
377
|
+
M[Combat HUD]
|
|
378
|
+
N[Status Panels]
|
|
379
|
+
end
|
|
380
|
+
|
|
381
|
+
A --> D
|
|
382
|
+
A --> E
|
|
383
|
+
B --> A
|
|
384
|
+
C --> A
|
|
385
|
+
C --> J
|
|
386
|
+
|
|
387
|
+
D --> F
|
|
388
|
+
F --> G
|
|
389
|
+
F --> H
|
|
390
|
+
F --> I
|
|
391
|
+
F --> J
|
|
392
|
+
F --> K
|
|
393
|
+
|
|
394
|
+
D --> L
|
|
395
|
+
L --> M
|
|
396
|
+
L --> N
|
|
397
|
+
|
|
398
|
+
style D fill:#00ffff,stroke:#333,stroke-width:3px
|
|
399
|
+
style F fill:#ffd700,stroke:#333,stroke-width:3px
|
|
400
|
+
style J fill:#ff4444,stroke:#333,stroke-width:2px
|
|
401
|
+
style L fill:#98fb98,stroke:#333,stroke-width:2px
|
|
402
|
+
```
|
|
403
|
+
|
|
404
|
+
### ๐ Rendering Pipeline
|
|
405
|
+
|
|
406
|
+
```mermaid
|
|
407
|
+
sequenceDiagram
|
|
408
|
+
participant React as React Component
|
|
409
|
+
participant Canvas as @react-three/fiber Canvas
|
|
410
|
+
participant Scene as Three.js Scene
|
|
411
|
+
participant WebGL as WebGL Renderer
|
|
412
|
+
participant Display as Browser Display
|
|
413
|
+
|
|
414
|
+
React->>Canvas: Render 3D components
|
|
415
|
+
Canvas->>Scene: Build scene graph
|
|
416
|
+
Scene->>Scene: Apply Korean materials
|
|
417
|
+
Scene->>Scene: Position characters
|
|
418
|
+
Scene->>Scene: Update particles
|
|
419
|
+
|
|
420
|
+
loop Animation Loop (60fps)
|
|
421
|
+
Canvas->>Scene: useFrame hook
|
|
422
|
+
Scene->>WebGL: Render scene
|
|
423
|
+
WebGL->>Display: Draw to canvas
|
|
424
|
+
end
|
|
425
|
+
|
|
426
|
+
Note over React,Display: Html overlays render separately via React DOM
|
|
427
|
+
```
|
|
428
|
+
|
|
429
|
+
### ๐ File Structure
|
|
430
|
+
|
|
431
|
+
#### Current Implementation
|
|
432
|
+
- **src/components/test/**
|
|
433
|
+
- `Hello3D.tsx` - Test component demonstrating Three.js setup
|
|
434
|
+
- `Hello3D.test.tsx` - Unit tests for Three.js infrastructure
|
|
435
|
+
- `Hello3D-demo.tsx` - Interactive demo with controls
|
|
436
|
+
|
|
437
|
+
#### Planned Structure
|
|
438
|
+
```
|
|
439
|
+
src/components/combat/
|
|
440
|
+
โโโ characters/
|
|
441
|
+
โ โโโ CharacterModel3D.tsx # Base 3D character model
|
|
442
|
+
โ โโโ VitalPointMarkers3D.tsx # 70 vital points in 3D
|
|
443
|
+
โ โโโ StanceAnimation3D.tsx # Eight trigram stances
|
|
444
|
+
โ โโโ DamageVisualization3D.tsx # Blood and injury effects
|
|
445
|
+
โโโ particles/
|
|
446
|
+
โ โโโ KiEnergyParticles3D.tsx # Ki energy particle system
|
|
447
|
+
โ โโโ HitEffects3D.tsx # Impact effects and sparks
|
|
448
|
+
โ โโโ BloodSplatter3D.tsx # Realistic blood effects
|
|
449
|
+
โโโ arena/
|
|
450
|
+
โ โโโ CombatArena3D.tsx # Complete 3D combat scene
|
|
451
|
+
โ โโโ DojangFloor3D.tsx # Traditional dojang floor
|
|
452
|
+
โ โโโ KoreanLighting3D.tsx # Korean-themed lighting setup
|
|
453
|
+
โโโ ui/
|
|
454
|
+
โโโ CombatHUDOverlayHtml.tsx # Html UI over 3D scene
|
|
455
|
+
โโโ PlayerNameplate3D.tsx # Player info in 3D space
|
|
456
|
+
โโโ VitalPointTooltip3D.tsx # Interactive tooltips
|
|
457
|
+
```
|
|
458
|
+
|
|
459
|
+
### ๐ง Configuration
|
|
460
|
+
|
|
461
|
+
**Vite Configuration (`vite.config.ts`):**
|
|
462
|
+
```typescript
|
|
463
|
+
export default defineConfig({
|
|
464
|
+
plugins: [react()],
|
|
465
|
+
optimizeDeps: {
|
|
466
|
+
include: [
|
|
467
|
+
// Three.js dependencies
|
|
468
|
+
"three",
|
|
469
|
+
"@react-three/fiber",
|
|
470
|
+
"@react-three/drei",
|
|
471
|
+
// Audio
|
|
472
|
+
"howler",
|
|
473
|
+
],
|
|
474
|
+
},
|
|
475
|
+
build: {
|
|
476
|
+
rollupOptions: {
|
|
477
|
+
output: {
|
|
478
|
+
manualChunks: {
|
|
479
|
+
'three-vendor': ['three', '@react-three/fiber', '@react-three/drei'],
|
|
480
|
+
},
|
|
481
|
+
},
|
|
482
|
+
},
|
|
483
|
+
},
|
|
484
|
+
});
|
|
485
|
+
```
|
|
486
|
+
|
|
487
|
+
**TypeScript Configuration (`tsconfig.json`):**
|
|
488
|
+
```json
|
|
489
|
+
{
|
|
490
|
+
"compilerOptions": {
|
|
491
|
+
"skipLibCheck": true, // Handles Three.js type complexities
|
|
492
|
+
"moduleResolution": "bundler", // Optimized for Vite + Three.js
|
|
493
|
+
"strict": true, // Strict type checking
|
|
494
|
+
"jsx": "react-jsx", // React 19 JSX transform
|
|
495
|
+
"types": ["vite/client", "node"]
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
```
|
|
499
|
+
|
|
500
|
+
**Test Setup (`src/test/setup.ts`):**
|
|
501
|
+
```typescript
|
|
502
|
+
// WebGL context mocking for Three.js tests
|
|
503
|
+
class MockWebGLRenderingContext {
|
|
504
|
+
getExtension = vi.fn();
|
|
505
|
+
getParameter = vi.fn();
|
|
506
|
+
// ... full WebGL API mock
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
// ResizeObserver polyfill for @react-three/fiber
|
|
510
|
+
class MockResizeObserver {
|
|
511
|
+
observe = vi.fn();
|
|
512
|
+
unobserve = vi.fn();
|
|
513
|
+
disconnect = vi.fn();
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
global.ResizeObserver = MockResizeObserver;
|
|
517
|
+
```
|
|
518
|
+
|
|
519
|
+
### ๐จ Core Patterns
|
|
520
|
+
|
|
521
|
+
#### Pattern 1: Canvas Setup with Korean Theming
|
|
522
|
+
|
|
523
|
+
```typescript
|
|
524
|
+
import { Canvas } from "@react-three/fiber";
|
|
525
|
+
import { Environment, PerspectiveCamera } from "@react-three/drei";
|
|
526
|
+
import { KOREAN_COLORS } from "../../types/constants";
|
|
527
|
+
import * as THREE from "three";
|
|
528
|
+
|
|
529
|
+
export function CombatScene3D() {
|
|
530
|
+
return (
|
|
531
|
+
<Canvas
|
|
532
|
+
gl={{
|
|
533
|
+
antialias: true,
|
|
534
|
+
alpha: false,
|
|
535
|
+
powerPreference: 'high-performance',
|
|
536
|
+
}}
|
|
537
|
+
dpr={[1, 2]}
|
|
538
|
+
shadows
|
|
539
|
+
onCreated={({ gl, scene }) => {
|
|
540
|
+
// Korean cyberpunk background
|
|
541
|
+
gl.setClearColor(KOREAN_COLORS.UI_BACKGROUND_DARK, 1);
|
|
542
|
+
scene.fog = new THREE.Fog(
|
|
543
|
+
KOREAN_COLORS.UI_BACKGROUND_DARK,
|
|
544
|
+
10,
|
|
545
|
+
50
|
|
546
|
+
);
|
|
547
|
+
}}
|
|
548
|
+
>
|
|
549
|
+
{/* Korean-themed lighting */}
|
|
550
|
+
<ambientLight intensity={0.4} color={KOREAN_COLORS.PRIMARY_CYAN} />
|
|
551
|
+
<directionalLight
|
|
552
|
+
position={[10, 10, 5]}
|
|
553
|
+
intensity={1}
|
|
554
|
+
castShadow
|
|
555
|
+
color={KOREAN_COLORS.ACCENT_GOLD}
|
|
556
|
+
/>
|
|
557
|
+
|
|
558
|
+
{/* Environment reflections */}
|
|
559
|
+
<Environment preset="city" />
|
|
560
|
+
|
|
561
|
+
{/* Camera */}
|
|
562
|
+
<PerspectiveCamera makeDefault position={[0, 5, 10]} fov={75} />
|
|
563
|
+
|
|
564
|
+
{/* Game content */}
|
|
565
|
+
<CombatArena3D />
|
|
566
|
+
</Canvas>
|
|
567
|
+
);
|
|
568
|
+
}
|
|
569
|
+
```
|
|
570
|
+
|
|
571
|
+
#### Pattern 2: useFrame Animation Loop
|
|
572
|
+
|
|
573
|
+
```typescript
|
|
574
|
+
import { useFrame } from "@react-three/fiber";
|
|
575
|
+
import { useRef } from "react";
|
|
576
|
+
import * as THREE from "three";
|
|
577
|
+
|
|
578
|
+
export function AnimatedCharacter({ stance, health }) {
|
|
579
|
+
const meshRef = useRef<THREE.Mesh>(null);
|
|
580
|
+
|
|
581
|
+
// 60fps animation loop
|
|
582
|
+
useFrame((state, delta) => {
|
|
583
|
+
if (!meshRef.current) return;
|
|
584
|
+
|
|
585
|
+
// Breathing animation
|
|
586
|
+
const breathScale = Math.sin(state.clock.elapsedTime * 2) * 0.02 + 1;
|
|
587
|
+
meshRef.current.scale.y = breathScale;
|
|
588
|
+
|
|
589
|
+
// Stance-based rotation
|
|
590
|
+
meshRef.current.rotation.y = getStanceRotation(stance);
|
|
591
|
+
});
|
|
592
|
+
|
|
593
|
+
return (
|
|
594
|
+
<mesh ref={meshRef} castShadow receiveShadow>
|
|
595
|
+
<capsuleGeometry args={[0.5, 1.5, 16, 32]} />
|
|
596
|
+
<meshStandardMaterial color={getHealthColor(health)} />
|
|
597
|
+
</mesh>
|
|
598
|
+
);
|
|
599
|
+
}
|
|
600
|
+
```
|
|
601
|
+
|
|
602
|
+
#### Pattern 3: Html Overlays for UI
|
|
603
|
+
|
|
604
|
+
{% raw %}
|
|
605
|
+
```typescript
|
|
606
|
+
import { Html } from "@react-three/drei";
|
|
607
|
+
|
|
608
|
+
export function PlayerNameplate3D({ name, nameKorean, health }) {
|
|
609
|
+
return (
|
|
610
|
+
<Html position={[0, 2.5, 0]} center>
|
|
611
|
+
<div style={{
|
|
612
|
+
background: `${KOREAN_COLORS.UI_BACKGROUND_DARK}cc`,
|
|
613
|
+
border: `2px solid ${KOREAN_COLORS.PRIMARY_CYAN}`,
|
|
614
|
+
borderRadius: '8px',
|
|
615
|
+
padding: '12px',
|
|
616
|
+
fontFamily: 'Korean Font',
|
|
617
|
+
}}>
|
|
618
|
+
<div style={{ color: KOREAN_COLORS.ACCENT_GOLD }}>
|
|
619
|
+
{nameKorean} | {name}
|
|
620
|
+
</div>
|
|
621
|
+
<HealthBar health={health} />
|
|
622
|
+
</div>
|
|
623
|
+
</Html>
|
|
624
|
+
);
|
|
625
|
+
}
|
|
626
|
+
```
|
|
627
|
+
{% endraw %}
|
|
628
|
+
|
|
629
|
+
#### Pattern 4: Korean Materials and Lighting
|
|
630
|
+
|
|
631
|
+
```typescript
|
|
632
|
+
// Eight Trigram color mapping
|
|
633
|
+
const TRIGRAM_COLORS: Record<TrigramStance, number> = {
|
|
634
|
+
geon: KOREAN_COLORS.CARDINAL_CENTER, // โฐ Heaven - Yellow
|
|
635
|
+
tae: KOREAN_COLORS.PRIMARY_CYAN, // โฑ Lake - Cyan
|
|
636
|
+
li: KOREAN_COLORS.CARDINAL_SOUTH, // โฒ Fire - Red
|
|
637
|
+
jin: KOREAN_COLORS.SECONDARY_YELLOW, // โณ Thunder - Yellow
|
|
638
|
+
son: KOREAN_COLORS.CARDINAL_EAST, // โด Wind - Green
|
|
639
|
+
gam: KOREAN_COLORS.ACCENT_BLUE, // โต Water - Blue
|
|
640
|
+
gan: KOREAN_COLORS.UI_BACKGROUND_LIGHT, // โถ Mountain - Gray
|
|
641
|
+
gon: KOREAN_COLORS.UI_BACKGROUND_DARK, // โท Earth - Dark
|
|
642
|
+
};
|
|
643
|
+
|
|
644
|
+
// Cardinal directions lighting (์ค๋ฐฉ์)
|
|
645
|
+
export function CardinalLighting() {
|
|
646
|
+
return (
|
|
647
|
+
<>
|
|
648
|
+
<pointLight position={[10, 0, 0]} color={KOREAN_COLORS.CARDINAL_EAST} />
|
|
649
|
+
<pointLight position={[-10, 0, 0]} color={KOREAN_COLORS.CARDINAL_WEST} />
|
|
650
|
+
<pointLight position={[0, 0, 10]} color={KOREAN_COLORS.CARDINAL_SOUTH} />
|
|
651
|
+
<pointLight position={[0, 0, -10]} color={KOREAN_COLORS.CARDINAL_NORTH} />
|
|
652
|
+
<pointLight position={[0, 10, 0]} color={KOREAN_COLORS.CARDINAL_CENTER} />
|
|
653
|
+
</>
|
|
654
|
+
);
|
|
655
|
+
}
|
|
656
|
+
```
|
|
657
|
+
|
|
658
|
+
### ๐ Performance Optimization
|
|
659
|
+
|
|
660
|
+
#### Bundle Size Management
|
|
661
|
+
|
|
662
|
+
| Asset | Size (Uncompressed) | Size (Gzipped) | Notes |
|
|
663
|
+
|-------|---------------------|----------------|-------|
|
|
664
|
+
| Three.js core | ~600KB | ~150KB | Tree-shaken imports |
|
|
665
|
+
| @react-three/fiber | ~100KB | ~30KB | React integration |
|
|
666
|
+
| @react-three/drei | ~200KB | ~60KB | Only imported helpers |
|
|
667
|
+
| **Total** | **~900KB** | **~240KB** | Lazy-loaded when needed |
|
|
668
|
+
|
|
669
|
+
#### Optimization Techniques
|
|
670
|
+
|
|
671
|
+
1. **Instancing for Particles**
|
|
672
|
+
```typescript
|
|
673
|
+
import { Instances, Instance } from '@react-three/drei';
|
|
674
|
+
|
|
675
|
+
<Instances limit={1000}>
|
|
676
|
+
<sphereGeometry args={[0.1, 8, 8]} />
|
|
677
|
+
<meshBasicMaterial color={KOREAN_COLORS.PRIMARY_CYAN} />
|
|
678
|
+
{particles.map((p, i) => (
|
|
679
|
+
<Instance key={i} position={p.position} scale={p.scale} />
|
|
680
|
+
))}
|
|
681
|
+
</Instances>
|
|
682
|
+
```
|
|
683
|
+
|
|
684
|
+
2. **LOD (Level of Detail)**
|
|
685
|
+
```typescript
|
|
686
|
+
import { Detailed } from '@react-three/drei';
|
|
687
|
+
|
|
688
|
+
<Detailed distances={[0, 10, 20]}>
|
|
689
|
+
<HighDetailCharacter />
|
|
690
|
+
<MediumDetailCharacter />
|
|
691
|
+
<LowDetailCharacter />
|
|
692
|
+
</Detailed>
|
|
693
|
+
```
|
|
694
|
+
|
|
695
|
+
3. **Object Pooling**
|
|
696
|
+
```typescript
|
|
697
|
+
// Reuse objects instead of creating new ones
|
|
698
|
+
const particlePool = new ParticlePool(createParticle, resetParticle, 100);
|
|
699
|
+
```
|
|
700
|
+
|
|
701
|
+
### ๐ Migration Strategy
|
|
702
|
+
|
|
703
|
+
#### Phase 1: Infrastructure Setup โ
COMPLETE
|
|
704
|
+
- [x] Three.js dependencies installed
|
|
705
|
+
- [x] Test component created (`Hello3D`)
|
|
706
|
+
- [x] Korean theming verified
|
|
707
|
+
- [x] Build and test pipeline working
|
|
708
|
+
|
|
709
|
+
#### Phase 2: Particle Systems (In Progress)
|
|
710
|
+
- [ ] Migrate ki energy particles to Three.js `Instances`
|
|
711
|
+
- [ ] Create 3D blood splatter effects
|
|
712
|
+
- [ ] Implement impact sparks with lighting
|
|
713
|
+
- [ ] Performance validation (1000+ particles at 60fps)
|
|
714
|
+
|
|
715
|
+
#### Phase 3: Character Models โ
COMPLETE
|
|
716
|
+
- [x] Create unified Player3D component (`Player3DUnified.tsx`)
|
|
717
|
+
- [x] Implement stance-based visual system (8 trigrams with color-coded auras)
|
|
718
|
+
- [x] Add health/stamina/Ki state indicators with Html overlays
|
|
719
|
+
- [x] Support all 5 player archetypes with visual differentiation
|
|
720
|
+
- [x] Integrate pain/balance/consciousness visualization
|
|
721
|
+
- [x] Add responsive scaling for mobile/desktop
|
|
722
|
+
- [x] Create conversion utilities for PlayerState integration
|
|
723
|
+
- [x] Integrate into CombatScreen3D (both players)
|
|
724
|
+
- [x] Integrate into TrainingScreen3D (trainee player)
|
|
725
|
+
- [x] Comprehensive test coverage (61 component + 29 integration tests)
|
|
726
|
+
|
|
727
|
+
**Key Components:**
|
|
728
|
+
- `src/components/three/Player3DUnified.tsx` - Main unified player visualization
|
|
729
|
+
- `src/components/three/PlayerStateIndicators.tsx` - Html overlay for stats
|
|
730
|
+
- `src/components/three/StanceAura.tsx` - Animated stance aura effects
|
|
731
|
+
- `src/utils/player3DHelpers.ts` - PlayerState conversion utilities
|
|
732
|
+
- `src/types/player-visual.ts` - TypeScript interfaces for player visuals
|
|
733
|
+
|
|
734
|
+
**Usage Example:**
|
|
735
|
+
```typescript
|
|
736
|
+
import { Player3DUnified } from '@/components/three';
|
|
737
|
+
import { convertPlayerStateToProps } from '@/utils/player3DHelpers';
|
|
738
|
+
|
|
739
|
+
// In CombatScreen3D or TrainingScreen3D:
|
|
740
|
+
<Player3DUnified
|
|
741
|
+
{...convertPlayerStateToProps(
|
|
742
|
+
playerState,
|
|
743
|
+
[x, y, z], // 3D position
|
|
744
|
+
rotation, // Y-axis rotation in radians
|
|
745
|
+
{
|
|
746
|
+
isMobile,
|
|
747
|
+
facing: "right",
|
|
748
|
+
showVitalPoints: true,
|
|
749
|
+
}
|
|
750
|
+
)}
|
|
751
|
+
/>
|
|
752
|
+
```
|
|
753
|
+
|
|
754
|
+
#### Phase 4: Combat Arena (Planned)
|
|
755
|
+
- [ ] Build 3D dojang environment
|
|
756
|
+
- [ ] Korean-themed lighting setup
|
|
757
|
+
- [ ] Shadow and reflection effects
|
|
758
|
+
- [ ] Environmental particles (dust, air)
|
|
759
|
+
|
|
760
|
+
#### Phase 5: UI Integration (Planned)
|
|
761
|
+
- [ ] Convert Combat HUD to Html overlays
|
|
762
|
+
- [ ] 3D-positioned player status panels
|
|
763
|
+
- [ ] Floating damage numbers
|
|
764
|
+
- [ ] Vital point targeting interface
|
|
765
|
+
|
|
766
|
+
#### Phase 6: Polish & Optimization (Planned)
|
|
767
|
+
- [ ] Post-processing effects (bloom, color grading)
|
|
768
|
+
- [ ] Advanced particle systems
|
|
769
|
+
- [ ] Mobile performance optimization
|
|
770
|
+
- [ ] Production deployment
|
|
771
|
+
|
|
772
|
+
### ๐งช Testing Strategy
|
|
773
|
+
|
|
774
|
+
#### Unit Tests
|
|
775
|
+
```typescript
|
|
776
|
+
// Test Three.js component imports and props
|
|
777
|
+
describe('CharacterModel3D', () => {
|
|
778
|
+
it('should be defined and importable', () => {
|
|
779
|
+
expect(CharacterModel3D).toBeDefined();
|
|
780
|
+
});
|
|
781
|
+
|
|
782
|
+
it('should accept Korean colors', () => {
|
|
783
|
+
expect(typeof KOREAN_COLORS.PRIMARY_CYAN).toBe('number');
|
|
784
|
+
});
|
|
785
|
+
});
|
|
786
|
+
```
|
|
787
|
+
|
|
788
|
+
#### E2E Tests
|
|
789
|
+
```typescript
|
|
790
|
+
// cypress/e2e/threejs-combat.cy.ts
|
|
791
|
+
describe('Three.js Combat Arena', () => {
|
|
792
|
+
it('should render 3D scene without errors', () => {
|
|
793
|
+
cy.visit('/combat');
|
|
794
|
+
cy.get('canvas').should('exist');
|
|
795
|
+
cy.wait(1000); // Allow scene to load
|
|
796
|
+
});
|
|
797
|
+
|
|
798
|
+
it('should maintain 60fps during combat', () => {
|
|
799
|
+
// Use custom FPS counter to validate performance
|
|
800
|
+
});
|
|
801
|
+
});
|
|
802
|
+
```
|
|
803
|
+
|
|
804
|
+
#### Manual Testing Checklist
|
|
805
|
+
- [ ] Visual quality on desktop (1920x1080)
|
|
806
|
+
- [ ] Visual quality on mobile (720p)
|
|
807
|
+
- [ ] 60fps sustained on desktop
|
|
808
|
+
- [ ] 55fps minimum on mobile
|
|
809
|
+
- [ ] Korean colors render correctly
|
|
810
|
+
- [ ] Html overlays positioned properly
|
|
811
|
+
- [ ] No WebGL errors in console
|
|
812
|
+
- [ ] Memory usage stays below 500MB (desktop)
|
|
813
|
+
|
|
814
|
+
### ๐ฌ Skeletal Animation Architecture
|
|
815
|
+
|
|
816
|
+
Black Trigram implements a comprehensive 28-bone skeletal system with hand poses and muscle tension visualization for authentic Korean martial arts movement.
|
|
817
|
+
|
|
818
|
+
#### Bone Hierarchy (28-Bone System)
|
|
819
|
+
|
|
820
|
+
```
|
|
821
|
+
PELVIS (root)
|
|
822
|
+
โโโ SPINE_LOWER
|
|
823
|
+
โ โโโ SPINE_MID
|
|
824
|
+
โ โ โโโ SPINE_UPPER
|
|
825
|
+
โ โ โโโ NECK
|
|
826
|
+
โ โ โ โโโ HEAD
|
|
827
|
+
โ โ โโโ SHOULDER_L โ UPPER_ARM_L โ ELBOW_L โ FOREARM_L โ WRIST_L โ HAND_L
|
|
828
|
+
โ โ โโโ SHOULDER_R โ UPPER_ARM_R โ ELBOW_R โ FOREARM_R โ WRIST_R โ HAND_R
|
|
829
|
+
โ โโโ HIP_L โ THIGH_L โ KNEE_L โ SHIN_L โ FOOT_L
|
|
830
|
+
โ โโโ HIP_R โ THIGH_R โ KNEE_R โ SHIN_R โ FOOT_R
|
|
831
|
+
```
|
|
832
|
+
|
|
833
|
+
**Total: 28 bones**
|
|
834
|
+
- 1 pelvis (root)
|
|
835
|
+
- 3 spine bones (lower, mid, upper)
|
|
836
|
+
- 2 head bones (neck, head)
|
|
837
|
+
- 12 arm bones (6 per arm: shoulder, upper_arm, elbow, forearm, wrist, hand)
|
|
838
|
+
- 10 leg bones (5 per leg: hip, thigh, knee, shin, foot)
|
|
839
|
+
|
|
840
|
+
**Implementation:** `src/types/skeletal.ts` - Complete bone hierarchy with TypeScript type definitions
|
|
841
|
+
|
|
842
|
+
#### Hand Pose System
|
|
843
|
+
|
|
844
|
+
**Seven Primary Hand Poses** (from `src/types/hand-animation.ts`):
|
|
845
|
+
- `fist` - Closed fist for punching - **์ฃผ๋จน** (Jumeok)
|
|
846
|
+
- `knife_hand` - Knife-hand strike with rigid edge - **์๋** (Sudo)
|
|
847
|
+
- `spear_hand` - Spear-hand thrust with pointed fingers - **๊ด์** (Gwansu)
|
|
848
|
+
- `palm_heel` - Palm-heel strike with curled fingers - **์ฅ๋ ฅ** (Jangnyeok)
|
|
849
|
+
- `grappling` - Grappling hand for grabs - **์ก๊ธฐ** (Japgi)
|
|
850
|
+
- `open` - Open hand neutral position - **ํด๊ธฐ** (Pyeogi)
|
|
851
|
+
- `relaxed` - Relaxed natural hand for walking/idle - **ํด์** (Hyusik)
|
|
852
|
+
|
|
853
|
+
**Implementation:** `src/types/hand-animation.ts` - Hand pose definitions and transitions
|
|
854
|
+
|
|
855
|
+
#### Muscle Tension Visualization
|
|
856
|
+
|
|
857
|
+
**Tension Mapping (0.0-1.0):**
|
|
858
|
+
- **High Tension (0.8-1.0)**: Bright red muscles - Active striking or blocking
|
|
859
|
+
- **Medium Tension (0.4-0.7)**: Orange muscles - Stance maintenance
|
|
860
|
+
- **Low Tension (0.0-0.3)**: Relaxed state - Recovery phase
|
|
861
|
+
|
|
862
|
+
**Visual Feedback:**
|
|
863
|
+
- Tension values mapped to bone visual intensity in real-time
|
|
864
|
+
- Color gradient from relaxed (dim) to maximum exertion (bright)
|
|
865
|
+
- Synchronized with technique execution and stance changes
|
|
866
|
+
|
|
867
|
+
**Implementation:** `src/types/muscle.ts` - Muscle activation system with tension tracking
|
|
868
|
+
|
|
869
|
+
#### Technique Animation System
|
|
870
|
+
|
|
871
|
+
**Keyframe Interpolation:**
|
|
872
|
+
- Start pose โ Intermediate frames โ Impact frame โ Recovery
|
|
873
|
+
- 60fps smooth interpolation between keyframes
|
|
874
|
+
- Technique-specific timing (fast strikes, slow defensive movements)
|
|
875
|
+
|
|
876
|
+
**Integration with Combat:**
|
|
877
|
+
- Technique selection triggers skeletal animation sequence
|
|
878
|
+
- Hand pose changes synchronized with strike timing
|
|
879
|
+
- Muscle tension peaks at impact frame
|
|
880
|
+
- Animation completes before next input accepted
|
|
881
|
+
|
|
882
|
+
**Implementation:**
|
|
883
|
+
- `src/types/technique.ts` - Technique type definitions with animation metadata
|
|
884
|
+
- `src/systems/animation/` - Animation system logic and keyframe management
|
|
885
|
+
|
|
886
|
+
#### Performance Considerations
|
|
887
|
+
|
|
888
|
+
**Optimization Strategies:**
|
|
889
|
+
- Bone transforms cached and reused when stance is stable
|
|
890
|
+
- Hand pose transitions use linear interpolation (LERP) for smooth 60fps
|
|
891
|
+
- Muscle tension updates only for visible characters
|
|
892
|
+
- Object pooling for animation state objects
|
|
893
|
+
|
|
894
|
+
**Memory Footprint:**
|
|
895
|
+
- 28 bones ร 16 bytes (Matrix4) = 448 bytes per character
|
|
896
|
+
- Hand pose state: ~50 bytes per character
|
|
897
|
+
- Muscle tension map: ~112 bytes (8 muscle groups)
|
|
898
|
+
- **Total per character: ~610 bytes**
|
|
899
|
+
|
|
900
|
+
**Target Performance:**
|
|
901
|
+
- 2 characters (player + opponent): ~1220 bytes animation overhead
|
|
902
|
+
- Negligible impact on 60fps target (<1ms per frame)
|
|
903
|
+
|
|
904
|
+
### ๐ฏ Performance Targets (Q1 2026)
|
|
905
|
+
|
|
906
|
+
| Platform | Resolution | Target FPS | Achieved FPS | Particles | Memory | Status |
|
|
907
|
+
|----------|-----------|------------|--------------|-----------|--------|--------|
|
|
908
|
+
| **Desktop** | 1200x800 | 60fps | 60fps | 1000+ | 180MB | โ
Met |
|
|
909
|
+
| **Tablet** | 1024x768 | 30fps | 30-45fps | 750+ | 150MB | โ ๏ธ Optimization Ongoing |
|
|
910
|
+
| **Mobile** | 720p | 30fps | 30-45fps | 500+ | 150MB | โ ๏ธ Optimization Ongoing |
|
|
911
|
+
|
|
912
|
+
**Overall Performance Rating**: 8.0/10 (60fps desktop maintained, mobile optimization in progress)
|
|
913
|
+
|
|
914
|
+
### ๐ Three.js Optimization Techniques
|
|
915
|
+
|
|
916
|
+
#### 1. Instancing for Particles
|
|
917
|
+
Single draw call for 1000+ particles using `<Instances>` from @react-three/drei.
|
|
918
|
+
|
|
919
|
+
#### 2. LOD (Level of Detail)
|
|
920
|
+
Automatic polygon reduction for distant objects using `<Detailed>` component.
|
|
921
|
+
|
|
922
|
+
#### 3. Skeletal Animation Optimization
|
|
923
|
+
- 28 bones per character (vs thousands of vertices)
|
|
924
|
+
- Cached bone matrices for stable stances
|
|
925
|
+
- 7 predefined hand poses (no per-frame calculations)
|
|
926
|
+
|
|
927
|
+
#### 4. Object Pooling
|
|
928
|
+
Particle systems and hit effects use object pooling to reduce garbage collection.
|
|
929
|
+
|
|
930
|
+
#### 5. Texture Compression
|
|
931
|
+
WebP for UI textures (70-80% size reduction), faster loading times.
|
|
932
|
+
|
|
933
|
+
#### 6. Geometry Merging
|
|
934
|
+
Static environment objects merged into single mesh for reduced draw calls.
|
|
935
|
+
|
|
936
|
+
### ๐ Current Benchmarks (Q1 2026)
|
|
937
|
+
|
|
938
|
+
| Metric | Desktop | Mobile | Target |
|
|
939
|
+
|--------|---------|--------|--------|
|
|
940
|
+
| **FPS** | 60fps | 30-45fps | 60fps / 30fps |
|
|
941
|
+
| **Memory** | 180MB | 150MB | <200MB |
|
|
942
|
+
| **Load Time** | 2.5s | 3.5s | <3s / <5s |
|
|
943
|
+
| **Draw Calls** | 50-80 | 40-60 | <100 |
|
|
944
|
+
| **Triangles** | 50k-80k | 30k-50k | <100k |
|
|
945
|
+
| **Bundle Size** | 240KB (gzipped) | 240KB (gzipped) | <300KB |
|
|
946
|
+
|
|
947
|
+
### ๐ฌ Performance Monitoring
|
|
948
|
+
|
|
949
|
+
- **Custom performance overlay component** (`PerformanceOverlay3D`) for real-time FPS and frame-timing monitoring (no `stats.js` dependency)
|
|
950
|
+
- **Custom performance metrics** tracked in React/Three.js state and surfaced via `PerformanceOverlay3D`
|
|
951
|
+
- **Performance tests** in the Vitest suite validating `PerformanceOverlay3D` frame timing, overlay stability, and animation timing
|
|
952
|
+
|
|
953
|
+
### ๐ฑ Mobile Performance Optimization (Q2 2026 Planned)
|
|
954
|
+
|
|
955
|
+
**Current Status:** 30-45fps on mobile (baseline target: 30fps, stretch goal: 60fps)
|
|
956
|
+
|
|
957
|
+
**Optimization Strategy:**
|
|
958
|
+
1. Adaptive quality settings based on device capabilities
|
|
959
|
+
2. Simplified shaders for mobile-optimized materials
|
|
960
|
+
3. Reduced particle count (500 cap vs 1000 desktop)
|
|
961
|
+
4. LOD aggressive tuning for earlier low-detail transitions
|
|
962
|
+
5. Optional 20-bone skeleton for mobile (remove finger bones)
|
|
963
|
+
|
|
964
|
+
### ๐ Documentation & Resources
|
|
965
|
+
|
|
966
|
+
#### Project Documentation
|
|
967
|
+
- **[ARCHITECTURE.md](./ARCHITECTURE.md)** - This document (architecture overview)
|
|
968
|
+
- **[FUTURE_ARCHITECTURE.md](./FUTURE_ARCHITECTURE.md)** - Roadmap and evolution planning
|
|
969
|
+
- **[game-status.md](./game-status.md)** - Current implementation status and metrics
|
|
970
|
+
|
|
971
|
+
#### External Resources
|
|
972
|
+
- **[Three.js Documentation](https://threejs.org/docs/)** - Official Three.js docs
|
|
973
|
+
- **[@react-three/fiber](https://docs.pmnd.rs/react-three-fiber/)** - React Three Fiber docs
|
|
974
|
+
- **[@react-three/drei](https://github.com/pmndrs/drei)** - Helper library
|
|
975
|
+
- **[Hack23/game](https://github.com/Hack23/game)** - Reference implementation
|
|
976
|
+
|
|
977
|
+
#### Learning Resources
|
|
978
|
+
- **Three.js Journey** - Comprehensive Three.js course
|
|
979
|
+
- **Discover three.js** - Free online book
|
|
980
|
+
- **React Three Fiber Examples** - Official example gallery
|
|
981
|
+
|
|
982
|
+
### โ
Success Criteria
|
|
983
|
+
|
|
984
|
+
**Infrastructure:**
|
|
985
|
+
- [x] Three.js packages installed and configured
|
|
986
|
+
- [x] TypeScript support enabled
|
|
987
|
+
- [x] Korean theming integration verified
|
|
988
|
+
- [x] Build pipeline working
|
|
989
|
+
- [x] Test infrastructure set up
|
|
990
|
+
|
|
991
|
+
**Performance:**
|
|
992
|
+
- [ ] 60fps sustained on desktop at 1920x1080
|
|
993
|
+
- [ ] 55fps minimum on mobile at 720p
|
|
994
|
+
- [ ] 1000+ particles at 60fps (desktop)
|
|
995
|
+
- [ ] Memory usage <500MB (desktop)
|
|
996
|
+
- [ ] Bundle size <1MB gzipped
|
|
997
|
+
|
|
998
|
+
**Quality:**
|
|
999
|
+
- [ ] Korean cultural aesthetics maintained
|
|
1000
|
+
- [ ] Smooth martial arts animations
|
|
1001
|
+
- [ ] Realistic vital point visualization
|
|
1002
|
+
- [ ] Immersive combat experience
|
|
1003
|
+
- [ ] Bilingual UI (Korean | English)
|
|
1004
|
+
|
|
1005
|
+
**Documentation:**
|
|
1006
|
+
- [x] Architecture documented
|
|
1007
|
+
- [x] Migration guide created
|
|
1008
|
+
- [x] Pattern library established
|
|
1009
|
+
- [ ] API documentation updated
|
|
1010
|
+
- [ ] Team training completed
|
|
1011
|
+
|
|
1012
|
+
---
|
|
1013
|
+
|
|
1014
|
+
## ๐ง File Structure (Q1 2026)
|
|
1015
|
+
|
|
1016
|
+
### Current Implementation Structure
|
|
1017
|
+
|
|
1018
|
+
```
|
|
1019
|
+
src/
|
|
1020
|
+
โโโ components/ # React + Three.js components
|
|
1021
|
+
โ โโโ screens/ # Main game screens
|
|
1022
|
+
โ โ โโโ combat/ # CombatScreen3D (production-ready)
|
|
1023
|
+
โ โ โโโ intro/ # IntroScreen with Korean aesthetics
|
|
1024
|
+
โ โ โโโ training/ # TrainingScreen for practice
|
|
1025
|
+
โ โ โโโ controls/ # ControlsScreen documentation
|
|
1026
|
+
โ โโโ game/ # Game-specific components
|
|
1027
|
+
โ โโโ shared/ # Shared components across screens
|
|
1028
|
+
โ โ โโโ three/ # Three.js 3D components
|
|
1029
|
+
โ โ โ โโโ anatomy/ # BoneAttachedMuscles, SkeletalRig
|
|
1030
|
+
โ โ โ โโโ effects/ # ParticleEffects, StanceAura
|
|
1031
|
+
โ โ โโโ mobile/ # Mobile touch controls
|
|
1032
|
+
โ โ โ โโโ *Pure.tsx # Pure DOM components (outside Canvas)
|
|
1033
|
+
โ โ โ โโโ *.tsx # Three.js Html components (inside Canvas)
|
|
1034
|
+
โ โ โโโ ui/ # UI components with Korean theming
|
|
1035
|
+
โ โโโ dev/ # Development and testing components
|
|
1036
|
+
โโโ systems/ # Core game logic systems
|
|
1037
|
+
โ โโโ trigram/ # 8-trigram stance system
|
|
1038
|
+
โ โ โโโ StanceManager.ts
|
|
1039
|
+
โ โ โโโ TransitionCalculator.ts
|
|
1040
|
+
โ โ โโโ TrigramCalculator.ts
|
|
1041
|
+
โ โ โโโ KoreanCulture.ts
|
|
1042
|
+
โ โโโ vitalpoint/ # 70 anatomical vital points
|
|
1043
|
+
โ โ โโโ VitalPointSystem.ts
|
|
1044
|
+
โ โ โโโ EnhancedAnatomy.ts
|
|
1045
|
+
โ โ โโโ HitDetection.ts
|
|
1046
|
+
โ โโโ CombatSystem.ts # Main combat logic and orchestration (36,888 bytes ~36KB)
|
|
1047
|
+
โ โโโ EffectCalculator.ts # Combat effect calculations
|
|
1048
|
+
โ โโโ PlayerEffectManager.ts # Player effect management
|
|
1049
|
+
โ โโโ combat/ # Combat subsystems
|
|
1050
|
+
โ โ โโโ PainResponseSystem.ts # Pain response (90% complete, 37 tests)
|
|
1051
|
+
โ โ โโโ ConsciousnessSystem.ts # Consciousness (90% complete, 36 tests)
|
|
1052
|
+
โ โ โโโ BalanceSystem.ts # Balance and fall mechanics
|
|
1053
|
+
โ โ โโโ CombatStateSystem.ts # Combat state management
|
|
1054
|
+
โ โโโ animation/ # Skeletal animation system (Q1 2026)
|
|
1055
|
+
โ โ โโโ core/ # Core animation logic
|
|
1056
|
+
โ โ โ โโโ AnimationRegistry.ts # Animation registration and lookup
|
|
1057
|
+
โ โ โ โโโ AnimationStateMachine.ts # Animation state transitions
|
|
1058
|
+
โ โ โโโ builders/ # Builders for animation data
|
|
1059
|
+
โ โ โ โโโ HandPoses.ts # 7 hand pose definitions
|
|
1060
|
+
โ โ โโโ systems/ # Animation systems and orchestration
|
|
1061
|
+
โ โ โโโ MuscleActivation.ts # Muscle tension visualization
|
|
1062
|
+
โ โโโ bodypart/ # Body part health tracking (8 parts)
|
|
1063
|
+
โ โโโ physics/ # Physics simulation
|
|
1064
|
+
โ โโโ breathing/ # Breathing disruption system (75% complete)
|
|
1065
|
+
โ โโโ ai/ # AI combat logic
|
|
1066
|
+
โโโ data/ # Game data and constants
|
|
1067
|
+
โ โโโ techniques.ts # 20 techniques (4 per archetype)
|
|
1068
|
+
โ โโโ archetypePhysicalAttributes.ts # 5 player archetypes
|
|
1069
|
+
โ โโโ archetypeClothing.ts # Clothing system per archetype
|
|
1070
|
+
โโโ audio/ # Audio system (87.38% line coverage)
|
|
1071
|
+
โ โโโ AudioProvider.tsx # React context provider and useAudio hook
|
|
1072
|
+
โ โโโ AudioAssetRegistry.ts # Sound library and metadata
|
|
1073
|
+
โ โโโ AudioManager.ts # Audio playback and routing
|
|
1074
|
+
โ โโโ BoneImpactAudioMap.ts # Bone impact audio system (60% complete)
|
|
1075
|
+
โโโ types/ # TypeScript type definitions
|
|
1076
|
+
โ โโโ constants/ # Korean colors, fonts, animations
|
|
1077
|
+
โ โโโ skeletal.ts # 28-bone skeletal system (Q1 2026)
|
|
1078
|
+
โ โโโ muscle.ts # Muscle tension system (Q1 2026)
|
|
1079
|
+
โ โโโ hand-animation.ts # 7 hand pose definitions (Q1 2026)
|
|
1080
|
+
โ โโโ technique.ts # Technique type definitions
|
|
1081
|
+
โ โโโ player-visual.ts # Player visual properties
|
|
1082
|
+
โ โโโ physics.ts # Physics types
|
|
1083
|
+
โ โโโ clothing.ts # Clothing system types
|
|
1084
|
+
โโโ utils/ # Utility functions
|
|
1085
|
+
โ โโโ player3DHelpers.ts # PlayerState conversion utilities
|
|
1086
|
+
โ โโโ combatHelpers.ts # Combat utility functions
|
|
1087
|
+
โ โโโ threeObjectPool.ts # Object pooling for performance
|
|
1088
|
+
โ โโโ clothingColors.ts # Archetype clothing colors
|
|
1089
|
+
โ โโโ performance/ # Performance monitoring utilities
|
|
1090
|
+
โโโ hooks/ # Custom React hooks
|
|
1091
|
+
โโโ useCombat.ts # Combat-related hooks
|
|
1092
|
+
```
|
|
1093
|
+
|
|
1094
|
+
### Key Implementation Files (Q1 2026)
|
|
1095
|
+
|
|
1096
|
+
**Combat Systems:**
|
|
1097
|
+
- `src/systems/CombatSystem.ts` (36,888 bytes ~36KB) - Core combat logic with 8/12 realism systems
|
|
1098
|
+
- `src/systems/VitalPointSystem.ts` (19,583 bytes ~20KB) - 70-point vital targeting (100% complete)
|
|
1099
|
+
- `src/systems/TrigramSystem.ts` (12,843 bytes ~13KB) - 8-stance management with I Ching philosophy
|
|
1100
|
+
- `src/systems/combat/PainResponseSystem.ts` - Pain response system (90% complete, production-ready with 37 tests)
|
|
1101
|
+
- `src/systems/combat/ConsciousnessSystem.ts` - Consciousness levels (90% complete, 4-level gradation, 36 tests)
|
|
1102
|
+
- `src/systems/breathing/BreathingDisruptionSystem.ts` - Breathing disruption (75% complete)
|
|
1103
|
+
|
|
1104
|
+
**Skeletal Animation (Q1 2026):**
|
|
1105
|
+
- `src/types/skeletal.ts` (857 lines) - 28-bone hierarchy definitions, BoneName enum, SkeletalRig interface
|
|
1106
|
+
- `src/types/muscle.ts` - Muscle tension visualization system (0.0-1.0 intensity mapping)
|
|
1107
|
+
- `src/types/hand-animation.ts` - Hand pose system (7 primary poses: fist_vertical, fist_horizontal, open_hand_knife, spear_hand, grasping, open_palm, relaxed)
|
|
1108
|
+
- `src/systems/animation/` - Animation system logic and keyframe management
|
|
1109
|
+
|
|
1110
|
+
**Player Archetypes:**
|
|
1111
|
+
- `src/data/archetypePhysicalAttributes.ts` (20,875 bytes ~21KB) - Physical attributes for 5 archetypes
|
|
1112
|
+
- `src/data/archetypeClothing.ts` (15,792 bytes ~16KB) - Clothing system per archetype
|
|
1113
|
+
- `src/data/techniques.ts` (19,730 bytes ~20KB) - 20 martial arts techniques (4 per archetype)
|
|
1114
|
+
|
|
1115
|
+
**Three.js Components:**
|
|
1116
|
+
- `src/components/shared/three/` - 3D rendering components (Player3DUnified, StanceAura, SkeletalRig)
|
|
1117
|
+
- `src/components/screens/combat/` - CombatScreen3D implementation (production-ready, 42.52% line coverage per docs/coverage/coverage-summary.json)
|
|
1118
|
+
- `src/utils/player3DHelpers.ts` - PlayerState to Three.js conversion utilities
|
|
1119
|
+
|
|
1120
|
+
**Audio System (87.38% Line Coverage):**
|
|
1121
|
+
- `src/audio/AudioProvider.tsx` - React context provider and useAudio hook
|
|
1122
|
+
- `src/audio/AudioAssetRegistry.ts` - Sound library with damage-scaled audio
|
|
1123
|
+
- `src/audio/AudioManager.ts` - Audio playback with Web Audio API
|
|
1124
|
+
- `src/audio/BoneImpactAudioMap.ts` - Bone impact audio system (60% complete)
|
|
1125
|
+
- 87.38% line coverage across audio systems (790/904 lines, per docs/coverage/coverage-summary.json)
|
|
1126
|
+
|
|
1127
|
+
**Test Coverage (Q1 2026):**
|
|
1128
|
+
- **Overall**: 73.73% line coverage (Vitest unit + Cypress E2E, from docs/coverage/coverage-summary.json)
|
|
1129
|
+
- **New Components**: 95% test coverage
|
|
1130
|
+
- **Core Systems**: >85% test coverage
|
|
1131
|
+
- **Audio System**: 87.38% line coverage (audio folder, per docs/coverage/coverage-summary.json)
|
|
1132
|
+
- **Pain/Consciousness**: 73 comprehensive tests (production-ready)
|
|
1133
|
+
|
|
1134
|
+
### Component Naming Conventions
|
|
1135
|
+
|
|
1136
|
+
**Mobile Component Pattern:**
|
|
1137
|
+
- Components with `Pure` suffix are pure DOM components without Three.js dependencies
|
|
1138
|
+
- Used for rendering outside Canvas context (e.g., `StanceWheelPure`, `GestureRecognizerPure`, `MobileControlsPure`)
|
|
1139
|
+
- Components without `Pure` suffix use `Html` from `@react-three/drei` and must be inside Canvas
|
|
1140
|
+
- Example: `StanceWheelPure.tsx` (position: fixed, z-index layering) vs `StanceWheel.tsx` (Html wrapper, Canvas-only)
|
|
1141
|
+
|
|
1142
|
+
**Rationale:**
|
|
1143
|
+
- Mobile touch controls must work outside Canvas for reliable event handling
|
|
1144
|
+
- Pure DOM components have no Three.js overhead and lighter bundle size
|
|
1145
|
+
- Clear naming prevents R3F hook errors ("R3F hooks can only be used inside canvas component")
|
|
1146
|
+
|
|
1147
|
+
|
|
1148
|
+
---
|
|
1149
|
+
|
|
1150
|
+
## ๐ Combat Flow Sequence
|
|
1151
|
+
|
|
1152
|
+
```mermaid
|
|
1153
|
+
sequenceDiagram
|
|
1154
|
+
title ๐ Combat Flow โ Fully Frontend (Black Trigram Q1 2026)
|
|
1155
|
+
|
|
1156
|
+
participant Player as "๐งโ๐คโ๐ง Player"
|
|
1157
|
+
participant InputSystem as "๐ฎ InputSystem"
|
|
1158
|
+
participant CombatEngine as "โ๏ธ Combat Engine"
|
|
1159
|
+
participant TrigramSystem as "๐ถ Trigram System"
|
|
1160
|
+
participant VitalPointSystem as "๐ฏ VitalPoint System"
|
|
1161
|
+
participant AudioManager as "๐ต Audio Manager"
|
|
1162
|
+
participant StateStore as "๐๏ธ Zustand Store"
|
|
1163
|
+
participant ThreeScene as "๐จ Three.js Scene"
|
|
1164
|
+
|
|
1165
|
+
Note over Player,ThreeScene: ๐ฅ Korean Martial Arts Real-Time Combat
|
|
1166
|
+
|
|
1167
|
+
Player->>InputSystem: ๐ฅ Press stance key (e.g., '1' for ๊ฑด/Geon)
|
|
1168
|
+
InputSystem->>CombatEngine: ๐ Stance change request
|
|
1169
|
+
CombatEngine->>TrigramSystem: ๐ Calculate transition (Current โ Geon)
|
|
1170
|
+
TrigramSystem->>StateStore: โ Deduct Ki/Stamina
|
|
1171
|
+
TrigramSystem-->>CombatEngine: โ
Transition result (Success/Fail)
|
|
1172
|
+
CombatEngine->>AudioManager: ๐ Play stance change SFX
|
|
1173
|
+
CombatEngine->>ThreeScene: โจ Update player aura visuals (StanceAura3D)
|
|
1174
|
+
|
|
1175
|
+
Player->>InputSystem: โ๏ธ Click to attack (Mouse click)
|
|
1176
|
+
InputSystem->>CombatEngine: ๐ฏ Attack command with screen coords
|
|
1177
|
+
CombatEngine->>TrigramSystem: ๐ก Get current technique parameters
|
|
1178
|
+
CombatEngine->>VitalPointSystem: ๐ Hit detection (polygon-based, <0.01ms)
|
|
1179
|
+
VitalPointSystem-->VitalPointSystem: ๐ฏ Compute precision vs 70 vital points
|
|
1180
|
+
VitalPointSystem-->>CombatEngine: โ
Hit result (VitalPointData, Multiplier)
|
|
1181
|
+
CombatEngine->>CombatEngine: ๐งฎ Compute final damage (base ร trigram_adv ร vp_mult)
|
|
1182
|
+
CombatEngine->>StateStore: ๐ฉธ Reduce enemy body part health (8 parts)
|
|
1183
|
+
CombatEngine->>AudioManager: ๐ Play impact SFX (damage-scaled audio)
|
|
1184
|
+
CombatEngine->>ThreeScene: ๐ฅ Render hit effects, damage numbers (HitEffects3D)
|
|
1185
|
+
CombatEngine->>StateStore: โก Update combat state (pain, consciousness, balance)
|
|
1186
|
+
CombatEngine-->>ThreeScene: ๐บ Trigger enemy reaction animation (SkeletalAnimation)
|
|
1187
|
+
```
|
|
1188
|
+
> - **AudioManager**: Web Audio API plays sound buffers loaded at runtime from the Audio CDN.
|
|
1189
|
+
> - **Three.js Scene**: Via `@react-three/fiber` Canvas component, renders 3D characters, environment, effects, and UI overlays via Html.
|
|
1190
|
+
> - **Zustand Store**: All shared state (player health, Ki, stance) resides in memory; React components subscribe.
|
|
1191
|
+
|
|
1192
|
+
---
|
|
1193
|
+
|
|
1194
|
+
## โก Performance Architecture (Q1 2026)
|
|
1195
|
+
|
|
1196
|
+
### **Performance Targets**
|
|
1197
|
+
|
|
1198
|
+
| Platform | Resolution | Target FPS | Achieved FPS | Particles | Memory | Status |
|
|
1199
|
+
|----------|-----------|------------|--------------|-----------|--------|--------|
|
|
1200
|
+
| **High-end Desktop** | 1920x1080 | 60fps | 60fps | 1000+ | <500MB | โ
Met |
|
|
1201
|
+
| **Mid-range Desktop** | 1920x1080 | 60fps | 58-60fps | 750+ | <400MB | โ
Good |
|
|
1202
|
+
| **High-end Mobile** | 1290x2796 | 55fps | 55-60fps | 500+ | <350MB | โ
Acceptable |
|
|
1203
|
+
| **Mid-range Mobile** | 1080x2400 | 55fps | 50-55fps | 400+ | <300MB | โ ๏ธ Needs Optimization |
|
|
1204
|
+
|
|
1205
|
+
**Overall Performance Rating**: 8.0/10 (60fps maintained on desktop, mobile optimization ongoing)
|
|
1206
|
+
|
|
1207
|
+
### **Three.js-Specific Optimizations**
|
|
1208
|
+
|
|
1209
|
+
```mermaid
|
|
1210
|
+
graph TD
|
|
1211
|
+
subgraph PM["๐ Performance Monitoring (Q1 2026)"]
|
|
1212
|
+
PerfMon[๐ Performance Monitor]
|
|
1213
|
+
FPS[๐ FPS Tracking - PerformanceOverlay3D]
|
|
1214
|
+
Memory[๐พ Memory Usage - Chrome DevTools]
|
|
1215
|
+
GC[๐๏ธ GC Observations - Three.js Object Disposal]
|
|
1216
|
+
AssetTiming[โฑ๏ธ Asset Load Times - Three.js Models & Textures]
|
|
1217
|
+
ThreeRenderer[๐จ Three.js Renderer Stats - Draw Calls]
|
|
1218
|
+
end
|
|
1219
|
+
|
|
1220
|
+
subgraph OT["๐ Optimization Techniques (Three.js)"]
|
|
1221
|
+
OptEngine[โ๏ธ Optimization Engine]
|
|
1222
|
+
Instancing[๐ฆ Three.js Instancing - 1000+ Particles]
|
|
1223
|
+
LOD[๐ญ Level of Detail - Character Models]
|
|
1224
|
+
ObjectPooling[๐ Object Pooling - Three.js Objects]
|
|
1225
|
+
GeometryReuse[๐บ Geometry Reuse - Shared Meshes]
|
|
1226
|
+
CodeSplitting[๐ Dynamic import - Three.js Chunks]
|
|
1227
|
+
AudioCompression[๐ต OGG/WebM Streaming - Web Audio API]
|
|
1228
|
+
Debounce[โณ Debounce/Throttle - useFrame Optimization]
|
|
1229
|
+
Memoization[๐ง React.memo / useMemo - Component Optimization]
|
|
1230
|
+
FrustumCulling[๐๏ธ Frustum Culling - Auto Off-screen Culling]
|
|
1231
|
+
MaterialReuse[๐จ Material Caching - Shared Materials]
|
|
1232
|
+
end
|
|
1233
|
+
|
|
1234
|
+
subgraph FS["๐ก๏ธ Fallback Systems"]
|
|
1235
|
+
FallbackMgr[โ ๏ธ Fallback Manager]
|
|
1236
|
+
LowQualityMode[๐ Reduced Polygon Count]
|
|
1237
|
+
ReducedEffects[โ Disable Shadows & Post-Processing]
|
|
1238
|
+
ProceduralAudio[๐น Procedural SFX Fallback]
|
|
1239
|
+
WebGLFallback[๐ผ๏ธ Fallback to WebGL 1.0]
|
|
1240
|
+
end
|
|
1241
|
+
|
|
1242
|
+
PerfMon --> FPS
|
|
1243
|
+
PerfMon --> Memory
|
|
1244
|
+
PerfMon --> GC
|
|
1245
|
+
PerfMon --> AssetTiming
|
|
1246
|
+
PerfMon --> ThreeRenderer
|
|
1247
|
+
|
|
1248
|
+
OptEngine --> Instancing
|
|
1249
|
+
OptEngine --> LOD
|
|
1250
|
+
OptEngine --> ObjectPooling
|
|
1251
|
+
OptEngine --> GeometryReuse
|
|
1252
|
+
OptEngine --> CodeSplitting
|
|
1253
|
+
OptEngine --> AudioCompression
|
|
1254
|
+
OptEngine --> Debounce
|
|
1255
|
+
OptEngine --> Memoization
|
|
1256
|
+
OptEngine --> FrustumCulling
|
|
1257
|
+
OptEngine --> MaterialReuse
|
|
1258
|
+
|
|
1259
|
+
FallbackMgr --> LowQualityMode
|
|
1260
|
+
FallbackMgr --> ReducedEffects
|
|
1261
|
+
FallbackMgr --> ProceduralAudio
|
|
1262
|
+
FallbackMgr --> WebGLFallback
|
|
1263
|
+
|
|
1264
|
+
PM -.-> OT
|
|
1265
|
+
OT -.-> FS
|
|
1266
|
+
|
|
1267
|
+
classDef perfMon fill:#4ecdc4,stroke:#333,stroke-width:2px,color:#000
|
|
1268
|
+
classDef optTech fill:#45b7d1,stroke:#333,stroke-width:2px,color:#000
|
|
1269
|
+
classDef fallback fill:#f9ca24,stroke:#333,stroke-width:2px,color:#000
|
|
1270
|
+
|
|
1271
|
+
class PerfMon,FPS,Memory,GC,AssetTiming,ThreeRenderer perfMon
|
|
1272
|
+
class OptEngine,Instancing,LOD,ObjectPooling,GeometryReuse,CodeSplitting,AudioCompression,Debounce,Memoization,FrustumCulling,MaterialReuse optTech
|
|
1273
|
+
class FallbackMgr,LowQualityMode,ReducedEffects,ProceduralAudio,WebGLFallback fallback
|
|
1274
|
+
```
|
|
1275
|
+
|
|
1276
|
+
### **Performance Monitoring (Q1 2026)**
|
|
1277
|
+
|
|
1278
|
+
- **๐ FPS Tracking**: PerformanceOverlay3D custom monitor component (`src/utils/performance/PerformanceOverlay3D.tsx`)
|
|
1279
|
+
- **๐พ Memory Usage**: Chrome DevTools memory profiling + custom Three.js object tracking
|
|
1280
|
+
- **๐๏ธ GC Observations**: Monitor Three.js object disposal (geometries, materials, textures) to prevent memory leaks
|
|
1281
|
+
- **โฑ๏ธ Asset Timing**: Three.js loading manager for 3D models, textures, and audio asset timing
|
|
1282
|
+
- **๐จ Renderer Stats**: Track draw calls, triangles rendered, and shader compile time
|
|
1283
|
+
|
|
1284
|
+
### **Three.js Optimization Techniques**
|
|
1285
|
+
|
|
1286
|
+
1. **๐ฆ Three.js Instancing** (Implementation: `src/utils/threeObjectPool.ts`)
|
|
1287
|
+
|
|
1288
|
+
- Use `THREE.InstancedMesh` for particle systems (1000+ particles at 60fps)
|
|
1289
|
+
- Batch hit effects, ki energy particles using instancing
|
|
1290
|
+
- Reduces draw calls from 1000+ to 1 per particle type
|
|
1291
|
+
|
|
1292
|
+
2. **๐ญ Level of Detail (LOD)** (Planned for Phase 4)
|
|
1293
|
+
|
|
1294
|
+
- High-detail character models at close range (28-bone skeletal system)
|
|
1295
|
+
- Medium-detail models at medium distance (simplified bone hierarchy)
|
|
1296
|
+
- Low-detail models at far distance (capsule geometry)
|
|
1297
|
+
- `@react-three/drei` `<Detailed>` component for automatic LOD switching
|
|
1298
|
+
|
|
1299
|
+
3. **๐ Object Pooling** (Implementation: `src/utils/threeObjectPool.ts`)
|
|
1300
|
+
|
|
1301
|
+
- Pre-allocate Three.js objects (meshes, materials, geometries)
|
|
1302
|
+
- Recycle particle objects instead of creating/destroying
|
|
1303
|
+
- Pool damage numbers, hit effects, and temporary visual elements
|
|
1304
|
+
- **Result**: Reduced GC pressure, stable 60fps
|
|
1305
|
+
|
|
1306
|
+
4. **๐บ Geometry Reuse**
|
|
1307
|
+
|
|
1308
|
+
- Shared geometries for identical shapes (capsules for characters, spheres for particles)
|
|
1309
|
+
- Single geometry instance referenced by multiple meshes
|
|
1310
|
+
- Dispose only when last reference removed
|
|
1311
|
+
|
|
1312
|
+
5. **๐จ Material Caching**
|
|
1313
|
+
|
|
1314
|
+
- Pre-create materials with Korean colors (`KOREAN_COLORS.PRIMARY_CYAN`, etc.)
|
|
1315
|
+
- Reuse materials across multiple meshes
|
|
1316
|
+
- Update material properties (color, emissive) instead of creating new materials
|
|
1317
|
+
|
|
1318
|
+
6. **๐๏ธ Three.js Resource Disposal** (์์ ์ ๋ฆฌ | Resource Cleanup)
|
|
1319
|
+
|
|
1320
|
+
**Critical for Memory Management**: All Three.js GPU resources (geometries, materials, textures) must be explicitly disposed when no longer needed. Failure to dispose causes memory leaks that degrade performance over time.
|
|
1321
|
+
|
|
1322
|
+
**Resources Requiring Disposal:**
|
|
1323
|
+
- โ
Geometries: `geometry.dispose()`
|
|
1324
|
+
- โ
Materials: `material.dispose()`
|
|
1325
|
+
- โ
Textures: `texture.dispose()`
|
|
1326
|
+
- โ ๏ธ Vector3, Matrix4, Color: No disposal needed (just data structures)
|
|
1327
|
+
|
|
1328
|
+
**Best Practices:**
|
|
1329
|
+
|
|
1330
|
+
```typescript
|
|
1331
|
+
// โ BAD: Memory leak - geometry never disposed
|
|
1332
|
+
export const Component3D: React.FC = () => {
|
|
1333
|
+
const geometry = useMemo(() => new THREE.BoxGeometry(1, 1, 1), []);
|
|
1334
|
+
const material = useMemo(() => new THREE.MeshStandardMaterial({ color: 0xff0000 }), []);
|
|
1335
|
+
|
|
1336
|
+
return <mesh geometry={geometry} material={material} />;
|
|
1337
|
+
};
|
|
1338
|
+
|
|
1339
|
+
// โ
GOOD: Proper cleanup on unmount
|
|
1340
|
+
export const Component3D: React.FC = () => {
|
|
1341
|
+
const geometry = useMemo(() => new THREE.BoxGeometry(1, 1, 1), []);
|
|
1342
|
+
const material = useMemo(() => new THREE.MeshStandardMaterial({ color: 0xff0000 }), []);
|
|
1343
|
+
|
|
1344
|
+
// ์์ ์ ๋ฆฌ | Resource cleanup
|
|
1345
|
+
useEffect(() => {
|
|
1346
|
+
return () => {
|
|
1347
|
+
geometry.dispose();
|
|
1348
|
+
material.dispose();
|
|
1349
|
+
};
|
|
1350
|
+
}, [geometry, material]);
|
|
1351
|
+
|
|
1352
|
+
return <mesh geometry={geometry} material={material} />;
|
|
1353
|
+
};
|
|
1354
|
+
```
|
|
1355
|
+
|
|
1356
|
+
**Implementation References:**
|
|
1357
|
+
- `src/utils/particlePool.ts` - Object pooling with proper disposal
|
|
1358
|
+
- `src/components/screens/training/components/TrainingDummy3D.tsx` - Component disposal patterns
|
|
1359
|
+
- `src/components/shared/three/scene/KoreanSignage3D.tsx` - Material cleanup examples
|
|
1360
|
+
|
|
1361
|
+
**Audit Tool:**
|
|
1362
|
+
```bash
|
|
1363
|
+
# Run automated disposal audit to find missing cleanup
|
|
1364
|
+
npx tsx scripts/audit-threejs-disposal.ts
|
|
1365
|
+
npx tsx scripts/audit-threejs-disposal.ts --fix-report
|
|
1366
|
+
```
|
|
1367
|
+
|
|
1368
|
+
**Memory Impact:**
|
|
1369
|
+
- **Before fixes**: ~4GB heap usage after 30min gameplay
|
|
1370
|
+
- **After fixes**: ~2.5GB heap usage after 30min gameplay
|
|
1371
|
+
- **Improvement**: 37.5% memory reduction, stable 60fps maintained
|
|
1372
|
+
|
|
1373
|
+
**Performance Monitoring:**
|
|
1374
|
+
```typescript
|
|
1375
|
+
// Monitor memory leaks during development
|
|
1376
|
+
import { globalParticlePool } from '@/utils/particlePool';
|
|
1377
|
+
|
|
1378
|
+
// Check pool stats
|
|
1379
|
+
console.log(globalParticlePool.getStats());
|
|
1380
|
+
// Output: { total: 20, active: 5, inactive: 15, maxSize: 50 }
|
|
1381
|
+
|
|
1382
|
+
// In Chrome DevTools:
|
|
1383
|
+
// 1. Memory โ Take heap snapshot
|
|
1384
|
+
// 2. Search for "THREE.BufferGeometry" or "THREE.Material"
|
|
1385
|
+
// 3. Check "Detached" instances - should be minimal
|
|
1386
|
+
```
|
|
1387
|
+
|
|
1388
|
+
7. **๐๏ธ Frustum Culling**
|
|
1389
|
+
|
|
1390
|
+
- Automatic off-screen object culling by Three.js renderer
|
|
1391
|
+
- No rendering cost for objects outside camera view
|
|
1392
|
+
- Works seamlessly with skeletal animation system
|
|
1393
|
+
|
|
1394
|
+
8. **๐ Code Splitting** (Implementation: `vite.config.ts`)
|
|
1395
|
+
|
|
1396
|
+
- Three.js vendor chunk (~240KB gzipped)
|
|
1397
|
+
- Lazy-load training screens and non-critical components
|
|
1398
|
+
- Dynamic import for large data files
|
|
1399
|
+
|
|
1400
|
+
9. **โณ useFrame Optimization**
|
|
1401
|
+
|
|
1402
|
+
- Selective updates in useFrame hooks (only when needed)
|
|
1403
|
+
- Skip animation updates for off-screen characters
|
|
1404
|
+
- Throttle muscle tension updates to 30fps (sufficient for visual feedback)
|
|
1405
|
+
|
|
1406
|
+
10. **๐ง React Memoization**
|
|
1407
|
+
|
|
1408
|
+
- `React.memo` for pure Three.js wrapper components
|
|
1409
|
+
- `useMemo` for expensive calculations (bone transforms, hit detection)
|
|
1410
|
+
- `useCallback` for event handlers passed to children
|
|
1411
|
+
|
|
1412
|
+
### **Performance Benchmarks (Q1 2026)**
|
|
1413
|
+
|
|
1414
|
+
#### Desktop Performance
|
|
1415
|
+
```
|
|
1416
|
+
Hardware: RTX 3080, Intel i7-11700K, 32GB RAM
|
|
1417
|
+
Resolution: 1920x1080
|
|
1418
|
+
Scene Complexity: 2 characters (28 bones each), 500 particles, 70 vital points
|
|
1419
|
+
Result: 60fps sustained, <400MB memory, 0.8ms GC pauses
|
|
1420
|
+
Status: โ
Exceeds target
|
|
1421
|
+
```
|
|
1422
|
+
|
|
1423
|
+
#### Mobile Performance
|
|
1424
|
+
```
|
|
1425
|
+
Hardware: iPhone 14 Pro, A16 Bionic
|
|
1426
|
+
Resolution: 1290x2796 (downscaled to 720p for rendering)
|
|
1427
|
+
Scene Complexity: 2 characters (simplified), 300 particles, 70 vital points
|
|
1428
|
+
Result: 55-60fps, <350MB memory, 1.2ms GC pauses
|
|
1429
|
+
Status: โ
Meets target
|
|
1430
|
+
```
|
|
1431
|
+
|
|
1432
|
+
#### Mid-range Mobile Performance
|
|
1433
|
+
```
|
|
1434
|
+
Hardware: Google Pixel 6a, Tensor SoC
|
|
1435
|
+
Resolution: 1080x2400 (downscaled to 540p for rendering)
|
|
1436
|
+
Scene Complexity: 2 characters (simplified), 200 particles, 35 visible vital points
|
|
1437
|
+
Result: 50-55fps, <300MB memory, 2.0ms GC pauses
|
|
1438
|
+
Status: โ ๏ธ Below 55fps target - needs optimization
|
|
1439
|
+
```
|
|
1440
|
+
|
|
1441
|
+
### **Optimization Priorities (Q2 2026)**
|
|
1442
|
+
|
|
1443
|
+
1. **๐ด Critical**: Mobile performance optimization (target 55fps on mid-range devices)
|
|
1444
|
+
2. **๐ก High**: Implement LOD system for character models
|
|
1445
|
+
3. **๐ก High**: Add post-processing effects toggle for low-end devices
|
|
1446
|
+
4. **๐ Medium**: Optimize skeletal animation for mobile (reduce bone updates)
|
|
1447
|
+
5. **๐ Medium**: Implement progressive 3D model loading
|
|
1448
|
+
|
|
1449
|
+
### **Fallback Systems (Graceful Degradation)**
|
|
1450
|
+
|
|
1451
|
+
1. **๐ Low Quality Mode**
|
|
1452
|
+
|
|
1453
|
+
- Detect GPU capabilities at startup. If low, reduce canvas resolution and disable sub-pixel effects.
|
|
1454
|
+
- Toggle via "Low Graphics" checkbox in settings (Zustand flag: `useUIState.isLowGraphicsMode`).
|
|
1455
|
+
|
|
1456
|
+
2. **โ Reduced Effects**
|
|
1457
|
+
|
|
1458
|
+
- On performance drop (FPS < 30), disable expensive particles: blood splatter, continuous ki swirl.
|
|
1459
|
+
- Use `useUIState.isLowPerfMode` to toggle off these render layers.
|
|
1460
|
+
|
|
1461
|
+
3. **๐น Procedural Audio**
|
|
1462
|
+
|
|
1463
|
+
- If Audio CDN fails (e.g., offline), fall back to simple beep-thump procedural sounds via `DefaultSoundGenerator.ts`.
|
|
1464
|
+
|
|
1465
|
+
---
|
|
1466
|
+
|
|
1467
|
+
## ๐ SWOT Analysis
|
|
1468
|
+
|
|
1469
|
+
### Traditional SWOT Quadrant Chart
|
|
1470
|
+
|
|
1471
|
+
```mermaid
|
|
1472
|
+
%%{init: {
|
|
1473
|
+
"theme": "neutral",
|
|
1474
|
+
"themeVariables": {
|
|
1475
|
+
"quadrant1Fill": "#2b83ba",
|
|
1476
|
+
"quadrant2Fill": "#1a9641",
|
|
1477
|
+
"quadrant3Fill": "#d7191c",
|
|
1478
|
+
"quadrant4Fill": "#756bb1",
|
|
1479
|
+
"quadrantTitleFill": "#ffffff",
|
|
1480
|
+
"quadrantPointFill": "#ffffff",
|
|
1481
|
+
"quadrantPointTextFill": "#000000",
|
|
1482
|
+
"quadrantXAxisTextFill": "#000000",
|
|
1483
|
+
"quadrantYAxisTextFill": "#000000"
|
|
1484
|
+
},
|
|
1485
|
+
"quadrantChart": {
|
|
1486
|
+
"chartWidth": 700,
|
|
1487
|
+
"chartHeight": 700,
|
|
1488
|
+
"pointLabelFontSize": 14,
|
|
1489
|
+
"titleFontSize": 24,
|
|
1490
|
+
"quadrantLabelFontSize": 18,
|
|
1491
|
+
"xAxisLabelFontSize": 16,
|
|
1492
|
+
"yAxisLabelFontSize": 16
|
|
1493
|
+
}
|
|
1494
|
+
}}%%
|
|
1495
|
+
quadrantChart
|
|
1496
|
+
title ๐ Black Trigram (ํ๊ด) Frontend-Only SWOT Analysis
|
|
1497
|
+
x-axis Internal --> External
|
|
1498
|
+
y-axis Negative --> Positive
|
|
1499
|
+
quadrant-1 Opportunities
|
|
1500
|
+
quadrant-2 Strengths
|
|
1501
|
+
quadrant-3 Weaknesses
|
|
1502
|
+
quadrant-4 Threats
|
|
1503
|
+
|
|
1504
|
+
"๐ก PWA & Offline Caching": [0.8, 0.9] radius: 7, color: #a4c2f4, stroke-color: #3d64ba, stroke-width: 2px
|
|
1505
|
+
"๐ฑ Mobile-First UX": [0.7, 0.8] radius: 7, color: #a4c2f4, stroke-color: #3d64ba, stroke-width: 2px
|
|
1506
|
+
"๐จ Community Modding": [0.85, 0.75] radius: 7, color: #a4c2f4, stroke-color: #3d64ba, stroke-width: 2px
|
|
1507
|
+
"๐ค AI-Driven Tutorials": [0.75, 0.85] radius: 7, color: #a4c2f4, stroke-color: #3d64ba, stroke-width: 2px
|
|
1508
|
+
"๐ฑ Ecosystem Partnerships": [0.65, 0.7] radius: 6, color: #a4c2f4, stroke-color: #3d64ba, stroke-width: 2px
|
|
1509
|
+
|
|
1510
|
+
"๐ ๏ธ Zero-Install Web App": [0.2, 0.8] radius: 7, color: #a2d2a4, stroke-color: #2c882c, stroke-width: 2px
|
|
1511
|
+
"โฑ Fast Iteration": [0.25, 0.75] radius: 6, color: #a2d2a4, stroke-color: #2c882c, stroke-width: 2px
|
|
1512
|
+
"๐ธ Reduced Operational Costs": [0.15, 0.85] radius: 6, color: #a2d2a4, stroke-color: #2c882c, stroke-width: 2px
|
|
1513
|
+
"๐ Immediate CDN Updates": [0.1, 0.7] radius: 7, color: #a2d2a4, stroke-color: #2c882c, stroke-width: 2px
|
|
1514
|
+
"๐ Global Accessibility": [0.05, 0.9] radius: 6, color: #a2d2a4, stroke-color: #2c882c, stroke-width: 2px
|
|
1515
|
+
|
|
1516
|
+
"๐ No Persistence (Session-Only)": [0.2, 0.25] radius: 7, color: #f5a9a9, stroke-color: #aa3939, stroke-width: 2px
|
|
1517
|
+
"๐ข Asset Load Latency": [0.3, 0.2] radius: 7, color: #f5a9a9, stroke-color: #aa3939, stroke-width: 2px
|
|
1518
|
+
"๐ด Limited Offline Play": [0.15, 0.3] radius: 6, color: #f5a9a9, stroke-color: #aa3939, stroke-width: 2px
|
|
1519
|
+
"๐ Browser Compatibility": [0.25, 0.15] radius: 7, color: #f5a9a9, stroke-color: #aa3939, stroke-width: 2px
|
|
1520
|
+
"โ ๏ธ Memory/GC Spikes": [0.35, 0.1] radius: 6, color: #f5a9a9, stroke-color: #aa3939, stroke-width: 2px
|
|
1521
|
+
|
|
1522
|
+
"๐ฉ๏ธ CDN Outages/Latency": [0.8, 0.3] radius: 7, color: #d5a6bd, stroke-color: #9b568a, stroke-width: 2px
|
|
1523
|
+
"โ ๏ธ WebGL Deprecation": [0.7, 0.2] radius: 7, color: #d5a6bd, stroke-color: #9b568a, stroke-width: 2px
|
|
1524
|
+
"๐ Competitive Mobile Games": [0.75, 0.25] radius: 7, color: #d5a6bd, stroke-color: #9b568a, stroke-width: 2px
|
|
1525
|
+
"๐ Tech Debt (State Complexity)": [0.9, 0.2] radius: 6, color: #d5a6bd, stroke-color: #9b568a, stroke-width: 2px
|
|
1526
|
+
"๐ CDN Security Risks": [0.85, 0.15] radius: 6, color: #d5a6bd, stroke-color: #9b568a, stroke-width: 2px
|
|
1527
|
+
"๐ Browser Standards Changes": [0.65, 0.25] radius: 6, color: #d5a6bd, stroke-color: #9b568a, stroke-width: 2px
|
|
1528
|
+
```
|
|
1529
|
+
|
|
1530
|
+
### Mindmap of Strengths
|
|
1531
|
+
|
|
1532
|
+
```mermaid
|
|
1533
|
+
mindmap
|
|
1534
|
+
root((๐ข Strengths Q1 2026))
|
|
1535
|
+
id1(๐ ๏ธ Zero-Install Web App)
|
|
1536
|
+
id1.1[Play immediatelyโno download/sign-up]
|
|
1537
|
+
id1.2[Instant patching via static hosting]
|
|
1538
|
+
id1.3[High adoption barrier removed]
|
|
1539
|
+
id2(โฑ Fast Iteration)
|
|
1540
|
+
id2.1[Front-end only; no backend migrations]
|
|
1541
|
+
id2.2[Rapid prototyping & feature rollout]
|
|
1542
|
+
id2.3[Hot reloading in dev mode]
|
|
1543
|
+
id3(๐ธ Reduced Operational Costs)
|
|
1544
|
+
id3.1[No server infrastructure costs]
|
|
1545
|
+
id3.2[AWS CloudFront + S3 multi-region with GitHub Pages DR]
|
|
1546
|
+
id3.3[Minimal DevOps overhead]
|
|
1547
|
+
id4(๐ Immediate CDN Updates)
|
|
1548
|
+
id4.1[Push new animations & sounds instantly]
|
|
1549
|
+
id4.2[JSON/trigram data can update in real time]
|
|
1550
|
+
id4.3[Rapid asset iteration in production]
|
|
1551
|
+
id5(๐ Global Accessibility)
|
|
1552
|
+
id5.1[Runs in any modern browser]
|
|
1553
|
+
id5.2[Cross-platform compatibility: desktop & mobile]
|
|
1554
|
+
id5.3[Low barrier to entry for users]
|
|
1555
|
+
id6(๐ถ Authentic Korean Martial Arts)
|
|
1556
|
+
id6.1[Deep I Ching philosophy - 8 trigrams complete]
|
|
1557
|
+
id6.2[70/70 vital points implemented - 100% complete]
|
|
1558
|
+
id6.3[Korean labels, audio, cultural immersion]
|
|
1559
|
+
id6.4[14 TCM meridians mapped, 127 medical references]
|
|
1560
|
+
id7(๐ต Rich Audio-Visual Experience)
|
|
1561
|
+
id7.1[Three.js 3D rendering with skeletal animation]
|
|
1562
|
+
id7.2[28-bone system with 7 hand poses]
|
|
1563
|
+
id7.3[Damage-based audio scaling - 87.38% line coverage]
|
|
1564
|
+
id7.4[1000+ particles at 60fps on desktop]
|
|
1565
|
+
id8(โ๏ธ Modular Architecture)
|
|
1566
|
+
id8.1[Clear separation: Combat, Trigram, VitalPoint, Animation]
|
|
1567
|
+
id8.2[Reusable React + Three.js components]
|
|
1568
|
+
id8.3[Zustand slices for isolated state]
|
|
1569
|
+
id9(๐ Comprehensive Testing Framework)
|
|
1570
|
+
id9.1[73.73% overall test coverage]
|
|
1571
|
+
id9.2[95% coverage on new components]
|
|
1572
|
+
id9.3[Vitest unit + Cypress E2E tests]
|
|
1573
|
+
id9.4[73 production-ready pain/consciousness tests]
|
|
1574
|
+
id10(๐ฅ Combat Realism Foundation)
|
|
1575
|
+
id10.1[8/12 systems complete - 67% combat realism]
|
|
1576
|
+
id10.2[Production-ready pain/consciousness systems]
|
|
1577
|
+
id10.3[8 body part health tracking with bilingual labels]
|
|
1578
|
+
```
|
|
1579
|
+
|
|
1580
|
+
### Mindmap of Weaknesses
|
|
1581
|
+
|
|
1582
|
+
```mermaid
|
|
1583
|
+
mindmap
|
|
1584
|
+
root((๐ Weaknesses Q1 2026))
|
|
1585
|
+
id1(๐ No Persistence Session-Only)
|
|
1586
|
+
id1.1[All progress lost on refresh]
|
|
1587
|
+
id1.2[No saved unlocks or training logs]
|
|
1588
|
+
id1.3[Limited long-term engagement]
|
|
1589
|
+
id2(๐ข Asset Load Latency)
|
|
1590
|
+
id2.1[Three.js bundle ~240KB gzipped]
|
|
1591
|
+
id2.2[3D models and textures loading time]
|
|
1592
|
+
id2.3[Initial loading screen 2.5-3.5 seconds]
|
|
1593
|
+
id3(๐ด Limited Offline Play)
|
|
1594
|
+
id3.1[Without service workers, no offline mode]
|
|
1595
|
+
id3.2[Users with spotty connectivity struggle]
|
|
1596
|
+
id3.3[No cached game state]
|
|
1597
|
+
id4(๐ Browser Compatibility)
|
|
1598
|
+
id4.1[WebGL 2 required for Three.js]
|
|
1599
|
+
id4.2[Web Audio API support varies]
|
|
1600
|
+
id4.3[Mobile browser performance gaps]
|
|
1601
|
+
id5(โ ๏ธ Memory/GC Concerns)
|
|
1602
|
+
id5.1[Three.js objects need manual disposal]
|
|
1603
|
+
id5.2[Skeletal animation memory overhead (~180MB desktop)]
|
|
1604
|
+
id5.3[Particle systems can spike memory (1000+ particles)]
|
|
1605
|
+
id6(โ๏ธ Combat Realism Systems)
|
|
1606
|
+
id6.1[8/12 systems complete or near-complete - 67%]
|
|
1607
|
+
id6.2[4 systems remaining: trauma visualization, balance, HUD, movement]
|
|
1608
|
+
id6.3[1 system partially implemented: bone impact audio (mapping + selection complete; asset coverage/final mix pending)]
|
|
1609
|
+
id7(โ Incomplete Features)
|
|
1610
|
+
id7.1[Techniques not yet stance-specific - 4 per archetype vs 3-5 per stance]
|
|
1611
|
+
id7.2[EndScreen3D implemented but missing final UX polish (detailed stats, meta-progression hooks)]
|
|
1612
|
+
id7.3[Training mode limited scope]
|
|
1613
|
+
id8(๐ฑ Mobile Performance)
|
|
1614
|
+
id8.1[30-45fps on mobile devices - meeting 30fps baseline target]
|
|
1615
|
+
id8.2[Complex 3D rendering challenges]
|
|
1616
|
+
id8.3[Touch controls need refinement]
|
|
1617
|
+
id9(๐ ๏ธ Test Coverage Gaps)
|
|
1618
|
+
id9.1[73.73% overall test coverage - target: 80%]
|
|
1619
|
+
id9.2[Some legacy components <80% coverage]
|
|
1620
|
+
id9.3[Combat realism systems integration tests incomplete]
|
|
1621
|
+
```
|
|
1622
|
+
|
|
1623
|
+
### Mindmap of Opportunities
|
|
1624
|
+
|
|
1625
|
+
```mermaid
|
|
1626
|
+
mindmap
|
|
1627
|
+
root((๐ต Opportunities Q1 2026))
|
|
1628
|
+
id1(๐ก PWA & Offline Caching)
|
|
1629
|
+
id1.1[Implement service workers for Three.js asset caching]
|
|
1630
|
+
id1.2[Cache 3D models & textures for offline play]
|
|
1631
|
+
id1.3[Persistence via IndexedDB for vital point progress]
|
|
1632
|
+
id2(๐ฑ Mobile-First UX)
|
|
1633
|
+
id2.1[Optimize to 60fps for mobile devices]
|
|
1634
|
+
id2.2[Adaptive 3D rendering quality for devices]
|
|
1635
|
+
id2.3[Accelerometer-based stance changes]
|
|
1636
|
+
id2.4[Simplified 20-bone skeleton for mobile]
|
|
1637
|
+
id3(๐จ Community Modding)
|
|
1638
|
+
id3.1[Allow custom 3D character models]
|
|
1639
|
+
id3.2[Community-created technique animations]
|
|
1640
|
+
id3.3[User-generated training scenarios]
|
|
1641
|
+
id4(๐ค AI-Driven Tutorial Modules)
|
|
1642
|
+
id4.1[AI coach analyzing vital point accuracy]
|
|
1643
|
+
id4.2[Real-time feedback on skeletal animation form]
|
|
1644
|
+
id4.3[Adaptive difficulty based on combat performance]
|
|
1645
|
+
id5(๐ฑ Martial Arts Education Market)
|
|
1646
|
+
id5.1[STEM gamification of traditional martial arts]
|
|
1647
|
+
id5.2[Korean Wave ํ๋ฅ global interest timing]
|
|
1648
|
+
id5.3[Partnerships with taekwondo schools]
|
|
1649
|
+
id6(๐ง VR/AR Integration)
|
|
1650
|
+
id6.1[WebXR support for immersive vital point training]
|
|
1651
|
+
id6.2[AR overlay for real-world practice]
|
|
1652
|
+
id6.3[VR dojang environment with Korean aesthetics]
|
|
1653
|
+
id7(โ๏ธ Complete Combat Realism)
|
|
1654
|
+
id7.1[Complete remaining 4/12 systems in Q2 2026]
|
|
1655
|
+
id7.2[Integrate trauma visualization with injury tracking]
|
|
1656
|
+
id7.3[Implement bone impact audio system]
|
|
1657
|
+
id7.4[Achieve 100% combat realism completion]
|
|
1658
|
+
id8(๐ E-Learning Certification)
|
|
1659
|
+
id8.1[Structured trigram theory courses]
|
|
1660
|
+
id8.2[Vital point mastery certification]
|
|
1661
|
+
id8.3[Korean martial arts digital badges]
|
|
1662
|
+
id9(๐ Global Localization)
|
|
1663
|
+
id9.1[Multi-language support - KR, EN, JP, CN]
|
|
1664
|
+
id9.2[Localized Korean terminology by region]
|
|
1665
|
+
id9.3[Cultural context adaptation]
|
|
1666
|
+
```
|
|
1667
|
+
|
|
1668
|
+
### Mindmap of Threats
|
|
1669
|
+
|
|
1670
|
+
```mermaid
|
|
1671
|
+
mindmap
|
|
1672
|
+
root((๐ด Threats Q1 2026))
|
|
1673
|
+
id1(๐ฉ๏ธ CDN Outages / Latency)
|
|
1674
|
+
id1.1[Audio CDN or 3D model CDN downtime]
|
|
1675
|
+
id1.2[High global latency affects Three.js loading]
|
|
1676
|
+
id1.3[Single region CDN cold starts]
|
|
1677
|
+
id2(โ ๏ธ Three.js / WebGL Evolution)
|
|
1678
|
+
id2.1[Three.js API breaking changes in future versions]
|
|
1679
|
+
id2.2[WebGL 3 transition requirements]
|
|
1680
|
+
id2.3[Mobile browser WebGL 2 limitations]
|
|
1681
|
+
id3(๐ Competitive Market)
|
|
1682
|
+
id3.1[Native mobile martial arts games with AAA graphics]
|
|
1683
|
+
id3.2[Lower-latency native rendering]
|
|
1684
|
+
id3.3[Established martial arts franchises]
|
|
1685
|
+
id4(๐ Technical Debt)
|
|
1686
|
+
id4.1[Three.js object disposal complexity]
|
|
1687
|
+
id4.2[Combat realism systems 67% complete - 4 systems remaining]
|
|
1688
|
+
id4.3[State management complexity growing]
|
|
1689
|
+
id4.4[73.73% test coverage below 80% target]
|
|
1690
|
+
id5(๐ CDN Security Risks)
|
|
1691
|
+
id5.1[MITM attacks on Three.js CDN]
|
|
1692
|
+
id5.2[Compromised 3D model hosting]
|
|
1693
|
+
id5.3[Subresource Integrity validation needed]
|
|
1694
|
+
id6(๐ Browser Standards Changes)
|
|
1695
|
+
id6.1[Web Audio API deprecations]
|
|
1696
|
+
id6.2[WebGL context loss handling]
|
|
1697
|
+
id6.3[New security policies - CORS, CSP]
|
|
1698
|
+
id7(๐ฎ Player Retention)
|
|
1699
|
+
id7.1[No persistence reduces engagement]
|
|
1700
|
+
id7.2[Lack of progression system]
|
|
1701
|
+
id7.3[Session-only gameplay limits depth]
|
|
1702
|
+
id8(๐ฐ Monetization Limits)
|
|
1703
|
+
id8.1[No backend for payment processing]
|
|
1704
|
+
id8.2[Difficult to track premium features]
|
|
1705
|
+
id8.3[Limited incentive for continued development]
|
|
1706
|
+
id9(๐ Cultural Sensitivity)
|
|
1707
|
+
id9.1[Misrepresentation of Korean culture risk]
|
|
1708
|
+
id9.2[Inappropriate use of traditional symbols]
|
|
1709
|
+
id9.3[Need cultural consultant validation]
|
|
1710
|
+
id10(๐ฑ Mobile Performance Gap)
|
|
1711
|
+
id10.1[30-45fps on mobile vs 60fps desktop]
|
|
1712
|
+
id10.2[Device fragmentation challenges]
|
|
1713
|
+
id10.3[Battery consumption concerns]
|
|
1714
|
+
```
|
|
1715
|
+
id6(๐ถ Browser Standards Evolution)
|
|
1716
|
+
id6.1[Changes to ES modules affect bundling]
|
|
1717
|
+
id6.2[New security policies - CORS, CSP]
|
|
1718
|
+
id6.3[Deprecated features in future standards]
|
|
1719
|
+
id7(๐ฎ Player Retention Challenges)
|
|
1720
|
+
id7.1[Without persistence, limited engagement]
|
|
1721
|
+
id7.2[Lack of progression incentives]
|
|
1722
|
+
id7.3[Session-only gameplay limits depth]
|
|
1723
|
+
id8(๐ฐ Monetization Limitations)
|
|
1724
|
+
id8.1[No backend for payment processing]
|
|
1725
|
+
id8.2[Limited ability to track purchases]
|
|
1726
|
+
id8.3[Difficult to implement premium features]
|
|
1727
|
+
id9(๐ Cultural Sensitivity Issues)
|
|
1728
|
+
id9.1[Misrepresentation of Korean culture]
|
|
1729
|
+
id9.2[Inappropriate use of traditional symbols]
|
|
1730
|
+
id9.3[Lack of cultural consultant validation]
|
|
1731
|
+
```
|
|
1732
|
+
|
|
1733
|
+
---
|
|
1734
|
+
|
|
1735
|
+
## ๐ฏ Core Game Concepts
|
|
1736
|
+
|
|
1737
|
+
### Player Archetypes & Combat Philosophy
|
|
1738
|
+
|
|
1739
|
+
```mermaid
|
|
1740
|
+
mindmap
|
|
1741
|
+
root((๐ฅ Black Trigram Core))
|
|
1742
|
+
id1[๐ฎ Player Archetypes]
|
|
1743
|
+
id1.1[๋ฌด์ฌ Musa - Traditional Warrior]
|
|
1744
|
+
id1.1.1[Honor-bound combat]
|
|
1745
|
+
id1.1.2[Balanced techniques]
|
|
1746
|
+
id1.1.3[Strong fundamentals]
|
|
1747
|
+
id1.2[์์ด์ Amsalja - Shadow Assassin]
|
|
1748
|
+
id1.2.1[Precision strikes]
|
|
1749
|
+
id1.2.2[Stealth mechanics]
|
|
1750
|
+
id1.2.3[Critical damage focus]
|
|
1751
|
+
id1.3[ํด์ปค Hacker - Cyber Warrior]
|
|
1752
|
+
id1.3.1[Tech-enhanced combat]
|
|
1753
|
+
id1.3.2[Digital disruption]
|
|
1754
|
+
id1.3.3[Augmented abilities]
|
|
1755
|
+
id1.4[์ ๋ณด์์ Jeongbo - Intelligence Op]
|
|
1756
|
+
id1.4.1[Analytical combat]
|
|
1757
|
+
id1.4.2[Predictive strikes]
|
|
1758
|
+
id1.4.3[Tactical advantage]
|
|
1759
|
+
id1.5[์กฐ์งํญ๋ ฅ๋ฐฐ Jojik - Crime Fighter]
|
|
1760
|
+
id1.5.1[Brutal efficiency]
|
|
1761
|
+
id1.5.2[Street techniques]
|
|
1762
|
+
id1.5.3[Overwhelming force]
|
|
1763
|
+
id2[โฏ๏ธ Eight Trigrams]
|
|
1764
|
+
id2.1[โฐ ๊ฑด Geon - Heaven]
|
|
1765
|
+
id2.1.1[Direct strikes]
|
|
1766
|
+
id2.1.2[Overwhelming power]
|
|
1767
|
+
id2.2[โฑ ํ Tae - Lake]
|
|
1768
|
+
id2.2.1[Fluid movements]
|
|
1769
|
+
id2.2.2[Joint manipulation]
|
|
1770
|
+
id2.3[โฒ ๋ฆฌ Li - Fire]
|
|
1771
|
+
id2.3.1[Nerve strikes]
|
|
1772
|
+
id2.3.2[Burning techniques]
|
|
1773
|
+
id2.4[โณ ์ง Jin - Thunder]
|
|
1774
|
+
id2.4.1[Explosive attacks]
|
|
1775
|
+
id2.4.2[Sudden impacts]
|
|
1776
|
+
id2.5[โด ์ Son - Wind]
|
|
1777
|
+
id2.5.1[Continuous pressure]
|
|
1778
|
+
id2.5.2[Rapid combos]
|
|
1779
|
+
id2.6[โต ๊ฐ Gam - Water]
|
|
1780
|
+
id2.6.1[Adaptive defense]
|
|
1781
|
+
id2.6.2[Flow counters]
|
|
1782
|
+
id2.7[โถ ๊ฐ Gan - Mountain]
|
|
1783
|
+
id2.7.1[Immovable defense]
|
|
1784
|
+
id2.7.2[Counter strikes]
|
|
1785
|
+
id2.8[โท ๊ณค Gon - Earth]
|
|
1786
|
+
id2.8.1[Grounding attacks]
|
|
1787
|
+
id2.8.2[Takedown focus]
|
|
1788
|
+
id3[๐ฏ Vital Points]
|
|
1789
|
+
id3.1[Critical Points]
|
|
1790
|
+
id3.1.1[Instant KO potential]
|
|
1791
|
+
id3.1.2[x5.0 damage multiplier]
|
|
1792
|
+
id3.2[Secondary Points]
|
|
1793
|
+
id3.2.1[Major damage]
|
|
1794
|
+
id3.2.2[x3.0 damage multiplier]
|
|
1795
|
+
id3.3[Standard Points]
|
|
1796
|
+
id3.3.1[Basic damage]
|
|
1797
|
+
id3.3.2[x1.5 damage multiplier]
|
|
1798
|
+
id4[โก Resources]
|
|
1799
|
+
id4.1[โค๏ธ Health]
|
|
1800
|
+
id4.1.1[100 HP per fighter]
|
|
1801
|
+
id4.1.2[No regeneration]
|
|
1802
|
+
id4.2[๐ช Stamina]
|
|
1803
|
+
id4.2.1[Physical actions]
|
|
1804
|
+
id4.2.2[Slow regeneration]
|
|
1805
|
+
id4.3[๐ต Ki Energy]
|
|
1806
|
+
id4.3.1[Special techniques]
|
|
1807
|
+
id4.3.2[Stance transitions]
|
|
1808
|
+
```
|
|
1809
|
+
|
|
1810
|
+
---
|
|
1811
|
+
|
|
1812
|
+
## ๐๏ธ Architecture Concepts
|
|
1813
|
+
|
|
1814
|
+
### System Architecture Layers
|
|
1815
|
+
|
|
1816
|
+
```mermaid
|
|
1817
|
+
mindmap
|
|
1818
|
+
root((๐๏ธ Architecture))
|
|
1819
|
+
id1[๐ฅ๏ธ Presentation Layer]
|
|
1820
|
+
id1.1[React Components]
|
|
1821
|
+
id1.1.1[Screens]
|
|
1822
|
+
id1.1.2[HUD Elements]
|
|
1823
|
+
id1.1.3[Controls]
|
|
1824
|
+
id1.2[Three.js 3D Rendering]
|
|
1825
|
+
id1.2.1[3D Models]
|
|
1826
|
+
id1.2.2[Particles]
|
|
1827
|
+
id1.2.3[Skeletal Animations]
|
|
1828
|
+
id1.3[UI/UX Design]
|
|
1829
|
+
id1.3.1[Korean Typography]
|
|
1830
|
+
id1.3.2[Cyberpunk Theme]
|
|
1831
|
+
id1.3.3[Responsive Layout]
|
|
1832
|
+
|
|
1833
|
+
id2[โ๏ธ Business Logic]
|
|
1834
|
+
id2.1[Combat System]
|
|
1835
|
+
id2.1.1[Damage Calculation]
|
|
1836
|
+
id2.1.2[Hit Detection]
|
|
1837
|
+
id2.1.3[Combat Flow]
|
|
1838
|
+
id2.2[Trigram System]
|
|
1839
|
+
id2.2.1[Stance Management]
|
|
1840
|
+
id2.2.2[Transitions]
|
|
1841
|
+
id2.2.3[Techniques]
|
|
1842
|
+
id2.3[Vital Point System]
|
|
1843
|
+
id2.3.1[Anatomy Mapping]
|
|
1844
|
+
id2.3.2[Multipliers]
|
|
1845
|
+
id2.3.3[Effects]
|
|
1846
|
+
|
|
1847
|
+
id3[๐๏ธ State Management]
|
|
1848
|
+
id3.1[Zustand Stores]
|
|
1849
|
+
id3.1.1[Game State]
|
|
1850
|
+
id3.1.2[UI State]
|
|
1851
|
+
id3.1.3[Enemy State]
|
|
1852
|
+
id3.2[React Context]
|
|
1853
|
+
id3.2.1[Audio Context]
|
|
1854
|
+
id3.2.2[Theme Context]
|
|
1855
|
+
id3.3[Session Storage]
|
|
1856
|
+
id3.3.1[Temporary Data]
|
|
1857
|
+
id3.3.2[Settings]
|
|
1858
|
+
|
|
1859
|
+
id4[๐ฆ Asset Management]
|
|
1860
|
+
id4.1[Three.js Loaders]
|
|
1861
|
+
id4.1.1[Texture Loading]
|
|
1862
|
+
id4.1.2[3D Model Loading]
|
|
1863
|
+
id4.2[Audio System]
|
|
1864
|
+
id4.2.1[Howler.js]
|
|
1865
|
+
id4.2.2[Web Audio API]
|
|
1866
|
+
id4.3[Data Loading]
|
|
1867
|
+
id4.3.1[JSON Import]
|
|
1868
|
+
id4.3.2[Dynamic Loading]
|
|
1869
|
+
|
|
1870
|
+
id5[๐ง Infrastructure]
|
|
1871
|
+
id5.1[Build System]
|
|
1872
|
+
id5.1.1[Vite]
|
|
1873
|
+
id5.1.2[TypeScript]
|
|
1874
|
+
id5.1.3[ESBuild]
|
|
1875
|
+
id5.2[Testing]
|
|
1876
|
+
id5.2.1[Vitest]
|
|
1877
|
+
id5.2.2[React Testing Library]
|
|
1878
|
+
id5.2.3[Cypress]
|
|
1879
|
+
id5.3[Deployment]
|
|
1880
|
+
id5.3.1[Static Hosting]
|
|
1881
|
+
id5.3.2[CDN Distribution]
|
|
1882
|
+
id5.3.3[CI/CD Pipeline]
|
|
1883
|
+
```
|
|
1884
|
+
|
|
1885
|
+
---
|
|
1886
|
+
|
|
1887
|
+
## ๐ UX Flow
|
|
1888
|
+
|
|
1889
|
+
### User Journey Through Game
|
|
1890
|
+
|
|
1891
|
+
```mermaid
|
|
1892
|
+
flowchart TD
|
|
1893
|
+
Start([๐ฎ Game Load]) --> Loading[โณ Loading Assets]
|
|
1894
|
+
Loading --> Intro[๐ฎ Intro Screen]
|
|
1895
|
+
|
|
1896
|
+
Intro --> |New Game| CharSelect[๐ค Archetype Selection]
|
|
1897
|
+
Intro --> |Training| Training[๐ฏ Training Mode]
|
|
1898
|
+
Intro --> |Settings| Settings[โ๏ธ Settings Menu]
|
|
1899
|
+
|
|
1900
|
+
CharSelect --> Combat[โ๏ธ Combat Arena]
|
|
1901
|
+
Training --> VitalPractice[๐ฏ Vital Point Practice]
|
|
1902
|
+
Training --> StancePractice[โฏ๏ธ Stance Training]
|
|
1903
|
+
|
|
1904
|
+
Combat --> |Victory| Victory[๐ Victory Screen]
|
|
1905
|
+
Combat --> |Defeat| Defeat[๐ Defeat Screen]
|
|
1906
|
+
Combat --> |Pause| PauseMenu[โธ๏ธ Pause Menu]
|
|
1907
|
+
|
|
1908
|
+
Victory --> Intro
|
|
1909
|
+
Defeat --> Intro
|
|
1910
|
+
PauseMenu --> |Resume| Combat
|
|
1911
|
+
PauseMenu --> |Quit| Intro
|
|
1912
|
+
|
|
1913
|
+
VitalPractice --> |Exit| Training
|
|
1914
|
+
StancePractice --> |Exit| Training
|
|
1915
|
+
Training --> |Back| Intro
|
|
1916
|
+
Settings --> |Back| Intro
|
|
1917
|
+
|
|
1918
|
+
%% Styling
|
|
1919
|
+
classDef screenNode fill:#FFD700,stroke:#333,stroke-width:2px,color:#000
|
|
1920
|
+
classDef actionNode fill:#00FFD0,stroke:#333,stroke-width:2px,color:#000
|
|
1921
|
+
classDef menuNode fill:#FF6B6B,stroke:#333,stroke-width:2px,color:#000
|
|
1922
|
+
|
|
1923
|
+
class Intro,CharSelect,Combat,Victory,Defeat,Training,Settings screenNode
|
|
1924
|
+
class Loading,VitalPractice,StancePractice actionNode
|
|
1925
|
+
class PauseMenu menuNode
|
|
1926
|
+
```
|
|
1927
|
+
|
|
1928
|
+
---
|
|
1929
|
+
|
|
1930
|
+
## ๐ Combat Mechanics & Data Relationships
|
|
1931
|
+
|
|
1932
|
+
### Combat System Data Flow
|
|
1933
|
+
|
|
1934
|
+
```mermaid
|
|
1935
|
+
graph TB
|
|
1936
|
+
subgraph "๐ฎ Input Layer"
|
|
1937
|
+
KI[Keyboard Input]
|
|
1938
|
+
MI[Mouse Input]
|
|
1939
|
+
TI[Touch Input]
|
|
1940
|
+
end
|
|
1941
|
+
|
|
1942
|
+
subgraph "โ๏ธ Combat Engine"
|
|
1943
|
+
IS[Input System]
|
|
1944
|
+
SM[Stance Manager]
|
|
1945
|
+
TC[Technique Calculator]
|
|
1946
|
+
HD[Hit Detection]
|
|
1947
|
+
DC[Damage Calculator]
|
|
1948
|
+
ES[Effect System]
|
|
1949
|
+
end
|
|
1950
|
+
|
|
1951
|
+
subgraph "๐ Game State"
|
|
1952
|
+
PS[Player State]
|
|
1953
|
+
ES2[Enemy State]
|
|
1954
|
+
CS[Combat State]
|
|
1955
|
+
end
|
|
1956
|
+
|
|
1957
|
+
subgraph "๐จ Rendering"
|
|
1958
|
+
VS[Visual System]
|
|
1959
|
+
AS[Audio System]
|
|
1960
|
+
PS2[Particle System]
|
|
1961
|
+
end
|
|
1962
|
+
|
|
1963
|
+
KI --> IS
|
|
1964
|
+
MI --> IS
|
|
1965
|
+
TI --> IS
|
|
1966
|
+
|
|
1967
|
+
IS --> SM
|
|
1968
|
+
SM --> TC
|
|
1969
|
+
TC --> HD
|
|
1970
|
+
HD --> DC
|
|
1971
|
+
DC --> ES
|
|
1972
|
+
|
|
1973
|
+
SM <--> PS
|
|
1974
|
+
DC <--> ES2
|
|
1975
|
+
ES <--> CS
|
|
1976
|
+
|
|
1977
|
+
CS --> VS
|
|
1978
|
+
CS --> AS
|
|
1979
|
+
CS --> PS2
|
|
1980
|
+
|
|
1981
|
+
%% Styling
|
|
1982
|
+
classDef inputClass fill:#87CEFA,stroke:#333,stroke-width:2px
|
|
1983
|
+
classDef engineClass fill:#00FFD0,stroke:#333,stroke-width:2px
|
|
1984
|
+
classDef stateClass fill:#FFD700,stroke:#333,stroke-width:2px
|
|
1985
|
+
classDef renderClass fill:#FF6B6B,stroke:#333,stroke-width:2px
|
|
1986
|
+
|
|
1987
|
+
class KI,MI,TI inputClass
|
|
1988
|
+
class IS,SM,TC,HD,DC,ES engineClass
|
|
1989
|
+
class PS,ES2,CS stateClass
|
|
1990
|
+
class VS,AS,PS2 renderClass
|
|
1991
|
+
```
|
|
1992
|
+
|
|
1993
|
+
### Trigram Advantage Matrix
|
|
1994
|
+
|
|
1995
|
+
```mermaid
|
|
1996
|
+
graph LR
|
|
1997
|
+
subgraph "โฏ๏ธ Trigram Relationships"
|
|
1998
|
+
G[โฐ ๊ฑด Geon]
|
|
1999
|
+
T[โฑ ํ Tae]
|
|
2000
|
+
L[โฒ ๋ฆฌ Li]
|
|
2001
|
+
J[โณ ์ง Jin]
|
|
2002
|
+
S[โด ์ Son]
|
|
2003
|
+
GM[โต ๊ฐ Gam]
|
|
2004
|
+
GN[โถ ๊ฐ Gan]
|
|
2005
|
+
K[โท ๊ณค Gon]
|
|
2006
|
+
end
|
|
2007
|
+
|
|
2008
|
+
%% Advantage relationships (โ means "has advantage over")
|
|
2009
|
+
G -->|Power > Fluid| T
|
|
2010
|
+
T -->|Fluid > Fire| L
|
|
2011
|
+
L -->|Fire > Thunder| J
|
|
2012
|
+
J -->|Thunder > Wind| S
|
|
2013
|
+
S -->|Wind > Water| GM
|
|
2014
|
+
GM -->|Water > Mountain| GN
|
|
2015
|
+
GN -->|Mountain > Earth| K
|
|
2016
|
+
K -->|Earth > Heaven| G
|
|
2017
|
+
|
|
2018
|
+
%% Defensive advantages (โข means "defends well against")
|
|
2019
|
+
G -.->|Blocks Earth| K
|
|
2020
|
+
GN -.->|Blocks Water| GM
|
|
2021
|
+
GM -.->|Blocks Wind| S
|
|
2022
|
+
|
|
2023
|
+
%% Style colors
|
|
2024
|
+
style G fill:#FFD700,stroke:#333,stroke-width:3px
|
|
2025
|
+
style T fill:#87CEEB,stroke:#333,stroke-width:3px
|
|
2026
|
+
style L fill:#FF6347,stroke:#333,stroke-width:3px
|
|
2027
|
+
style J fill:#FF1493,stroke:#333,stroke-width:3px
|
|
2028
|
+
style S fill:#98FB98,stroke:#333,stroke-width:3px
|
|
2029
|
+
style GM fill:#4682B4,stroke:#333,stroke-width:3px
|
|
2030
|
+
style GN fill:#8B4513,stroke:#333,stroke-width:3px
|
|
2031
|
+
style K fill:#D2691E,stroke:#333,stroke-width:3px
|
|
2032
|
+
```
|
|
2033
|
+
|
|
2034
|
+
---
|
|
2035
|
+
|
|
2036
|
+
## ๐ Performance Optimization Strategy
|
|
2037
|
+
|
|
2038
|
+
### Resource Loading Pipeline
|
|
2039
|
+
|
|
2040
|
+
```mermaid
|
|
2041
|
+
sequenceDiagram
|
|
2042
|
+
participant B as Browser
|
|
2043
|
+
participant L as Asset Loader
|
|
2044
|
+
participant CDN as CDN Servers
|
|
2045
|
+
participant C as Cache
|
|
2046
|
+
participant G as Game Engine
|
|
2047
|
+
|
|
2048
|
+
B->>L: Initialize game
|
|
2049
|
+
L->>C: Check local cache
|
|
2050
|
+
|
|
2051
|
+
alt Assets cached
|
|
2052
|
+
C-->>L: Return cached assets
|
|
2053
|
+
else Assets not cached
|
|
2054
|
+
L->>CDN: Request assets
|
|
2055
|
+
CDN-->>L: Stream assets
|
|
2056
|
+
L->>C: Store in cache
|
|
2057
|
+
end
|
|
2058
|
+
|
|
2059
|
+
L->>G: Assets ready
|
|
2060
|
+
G->>B: Start game
|
|
2061
|
+
|
|
2062
|
+
Note over B,G: Lazy load non-critical assets during gameplay
|
|
2063
|
+
```
|
|
2064
|
+
|
|
2065
|
+
### Memory Management Strategy
|
|
2066
|
+
|
|
2067
|
+
```mermaid
|
|
2068
|
+
graph TD
|
|
2069
|
+
subgraph "๐ง Memory Pools"
|
|
2070
|
+
PP[Particle Pool<br/>Pre-allocated: 1000]
|
|
2071
|
+
DP[Damage Number Pool<br/>Pre-allocated: 50]
|
|
2072
|
+
EP[Effect Pool<br/>Pre-allocated: 100]
|
|
2073
|
+
end
|
|
2074
|
+
|
|
2075
|
+
subgraph "โป๏ธ Object Lifecycle"
|
|
2076
|
+
CR[Create/Reset]
|
|
2077
|
+
US[Use in Scene]
|
|
2078
|
+
RE[Return to Pool]
|
|
2079
|
+
end
|
|
2080
|
+
|
|
2081
|
+
subgraph "๐๏ธ Garbage Collection Mitigation"
|
|
2082
|
+
RA[Reuse Allocations]
|
|
2083
|
+
PO[Pool Objects]
|
|
2084
|
+
LG[Limit Generation]
|
|
2085
|
+
end
|
|
2086
|
+
|
|
2087
|
+
PP --> CR
|
|
2088
|
+
DP --> CR
|
|
2089
|
+
EP --> CR
|
|
2090
|
+
|
|
2091
|
+
CR --> US
|
|
2092
|
+
US --> RE
|
|
2093
|
+
RE --> PP
|
|
2094
|
+
RE --> DP
|
|
2095
|
+
RE --> EP
|
|
2096
|
+
|
|
2097
|
+
RA --> PO
|
|
2098
|
+
PO --> LG
|
|
2099
|
+
|
|
2100
|
+
style PP fill:#A5D6A7,stroke:#333,stroke-width:2px
|
|
2101
|
+
style DP fill:#81C784,stroke:#333,stroke-width:2px
|
|
2102
|
+
style EP fill:#66BB6A,stroke:#333,stroke-width:2px
|
|
2103
|
+
```
|
|
2104
|
+
|
|
2105
|
+
---
|
|
2106
|
+
|
|
2107
|
+
## ๐ Security Considerations
|
|
2108
|
+
|
|
2109
|
+
### Frontend Security Architecture
|
|
2110
|
+
|
|
2111
|
+
```mermaid
|
|
2112
|
+
graph TB
|
|
2113
|
+
subgraph "๐ก๏ธ Security Layers"
|
|
2114
|
+
CSP[Content Security Policy]
|
|
2115
|
+
SRI[Subresource Integrity]
|
|
2116
|
+
CORS[CORS Headers]
|
|
2117
|
+
VAL[Input Validation]
|
|
2118
|
+
end
|
|
2119
|
+
|
|
2120
|
+
subgraph "๐ Asset Security"
|
|
2121
|
+
HTTPS[HTTPS Only CDN]
|
|
2122
|
+
SIGN[Signed Assets]
|
|
2123
|
+
HASH[Asset Hashing]
|
|
2124
|
+
end
|
|
2125
|
+
|
|
2126
|
+
subgraph "๐ซ Attack Mitigation"
|
|
2127
|
+
XSS[XSS Prevention]
|
|
2128
|
+
CSRF[CSRF Protection]
|
|
2129
|
+
INJ[Injection Prevention]
|
|
2130
|
+
end
|
|
2131
|
+
|
|
2132
|
+
CSP --> XSS
|
|
2133
|
+
SRI --> SIGN
|
|
2134
|
+
CORS --> HTTPS
|
|
2135
|
+
VAL --> INJ
|
|
2136
|
+
|
|
2137
|
+
HTTPS --> HASH
|
|
2138
|
+
SIGN --> HASH
|
|
2139
|
+
|
|
2140
|
+
style CSP fill:#FF6B6B,stroke:#333,stroke-width:2px
|
|
2141
|
+
style HTTPS fill:#FFD700,stroke:#333,stroke-width:2px
|
|
2142
|
+
style XSS fill:#87CEEB,stroke:#333,stroke-width:2px
|
|
2143
|
+
```
|
|
2144
|
+
|
|
2145
|
+
---
|
|
2146
|
+
|
|
2147
|
+
## ๐ Deployment Architecture
|
|
2148
|
+
|
|
2149
|
+
### CI/CD Pipeline
|
|
2150
|
+
|
|
2151
|
+
```mermaid
|
|
2152
|
+
graph LR
|
|
2153
|
+
subgraph "๐ง Development"
|
|
2154
|
+
DEV[Local Dev]
|
|
2155
|
+
TEST[Test Suite]
|
|
2156
|
+
end
|
|
2157
|
+
|
|
2158
|
+
subgraph "๐๏ธ Build Pipeline"
|
|
2159
|
+
GH[GitHub Actions]
|
|
2160
|
+
BUILD[Vite Build]
|
|
2161
|
+
OPT[Optimization]
|
|
2162
|
+
end
|
|
2163
|
+
|
|
2164
|
+
subgraph "๐ฆ Distribution"
|
|
2165
|
+
CDN1[Asset CDN]
|
|
2166
|
+
CDN2[App CDN]
|
|
2167
|
+
CACHE[Edge Cache]
|
|
2168
|
+
end
|
|
2169
|
+
|
|
2170
|
+
subgraph "๐ Global Delivery"
|
|
2171
|
+
US[US Servers]
|
|
2172
|
+
EU[EU Servers]
|
|
2173
|
+
ASIA[Asia Servers]
|
|
2174
|
+
end
|
|
2175
|
+
|
|
2176
|
+
DEV --> TEST
|
|
2177
|
+
TEST --> GH
|
|
2178
|
+
GH --> BUILD
|
|
2179
|
+
BUILD --> OPT
|
|
2180
|
+
|
|
2181
|
+
OPT --> CDN1
|
|
2182
|
+
OPT --> CDN2
|
|
2183
|
+
|
|
2184
|
+
CDN1 --> CACHE
|
|
2185
|
+
CDN2 --> CACHE
|
|
2186
|
+
|
|
2187
|
+
CACHE --> US
|
|
2188
|
+
CACHE --> EU
|
|
2189
|
+
CACHE --> ASIA
|
|
2190
|
+
|
|
2191
|
+
style GH fill:#24292E,stroke:#fff,stroke-width:2px,color:#fff
|
|
2192
|
+
style CDN1 fill:#FF9500,stroke:#333,stroke-width:2px
|
|
2193
|
+
style CACHE fill:#00C851,stroke:#333,stroke-width:2px
|
|
2194
|
+
```
|
|
2195
|
+
|
|
2196
|
+
---
|
|
2197
|
+
|
|
2198
|
+
## ๐ Metrics & Monitoring
|
|
2199
|
+
|
|
2200
|
+
### Performance Monitoring Dashboard
|
|
2201
|
+
|
|
2202
|
+
```mermaid
|
|
2203
|
+
graph TD
|
|
2204
|
+
subgraph "๐ Client Metrics"
|
|
2205
|
+
FPS[FPS Counter]
|
|
2206
|
+
MEM[Memory Usage]
|
|
2207
|
+
LAT[Input Latency]
|
|
2208
|
+
LOAD[Asset Load Time]
|
|
2209
|
+
end
|
|
2210
|
+
|
|
2211
|
+
subgraph "๐ Game Metrics"
|
|
2212
|
+
DMG[Damage Dealt]
|
|
2213
|
+
ACC[Hit Accuracy]
|
|
2214
|
+
COMBO[Combo Success]
|
|
2215
|
+
TIME[Session Duration]
|
|
2216
|
+
end
|
|
2217
|
+
|
|
2218
|
+
subgraph "๐ Analytics"
|
|
2219
|
+
GA[Google Analytics]
|
|
2220
|
+
CUSTOM[Custom Events]
|
|
2221
|
+
ERROR[Error Tracking]
|
|
2222
|
+
end
|
|
2223
|
+
|
|
2224
|
+
FPS --> GA
|
|
2225
|
+
MEM --> GA
|
|
2226
|
+
LAT --> CUSTOM
|
|
2227
|
+
LOAD --> CUSTOM
|
|
2228
|
+
|
|
2229
|
+
DMG --> CUSTOM
|
|
2230
|
+
ACC --> CUSTOM
|
|
2231
|
+
COMBO --> CUSTOM
|
|
2232
|
+
TIME --> GA
|
|
2233
|
+
|
|
2234
|
+
GA --> ERROR
|
|
2235
|
+
CUSTOM --> ERROR
|
|
2236
|
+
|
|
2237
|
+
style FPS fill:#4CAF50,stroke:#333,stroke-width:2px
|
|
2238
|
+
style GA fill:#FFA726,stroke:#333,stroke-width:2px
|
|
2239
|
+
style ERROR fill:#EF5350,stroke:#333,stroke-width:2px
|
|
2240
|
+
```
|
|
2241
|
+
|
|
2242
|
+
---
|
|
2243
|
+
|
|
2244
|
+
## ๐ฎ Future Architecture Considerations
|
|
2245
|
+
|
|
2246
|
+
### Potential Backend Integration
|
|
2247
|
+
|
|
2248
|
+
```mermaid
|
|
2249
|
+
graph TD
|
|
2250
|
+
subgraph "Current: Frontend Only"
|
|
2251
|
+
FE[React + Three.js]
|
|
2252
|
+
LOCAL[Local State]
|
|
2253
|
+
CDN[Static CDN]
|
|
2254
|
+
end
|
|
2255
|
+
|
|
2256
|
+
subgraph "Future: Optional Backend"
|
|
2257
|
+
API[REST API]
|
|
2258
|
+
DB[Database]
|
|
2259
|
+
AUTH[Authentication]
|
|
2260
|
+
LEAD[Leaderboards]
|
|
2261
|
+
SAVE[Save Games]
|
|
2262
|
+
end
|
|
2263
|
+
|
|
2264
|
+
FE -.->|Future Integration| API
|
|
2265
|
+
LOCAL -.->|Sync| DB
|
|
2266
|
+
CDN -.->|Dynamic Assets| API
|
|
2267
|
+
|
|
2268
|
+
API --> AUTH
|
|
2269
|
+
API --> LEAD
|
|
2270
|
+
API --> SAVE
|
|
2271
|
+
|
|
2272
|
+
style FE fill:#61DAFB,stroke:#333,stroke-width:2px
|
|
2273
|
+
style API fill:#FF6B6B,stroke:#333,stroke-width:2px,stroke-dasharray: 5 5
|
|
2274
|
+
style DB fill:#336791,stroke:#333,stroke-width:2px,stroke-dasharray: 5 5
|
|
2275
|
+
```
|
|
2276
|
+
|
|
2277
|
+
---
|
|
2278
|
+
|
|
2279
|
+
## ๐ Architecture Decision Records (ADRs)
|
|
2280
|
+
|
|
2281
|
+
### ADR-001: Frontend-Only Architecture
|
|
2282
|
+
|
|
2283
|
+
**Status**: Accepted
|
|
2284
|
+
**Date**: 2024-01-01
|
|
2285
|
+
**Context**: Need to minimize operational complexity and maximize accessibility
|
|
2286
|
+
**Decision**: Build as purely frontend application with no backend dependencies
|
|
2287
|
+
**Consequences**:
|
|
2288
|
+
|
|
2289
|
+
- โ
Zero server costs
|
|
2290
|
+
- โ
Instant deployment
|
|
2291
|
+
- โ
No database management
|
|
2292
|
+
- โ No persistence
|
|
2293
|
+
- โ Limited multiplayer options
|
|
2294
|
+
|
|
2295
|
+
### ADR-002: React + Three.js Integration
|
|
2296
|
+
|
|
2297
|
+
**Status**: Accepted
|
|
2298
|
+
**Date**: 2024-01-01
|
|
2299
|
+
**Context**: Need powerful 3D rendering with modern React development
|
|
2300
|
+
**Decision**: Use @react-three/fiber for seamless Three.js integration
|
|
2301
|
+
**Consequences**:
|
|
2302
|
+
|
|
2303
|
+
- โ
Best of both worlds (React + Three.js)
|
|
2304
|
+
- โ
Strong ecosystem (@react-three/drei helpers)
|
|
2305
|
+
- โ
Type safety with TypeScript
|
|
2306
|
+
- โ
Declarative 3D scene graph
|
|
2307
|
+
- โ Learning curve for Three.js concepts
|
|
2308
|
+
- โ Bundle size considerations
|
|
2309
|
+
|
|
2310
|
+
### ADR-003: Zustand for State Management
|
|
2311
|
+
|
|
2312
|
+
**Status**: Accepted
|
|
2313
|
+
**Date**: 2024-01-01
|
|
2314
|
+
**Context**: Need lightweight state management without Redux complexity
|
|
2315
|
+
**Decision**: Use Zustand for all global state
|
|
2316
|
+
**Consequences**:
|
|
2317
|
+
|
|
2318
|
+
- โ
Minimal boilerplate
|
|
2319
|
+
- โ
TypeScript friendly
|
|
2320
|
+
- โ
DevTools support
|
|
2321
|
+
- โ Less ecosystem than Redux
|
|
2322
|
+
- โ Need custom persistence layer
|
|
2323
|
+
|
|
2324
|
+
---
|
|
2325
|
+
|
|
2326
|
+
## ๐ Conclusion (Q1 2026)
|
|
2327
|
+
|
|
2328
|
+
Black Trigram's architecture represents a modern approach to browser-based gaming, leveraging Three.js 3D rendering and React 19 while maintaining simplicity through its frontend-only design. The Q1 2026 implementation demonstrates the successful completion of the Three.js migration, with 70/70 vital points implemented (100% complete), a comprehensive 28-bone skeletal animation system, and 73.73% test coverage.
|
|
2329
|
+
|
|
2330
|
+
### Key Architectural Strengths (Q1 2026):
|
|
2331
|
+
|
|
2332
|
+
- **Three.js Migration Complete**: Modern 3D rendering with @react-three/fiber and @react-three/drei (60fps desktop, 30-45fps mobile with optimization ongoing)
|
|
2333
|
+
- **Authentic Korean Martial Arts**: 70/70 vital points (100% complete with 14 TCM meridians, 127 medical references), 8 trigram stances, 5 player archetypes with Korean names (๋ฌด์ฌ, ์์ด์, ํด์ปค, ์ ๋ณด์์, ์กฐ์งํญ๋ ฅ๋ฐฐ)
|
|
2334
|
+
- **Advanced Animation System**: 28-bone skeletal hierarchy, 7 hand poses with Korean terminology (์ฃผ๋จน, ์๋, ๊ด์, ์ฅ๋ ฅ, ์ก๊ธฐ, ํด๊ธฐ, ํด์), muscle tension visualization (0.0-1.0 intensity mapping)
|
|
2335
|
+
- **Combat Realism Foundation**: 8/12 systems complete (67%) including production-ready pain/consciousness (73 tests), body part health, vital point targeting, enhanced anatomy, visual feedback, breathing disruption (75%)
|
|
2336
|
+
- **High Test Coverage**: 73.73% overall, with detailed coverage reporting for all core systems (Vitest unit + Cypress E2E, see docs/coverage/coverage-summary.json)
|
|
2337
|
+
- **Zero Backend Complexity**: Pure frontend eliminates server management costs
|
|
2338
|
+
- **Modular Design**: Clear separation of systems/ (combat, trigram, vitalpoint, animation, pain, consciousness, breathing), components/, data/, types/
|
|
2339
|
+
- **Performance Optimized**: Three.js instancing (1000+ particles), object pooling, geometry/material reuse, automatic frustum culling, skeletal animation (28 bones vs thousands of vertices)
|
|
2340
|
+
- **Developer Friendly**: TypeScript strict mode, React 19, comprehensive testing framework (73 pain/consciousness tests production-ready)
|
|
2341
|
+
|
|
2342
|
+
### Current Status & Metrics (Q1 2026):
|
|
2343
|
+
|
|
2344
|
+
- **Overall Rating**: 8.4/10 (Beta Stage - Combat Realism Production-Ready)
|
|
2345
|
+
- **Vital Points**: 70/70 implemented (100% complete) - up from 4.3% in 2024
|
|
2346
|
+
- **Skeletal Animation**: 28-bone system operational, 7 hand poses functional
|
|
2347
|
+
- **Test Coverage**: 73.73% overall, 87.38% audio system line coverage, 73 pain/consciousness tests
|
|
2348
|
+
- **Performance**: 60fps desktop (โ
met), 30-45fps mobile (โ ๏ธ optimization ongoing)
|
|
2349
|
+
- **Bundle Size**: ~240KB gzipped (Three.js vendor chunk)
|
|
2350
|
+
- **Memory**: 180MB desktop, 150MB mobile
|
|
2351
|
+
- **Combat Realism**: 8/12 systems complete (67%), production-ready pain/consciousness with comprehensive tests
|
|
2352
|
+
|
|
2353
|
+
### Areas for Q2 2026 Enhancement:
|
|
2354
|
+
|
|
2355
|
+
- **Combat Realism Completion**: Complete remaining 4/12 systems (trauma visualization, balance/vulnerability, combat readiness HUD, injury-based movement) + finalize bone impact audio pipeline (BoneImpactAudioMap + useCombatAudio integrated; remaining work: asset coverage expansion and final mix/tuning)
|
|
2356
|
+
- **Mobile Performance**: Optimize to achieve consistent 30fps baseline on mobile devices (currently 30-45fps; stretch goal: 60fps)
|
|
2357
|
+
- **Technique Expansion**: Expand from 4 techniques/archetype to 3-5 techniques/stance (24-40 total)
|
|
2358
|
+
- **EndScreen UX & Flow Enhancements**: Improve EndScreen3D UX (results presentation, bilingual Korean/English copy, audio/visual polish), add replay/rematch flow and analytics/telemetry hooks while keeping the existing Intro โ Combat โ End wiring
|
|
2359
|
+
- **Persistence Layer**: Optional IndexedDB/localStorage for vital point progress and training logs
|
|
2360
|
+
- **VR/AR Integration**: WebXR support for immersive vital point training with skeletal animation
|
|
2361
|
+
- **Advanced Analytics**: Vital point targeting heatmaps, combat effectiveness metrics, skeletal animation quality scoring
|
|
2362
|
+
- **Content Expansion**: Additional training scenarios, difficulty progression, AI enhancements, stance-specific techniques
|
|
2363
|
+
|
|
2364
|
+
The Q1 2026 architecture successfully demonstrates the feasibility of authentic Korean martial arts simulation in the browser, with a solid foundation for Q2 2026 completion of combat realism systems (targeting 12/12 = 100%) and mobile optimization (targeting consistent 60fps).
|
|
2365
|
+
|
|
2366
|
+
**Key Q1 2026 Achievements:**
|
|
2367
|
+
- โ
70/70 vital points complete (100%) with TCM meridians
|
|
2368
|
+
- โ
28-bone skeletal animation system operational
|
|
2369
|
+
- โ
8/12 combat realism systems complete (67%)
|
|
2370
|
+
- โ
Production-ready pain/consciousness with 73 tests
|
|
2371
|
+
- โ
73.73% test coverage (from docs/coverage/coverage-summary.json)
|
|
2372
|
+
- โ
60fps desktop performance maintained
|
|
2373
|
+
- โ ๏ธ Mobile optimization to 60fps (Q2 2026 priority)
|
|
2374
|
+
|
|
2375
|
+
---
|
|
2376
|
+
|
|
2377
|
+
**ํ๊ด์ ๊ธธ์ ๊ฑธ์ด๋ผ** - _Walk the Path of the Black Trigram_
|
|
2378
|
+
|
|
2379
|
+
---
|
|
2380
|
+
|
|
2381
|
+
## ๐ Related Documents
|
|
2382
|
+
|
|
2383
|
+
### ๐ ISMS Policies
|
|
2384
|
+
- [๐ Information Security Policy](https://github.com/Hack23/ISMS-PUBLIC/blob/main/Information_Security_Policy.md) - Overall security governance
|
|
2385
|
+
- [๐ ๏ธ Secure Development Policy](https://github.com/Hack23/ISMS-PUBLIC/blob/main/Secure_Development_Policy.md) - Security-integrated SDLC
|
|
2386
|
+
- [๐ท๏ธ Classification Framework](https://github.com/Hack23/ISMS-PUBLIC/blob/main/CLASSIFICATION.md) - Business impact analysis
|
|
2387
|
+
|
|
2388
|
+
### ๐ก๏ธ Black Trigram Documentation
|
|
2389
|
+
- [๐ก๏ธ Security Architecture](./SECURITY_ARCHITECTURE.md) - Security implementation
|
|
2390
|
+
- [๐ฎ Future Architecture](./FUTURE_ARCHITECTURE.md) - Planned system evolution
|
|
2391
|
+
- [โ๏ธ Combat Architecture](./COMBAT_ARCHITECTURE.md) - Combat system design
|
|
2392
|
+
- [๐ฏ Threat Model](./THREAT_MODEL.md) - Security threat analysis
|
|
2393
|
+
- [๐ Workflows](./WORKFLOWS.md) - CI/CD security automation
|
|
2394
|
+
- [๐ง Development Guide](./development.md) - Security features
|
|
2395
|
+
|
|
2396
|
+
---
|
|
2397
|
+
|
|
2398
|
+
**๐ Document Control:**
|
|
2399
|
+
**โ
Approved by:** James Pether Sรถrling, CEO
|
|
2400
|
+
**๐ค Distribution:** Public
|
|
2401
|
+
**๐ท๏ธ Classification:** [](https://github.com/Hack23/ISMS-PUBLIC/blob/main/CLASSIFICATION.md#confidentiality-levels) [](https://github.com/Hack23/ISMS-PUBLIC/blob/main/CLASSIFICATION.md#integrity-levels) [](https://github.com/Hack23/ISMS-PUBLIC/blob/main/CLASSIFICATION.md#availability-levels)
|
|
2402
|
+
**๐
Effective Date:** 2026-03-19
|
|
2403
|
+
**โฐ Next Review:** 2026-09-19
|
|
2404
|
+
**๐ฏ Framework Compliance:** [](https://github.com/Hack23/ISMS-PUBLIC/blob/main/CLASSIFICATION.md) [](https://github.com/Hack23/ISMS-PUBLIC/blob/main/CLASSIFICATION.md) [](https://github.com/Hack23/ISMS-PUBLIC/blob/main/CLASSIFICATION.md)
|