vibes-plug 2.14.1 → 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 (151) hide show
  1. package/.claude/rules/vibes-plug-core.md +5 -0
  2. package/.cursor/rules/vibes-plug-core.mdc +7 -2
  3. package/.cursorrules +8 -2
  4. package/AGENTS.md +23 -2
  5. package/CHANGELOG.md +114 -0
  6. package/CLAUDE.md +10 -3
  7. package/README.md +216 -611
  8. package/bin/vibes.mjs +1104 -0
  9. package/package.json +11 -3
  10. package/plugin.json +4 -3
  11. package/scripts/check-anti-slop.mjs +53 -0
  12. package/scripts/install.js +3 -1
  13. package/scripts/update_skills.js +1 -1
  14. package/scripts/update_skills.mjs +86 -0
  15. package/scripts/validate-skills.mjs +111 -0
  16. package/skills/accessibility-testing-expert/SKILL.md +117 -116
  17. package/skills/affective-computing-emotion-ai/SKILL.md +83 -0
  18. package/skills/agentic-coding-workflow-expert/SKILL.md +297 -0
  19. package/skills/agentic-memory-architect/SKILL.md +52 -0
  20. package/skills/agentic-micro-economy-architect/SKILL.md +92 -0
  21. package/skills/ai-llm-integration-expert/SKILL.md +330 -194
  22. package/skills/ai-media-generation-expert/SKILL.md +173 -172
  23. package/skills/ai-prompt-engineering-expert/SKILL.md +204 -134
  24. package/skills/ai-safety-governance-expert/SKILL.md +223 -0
  25. package/skills/angular-expert/SKILL.md +149 -148
  26. package/skills/anti-slop/SKILL.md +134 -133
  27. package/skills/api-design-expert/SKILL.md +4 -3
  28. package/skills/api-gateway-proxy-expert/SKILL.md +3 -2
  29. package/skills/app-analyzer-optimizer/SKILL.md +4 -3
  30. package/skills/apple-ecosystem-expert/SKILL.md +6 -5
  31. package/skills/astro-framework-expert/SKILL.md +201 -200
  32. package/skills/async-queue-temporal-expert/SKILL.md +218 -217
  33. package/skills/authentication-identity-expert/SKILL.md +174 -173
  34. package/skills/autonomous-red-teamer/SKILL.md +338 -203
  35. package/skills/autonomous-tdd-debugger/SKILL.md +6 -5
  36. package/skills/biome-linter-formatter-expert/SKILL.md +90 -89
  37. package/skills/blockchain-web3-expert/SKILL.md +116 -115
  38. package/skills/brainstorming/SKILL.md +392 -377
  39. package/skills/browser-automation-expert/SKILL.md +260 -222
  40. package/skills/bun-runtime-expert/SKILL.md +5 -4
  41. package/skills/chatbot-messaging-expert/SKILL.md +115 -114
  42. package/skills/ci-cd-devops-architect/SKILL.md +3 -2
  43. package/skills/cloud-hosting-expert/SKILL.md +5 -4
  44. package/skills/coderabbit/SKILL.md +5 -4
  45. package/skills/compliance-gdpr-privacy-expert/SKILL.md +3 -2
  46. package/skills/composable-mach-architect/SKILL.md +338 -0
  47. package/skills/cron-scheduler-expert/SKILL.md +5 -4
  48. package/skills/data-pipeline-etl-expert/SKILL.md +3 -2
  49. package/skills/data-telemetry-expert/SKILL.md +5 -4
  50. package/skills/data-visualization-expert/SKILL.md +155 -154
  51. package/skills/database-orm-expert/SKILL.md +166 -165
  52. package/skills/deep-research-analyst/SKILL.md +182 -136
  53. package/skills/dependency-upgrade-migrator/SKILL.md +11 -10
  54. package/skills/design-system-architect/SKILL.md +4 -3
  55. package/skills/desktop-electron-expert/SKILL.md +129 -128
  56. package/skills/documentation-site-expert/SKILL.md +60 -59
  57. package/skills/doku-mcp-server/SKILL.md +5 -4
  58. package/skills/doku-payment-gateway/SKILL.md +250 -232
  59. package/skills/domain-driven-design-expert/SKILL.md +3 -2
  60. package/skills/e2e-testing-expert/SKILL.md +5 -4
  61. package/skills/ecommerce-expert/SKILL.md +88 -87
  62. package/skills/email-notification-expert/SKILL.md +5 -4
  63. package/skills/ephemeral-generative-ui-architect/SKILL.md +88 -0
  64. package/skills/error-resilience-expert/SKILL.md +14 -13
  65. package/skills/event-driven-architect/SKILL.md +5 -4
  66. package/skills/feature-flag-analytics-expert/SKILL.md +3 -2
  67. package/skills/file-upload-media-expert/SKILL.md +5 -4
  68. package/skills/firebase-security-expert/SKILL.md +5 -4
  69. package/skills/form-validation-expert/SKILL.md +7 -6
  70. package/skills/frontier-ai-models-expert/SKILL.md +116 -0
  71. package/skills/fullstack-expert/SKILL.md +185 -184
  72. package/skills/gemini-agent-booster/SKILL.md +248 -172
  73. package/skills/geospatial-maps-expert/SKILL.md +81 -80
  74. package/skills/global-a11y-i18n-expert/SKILL.md +5 -4
  75. package/skills/glsl-shader-expert/SKILL.md +191 -190
  76. package/skills/go-programming-expert/SKILL.md +5 -4
  77. package/skills/graph-rag-knowledge-expert/SKILL.md +201 -200
  78. package/skills/graphql-apollo-expert/SKILL.md +5 -4
  79. package/skills/headless-cms-expert/SKILL.md +182 -181
  80. package/skills/hig/SKILL.md +5 -4
  81. package/skills/js-backend-expert/SKILL.md +219 -218
  82. package/skills/legacy-code-translator/SKILL.md +6 -5
  83. package/skills/llm-finops-router/SKILL.md +52 -0
  84. package/skills/local-slm-edge-ai-expert/SKILL.md +168 -167
  85. package/skills/logging-error-tracking-expert/SKILL.md +5 -4
  86. package/skills/mcp-server-architect/SKILL.md +315 -307
  87. package/skills/micro-frontend-architect/SKILL.md +5 -4
  88. package/skills/mobile-expo-expert/SKILL.md +5 -4
  89. package/skills/modern-css-native-expert/SKILL.md +190 -189
  90. package/skills/monorepo-architect/SKILL.md +5 -4
  91. package/skills/mpa-orchestrator/SKILL.md +41 -4
  92. package/skills/multi-agent-orchestration/SKILL.md +388 -254
  93. package/skills/mvc-expert/SKILL.md +5 -4
  94. package/skills/n8n-automation-expert/SKILL.md +90 -89
  95. package/skills/nextjs-app-router-expert/SKILL.md +3 -2
  96. package/skills/openapi-swagger-codegen-expert/SKILL.md +4 -3
  97. package/skills/payment-gateway-expert/SKILL.md +131 -128
  98. package/skills/pdf-document-generation-expert/SKILL.md +92 -91
  99. package/skills/performance-web-vitals/SKILL.md +5 -4
  100. package/skills/post-quantum-crypto-migrator/SKILL.md +3 -2
  101. package/skills/prd-architect/SKILL.md +183 -182
  102. package/skills/proactive-background-watcher/SKILL.md +5 -4
  103. package/skills/production-ready-hardener/SKILL.md +10 -9
  104. package/skills/pwa-offline-first-expert/SKILL.md +227 -226
  105. package/skills/pydantic-ai-expert/SKILL.md +162 -161
  106. package/skills/python-programming-expert/SKILL.md +5 -4
  107. package/skills/rate-limit-abuse-prevention/SKILL.md +5 -4
  108. package/skills/realtime-collaboration-expert/SKILL.md +3 -2
  109. package/skills/rich-text-editor-expert/SKILL.md +178 -177
  110. package/skills/rust-programming-expert/SKILL.md +5 -4
  111. package/skills/saas-architect/SKILL.md +155 -154
  112. package/skills/saas-billing/SKILL.md +394 -382
  113. package/skills/saas-multi-tenant/SKILL.md +7 -6
  114. package/skills/scalability-clean-code/SKILL.md +5 -4
  115. package/skills/search-engine-expert/SKILL.md +90 -89
  116. package/skills/self-healing-cloud-orchestrator/SKILL.md +3 -2
  117. package/skills/senior-frontend/SKILL.md +14 -9
  118. package/skills/seo/SKILL.md +4 -4
  119. package/skills/session-memory-manager/SKILL.md +129 -128
  120. package/skills/solidjs-expert/SKILL.md +81 -80
  121. package/skills/spa-orchestrator/SKILL.md +5 -4
  122. package/skills/sse-websocket-streaming-expert/SKILL.md +3 -2
  123. package/skills/state-management-expert/SKILL.md +5 -4
  124. package/skills/supabase-security-expert/SKILL.md +5 -4
  125. package/skills/svelte-sveltekit-expert/SKILL.md +92 -91
  126. package/skills/svg-animation-motion-expert/SKILL.md +3 -2
  127. package/skills/synthetic-data-finetuning-expert/SKILL.md +156 -155
  128. package/skills/tailwind-expert/SKILL.md +62 -5
  129. package/skills/tanstack-query-expert/SKILL.md +5 -4
  130. package/skills/tauri-expert/SKILL.md +5 -4
  131. package/skills/typescript-expert/SKILL.md +5 -4
  132. package/skills/ui-ux-pro-max/SKILL.md +7 -6
  133. package/skills/vector-db-rag-expert/SKILL.md +209 -208
  134. package/skills/vercel-ai-sdk-expert/SKILL.md +226 -181
  135. package/skills/voice-ai-realtime-agent/SKILL.md +243 -242
  136. package/skills/vue-frontend-expert/SKILL.md +5 -4
  137. package/skills/wasm-edge-computing-expert/SKILL.md +3 -2
  138. package/skills/web-3d-graphics-expert/SKILL.md +314 -313
  139. package/skills/web-game-engine-expert/SKILL.md +330 -329
  140. package/skills/web-scraper/SKILL.md +158 -157
  141. package/skills/website-design-cloner/SKILL.md +5 -4
  142. package/skills/webxr-ar-vr-expert/SKILL.md +163 -162
  143. package/skills/wordpress-headless-expert/SKILL.md +145 -144
  144. package/skills/zero-tech-debt-auditor/SKILL.md +115 -0
  145. package/skills/zero-to-prod-orchestrator/SKILL.md +281 -229
  146. package/skills/zero-trust-secret-vault/SKILL.md +3 -2
  147. package/BLUEPRINT.md +0 -319
  148. package/skills/bootstrap-to-modern/SKILL.md +0 -94
  149. package/skills/multiple-entry-points/SKILL.md +0 -91
  150. package/skills/secure-fuzz-testing/SKILL.md +0 -207
  151. package/skills/visual-qa-vision-agent/SKILL.md +0 -71
@@ -1,313 +1,314 @@
1
- ---
2
- name: web-3d-graphics-expert
3
- description: "Expert guide for modern WebGPU and WebGL 3D graphics in the browser using Three.js (WebGPURenderer + TSL), Babylon.js, PlayCanvas, React Three Fiber (R3F), and TresJS. Covers scene optimization, compute shaders, KTX2/Meshopt compression, and memory management / Panduan ahli grafis 3D web dan WebGPU modern."
4
- author: "vibes-plug-swarm"
5
- ---
6
-
7
- # Web 3D Graphics Expert (WebGPU, Three.js, Babylon.js & PlayCanvas)
8
-
9
- [English](#english) | [Bahasa Indonesia](#bahasa-indonesia)
10
-
11
- ---
12
-
13
- <a name="english"></a>
14
- ## English
15
-
16
- ### Orchestration & Integration
17
- Connects and orchestrates with relevant domain skills:
18
- - `senior-frontend` — Integrating React Three Fiber (R3F) in React 19 / Next.js 15.
19
- - `vue-frontend-expert` — Integrating TresJS in Vue 3 / Nuxt 3.
20
- - `svelte-sveltekit-expert` — Integrating Threlte in Svelte 5 (Runes).
21
- - `web-game-engine-expert` — Physics simulations (Rapier, Jolt, Havok), game loops, and ECS.
22
- - `glsl-shader-expert` — Shading languages, WGSL compute shaders, and TSL nodes.
23
- - `webxr-ar-vr-expert` — WebXR immersive VR/AR experiences.
24
- - `performance-web-vitals` — Minimizing Total Blocking Time (TBT), asset streaming, and bundle sizing.
25
-
26
- ### Description
27
- Production-grade guidance for architecting high-fidelity, high-framerate 3D experiences in the browser. Covers the modern **WebGPU-first** paradigm with automatic WebGL2 fallbacks, **Three.js (r170+) WebGPURenderer** and **TSL (Three Shading Language)**, **Babylon.js WebGPUEngine** with Snapshot Rendering, and **PlayCanvas Engine** for ultra-lightweight, mobile-first commercial applications.
28
-
29
- ### Trigger Conditions
30
- Activate this skill when the user is:
31
- - Initializing a WebGPU or WebGL 3D scene.
32
- - Using `three` (`three/webgpu`), `@react-three/fiber`, `@babylonjs/core`, `playcanvas`, `@tresjs/core`, or `@threlte/core`.
33
- - Writing or refactoring shaders to Three Shading Language (TSL) or WGSL.
34
- - Loading and optimizing 3D models (`.glb`, `.gltf`) with KTX2 texture compression or Meshopt.
35
- - Implementing post-processing passes, compute shaders, or particle systems on the GPU.
36
- - Diagnosing FPS drops, draw call bottlenecks, or VRAM memory leaks.
37
-
38
- ---
39
-
40
- ### Modern Web 3D Engine Landscape (2026)
41
-
42
- | Engine / Stack | Best Use Case | Rendering Backend | Key Strengths |
43
- | :--- | :--- | :--- | :--- |
44
- | **Three.js (WebGPU + TSL)** | Creative landing pages, interactive portfolios, R3F React ecosystems | WebGPU (primary) + WebGL2 (fallback) | Vast community, huge ecosystem, TSL cross-compiles to WGSL & GLSL, node materials. |
45
- | **Babylon.js** | Enterprise 3D simulations, CAD viewers, AAA web games with Havok | WebGPU + WebGL2 | Snapshot rendering, native Havok physics, compute shaders, robust GUI & inspector. |
46
- | **PlayCanvas Engine** | High-performance mobile 3D, instant-load web games, e-commerce configurators | WebGPU + WebGL2 | Tiny runtime (~200KB gzipped), clustered lighting, zero-overhead scene graph. |
47
- | **Threlte (Svelte 5)** | Svelte 5 apps requiring declarative 3D reactive components | Three.js WebGL/WebGPU | Svelte Runes reactivity (`$state`, `$derived`), lightweight bundle footprint. |
48
-
49
- ---
50
-
51
- ### 1. Three.js WebGPU & TSL (Three Shading Language)
52
-
53
- Starting with modern Three.js, transition from `WebGLRenderer` to `WebGPURenderer`. It natively uses WebGPU when available and falls back cleanly to WebGL2.
54
-
55
- ```typescript
56
- // Modern Three.js WebGPU Scene Setup
57
- import * as THREE from 'three/webgpu';
58
- import { color, float, positionLocal, time, vec3, Fn } from 'three/tsl';
59
-
60
- const canvas = document.querySelector('#canvas') as HTMLCanvasElement;
61
- const renderer = new THREE.WebGPURenderer({ canvas, antialias: true });
62
- renderer.setSize(window.innerWidth, window.innerHeight);
63
- renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
64
-
65
- // Initialize async WebGPU pipeline
66
- await renderer.init();
67
-
68
- const scene = new THREE.Scene();
69
- const camera = new THREE.PerspectiveCamera(60, window.innerWidth / window.innerHeight, 0.1, 1000);
70
- camera.position.set(0, 2, 5);
71
-
72
- // TSL (Three Shading Language) Custom Node Material
73
- // Compiles automatically to WGSL on WebGPU and GLSL on WebGL2!
74
- const customMaterial = new THREE.MeshStandardNodeMaterial();
75
-
76
- // Node-based animated color shader function
77
- const animatedColor = Fn(() => {
78
- const t = time.mul(2.0);
79
- const wave = positionLocal.y.add(t).sin().mul(0.5).add(0.5);
80
- return color(0x00ffff).mul(wave);
81
- });
82
-
83
- customMaterial.colorNode = animatedColor();
84
-
85
- const mesh = new THREE.Mesh(new THREE.TorusKnotGeometry(1, 0.3, 128, 32), customMaterial);
86
- scene.add(mesh);
87
-
88
- // Render loop using setAnimationLoop (WebGPU & WebXR compatible)
89
- renderer.setAnimationLoop(() => {
90
- mesh.rotation.y += 0.01;
91
- renderer.render(scene, camera);
92
- });
93
- ```
94
-
95
- ---
96
-
97
- ### 2. Babylon.js WebGPU Engine & Snapshot Rendering
98
-
99
- For scenes with thousands of static meshes, Babylon.js **Snapshot Rendering** records GPU command buffers once and replays them, bypassing JavaScript CPU draw call overhead.
100
-
101
- ```typescript
102
- import { WebGPUEngine, Scene, ArcRotateCamera, Vector3, HemisphericLight, MeshBuilder } from '@babylonjs/core';
103
-
104
- async function initBabylonWebGPU() {
105
- const canvas = document.getElementById('renderCanvas') as HTMLCanvasElement;
106
- const engine = new WebGPUEngine(canvas, { antialiasing: true });
107
- await engine.initAsync();
108
-
109
- const scene = new Scene(engine);
110
- const camera = new ArcRotateCamera('camera', -Math.PI / 2, Math.PI / 2.5, 10, Vector3.Zero(), scene);
111
- camera.attachControl(canvas, true);
112
-
113
- const light = new HemisphericLight('light', new Vector3(0, 1, 0), scene);
114
-
115
- // Enable Snapshot Rendering for extreme draw call reduction
116
- engine.snapshotRendering = true;
117
- engine.snapshotRenderingMode = WebGPUEngine.SNAPSHOTRENDERING_FAST;
118
-
119
- engine.runRenderLoop(() => {
120
- scene.render();
121
- });
122
- }
123
- ```
124
-
125
- ---
126
-
127
- ### 3. PlayCanvas Engine (Ultra-Lightweight & Fast-Loading)
128
-
129
- When bundle size and instant mobile loading are the primary constraints, use the standalone PlayCanvas Engine:
130
-
131
- ```typescript
132
- import * as pc from 'playcanvas';
133
-
134
- const canvas = document.getElementById('application-canvas') as HTMLCanvasElement;
135
- const app = new pc.Application(canvas, {
136
- graphicsDeviceOptions: { alpha: false, antialias: true, preferWebGpu: true }
137
- });
138
- app.start();
139
- app.setCanvasFillMode(pc.FILLMODE_FILL_WINDOW);
140
- app.setCanvasResolution(pc.RESOLUTION_AUTO);
141
-
142
- // Create Entity: Camera
143
- const camera = new pc.Entity('camera');
144
- camera.addComponent('camera', { clearColor: new pc.Color(0.1, 0.1, 0.15) });
145
- camera.translate(0, 2, 6);
146
- camera.lookAt(0, 0, 0);
147
- app.root.addChild(camera);
148
-
149
- // Create Entity: Clustered Directional Light
150
- const light = new pc.Entity('light');
151
- light.addComponent('light', { type: 'directional', castShadows: true });
152
- light.setEulerAngles(45, 30, 0);
153
- app.root.addChild(light);
154
-
155
- // Create Entity: Box with Standard Material
156
- const box = new pc.Entity('box');
157
- box.addComponent('render', { type: 'box' });
158
- app.root.addChild(box);
159
-
160
- app.on('update', (dt: number) => {
161
- box.rotate(10 * dt, 20 * dt, 30 * dt);
162
- });
163
- ```
164
-
165
- ---
166
-
167
- ### 4. React Three Fiber (R3F) with React 19
168
-
169
- ```tsx
170
- import { Canvas } from '@react-three/fiber';
171
- import { OrbitControls, Environment, useGLTF, Float } from '@react-three/drei';
172
-
173
- function ModelViewer() {
174
- const { scene } = useGLTF('/models/drone.glb');
175
- return (
176
- <Float speed={2} rotationIntensity={0.5} floatIntensity={1}>
177
- <primitive object={scene} />
178
- </Float>
179
- );
180
- }
181
-
182
- export default function App() {
183
- return (
184
- <Canvas
185
- gl={(canvas) => new THREE.WebGPURenderer({ canvas, antialias: true })}
186
- camera={{ position: [0, 1.5, 4], fov: 45 }}
187
- dpr={[1, 2]}
188
- >
189
- <ambientLight intensity={0.6} />
190
- <directionalLight position={[5, 10, 5]} castShadow intensity={1.5} />
191
- <ModelViewer />
192
- <Environment preset="city" />
193
- <OrbitControls makeDefault enableDamping dampingFactor={0.05} />
194
- </Canvas>
195
- );
196
- }
197
-
198
- // Preload critical assets outside component tree
199
- useGLTF.preload('/models/drone.glb');
200
- ```
201
-
202
- ---
203
-
204
- ### Modern Asset Pipeline & GPU Memory Optimization
205
-
206
- #### 1. GPU Texture Compression: KTX2 + Basis Universal (`KHR_texture_basisu`)
207
- > **CRITICAL RULE**: Never deploy raw PNG or JPG textures for 3D production models.
208
- - **Why?** PNG/JPG files decompress into uncompressed 32-bit RGBA inside GPU VRAM. A 2048x2048 PNG consumes **16MB of VRAM**; an uncompressed 4K texture consumes **64MB of VRAM**.
209
- - **KTX2 with Basis Universal** transcodes in real-time into native GPU-compressed formats:
210
- - Mobile: ASTC / ETC2.
211
- - Desktop: BC7 / BC1.
212
- - **Result:** Saves **75% to 85% of GPU VRAM**, prevents mobile browser tab crashes, and eliminates texture upload GPU hitches.
213
- - **Tooling:** Compress glTF files with `gltf-transform`:
214
- ```bash
215
- npx @gltf-transform/cli optimize input.glb output.glb --texture-compress ktx2
216
- ```
217
-
218
- #### 2. Geometry Optimization: Meshopt (`EXT_meshopt_compression`)
219
- - Prefer **Meshopt** over Draco for high-framerate interactive apps and games.
220
- - **Advantage:** Meshopt WASM decompressor runs at **gigabytes per second** (up to 10x faster decompression than Draco on mobile CPUs) and organizes vertex attributes for maximum GPU vertex cache efficiency.
221
- ```bash
222
- npx @gltf-transform/cli meshopt input.glb output.glb
223
- ```
224
-
225
- #### 3. Strict Memory Lifecycle Management (`.dispose()`)
226
- Garbage collection does NOT clean up WebGL/WebGPU buffers:
227
- - When removing an object from Three.js or Babylon.js, explicitly traverse and dispose:
228
- ```typescript
229
- export function purgeObject(object: THREE.Object3D) {
230
- object.traverse((child) => {
231
- if ((child as THREE.Mesh).isMesh) {
232
- const mesh = child as THREE.Mesh;
233
- mesh.geometry?.dispose();
234
- if (Array.isArray(mesh.material)) {
235
- mesh.material.forEach((m) => disposeMaterial(m));
236
- } else if (mesh.material) {
237
- disposeMaterial(mesh.material);
238
- }
239
- }
240
- });
241
- }
242
-
243
- function disposeMaterial(material: THREE.Material) {
244
- Object.keys(material).forEach((prop) => {
245
- const value = (material as any)[prop];
246
- if (value && typeof value.dispose === 'function') {
247
- value.dispose();
248
- }
249
- });
250
- material.dispose();
251
- }
252
- ```
253
-
254
- ---
255
-
256
- ### Production Checklist
257
- - [ ] Render with `WebGPURenderer` (Three.js) or `WebGPUEngine` (Babylon.js) with fallback enabled.
258
- - [ ] Use KTX2 / Basis Universal compressed textures on all `.glb` assets.
259
- - [ ] Use Meshopt geometry compression to eliminate model loading CPU stalls.
260
- - [ ] Clamp `devicePixelRatio` to `Math.min(window.devicePixelRatio, 2)` to prevent 4K/Retina mobile GPU thermal throttling.
261
- - [ ] Use `InstancedMesh` (Three.js) or `Thin Instances` (Babylon.js) for repetitive assets (>10 meshes).
262
- - [ ] Implement explicit `.dispose()` cleanup in `useEffect` or component unmount hooks.
263
-
264
- ---
265
-
266
- <a name="bahasa-indonesia"></a>
267
- ## Bahasa Indonesia
268
-
269
- ### Integrasi Orkestrasi
270
- Terhubung dan mengorkestrasi skill domain yang relevan:
271
- - `senior-frontend` — Integrasi React Three Fiber (R3F) pada React 19 / Next.js 15.
272
- - `vue-frontend-expert` — Integrasi TresJS pada Vue 3 / Nuxt 3.
273
- - `svelte-sveltekit-expert` — Integrasi Threlte pada Svelte 5 (Runes).
274
- - `web-game-engine-expert` — Simulasi fisika (Rapier, Jolt, Havok), game loop, dan ECS.
275
- - `glsl-shader-expert` — Bahasa shader, compute shader WGSL, dan node TSL.
276
- - `webxr-ar-vr-expert` — Pengalaman WebXR VR/AR imersif.
277
- - `performance-web-vitals` — Meminimalkan TBT (Total Blocking Time) dan optimasi ukuran bundle.
278
-
279
- ### Deskripsi
280
- Panduan produksi untuk membangun grafis 3D performa tinggi di browser. Mengutamakan paradigma modern **WebGPU-first** dengan fallback otomatis ke WebGL2, **Three.js (r170+) WebGPURenderer** dan **TSL (Three Shading Language)**, **Babylon.js WebGPUEngine** dengan Snapshot Rendering, serta **PlayCanvas Engine** untuk aplikasi komersial mobile yang sangat ringan dan cepat dimuat.
281
-
282
- ### Kondisi Pemicu
283
- Aktifkan skill ini ketika pengguna:
284
- - Menginisialisasi *scene* WebGPU atau WebGL 3D.
285
- - Menggunakan `three` (`three/webgpu`), `@react-three/fiber`, `@babylonjs/core`, `playcanvas`, `@tresjs/core`, atau `@threlte/core`.
286
- - Menulis atau merefaktor shader ke Three Shading Language (TSL) atau WGSL.
287
- - Memuat dan mengoptimalkan model 3D (`.glb`, `.gltf`) menggunakan kompresi tekstur KTX2 atau Meshopt.
288
- - Mengimplementasikan post-processing, compute shader, atau sistem partikel pada GPU.
289
- - Mengatasi penurunan FPS (*frame drop*), hambatan *draw call*, atau kebocoran memori VRAM.
290
-
291
- ---
292
-
293
- ### Panduan Inti & Rekomendasi Mesin 3D
294
-
295
- 1. **Three.js WebGPU + TSL**:
296
- - Gunakan `WebGPURenderer` alih-alih `WebGLRenderer` standar.
297
- - Manfaatkan TSL (*Three Shading Language*) dan *Node Materials*. Kode shader TSL ditulis secara deklaratif dalam TypeScript/JavaScript dan otomatis dikompilasi menjadi WGSL pada WebGPU dan GLSL pada WebGL2.
298
-
299
- 2. **Babylon.js Snapshot Rendering**:
300
- - Untuk skenario dengan ribuan mesh statis, aktifkan `engine.snapshotRendering = true` untuk merekam *command buffer* GPU sekali saja, memotong hampir 100% *overhead* CPU draw call JavaScript.
301
-
302
- 3. **PlayCanvas Engine (Performa Mobile Ekstrem)**:
303
- - Jika waktu muat (*initial load*) dan ukuran bundle adalah prioritas utama (misalnya iklan interaktif, 3D e-commerce configurator, game web mobile), PlayCanvas hanya memakan ~200KB gzipped dengan fitur *clustered lighting* yang sangat cepat.
304
-
305
- 4. **Kompresi Tekstur GPU KTX2 (Wajib)**:
306
- - Jangan menyajikan file PNG/JPG mentah di produksi. Format PNG/JPG diekspansi menjadi uncompressed RGBA di VRAM GPU (tekstur 4K memakan 64MB VRAM).
307
- - Gunakan **KTX2 / Basis Universal** yang tetap terkompresi langsung di VRAM GPU (menghemat 75%-85% VRAM dan mencegah browser mobile crash).
308
-
309
- 5. **Kompresi Geometri Meshopt**:
310
- - Gunakan kompresi **Meshopt** (`EXT_meshopt_compression`) alih-alih Draco jika membutuhkan dekompresi super cepat di browser (hingga 10x lebih cepat dibanding Draco pada CPU mobile).
311
-
312
- 6. **Pembersihan Memori Bersih (`.dispose()`)**:
313
- - Browser garbage collector tidak dapat menghapus buffer GPU secara otomatis. Selalu panggil method `.dispose()` pada geometry, material, dan texture saat komponen di-unmount.
1
+ ---
2
+ name: web-3d-graphics-expert
3
+ description: "Expert guide for modern WebGPU and WebGL 3D graphics in the browser using Three.js (WebGPURenderer + TSL), Babylon.js, PlayCanvas, React Three Fiber (R3F), and TresJS. Covers scene optimization, compute shaders, KTX2/Meshopt compression, and memory management / Panduan ahli grafis 3D web dan WebGPU modern."
4
+ author: "vibes-plug-swarm"
5
+ version: "3.0.0"
6
+ ---
7
+
8
+ # Web 3D Graphics Expert (WebGPU, Three.js, Babylon.js & PlayCanvas)
9
+
10
+ [English](#english) | [Bahasa Indonesia](#bahasa-indonesia)
11
+
12
+ ---
13
+
14
+ <a name="english"></a>
15
+ ## English
16
+
17
+ ### Orchestration & Integration
18
+ Connects and orchestrates with relevant domain skills:
19
+ - `senior-frontend` — Integrating React Three Fiber (R3F) in React 19 / Next.js 15.
20
+ - `vue-frontend-expert` — Integrating TresJS in Vue 3 / Nuxt 3.
21
+ - `svelte-sveltekit-expert` — Integrating Threlte in Svelte 5 (Runes).
22
+ - `web-game-engine-expert` — Physics simulations (Rapier, Jolt, Havok), game loops, and ECS.
23
+ - `glsl-shader-expert` — Shading languages, WGSL compute shaders, and TSL nodes.
24
+ - `webxr-ar-vr-expert` — WebXR immersive VR/AR experiences.
25
+ - `performance-web-vitals` — Minimizing Total Blocking Time (TBT), asset streaming, and bundle sizing.
26
+
27
+ ### Description
28
+ Production-grade guidance for architecting high-fidelity, high-framerate 3D experiences in the browser. Covers the modern **WebGPU-first** paradigm with automatic WebGL2 fallbacks, **Three.js (r170+) WebGPURenderer** and **TSL (Three Shading Language)**, **Babylon.js WebGPUEngine** with Snapshot Rendering, and **PlayCanvas Engine** for ultra-lightweight, mobile-first commercial applications.
29
+
30
+ ### Trigger Conditions
31
+ Activate this skill when the user is:
32
+ - Initializing a WebGPU or WebGL 3D scene.
33
+ - Using `three` (`three/webgpu`), `@react-three/fiber`, `@babylonjs/core`, `playcanvas`, `@tresjs/core`, or `@threlte/core`.
34
+ - Writing or refactoring shaders to Three Shading Language (TSL) or WGSL.
35
+ - Loading and optimizing 3D models (`.glb`, `.gltf`) with KTX2 texture compression or Meshopt.
36
+ - Implementing post-processing passes, compute shaders, or particle systems on the GPU.
37
+ - Diagnosing FPS drops, draw call bottlenecks, or VRAM memory leaks.
38
+
39
+ ---
40
+
41
+ ### Modern Web 3D Engine Landscape (2026)
42
+
43
+ | Engine / Stack | Best Use Case | Rendering Backend | Key Strengths |
44
+ | :--- | :--- | :--- | :--- |
45
+ | **Three.js (WebGPU + TSL)** | Creative landing pages, interactive portfolios, R3F React ecosystems | WebGPU (primary) + WebGL2 (fallback) | Vast community, huge ecosystem, TSL cross-compiles to WGSL & GLSL, node materials. |
46
+ | **Babylon.js** | Enterprise 3D simulations, CAD viewers, AAA web games with Havok | WebGPU + WebGL2 | Snapshot rendering, native Havok physics, compute shaders, robust GUI & inspector. |
47
+ | **PlayCanvas Engine** | High-performance mobile 3D, instant-load web games, e-commerce configurators | WebGPU + WebGL2 | Tiny runtime (~200KB gzipped), clustered lighting, zero-overhead scene graph. |
48
+ | **Threlte (Svelte 5)** | Svelte 5 apps requiring declarative 3D reactive components | Three.js WebGL/WebGPU | Svelte Runes reactivity (`$state`, `$derived`), lightweight bundle footprint. |
49
+
50
+ ---
51
+
52
+ ### 1. Three.js WebGPU & TSL (Three Shading Language)
53
+
54
+ Starting with modern Three.js, transition from `WebGLRenderer` to `WebGPURenderer`. It natively uses WebGPU when available and falls back cleanly to WebGL2.
55
+
56
+ ```typescript
57
+ // Modern Three.js WebGPU Scene Setup
58
+ import * as THREE from 'three/webgpu';
59
+ import { color, float, positionLocal, time, vec3, Fn } from 'three/tsl';
60
+
61
+ const canvas = document.querySelector('#canvas') as HTMLCanvasElement;
62
+ const renderer = new THREE.WebGPURenderer({ canvas, antialias: true });
63
+ renderer.setSize(window.innerWidth, window.innerHeight);
64
+ renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
65
+
66
+ // Initialize async WebGPU pipeline
67
+ await renderer.init();
68
+
69
+ const scene = new THREE.Scene();
70
+ const camera = new THREE.PerspectiveCamera(60, window.innerWidth / window.innerHeight, 0.1, 1000);
71
+ camera.position.set(0, 2, 5);
72
+
73
+ // TSL (Three Shading Language) Custom Node Material
74
+ // Compiles automatically to WGSL on WebGPU and GLSL on WebGL2!
75
+ const customMaterial = new THREE.MeshStandardNodeMaterial();
76
+
77
+ // Node-based animated color shader function
78
+ const animatedColor = Fn(() => {
79
+ const t = time.mul(2.0);
80
+ const wave = positionLocal.y.add(t).sin().mul(0.5).add(0.5);
81
+ return color(0x00ffff).mul(wave);
82
+ });
83
+
84
+ customMaterial.colorNode = animatedColor();
85
+
86
+ const mesh = new THREE.Mesh(new THREE.TorusKnotGeometry(1, 0.3, 128, 32), customMaterial);
87
+ scene.add(mesh);
88
+
89
+ // Render loop using setAnimationLoop (WebGPU & WebXR compatible)
90
+ renderer.setAnimationLoop(() => {
91
+ mesh.rotation.y += 0.01;
92
+ renderer.render(scene, camera);
93
+ });
94
+ ```
95
+
96
+ ---
97
+
98
+ ### 2. Babylon.js WebGPU Engine & Snapshot Rendering
99
+
100
+ For scenes with thousands of static meshes, Babylon.js **Snapshot Rendering** records GPU command buffers once and replays them, bypassing JavaScript CPU draw call overhead.
101
+
102
+ ```typescript
103
+ import { WebGPUEngine, Scene, ArcRotateCamera, Vector3, HemisphericLight, MeshBuilder } from '@babylonjs/core';
104
+
105
+ async function initBabylonWebGPU() {
106
+ const canvas = document.getElementById('renderCanvas') as HTMLCanvasElement;
107
+ const engine = new WebGPUEngine(canvas, { antialiasing: true });
108
+ await engine.initAsync();
109
+
110
+ const scene = new Scene(engine);
111
+ const camera = new ArcRotateCamera('camera', -Math.PI / 2, Math.PI / 2.5, 10, Vector3.Zero(), scene);
112
+ camera.attachControl(canvas, true);
113
+
114
+ const light = new HemisphericLight('light', new Vector3(0, 1, 0), scene);
115
+
116
+ // Enable Snapshot Rendering for extreme draw call reduction
117
+ engine.snapshotRendering = true;
118
+ engine.snapshotRenderingMode = WebGPUEngine.SNAPSHOTRENDERING_FAST;
119
+
120
+ engine.runRenderLoop(() => {
121
+ scene.render();
122
+ });
123
+ }
124
+ ```
125
+
126
+ ---
127
+
128
+ ### 3. PlayCanvas Engine (Ultra-Lightweight & Fast-Loading)
129
+
130
+ When bundle size and instant mobile loading are the primary constraints, use the standalone PlayCanvas Engine:
131
+
132
+ ```typescript
133
+ import * as pc from 'playcanvas';
134
+
135
+ const canvas = document.getElementById('application-canvas') as HTMLCanvasElement;
136
+ const app = new pc.Application(canvas, {
137
+ graphicsDeviceOptions: { alpha: false, antialias: true, preferWebGpu: true }
138
+ });
139
+ app.start();
140
+ app.setCanvasFillMode(pc.FILLMODE_FILL_WINDOW);
141
+ app.setCanvasResolution(pc.RESOLUTION_AUTO);
142
+
143
+ // Create Entity: Camera
144
+ const camera = new pc.Entity('camera');
145
+ camera.addComponent('camera', { clearColor: new pc.Color(0.1, 0.1, 0.15) });
146
+ camera.translate(0, 2, 6);
147
+ camera.lookAt(0, 0, 0);
148
+ app.root.addChild(camera);
149
+
150
+ // Create Entity: Clustered Directional Light
151
+ const light = new pc.Entity('light');
152
+ light.addComponent('light', { type: 'directional', castShadows: true });
153
+ light.setEulerAngles(45, 30, 0);
154
+ app.root.addChild(light);
155
+
156
+ // Create Entity: Box with Standard Material
157
+ const box = new pc.Entity('box');
158
+ box.addComponent('render', { type: 'box' });
159
+ app.root.addChild(box);
160
+
161
+ app.on('update', (dt: number) => {
162
+ box.rotate(10 * dt, 20 * dt, 30 * dt);
163
+ });
164
+ ```
165
+
166
+ ---
167
+
168
+ ### 4. React Three Fiber (R3F) with React 19
169
+
170
+ ```tsx
171
+ import { Canvas } from '@react-three/fiber';
172
+ import { OrbitControls, Environment, useGLTF, Float } from '@react-three/drei';
173
+
174
+ function ModelViewer() {
175
+ const { scene } = useGLTF('/models/drone.glb');
176
+ return (
177
+ <Float speed={2} rotationIntensity={0.5} floatIntensity={1}>
178
+ <primitive object={scene} />
179
+ </Float>
180
+ );
181
+ }
182
+
183
+ export default function App() {
184
+ return (
185
+ <Canvas
186
+ gl={(canvas) => new THREE.WebGPURenderer({ canvas, antialias: true })}
187
+ camera={{ position: [0, 1.5, 4], fov: 45 }}
188
+ dpr={[1, 2]}
189
+ >
190
+ <ambientLight intensity={0.6} />
191
+ <directionalLight position={[5, 10, 5]} castShadow intensity={1.5} />
192
+ <ModelViewer />
193
+ <Environment preset="city" />
194
+ <OrbitControls makeDefault enableDamping dampingFactor={0.05} />
195
+ </Canvas>
196
+ );
197
+ }
198
+
199
+ // Preload critical assets outside component tree
200
+ useGLTF.preload('/models/drone.glb');
201
+ ```
202
+
203
+ ---
204
+
205
+ ### Modern Asset Pipeline & GPU Memory Optimization
206
+
207
+ #### 1. GPU Texture Compression: KTX2 + Basis Universal (`KHR_texture_basisu`)
208
+ > **CRITICAL RULE**: Never deploy raw PNG or JPG textures for 3D production models.
209
+ - **Why?** PNG/JPG files decompress into uncompressed 32-bit RGBA inside GPU VRAM. A 2048x2048 PNG consumes **16MB of VRAM**; an uncompressed 4K texture consumes **64MB of VRAM**.
210
+ - **KTX2 with Basis Universal** transcodes in real-time into native GPU-compressed formats:
211
+ - Mobile: ASTC / ETC2.
212
+ - Desktop: BC7 / BC1.
213
+ - **Result:** Saves **75% to 85% of GPU VRAM**, prevents mobile browser tab crashes, and eliminates texture upload GPU hitches.
214
+ - **Tooling:** Compress glTF files with `gltf-transform`:
215
+ ```bash
216
+ npx @gltf-transform/cli optimize input.glb output.glb --texture-compress ktx2
217
+ ```
218
+
219
+ #### 2. Geometry Optimization: Meshopt (`EXT_meshopt_compression`)
220
+ - Prefer **Meshopt** over Draco for high-framerate interactive apps and games.
221
+ - **Advantage:** Meshopt WASM decompressor runs at **gigabytes per second** (up to 10x faster decompression than Draco on mobile CPUs) and organizes vertex attributes for maximum GPU vertex cache efficiency.
222
+ ```bash
223
+ npx @gltf-transform/cli meshopt input.glb output.glb
224
+ ```
225
+
226
+ #### 3. Strict Memory Lifecycle Management (`.dispose()`)
227
+ Garbage collection does NOT clean up WebGL/WebGPU buffers:
228
+ - When removing an object from Three.js or Babylon.js, explicitly traverse and dispose:
229
+ ```typescript
230
+ export function purgeObject(object: THREE.Object3D) {
231
+ object.traverse((child) => {
232
+ if ((child as THREE.Mesh).isMesh) {
233
+ const mesh = child as THREE.Mesh;
234
+ mesh.geometry?.dispose();
235
+ if (Array.isArray(mesh.material)) {
236
+ mesh.material.forEach((m) => disposeMaterial(m));
237
+ } else if (mesh.material) {
238
+ disposeMaterial(mesh.material);
239
+ }
240
+ }
241
+ });
242
+ }
243
+
244
+ function disposeMaterial(material: THREE.Material) {
245
+ Object.keys(material).forEach((prop) => {
246
+ const value = (material as any)[prop];
247
+ if (value && typeof value.dispose === 'function') {
248
+ value.dispose();
249
+ }
250
+ });
251
+ material.dispose();
252
+ }
253
+ ```
254
+
255
+ ---
256
+
257
+ ### Production Checklist
258
+ - [ ] Render with `WebGPURenderer` (Three.js) or `WebGPUEngine` (Babylon.js) with fallback enabled.
259
+ - [ ] Use KTX2 / Basis Universal compressed textures on all `.glb` assets.
260
+ - [ ] Use Meshopt geometry compression to eliminate model loading CPU stalls.
261
+ - [ ] Clamp `devicePixelRatio` to `Math.min(window.devicePixelRatio, 2)` to prevent 4K/Retina mobile GPU thermal throttling.
262
+ - [ ] Use `InstancedMesh` (Three.js) or `Thin Instances` (Babylon.js) for repetitive assets (>10 meshes).
263
+ - [ ] Implement explicit `.dispose()` cleanup in `useEffect` or component unmount hooks.
264
+
265
+ ---
266
+
267
+ <a name="bahasa-indonesia"></a>
268
+ ## Bahasa Indonesia
269
+
270
+ ### Integrasi Orkestrasi
271
+ Terhubung dan mengorkestrasi skill domain yang relevan:
272
+ - `senior-frontend` — Integrasi React Three Fiber (R3F) pada React 19 / Next.js 15.
273
+ - `vue-frontend-expert` — Integrasi TresJS pada Vue 3 / Nuxt 3.
274
+ - `svelte-sveltekit-expert` — Integrasi Threlte pada Svelte 5 (Runes).
275
+ - `web-game-engine-expert` — Simulasi fisika (Rapier, Jolt, Havok), game loop, dan ECS.
276
+ - `glsl-shader-expert` — Bahasa shader, compute shader WGSL, dan node TSL.
277
+ - `webxr-ar-vr-expert` — Pengalaman WebXR VR/AR imersif.
278
+ - `performance-web-vitals` — Meminimalkan TBT (Total Blocking Time) dan optimasi ukuran bundle.
279
+
280
+ ### Deskripsi
281
+ Panduan produksi untuk membangun grafis 3D performa tinggi di browser. Mengutamakan paradigma modern **WebGPU-first** dengan fallback otomatis ke WebGL2, **Three.js (r170+) WebGPURenderer** dan **TSL (Three Shading Language)**, **Babylon.js WebGPUEngine** dengan Snapshot Rendering, serta **PlayCanvas Engine** untuk aplikasi komersial mobile yang sangat ringan dan cepat dimuat.
282
+
283
+ ### Kondisi Pemicu
284
+ Aktifkan skill ini ketika pengguna:
285
+ - Menginisialisasi *scene* WebGPU atau WebGL 3D.
286
+ - Menggunakan `three` (`three/webgpu`), `@react-three/fiber`, `@babylonjs/core`, `playcanvas`, `@tresjs/core`, atau `@threlte/core`.
287
+ - Menulis atau merefaktor shader ke Three Shading Language (TSL) atau WGSL.
288
+ - Memuat dan mengoptimalkan model 3D (`.glb`, `.gltf`) menggunakan kompresi tekstur KTX2 atau Meshopt.
289
+ - Mengimplementasikan post-processing, compute shader, atau sistem partikel pada GPU.
290
+ - Mengatasi penurunan FPS (*frame drop*), hambatan *draw call*, atau kebocoran memori VRAM.
291
+
292
+ ---
293
+
294
+ ### Panduan Inti & Rekomendasi Mesin 3D
295
+
296
+ 1. **Three.js WebGPU + TSL**:
297
+ - Gunakan `WebGPURenderer` alih-alih `WebGLRenderer` standar.
298
+ - Manfaatkan TSL (*Three Shading Language*) dan *Node Materials*. Kode shader TSL ditulis secara deklaratif dalam TypeScript/JavaScript dan otomatis dikompilasi menjadi WGSL pada WebGPU dan GLSL pada WebGL2.
299
+
300
+ 2. **Babylon.js Snapshot Rendering**:
301
+ - Untuk skenario dengan ribuan mesh statis, aktifkan `engine.snapshotRendering = true` untuk merekam *command buffer* GPU sekali saja, memotong hampir 100% *overhead* CPU draw call JavaScript.
302
+
303
+ 3. **PlayCanvas Engine (Performa Mobile Ekstrem)**:
304
+ - Jika waktu muat (*initial load*) dan ukuran bundle adalah prioritas utama (misalnya iklan interaktif, 3D e-commerce configurator, game web mobile), PlayCanvas hanya memakan ~200KB gzipped dengan fitur *clustered lighting* yang sangat cepat.
305
+
306
+ 4. **Kompresi Tekstur GPU KTX2 (Wajib)**:
307
+ - Jangan menyajikan file PNG/JPG mentah di produksi. Format PNG/JPG diekspansi menjadi uncompressed RGBA di VRAM GPU (tekstur 4K memakan 64MB VRAM).
308
+ - Gunakan **KTX2 / Basis Universal** yang tetap terkompresi langsung di VRAM GPU (menghemat 75%-85% VRAM dan mencegah browser mobile crash).
309
+
310
+ 5. **Kompresi Geometri Meshopt**:
311
+ - Gunakan kompresi **Meshopt** (`EXT_meshopt_compression`) alih-alih Draco jika membutuhkan dekompresi super cepat di browser (hingga 10x lebih cepat dibanding Draco pada CPU mobile).
312
+
313
+ 6. **Pembersihan Memori Bersih (`.dispose()`)**:
314
+ - Browser garbage collector tidak dapat menghapus buffer GPU secara otomatis. Selalu panggil method `.dispose()` pada geometry, material, dan texture saat komponen di-unmount.