vibes-plug 2.11.0 → 3.9.0

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.
Files changed (181) hide show
  1. package/.claude/rules/vibes-plug-core.md +5 -0
  2. package/.cursor/rules/vibes-plug-core.mdc +8 -3
  3. package/.cursorrules +9 -3
  4. package/AGENTS.md +25 -4
  5. package/CHANGELOG.md +151 -0
  6. package/CLAUDE.md +15 -8
  7. package/README.md +216 -641
  8. package/bin/vibes.mjs +1104 -0
  9. package/index.js +1 -1
  10. package/package.json +11 -3
  11. package/plugin.json +4 -3
  12. package/scripts/check-anti-slop.js +53 -0
  13. package/scripts/check-anti-slop.mjs +53 -0
  14. package/scripts/generate_swarm_gif.py +2 -2
  15. package/scripts/install.js +3 -1
  16. package/scripts/update_skills.js +1 -1
  17. package/scripts/update_skills.mjs +86 -0
  18. package/scripts/validate-skills.mjs +111 -0
  19. package/skills/accessibility-testing-expert/SKILL.md +117 -116
  20. package/skills/affective-computing-emotion-ai/SKILL.md +83 -0
  21. package/skills/agentic-coding-workflow-expert/SKILL.md +297 -0
  22. package/skills/agentic-memory-architect/SKILL.md +52 -0
  23. package/skills/agentic-micro-economy-architect/SKILL.md +92 -0
  24. package/skills/ai-llm-integration-expert/SKILL.md +330 -187
  25. package/skills/ai-media-generation-expert/SKILL.md +173 -172
  26. package/skills/ai-prompt-engineering-expert/SKILL.md +170 -50
  27. package/skills/ai-safety-governance-expert/SKILL.md +223 -0
  28. package/skills/angular-expert/SKILL.md +149 -148
  29. package/skills/anti-slop/SKILL.md +134 -0
  30. package/skills/api-design-expert/SKILL.md +4 -3
  31. package/skills/api-gateway-proxy-expert/SKILL.md +3 -2
  32. package/skills/app-analyzer-optimizer/SKILL.md +4 -3
  33. package/skills/apple-ecosystem-expert/SKILL.md +6 -5
  34. package/skills/astro-framework-expert/SKILL.md +201 -200
  35. package/skills/async-queue-temporal-expert/SKILL.md +218 -240
  36. package/skills/authentication-identity-expert/SKILL.md +79 -184
  37. package/skills/autonomous-red-teamer/SKILL.md +338 -203
  38. package/skills/autonomous-tdd-debugger/SKILL.md +6 -5
  39. package/skills/biome-linter-formatter-expert/SKILL.md +90 -89
  40. package/skills/blockchain-web3-expert/SKILL.md +116 -115
  41. package/skills/brainstorming/SKILL.md +392 -377
  42. package/skills/browser-automation-expert/SKILL.md +260 -222
  43. package/skills/bun-runtime-expert/SKILL.md +5 -4
  44. package/skills/chatbot-messaging-expert/SKILL.md +115 -114
  45. package/skills/ci-cd-devops-architect/SKILL.md +3 -2
  46. package/skills/cloud-hosting-expert/SKILL.md +5 -4
  47. package/skills/coderabbit/SKILL.md +5 -4
  48. package/skills/compliance-gdpr-privacy-expert/SKILL.md +3 -2
  49. package/skills/composable-mach-architect/SKILL.md +338 -0
  50. package/skills/cron-scheduler-expert/SKILL.md +5 -4
  51. package/skills/data-pipeline-etl-expert/SKILL.md +3 -2
  52. package/skills/data-telemetry-expert/SKILL.md +5 -4
  53. package/skills/data-visualization-expert/SKILL.md +155 -154
  54. package/skills/database-orm-expert/SKILL.md +102 -240
  55. package/skills/deep-research-analyst/SKILL.md +182 -0
  56. package/skills/dependency-upgrade-migrator/SKILL.md +11 -10
  57. package/skills/design-system-architect/SKILL.md +34 -3
  58. package/skills/desktop-electron-expert/SKILL.md +129 -128
  59. package/skills/documentation-site-expert/SKILL.md +60 -59
  60. package/skills/doku-mcp-server/SKILL.md +5 -4
  61. package/skills/doku-payment-gateway/SKILL.md +250 -232
  62. package/skills/domain-driven-design-expert/SKILL.md +3 -2
  63. package/skills/e2e-testing-expert/SKILL.md +5 -4
  64. package/skills/ecommerce-expert/SKILL.md +88 -87
  65. package/skills/email-notification-expert/SKILL.md +35 -7
  66. package/skills/ephemeral-generative-ui-architect/SKILL.md +88 -0
  67. package/skills/error-resilience-expert/SKILL.md +26 -4
  68. package/skills/event-driven-architect/SKILL.md +5 -4
  69. package/skills/feature-flag-analytics-expert/SKILL.md +3 -2
  70. package/skills/file-upload-media-expert/SKILL.md +5 -4
  71. package/skills/firebase-security-expert/SKILL.md +5 -4
  72. package/skills/form-validation-expert/SKILL.md +7 -6
  73. package/skills/frontier-ai-models-expert/SKILL.md +116 -0
  74. package/skills/fullstack-expert/SKILL.md +68 -144
  75. package/skills/gemini-agent-booster/SKILL.md +248 -172
  76. package/skills/geospatial-maps-expert/SKILL.md +81 -80
  77. package/skills/global-a11y-i18n-expert/SKILL.md +5 -4
  78. package/skills/glsl-shader-expert/SKILL.md +155 -71
  79. package/skills/go-programming-expert/SKILL.md +5 -4
  80. package/skills/graph-rag-knowledge-expert/SKILL.md +201 -159
  81. package/skills/graphql-apollo-expert/SKILL.md +5 -4
  82. package/skills/headless-cms-expert/SKILL.md +182 -181
  83. package/skills/hig/SKILL.md +5 -4
  84. package/skills/js-backend-expert/SKILL.md +219 -218
  85. package/skills/legacy-code-translator/SKILL.md +6 -5
  86. package/skills/llm-finops-router/SKILL.md +52 -0
  87. package/skills/local-slm-edge-ai-expert/SKILL.md +168 -167
  88. package/skills/logging-error-tracking-expert/SKILL.md +5 -4
  89. package/skills/mcp-server-architect/SKILL.md +316 -294
  90. package/skills/micro-frontend-architect/SKILL.md +5 -4
  91. package/skills/mobile-expo-expert/SKILL.md +5 -4
  92. package/skills/modern-css-native-expert/SKILL.md +190 -189
  93. package/skills/monorepo-architect/SKILL.md +5 -4
  94. package/skills/mpa-orchestrator/SKILL.md +41 -4
  95. package/skills/multi-agent-orchestration/SKILL.md +388 -254
  96. package/skills/mvc-expert/SKILL.md +5 -4
  97. package/skills/n8n-automation-expert/SKILL.md +90 -89
  98. package/skills/nextjs-app-router-expert/SKILL.md +3 -2
  99. package/skills/openapi-swagger-codegen-expert/SKILL.md +4 -3
  100. package/skills/payment-gateway-expert/SKILL.md +131 -128
  101. package/skills/pdf-document-generation-expert/SKILL.md +92 -91
  102. package/skills/performance-web-vitals/SKILL.md +5 -4
  103. package/skills/post-quantum-crypto-migrator/SKILL.md +3 -2
  104. package/skills/prd-architect/SKILL.md +85 -109
  105. package/skills/proactive-background-watcher/SKILL.md +5 -4
  106. package/skills/production-ready-hardener/SKILL.md +25 -27
  107. package/skills/pwa-offline-first-expert/SKILL.md +227 -185
  108. package/skills/pydantic-ai-expert/SKILL.md +162 -0
  109. package/skills/python-programming-expert/SKILL.md +5 -4
  110. package/skills/rate-limit-abuse-prevention/SKILL.md +5 -4
  111. package/skills/realtime-collaboration-expert/SKILL.md +3 -2
  112. package/skills/rich-text-editor-expert/SKILL.md +178 -177
  113. package/skills/rust-programming-expert/SKILL.md +5 -4
  114. package/skills/saas-architect/SKILL.md +155 -0
  115. package/skills/saas-billing/SKILL.md +394 -382
  116. package/skills/saas-multi-tenant/SKILL.md +7 -6
  117. package/skills/scalability-clean-code/SKILL.md +5 -4
  118. package/skills/search-engine-expert/SKILL.md +90 -89
  119. package/skills/self-healing-cloud-orchestrator/SKILL.md +3 -2
  120. package/skills/senior-frontend/SKILL.md +21 -18
  121. package/skills/senior-frontend/scripts/frontend_scaffolder.py +1 -1
  122. package/skills/seo/SKILL.md +4 -4
  123. package/skills/session-memory-manager/SKILL.md +129 -0
  124. package/skills/solidjs-expert/SKILL.md +81 -80
  125. package/skills/spa-orchestrator/SKILL.md +5 -4
  126. package/skills/sse-websocket-streaming-expert/SKILL.md +3 -2
  127. package/skills/state-management-expert/SKILL.md +5 -4
  128. package/skills/supabase-security-expert/SKILL.md +5 -4
  129. package/skills/svelte-sveltekit-expert/SKILL.md +92 -91
  130. package/skills/svg-animation-motion-expert/SKILL.md +3 -2
  131. package/skills/synthetic-data-finetuning-expert/SKILL.md +156 -0
  132. package/skills/tailwind-expert/SKILL.md +62 -5
  133. package/skills/tanstack-query-expert/SKILL.md +5 -4
  134. package/skills/tauri-expert/SKILL.md +5 -4
  135. package/skills/typescript-expert/SKILL.md +5 -4
  136. package/skills/ui-ux-pro-max/SKILL.md +7 -4
  137. package/skills/vector-db-rag-expert/SKILL.md +209 -208
  138. package/skills/vercel-ai-sdk-expert/SKILL.md +226 -0
  139. package/skills/voice-ai-realtime-agent/SKILL.md +243 -202
  140. package/skills/vue-frontend-expert/SKILL.md +5 -4
  141. package/skills/wasm-edge-computing-expert/SKILL.md +3 -2
  142. package/skills/web-3d-graphics-expert/SKILL.md +259 -82
  143. package/skills/web-game-engine-expert/SKILL.md +278 -50
  144. package/skills/web-scraper/SKILL.md +158 -157
  145. package/skills/website-design-cloner/SKILL.md +5 -4
  146. package/skills/webxr-ar-vr-expert/SKILL.md +105 -65
  147. package/skills/wordpress-headless-expert/SKILL.md +145 -144
  148. package/skills/zero-tech-debt-auditor/SKILL.md +115 -0
  149. package/skills/zero-to-prod-orchestrator/SKILL.md +281 -227
  150. package/skills/zero-trust-secret-vault/SKILL.md +3 -2
  151. package/BLUEPRINT.md +0 -309
  152. package/skills/ai-cost-token-optimizer/SKILL.md +0 -82
  153. package/skills/ai-evals-benchmark-expert/SKILL.md +0 -188
  154. package/skills/asisten-ramah/SKILL.md +0 -47
  155. package/skills/auto-doc-updater/SKILL.md +0 -220
  156. package/skills/autonomous-chaos-monkey/SKILL.md +0 -63
  157. package/skills/background-jobs-queue-expert/SKILL.md +0 -235
  158. package/skills/bootstrap-to-modern/SKILL.md +0 -94
  159. package/skills/database-migration-versioning-expert/SKILL.md +0 -90
  160. package/skills/edge-serverless-db-expert/SKILL.md +0 -99
  161. package/skills/mcp-client-orchestrator/SKILL.md +0 -76
  162. package/skills/mobile-push-notification-expert/SKILL.md +0 -71
  163. package/skills/monday-design-aesthetic/SKILL.md +0 -73
  164. package/skills/multiple-entry-points/SKILL.md +0 -91
  165. package/skills/project-context-mapper/SKILL.md +0 -85
  166. package/skills/saas-mvp-launcher/SKILL.md +0 -260
  167. package/skills/saas-transformer/SKILL.md +0 -500
  168. package/skills/saas-transformer/references/billing_integration_guide.md +0 -401
  169. package/skills/secure-fuzz-testing/SKILL.md +0 -207
  170. package/skills/self-evolving-memory-graph/SKILL.md +0 -91
  171. package/skills/session-context-loader/SKILL.md +0 -83
  172. package/skills/session-handoff-resume/SKILL.md +0 -164
  173. package/skills/skill-baru/SKILL.md +0 -178
  174. package/skills/supabase-migration/SKILL.md +0 -91
  175. package/skills/token-saver/SKILL.md +0 -119
  176. package/skills/ui-components-expert/SKILL.md +0 -166
  177. package/skills/vibe-code-gardener/SKILL.md +0 -181
  178. package/skills/visual-qa-vision-agent/SKILL.md +0 -71
  179. /package/skills/{saas-transformer → saas-architect}/references/feature_gating_patterns.md +0 -0
  180. /package/skills/{saas-transformer → saas-architect}/references/saas_transformation_checklist.md +0 -0
  181. /package/skills/{saas-transformer → saas-architect}/scripts/saas_transformation_scanner.py +0 -0
@@ -1,10 +1,11 @@
1
1
  ---
2
2
  name: web-game-engine-expert
3
- description: "Expert guide for web-based game development. Covers Entity Component System (ECS) architectures, physics engines (Rapier, Havok, Cannon-es), collision detection, and game loop optimization."
4
- author: "Roedy Rustam"
3
+ description: "Expert guide for modern web-based game development. Covers PlayCanvas, Babylon.js Havok, Three.js/R3F Rapier & Jolt Physics, Fixed-Timestep Accumulators, Zero-GC Pooling, ECS (bitECS/Miniplex), Spatial Audio (HRTF), and WebTransport networking / Panduan ahli pengembangan game web modern dan efisien."
4
+ author: "vibes-plug-swarm"
5
+ version: "3.0.0"
5
6
  ---
6
7
 
7
- # Web Game Engine Expert (Physics & ECS)
8
+ # Web Game Engine Expert (Physics, Architecture & Game Loops)
8
9
 
9
10
  [English](#english) | [Bahasa Indonesia](#bahasa-indonesia)
10
11
 
@@ -14,72 +15,262 @@ author: "Roedy Rustam"
14
15
  ## English
15
16
 
16
17
  ### Orchestration & Integration
17
- Connects and orchestrates with relevant domain skills like `brainstorming`, `zero-to-prod-orchestrator`, and `project-context-mapper` to ensure cohesive execution.
18
+ Connects and orchestrates with relevant domain skills:
19
+ - `web-3d-graphics-expert` — Visual rendering layer (WebGPU, Three.js, Babylon.js, PlayCanvas).
20
+ - `glsl-shader-expert` — Custom gameplay shaders, damage flashes, VFX materials.
21
+ - `webxr-ar-vr-expert` — Spatial controls and VR/AR controller tracking.
22
+ - `realtime-collaboration-expert` — Low-latency multiplayer state synchronization (WebRTC / WebTransport).
23
+ - `performance-web-vitals` — Frame budgeting (16.6ms for 60fps, 8.3ms for 120fps) and eliminating Garbage Collection stalls.
24
+ - `wasm-edge-computing-expert` — Compiling custom Rust/C++ simulation modules to WASM.
18
25
 
19
26
  ### Description
20
- Production-grade guidance for building highly interactive 3D simulations and web games. Focuses on integrating modern WebAssembly-based **Physics Engines** (Havok, Rapier, Cannon-es) and structuring application state using the **Entity Component System (ECS)** pattern (e.g., bitECS, Miniplex).
27
+ Production-grade guidance for engineering commercial-quality 2D and 3D web games running at steady 60 to 144+ FPS. Enforces strict game architectural patterns: **Fixed-Timestep Accumulators with render interpolation**, **WebAssembly Physics Engines** (Rapier 3D, Jolt Physics, Havok), **Zero-GC Object Pooling** to eliminate JavaScript garbage collection stutters, **Entity Component System (ECS)** architectures, **Web Audio API 3D Spatial Sound (HRTF)**, and **WebTransport / WebRTC low-latency netcode**.
21
28
 
22
29
  ### Trigger Conditions
23
30
  Activate this skill when the user is:
24
- - Adding physics (gravity, collisions, rigid bodies) to a 3D scene (Three.js/Babylon.js).
25
- - Dealing with performance issues in web games with thousands of objects.
26
- - Structuring a complex game or simulation architecture.
27
- - Using `@dimforge/rapier3d`, `havok`, or `cannon-es`.
31
+ - Developing a web-based game or physics simulation (2D or 3D).
32
+ - Integrating physics with `@dimforge/rapier3d`, `jolt-physics`, `@babylonjs/havok`, or `@react-three/rapier`.
33
+ - Building or refactoring a game loop to fix frame pacing or physics stuttering on 120Hz/144Hz monitors.
34
+ - Implementing an Entity Component System (ECS) with `bitECS` or `miniplex`.
35
+ - Designing zero-allocation object pools for projectiles, particles, or temporary math vectors.
36
+ - Adding Gamepad API, Pointer Lock mouse look, or mobile virtual touch controls.
37
+ - Integrating 3D positional audio via the Web Audio API.
38
+ - Architecting multiplayer game networking with WebTransport (QUIC datagrams) or WebRTC DataChannels.
28
39
 
29
- ### Core Concepts
40
+ ---
41
+
42
+ ### Modern Web Game Engine Landscape (2026)
43
+
44
+ | Engine / Stack | Dimension | Physics Backend | Key Strengths |
45
+ | :--- | :--- | :--- | :--- |
46
+ | **PlayCanvas Engine** | 3D | Ammo.js / Rapier WASM | Complete production game engine, tiny runtime (~200KB), mobile-first 60fps, built-in sound & input. |
47
+ | **Babylon.js + Havok** | 3D | Havok Physics WASM | AAA physics simulation, native sub-stepping, character controllers, convex decomposition. |
48
+ | **Three.js / R3F + Rapier / Jolt** | 3D | Rapier 3D (Rust) / Jolt (C++) | Modular, massive ecosystem, best for React/Vue indie games and procedural worlds. |
49
+ | **LittleJS** | 2D | Built-in lightweight physics | Micro-size (<50KB), hyper-fast hybrid WebGL/2D canvas, ideal for 2D platformers & game jams. |
50
+ | **PixiJS v8** | 2D | Matter.js / Rapier 2D | Next-gen WebGPU 2D rendering pipeline, thousands of animated sprites at 144 FPS. |
51
+ | **Needle Engine** | 3D | PhysX / Rapier | Export directly from Unity/Blender into Three.js with full component lifecycles. |
52
+
53
+ ---
54
+
55
+ ### 1. The Deterministic Game Loop: Fixed-Timestep Accumulator
56
+
57
+ > **CRITICAL RULE**: Never tie physics updates directly to `requestAnimationFrame` delta time. A variable delta causes non-deterministic physics, tunneling, and jitter on 120Hz/144Hz monitors.
58
+ - **Solution:** Accumulate frame time and step physics at a fixed tick rate (e.g., 60Hz). Calculate `alpha` to interpolate render transforms smoothly between the previous and current physics state.
59
+
60
+ ```typescript
61
+ export class GameLoop {
62
+ private accumulator = 0;
63
+ private lastTime = performance.now();
64
+ private readonly FIXED_TIMESTEP = 1 / 60; // 60Hz fixed physics step
65
+ private readonly MAX_FRAME_TIME = 0.25; // Clamp to prevent "spiral of death" during lag
66
+
67
+ constructor(
68
+ private updatePhysics: (dt: number) => void,
69
+ private render: (alpha: number) => void
70
+ ) {}
71
+
72
+ public start() {
73
+ this.lastTime = performance.now();
74
+ requestAnimationFrame(this.tick);
75
+ }
76
+
77
+ private tick = (currentTime: number) => {
78
+ let frameTime = (currentTime - this.lastTime) / 1000;
79
+ this.lastTime = currentTime;
80
+
81
+ // Clamp huge lags (e.g., user changed browser tab)
82
+ if (frameTime > this.MAX_FRAME_TIME) {
83
+ frameTime = this.MAX_FRAME_TIME;
84
+ }
85
+
86
+ this.accumulator += frameTime;
87
+
88
+ // Execute fixed updates
89
+ while (this.accumulator >= this.FIXED_TIMESTEP) {
90
+ this.updatePhysics(this.FIXED_TIMESTEP);
91
+ this.accumulator -= this.FIXED_TIMESTEP;
92
+ }
93
+
94
+ // Alpha is the leftover fractional progress towards the next physics step [0.0, 1.0)
95
+ const alpha = this.accumulator / this.FIXED_TIMESTEP;
96
+ this.render(alpha);
30
97
 
31
- #### 1. Physics Engine Integration
32
- Avoid calculating collisions manually in JavaScript. Use a dedicated physics engine.
33
- - **Babylon.js + Havok:** Babylon.js natively supports Havok Physics (the same engine used in AAA titles like Zelda BotW).
34
- - **Three.js / React Three Fiber + Rapier:** Use `@react-three/rapier` for seamless integration in R3F. It is written in Rust and compiled to WebAssembly.
98
+ requestAnimationFrame(this.tick);
99
+ };
100
+ }
101
+ ```
102
+
103
+ ---
35
104
 
105
+ ### 2. High-Performance WASM Physics: Rapier & Jolt
106
+
107
+ #### Option A: Rapier 3D (Rust + WASM + SIMD)
108
+ Lightweight, determinism-friendly, native support in React Three Fiber (`@react-three/rapier`):
36
109
  ```tsx
37
- // React Three Fiber + Rapier Example
38
- import { Physics, RigidBody } from '@react-three/rapier';
110
+ import { Physics, RigidBody, CuboidCollider } from '@react-three/rapier';
39
111
 
40
- function GameScene() {
112
+ export function GamePhysicsWorld({ children }: { children: React.ReactNode }) {
41
113
  return (
42
- <Physics gravity={[0, -9.81, 0]}>
43
- {/* Falling Object */}
44
- <RigidBody colliders="box" position={[0, 10, 0]}>
114
+ <Physics gravity={[0, -9.81, 0]} timeStep="vary">
115
+ {/* Player Dynamic Capsule */}
116
+ <RigidBody position={[0, 2, 0]} enabledRotations={[false, false, false]} colliders="ball">
45
117
  <mesh>
46
- <boxGeometry />
47
- <meshStandardMaterial color="hotpink" />
118
+ <sphereGeometry args={[0.5]} />
119
+ <meshStandardMaterial color="dodgerblue" />
48
120
  </mesh>
49
121
  </RigidBody>
50
122
 
51
123
  {/* Static Floor */}
52
- <RigidBody type="fixed" colliders="cuboid">
53
- <mesh position={[0, -1, 0]}>
54
- <boxGeometry args={[10, 1, 10]} />
55
- <meshStandardMaterial color="gray" />
56
- </mesh>
124
+ <RigidBody type="fixed">
125
+ <CuboidCollider args={[20, 0.5, 20]} position={[0, -0.5, 0]} />
57
126
  </RigidBody>
127
+
128
+ {children}
58
129
  </Physics>
59
130
  );
60
131
  }
61
132
  ```
62
133
 
63
- #### 2. Entity Component System (ECS)
64
- Traditional Object-Oriented Programming (OOP) can cause performance bottlenecks in games due to poor cache locality. ECS stores data in contiguous memory arrays (Components) and processes them in tight loops (Systems).
65
- - Use **bitECS** for extreme performance (uses TypedArrays).
66
- - Use **Miniplex** for an easier, developer-friendly React integration.
134
+ #### Option B: Jolt Physics WASM (`jolt-physics`)
135
+ The AAA open-source physics engine used in titles like *Horizon Forbidden West*. Best for massive simulations (>2,000 rigid bodies) and advanced ragdolls in vanilla Three.js or Babylon.js.
136
+
137
+ > **Physics Best Practice**: ALWAYS use primitive colliders (`Sphere`, `Box`, `Capsule`) for moving dynamic bodies. NEVER use `Trimesh` (triangle mesh) for dynamic objects; `Trimesh` should only be used for static world terrain.
138
+
139
+ ---
140
+
141
+ ### 3. Zero-GC Memory Management & Object Pooling
142
+
143
+ > **CRITICAL RULE**: In games, memory allocation (`new Vector3()`, `new Bullet()`) inside the tick loop triggers V8 Garbage Collection (GC) pauses every few seconds, dropping frames from 60 to 45 FPS.
144
+ - **Scratch Object Reuse:** Create scratch variables once at module level.
145
+ ```typescript
146
+ // BAD: Allocates a new vector every frame
147
+ const dir = new THREE.Vector3().subVectors(target, source).normalize();
148
+
149
+ // GOOD: Reuses module-level scratch vector
150
+ const _scratchVec = new THREE.Vector3();
151
+ _scratchVec.subVectors(target, source).normalize();
152
+ ```
153
+ - **Generic Object Pool:**
154
+ ```typescript
155
+ export class ObjectPool<T> {
156
+ private pool: T[] = [];
157
+ constructor(
158
+ private factory: () => T,
159
+ private reset: (item: T) => void,
160
+ initialSize = 50
161
+ ) {
162
+ for (let i = 0; i < initialSize; i++) {
163
+ this.pool.push(this.factory());
164
+ }
165
+ }
166
+
167
+ public acquire(): T {
168
+ return this.pool.length > 0 ? this.pool.pop()! : this.factory();
169
+ }
170
+
171
+ public release(item: T): void {
172
+ this.reset(item);
173
+ this.pool.push(item);
174
+ }
175
+ }
176
+ ```
177
+
178
+ ---
179
+
180
+ ### 4. Input Management: Pointer Lock & Gamepad API
181
+
182
+ ```typescript
183
+ // 1. First-Person / Third-Person Mouse Look
184
+ export function setupPointerLock(canvas: HTMLCanvasElement, onLook: (dx: number, dy: number) => void) {
185
+ canvas.addEventListener('click', () => {
186
+ if (document.pointerLockElement !== canvas) {
187
+ canvas.requestPointerLock();
188
+ }
189
+ });
190
+
191
+ window.addEventListener('mousemove', (e) => {
192
+ if (document.pointerLockElement === canvas) {
193
+ onLook(e.movementX, e.movementY);
194
+ }
195
+ });
196
+ }
197
+
198
+ // 2. Gamepad API with Deadzone Normalization
199
+ export function pollGamepad(deadzone = 0.15) {
200
+ const gamepads = navigator.getGamepads ? navigator.getGamepads() : [];
201
+ const gp = gamepads[0];
202
+ if (!gp) return null;
203
+
204
+ const filterAxis = (val: number) => (Math.abs(val) > deadzone ? val : 0);
205
+
206
+ return {
207
+ moveX: filterAxis(gp.axes[0]),
208
+ moveY: filterAxis(gp.axes[1]),
209
+ lookX: filterAxis(gp.axes[2]),
210
+ lookY: filterAxis(gp.axes[3]),
211
+ buttonJump: gp.buttons[0]?.pressed ?? false,
212
+ buttonAction: gp.buttons[1]?.pressed ?? false
213
+ };
214
+ }
215
+ ```
216
+
217
+ ---
218
+
219
+ ### 5. 3D Spatial Positional Audio (Web Audio API)
220
+
221
+ ```typescript
222
+ export class SpatialAudioManager {
223
+ private ctx = new AudioContext();
224
+ private listener = this.ctx.listener;
225
+
226
+ public updateListenerPosition(pos: { x: number; y: number; z: number }, forward: { x: number; y: number; z: number }, up = { x: 0, y: 1, z: 0 }) {
227
+ if (this.listener.positionX) {
228
+ this.listener.positionX.value = pos.x;
229
+ this.listener.positionY.value = pos.y;
230
+ this.listener.positionZ.value = pos.z;
231
+ this.listener.forwardX.value = forward.x;
232
+ this.listener.forwardY.value = forward.y;
233
+ this.listener.forwardZ.value = forward.z;
234
+ this.listener.upX.value = up.x;
235
+ this.listener.upY.value = up.y;
236
+ this.listener.upZ.value = up.z;
237
+ }
238
+ }
239
+
240
+ public createSpatialSound(audioBuffer: AudioBuffer, pos: { x: number; y: number; z: number }) {
241
+ const source = this.ctx.createBufferSource();
242
+ source.buffer = audioBuffer;
67
243
 
68
- ### Best Practices
69
- - **Decouple Logic from Rendering:** The physics engine should update at a fixed timestep (e.g., 60Hz), while rendering should happen at the screen's refresh rate (e.g., 144Hz) using interpolation to prevent stuttering.
70
- - **Use Simple Colliders:** Never use complex mesh colliders (Convex/Trimesh) for moving objects unless absolutely necessary. Use primitives (Spheres, Boxes, Capsules).
244
+ const panner = this.ctx.createPanner();
245
+ panner.panningModel = 'HRTF'; // High-fidelity Head-Related Transfer Function
246
+ panner.distanceModel = 'inverse';
247
+ panner.refDistance = 1;
248
+ panner.maxDistance = 1000;
249
+ panner.rolloffFactor = 1;
250
+ panner.positionX.value = pos.x;
251
+ panner.positionY.value = pos.y;
252
+ panner.positionZ.value = pos.z;
253
+
254
+ source.connect(panner);
255
+ panner.connect(this.ctx.destination);
256
+ source.start();
257
+ }
258
+ }
259
+ ```
71
260
 
72
261
  ---
73
262
 
74
- ### Integration with Other Skills (MANDATORY)
75
- This skill works best when combined with:
76
- - `web-3d-graphics-expert` — For the visual rendering of the physics world.
77
- - `webxr-ar-vr-expert` — For adding grabbable physics objects in VR space.
78
- - `realtime-collaboration-expert` — For synchronizing physics state across multiple players using WebRTC.
263
+ ### 6. Modern Multiplayer Networking: WebTransport vs WebRTC
79
264
 
80
- ### Referenced By Orchestrators (MANDATORY)
81
- - `brainstorming` — Add to "3D & Graphics" or "Game Development".
82
- - `zero-to-prod-orchestrator` — Phase 5 (Frontend / Simulation).
265
+ For fast-paced real-time action games:
266
+ - **Avoid WebSockets for player movement:** WebSockets use TCP. When a packet is lost, TCP pauses delivery of all subsequent packets (Head-of-Line blocking), causing massive lag spikes.
267
+ - **Use WebTransport (QUIC) or WebRTC DataChannels:**
268
+ - Unreliable, unordered datagrams for continuous movement updates (`x, y, z, vx, vy, vz`).
269
+ - Reliable streams for critical state transitions (damage, weapon fire, chat, player joined).
270
+ - **Client-Side Prediction & Reconciliation:**
271
+ 1. Client immediately simulates movement locally upon keypress and stores input history with tick numbers.
272
+ 2. Server processes input at fixed 20Hz-60Hz and replies with authoritative position.
273
+ 3. Client reconciles authoritative state and replays unacknowledged inputs to avoid input lag.
83
274
 
84
275
  ---
85
276
 
@@ -87,16 +278,53 @@ This skill works best when combined with:
87
278
  ## Bahasa Indonesia
88
279
 
89
280
  ### Integrasi Orkestrasi
90
- Terhubung dan mengorkestrasi skill domain yang relevan seperti `brainstorming`, `zero-to-prod-orchestrator`, dan `project-context-mapper` untuk memastikan eksekusi yang kohesif.
281
+ Terhubung dan mengorkestrasi skill domain yang relevan:
282
+ - `web-3d-graphics-expert` — Lapisan visual rendering (WebGPU, Three.js, Babylon.js, PlayCanvas).
283
+ - `glsl-shader-expert` — Shader kustom untuk efek visual, kilatan luka, dan partikel game.
284
+ - `webxr-ar-vr-expert` — Kontrol spasial dan pelacakan kontroler VR/AR.
285
+ - `realtime-collaboration-expert` — Sinkronisasi state multiplayer real-time (WebRTC / WebTransport).
286
+ - `performance-web-vitals` — Manajemen frame budget (16.6ms untuk 60fps) dan pencegahan Garbage Collection stall.
287
+ - `wasm-edge-computing-expert` — Kompilasi modul simulasi C++/Rust kustom ke WebAssembly.
91
288
 
92
289
  ### Deskripsi
93
- Panduan pengembangan *game* dan simulasi 3D di web. Mencakup integrasi *Physics Engine* berbasis WebAssembly (Rapier, Havok, Cannon) dan arsitektur *Entity Component System* (ECS).
290
+ Panduan produksi untuk merekayasa game web komersial 2D dan 3D dengan target stabil di 60 hingga 144+ FPS. Menerapkan arsitektur game modern: **Fixed-Timestep Accumulator dengan interpolasi render**, **Physics Engine berbasis WebAssembly** (Rapier 3D, Jolt Physics, Havok), **Zero-GC Object Pooling** untuk mencegah lonjakan Garbage Collector JavaScript, arsitektur **ECS (Entity Component System)**, **Audio Spasial 3D Web Audio API (HRTF)**, dan **Netcode WebTransport / WebRTC berlatensi rendah**.
94
291
 
95
292
  ### Kondisi Pemicu
96
- - Saat menambahkan gravitasi, tabrakan (collision), atau benda padat (rigid body) ke dalam aplikasi 3D.
97
- - Saat membuat game web yang membutuhkan performa tinggi dengan ribuan entitas.
293
+ Aktifkan skill ini ketika pengguna:
294
+ - Membangun game web atau simulasi fisika (2D maupun 3D).
295
+ - Mengintegrasikan mesin fisika `@dimforge/rapier3d`, `jolt-physics`, `@babylonjs/havok`, atau `@react-three/rapier`.
296
+ - Memperbaiki ketidakteraturan fisika atau *stuttering* pada monitor 120Hz/144Hz.
297
+ - Mengimplementasikan ECS (*Entity Component System*) dengan `bitECS` atau `miniplex`.
298
+ - Mendesain *Object Pool* tanpa alokasi memori berulang untuk proyektil, peluru, atau partikel.
299
+ - Mengintegrasikan kontrol Gamepad API, Pointer Lock (mouse look), atau kontrol sentuh virtual mobile.
300
+ - Menambahkan audio spasial 3D menggunakan Web Audio API.
301
+ - Merancang arsitektur multiplayer real-time menggunakan WebTransport atau WebRTC.
302
+
303
+ ---
304
+
305
+ ### Prinsip Inti Rekayasa Game Web
306
+
307
+ 1. **Fixed-Timestep Accumulator Loop (Wajib)**:
308
+ - Jangan pernah menjalankan komputasi fisika langsung pada delta waktu `requestAnimationFrame`. Perubahan refresh rate monitor (60Hz, 120Hz, 144Hz) akan merusak konsistensi fisika.
309
+ - Akumulasikan waktu frame dan jalankan langkah fisika pada tick tetap (misal 60Hz), lalu hitung `alpha` untuk menginterpolasikan posisi render grafis secara mulus.
310
+
311
+ 2. **Mesin Fisika WASM (Rapier / Jolt / Havok)**:
312
+ - Gunakan **Rapier 3D** (Rust WASM + SIMD) untuk Three.js/R3F.
313
+ - Gunakan **Jolt Physics** untuk simulasi skala besar ribuan objek dinamis.
314
+ - Gunakan **Havok** jika membangun di atas Babylon.js.
315
+ - Hindari penggunaan *mesh collider* (Trimesh) pada objek bergerak; selalu gunakan primitif (Bola, Kotak, Kapsul).
316
+
317
+ 3. **Manajemen Memori Zero-GC**:
318
+ - Pembuatan objek baru (`new Vector3()`, objek peluru) setiap frame memicu *Garbage Collection* di browser yang menyebabkan frame drop berkala.
319
+ - Daur ulang objek menggunakan pola *Object Pooling* dan gunakan kembali variabel scratch statis.
320
+
321
+ 4. **Kontrol Responsif**:
322
+ - Manfaatkan *Pointer Lock API* untuk kontrol kamera first-person / third-person dengan `movementX` dan `movementY`.
323
+ - Gunakan *Gamepad API* dengan deadzone filter untuk mendukung controller konsol (PlayStation, Xbox).
324
+
325
+ 5. **Audio Spasial 3D (HRTF)**:
326
+ - Hubungkan *AudioListener* ke transformasi kamera, dan hubungkan suara ke *PannerNode* dengan model panning `'HRTF'` untuk audio 3 dimensi realistis berdasarkan jarak dan arah.
98
327
 
99
- ### Panduan Singkat
100
- - **Pilih Mesin Fisika:** Gunakan **Havok** jika menggunakan Babylon.js. Gunakan **Rapier** (`@react-three/rapier`) jika menggunakan Three.js/R3F.
101
- - **Gunakan Collider Sederhana:** Untuk objek bergerak, selalu gunakan *primitive colliders* (Kotak, Bola, Kapsul) alih-alih *mesh collider* agar perhitungan CPU/WASM tetap ringan.
102
- - **Pola ECS (Entity Component System):** Untuk game kompleks, pisahkan logika dan data menggunakan arsitektur ECS (seperti `miniplex` atau `bitECS`) untuk memaksimalkan performa *cache* memori.
328
+ 6. **Netcode Modern (WebTransport)**:
329
+ - Jangan gunakan WebSocket (TCP) untuk posisi pergerakan pemain karena rentan terhadap *Head-of-Line blocking*.
330
+ - Gunakan **WebTransport** (datagram UDP over QUIC) atau WebRTC DataChannels disertai *Client-Side Prediction* dan *Server Reconciliation*.