vibes-plug 2.11.0 → 2.14.1
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/.cursor/rules/vibes-plug-core.mdc +3 -3
- package/.cursorrules +3 -3
- package/AGENTS.md +4 -4
- package/BLUEPRINT.md +16 -6
- package/CHANGELOG.md +37 -0
- package/CLAUDE.md +8 -8
- package/README.md +85 -115
- package/index.js +1 -1
- package/package.json +2 -2
- package/plugin.json +2 -2
- package/scripts/check-anti-slop.js +53 -0
- package/scripts/generate_swarm_gif.py +2 -2
- package/skills/ai-llm-integration-expert/SKILL.md +22 -15
- package/skills/ai-prompt-engineering-expert/SKILL.md +133 -83
- package/skills/anti-slop/SKILL.md +133 -0
- package/skills/async-queue-temporal-expert/SKILL.md +135 -158
- package/skills/authentication-identity-expert/SKILL.md +172 -278
- package/skills/brainstorming/SKILL.md +26 -26
- package/skills/database-orm-expert/SKILL.md +164 -303
- package/skills/deep-research-analyst/SKILL.md +136 -0
- package/skills/design-system-architect/SKILL.md +31 -1
- package/skills/email-notification-expert/SKILL.md +31 -4
- package/skills/error-resilience-expert/SKILL.md +21 -0
- package/skills/fullstack-expert/SKILL.md +183 -260
- package/skills/glsl-shader-expert/SKILL.md +190 -107
- package/skills/graph-rag-knowledge-expert/SKILL.md +42 -1
- package/skills/mcp-server-architect/SKILL.md +15 -1
- package/skills/prd-architect/SKILL.md +181 -206
- package/skills/production-ready-hardener/SKILL.md +16 -19
- package/skills/pwa-offline-first-expert/SKILL.md +42 -1
- package/skills/pydantic-ai-expert/SKILL.md +161 -0
- package/skills/saas-architect/SKILL.md +154 -0
- package/skills/senior-frontend/SKILL.md +9 -11
- package/skills/senior-frontend/scripts/frontend_scaffolder.py +1 -1
- package/skills/session-memory-manager/SKILL.md +128 -0
- package/skills/synthetic-data-finetuning-expert/SKILL.md +155 -0
- package/skills/ui-ux-pro-max/SKILL.md +4 -2
- package/skills/vercel-ai-sdk-expert/SKILL.md +181 -0
- package/skills/voice-ai-realtime-agent/SKILL.md +41 -1
- package/skills/web-3d-graphics-expert/SKILL.md +313 -137
- package/skills/web-game-engine-expert/SKILL.md +329 -102
- package/skills/webxr-ar-vr-expert/SKILL.md +162 -123
- package/skills/zero-to-prod-orchestrator/SKILL.md +26 -24
- package/skills/ai-cost-token-optimizer/SKILL.md +0 -82
- package/skills/ai-evals-benchmark-expert/SKILL.md +0 -188
- package/skills/asisten-ramah/SKILL.md +0 -47
- package/skills/auto-doc-updater/SKILL.md +0 -220
- package/skills/autonomous-chaos-monkey/SKILL.md +0 -63
- package/skills/background-jobs-queue-expert/SKILL.md +0 -235
- package/skills/database-migration-versioning-expert/SKILL.md +0 -90
- package/skills/edge-serverless-db-expert/SKILL.md +0 -99
- package/skills/mcp-client-orchestrator/SKILL.md +0 -76
- package/skills/mobile-push-notification-expert/SKILL.md +0 -71
- package/skills/monday-design-aesthetic/SKILL.md +0 -73
- package/skills/project-context-mapper/SKILL.md +0 -85
- package/skills/saas-mvp-launcher/SKILL.md +0 -260
- package/skills/saas-transformer/SKILL.md +0 -500
- package/skills/saas-transformer/references/billing_integration_guide.md +0 -401
- package/skills/self-evolving-memory-graph/SKILL.md +0 -91
- package/skills/session-context-loader/SKILL.md +0 -83
- package/skills/session-handoff-resume/SKILL.md +0 -164
- package/skills/skill-baru/SKILL.md +0 -178
- package/skills/supabase-migration/SKILL.md +0 -91
- package/skills/token-saver/SKILL.md +0 -119
- package/skills/ui-components-expert/SKILL.md +0 -166
- package/skills/vibe-code-gardener/SKILL.md +0 -181
- /package/skills/{saas-transformer → saas-architect}/references/feature_gating_patterns.md +0 -0
- /package/skills/{saas-transformer → saas-architect}/references/saas_transformation_checklist.md +0 -0
- /package/skills/{saas-transformer → saas-architect}/scripts/saas_transformation_scanner.py +0 -0
|
@@ -1,137 +1,313 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: web-3d-graphics-expert
|
|
3
|
-
description: "Expert guide for
|
|
4
|
-
author: "
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
# Web 3D Graphics Expert (Three.js
|
|
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
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
const
|
|
69
|
-
camera.
|
|
70
|
-
camera.
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
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.
|