@istmx/skills 1.1.0 → 2.0.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 (153) hide show
  1. package/CODE_OF_CONDUCT.md +47 -0
  2. package/LICENSE +30 -0
  3. package/README.md +48 -22
  4. package/bin/cli.js +130 -119
  5. package/istm-animate/SKILL.md +28 -58
  6. package/istm-animate/core/motion-principles/SKILL.md +284 -0
  7. package/istm-animate/core/motion-principles/references/designers.md +127 -0
  8. package/istm-animate/core/motion-principles/references/easing-guide.md +231 -0
  9. package/istm-animate/core/motion-principles/references/enter-exit-recipes.md +466 -0
  10. package/istm-animate/frameworks/canvas-generative/SKILL.md +325 -0
  11. package/istm-animate/frameworks/canvas-generative/references/algorithms.md +925 -0
  12. package/istm-animate/frameworks/css-native/SKILL.md +319 -0
  13. package/istm-animate/frameworks/css-native/references/modern-css.md +465 -0
  14. package/istm-animate/frameworks/framer-motion/SKILL.md +187 -0
  15. package/istm-animate/frameworks/framer-motion/references/api.md +312 -0
  16. package/istm-animate/frameworks/gsap/SKILL.md +188 -0
  17. package/istm-animate/frameworks/gsap/references/core.md +218 -0
  18. package/istm-animate/frameworks/gsap/references/plugins.md +371 -0
  19. package/istm-animate/frameworks/gsap/references/scrolltrigger.md +325 -0
  20. package/istm-animate/frameworks/gsap/references/timeline.md +218 -0
  21. package/istm-animate/frameworks/threejs-r3f/SKILL.md +243 -0
  22. package/istm-animate/frameworks/threejs-r3f/references/scene-setup.md +392 -0
  23. package/istm-animate/frameworks/threejs-r3f/references/shaders.md +446 -0
  24. package/istm-animate/mobile/android/compose-graphics/SKILL.md +503 -0
  25. package/istm-animate/mobile/android/compose-graphics/references/agsl-recipes.md +356 -0
  26. package/istm-animate/mobile/android/compose-graphics/references/canvas-generative.md +282 -0
  27. package/istm-animate/mobile/android/compose-graphics/references/m3-expressive-deep.md +303 -0
  28. package/istm-animate/mobile/android/compose-motion/SKILL.md +359 -0
  29. package/istm-animate/mobile/android/compose-motion/references/gestures-compose.md +273 -0
  30. package/istm-animate/mobile/android/compose-motion/references/recomposition-and-anim.md +196 -0
  31. package/istm-animate/mobile/android/compose-motion/references/shared-transitions.md +281 -0
  32. package/istm-animate/mobile/android/compose-multiplatform/SKILL.md +311 -0
  33. package/istm-animate/mobile/android/compose-multiplatform/references/cmp-interop.md +288 -0
  34. package/istm-animate/mobile/android/compose-multiplatform/references/cmp-platform-quirks.md +156 -0
  35. package/istm-animate/mobile/apple/swiftui-graphics/SKILL.md +408 -0
  36. package/istm-animate/mobile/apple/swiftui-graphics/references/canvas-swiftui.md +239 -0
  37. package/istm-animate/mobile/apple/swiftui-graphics/references/liquid-glass-deep.md +252 -0
  38. package/istm-animate/mobile/apple/swiftui-graphics/references/metal-recipes.md +382 -0
  39. package/istm-animate/mobile/apple/swiftui-motion/SKILL.md +379 -0
  40. package/istm-animate/mobile/apple/swiftui-motion/references/gestures-swiftui.md +336 -0
  41. package/istm-animate/mobile/apple/swiftui-motion/references/phase-keyframe-deep.md +231 -0
  42. package/istm-animate/mobile/apple/swiftui-motion/references/springs-cheatsheet.md +129 -0
  43. package/istm-animate/references/animate.md +199 -0
  44. package/istm-animate/references/audit.md +115 -0
  45. package/istm-animate/references/design-engineering.md +674 -0
  46. package/istm-animate/references/improve.md +101 -0
  47. package/istm-animate/references/opportunities.md +132 -0
  48. package/istm-animate/references/plan-template.md +73 -0
  49. package/istm-animate/references/recipes.md +324 -0
  50. package/istm-animate/references/review.md +112 -0
  51. package/istm-animate/references/standards.md +187 -0
  52. package/istm-animate/references/vocabulary.md +173 -0
  53. package/istm-architecture/SKILL.md +10 -1
  54. package/istm-awwward-designer/SKILL.md +28 -20
  55. package/istm-design/SKILL.md +31 -58
  56. package/istm-design/core/design-audit/SKILL.md +248 -0
  57. package/istm-design/core/desktop-principles/SKILL.md +363 -0
  58. package/istm-design/core/desktop-principles/references/keyboard-patterns.md +137 -0
  59. package/istm-design/core/desktop-principles/references/multi-window.md +105 -0
  60. package/istm-design/core/mobile-principles/SKILL.md +289 -0
  61. package/istm-design/core/mobile-principles/references/accessibility-mobile.md +175 -0
  62. package/istm-design/core/mobile-principles/references/gestures-deep.md +220 -0
  63. package/istm-design/core/ui-ux-pro-max/SKILL.md +392 -0
  64. package/istm-design/core/ui-ux-pro-max/UPSTREAM.md +23 -0
  65. package/istm-design/core/ui-ux-pro-max/data/app-interface.csv +31 -0
  66. package/istm-design/core/ui-ux-pro-max/data/charts.csv +26 -0
  67. package/istm-design/core/ui-ux-pro-max/data/colors.csv +193 -0
  68. package/istm-design/core/ui-ux-pro-max/data/google-fonts.csv +1924 -0
  69. package/istm-design/core/ui-ux-pro-max/data/icons.csv +106 -0
  70. package/istm-design/core/ui-ux-pro-max/data/landing.csv +35 -0
  71. package/istm-design/core/ui-ux-pro-max/data/motion.csv +17 -0
  72. package/istm-design/core/ui-ux-pro-max/data/products.csv +193 -0
  73. package/istm-design/core/ui-ux-pro-max/data/react-performance.csv +45 -0
  74. package/istm-design/core/ui-ux-pro-max/data/stacks/angular.csv +51 -0
  75. package/istm-design/core/ui-ux-pro-max/data/stacks/astro.csv +54 -0
  76. package/istm-design/core/ui-ux-pro-max/data/stacks/avalonia.csv +57 -0
  77. package/istm-design/core/ui-ux-pro-max/data/stacks/flutter.csv +53 -0
  78. package/istm-design/core/ui-ux-pro-max/data/stacks/html-tailwind.csv +56 -0
  79. package/istm-design/core/ui-ux-pro-max/data/stacks/javafx.csv +76 -0
  80. package/istm-design/core/ui-ux-pro-max/data/stacks/jetpack-compose.csv +53 -0
  81. package/istm-design/core/ui-ux-pro-max/data/stacks/laravel.csv +51 -0
  82. package/istm-design/core/ui-ux-pro-max/data/stacks/nextjs.csv +53 -0
  83. package/istm-design/core/ui-ux-pro-max/data/stacks/nuxt-ui.csv +71 -0
  84. package/istm-design/core/ui-ux-pro-max/data/stacks/nuxtjs.csv +59 -0
  85. package/istm-design/core/ui-ux-pro-max/data/stacks/react-native.csv +52 -0
  86. package/istm-design/core/ui-ux-pro-max/data/stacks/react.csv +54 -0
  87. package/istm-design/core/ui-ux-pro-max/data/stacks/shadcn.csv +61 -0
  88. package/istm-design/core/ui-ux-pro-max/data/stacks/svelte.csv +54 -0
  89. package/istm-design/core/ui-ux-pro-max/data/stacks/swiftui.csv +51 -0
  90. package/istm-design/core/ui-ux-pro-max/data/stacks/threejs.csv +54 -0
  91. package/istm-design/core/ui-ux-pro-max/data/stacks/uno.csv +60 -0
  92. package/istm-design/core/ui-ux-pro-max/data/stacks/uwp.csv +56 -0
  93. package/istm-design/core/ui-ux-pro-max/data/stacks/vue.csv +50 -0
  94. package/istm-design/core/ui-ux-pro-max/data/stacks/winui.csv +60 -0
  95. package/istm-design/core/ui-ux-pro-max/data/stacks/wpf.csv +57 -0
  96. package/istm-design/core/ui-ux-pro-max/data/styles.csv +85 -0
  97. package/istm-design/core/ui-ux-pro-max/data/typography.csv +75 -0
  98. package/istm-design/core/ui-ux-pro-max/data/ui-reasoning.csv +162 -0
  99. package/istm-design/core/ui-ux-pro-max/data/ux-guidelines.csv +100 -0
  100. package/istm-design/core/ui-ux-pro-max/references/pro-rules.md +109 -0
  101. package/istm-design/core/ui-ux-pro-max/references/quick-reference.md +240 -0
  102. package/istm-design/core/ui-ux-pro-max/scripts/core.py +464 -0
  103. package/istm-design/core/ui-ux-pro-max/scripts/design_system.py +1371 -0
  104. package/istm-design/core/ui-ux-pro-max/scripts/search.py +162 -0
  105. package/istm-design/core/ui-ux-pro-max/scripts/tests/test_core.py +134 -0
  106. package/istm-design/core/ui-ux-pro-max/scripts/validate_data.py +114 -0
  107. package/istm-design/references/apple-design.md +282 -0
  108. package/istm-design/references/generation-guide.md +209 -0
  109. package/istm-design/references/pick-ui-library.md +77 -0
  110. package/istm-design/references/picker.md +197 -0
  111. package/istm-design/references/prototype.md +90 -0
  112. package/istm-design/references/schema.md +366 -0
  113. package/istm-workflow/istm-audit/SKILL.md +7 -7
  114. package/istm-workflow/istm-audit/agent-prompt.md +20 -20
  115. package/istm-workflow/istm-audit/modes/area.md +1 -1
  116. package/istm-workflow/istm-audit/modes/greenfield.md +4 -4
  117. package/istm-workflow/istm-audit/modes/tool-skills.md +1 -1
  118. package/istm-workflow/istm-check/SKILL.md +10 -10
  119. package/istm-workflow/istm-check/modes/review.md +9 -9
  120. package/istm-workflow/istm-check/modes/verify.md +19 -19
  121. package/istm-workflow/istm-check/review-agent-prompt.md +2 -2
  122. package/istm-workflow/istm-check/review-guide.md +4 -4
  123. package/istm-workflow/istm-craft/SKILL.md +20 -11
  124. package/istm-workflow/istm-craft/agent-modes/architecture.md +1 -1
  125. package/istm-workflow/istm-craft/agent-prompt.md +8 -8
  126. package/istm-workflow/istm-craft/internal/after-subagent.md +11 -11
  127. package/istm-workflow/istm-craft/internal/design-conversation.md +9 -9
  128. package/istm-workflow/istm-craft/internal/tool-discovery.md +2 -2
  129. package/istm-workflow/istm-craft/spec-template.md +18 -18
  130. package/istm-workflow/istm-debug/SKILL.md +6 -6
  131. package/istm-workflow/istm-develop/SKILL.md +31 -16
  132. package/istm-workflow/istm-develop/checklist.md +1 -1
  133. package/istm-workflow/istm-develop/flow/build.md +21 -21
  134. package/istm-workflow/istm-develop/flow/git.md +4 -4
  135. package/istm-workflow/istm-develop/logical-guide.md +5 -5
  136. package/istm-workflow/istm-develop/ui/implementation.md +2 -2
  137. package/istm-workflow/istm-develop/ui-guide.md +3 -3
  138. package/istm-workflow/istm-document/SKILL.md +6 -6
  139. package/istm-workflow/istm-document/templates/postmortem.md +1 -1
  140. package/istm-workflow/istm-scope/SKILL.md +20 -20
  141. package/istm-workflow/istm-scope/modes/add.md +1 -1
  142. package/istm-workflow/istm-scope/modes/plan-brownfield.md +2 -2
  143. package/istm-workflow/istm-scope/modes/plan-greenfield.md +4 -4
  144. package/istm-workflow/istm-scope/modes/plan-monorepo.md +3 -3
  145. package/istm-workflow/istm-scope/modes/plan.md +16 -16
  146. package/istm-workflow/istm-scope/modes/replan.md +2 -2
  147. package/istm-workflow/istm-scope/scope-template.md +29 -29
  148. package/istm-workflow/istm-sync/SKILL.md +37 -25
  149. package/istm-workflow/istm-sync/agent-prompt.md +37 -19
  150. package/istm-workflow/istm-test/SKILL.md +12 -12
  151. package/istm-workflow/istm-test/modes/setup.md +6 -6
  152. package/istm-workflow/istm-test/writing-guide.md +1 -1
  153. package/package.json +1 -1
@@ -0,0 +1,243 @@
1
+ ---
2
+ name: threejs-r3f
3
+ description: "Three.js and React Three Fiber sub-skill - 3D scenes, shaders, postprocessing."
4
+ ---
5
+
6
+ # Three.js & React Three Fiber
7
+
8
+ > 3D on the web. Three.js is the engine, R3F is the React renderer.
9
+ > Concise rules here. Deep-dive in `references/`.
10
+
11
+ ---
12
+
13
+ ## When to Use What
14
+
15
+ | Need | Tool | Why |
16
+ |---|---|---|
17
+ | Full 3D scene (models, lights, physics) | R3F + drei | Declarative, React-friendly, ecosystem |
18
+ | Vanilla 3D (no React) | Three.js direct | Lighter, no React overhead |
19
+ | Simple 3D transforms on UI | CSS `transform3d` | GPU-composited, no WebGL context |
20
+ | 2D particles / generative | Canvas 2D | Simpler API, less GPU overhead |
21
+ | Shader-only visuals (no scene graph) | Raw WebGL / ShaderMaterial | Maximum control, minimal abstraction |
22
+
23
+ ---
24
+
25
+ ## Scene Setup Patterns
26
+
27
+ ```tsx
28
+ import { Canvas } from '@react-three/fiber'
29
+ import { Environment, OrbitControls } from '@react-three/drei'
30
+ import { Suspense } from 'react'
31
+
32
+ <Canvas camera={{ position: [0, 2, 5], fov: 45 }} dpr={[1, 2]} gl={{ antialias: true }}>
33
+ <Suspense fallback={null}>
34
+ <Environment preset="studio" />
35
+ <OrbitControls makeDefault />
36
+ <Scene />
37
+ </Suspense>
38
+ </Canvas>
39
+ ```
40
+
41
+ **Rules:**
42
+ - Always wrap scene content in `<Suspense>` -- loaders (GLTF, textures, HDRI) need it
43
+ - Set `dpr={[1, 2]}` to clamp pixel ratio (Retina without melting GPUs)
44
+ - Keep the Canvas parent component minimal -- re-renders propagate into the scene
45
+
46
+ ---
47
+
48
+ ## R3F Hooks
49
+
50
+ | Hook | Purpose | Gotcha |
51
+ |---|---|---|
52
+ | `useFrame((state, delta) => {})` | Per-frame logic (animation, physics) | Never setState inside |
53
+ | `useThree()` | Access gl, scene, camera, size, viewport, pointer | Destructure only what you need |
54
+ | `useLoader(TextureLoader, url)` | Load any Three.js resource | Wrap parent in Suspense |
55
+ | `useGraph(scene)` | Extract nodes/materials from loaded scene | Useful after useGLTF |
56
+
57
+ ### useFrame Tips
58
+
59
+ ```tsx
60
+ useFrame((state, delta) => {
61
+ // Use delta for framerate-independent animation
62
+ meshRef.current.rotation.y += delta * 0.5
63
+ // Access clock for time-based effects
64
+ material.uniforms.uTime.value = state.clock.elapsedTime
65
+ })
66
+ ```
67
+
68
+ ---
69
+
70
+ ## Drei Essentials
71
+
72
+ | Component | Use Case |
73
+ |---|---|
74
+ | `Environment` | HDRI lighting (presets: studio, sunset, city, forest, dawn) |
75
+ | `Float` | Idle floating animation (speed, rotationIntensity, floatIntensity) |
76
+ | `Text3D` | Extruded 3D text (needs JSON font from Facetype.js) |
77
+ | `useGLTF` | Load .glb/.gltf models (returns { nodes, materials, scene }) |
78
+ | `useGLTF.preload(url)` | Preload model before component mounts |
79
+ | `MeshTransmissionMaterial` | Glass/crystal/liquid refraction effects |
80
+ | `PresentationControls` | Drag-to-rotate for product showcases |
81
+ | `Center` | Auto-center any group of meshes |
82
+ | `Detailed` | LOD -- swap geometry by camera distance |
83
+ | `useTexture` | Load textures with Suspense support |
84
+ | `Instances` | Declarative instancing for repeated meshes |
85
+
86
+ ---
87
+
88
+ ## Postprocessing
89
+
90
+ ```tsx
91
+ import { EffectComposer, Bloom, ChromaticAberration } from '@react-three/postprocessing'
92
+ import { BlendFunction } from 'postprocessing'
93
+
94
+ <EffectComposer>
95
+ <Bloom
96
+ luminanceThreshold={1}
97
+ luminanceSmoothing={0.4}
98
+ intensity={0.6}
99
+ />
100
+ <ChromaticAberration
101
+ blendFunction={BlendFunction.NORMAL}
102
+ offset={[0.002, 0.002]}
103
+ />
104
+ </EffectComposer>
105
+ ```
106
+
107
+ **Rules:**
108
+ - Bloom is selective by default -- lift material color/emissive above 1.0 to make it glow
109
+ - `luminanceThreshold={1}` = nothing glows unless explicitly emissive
110
+ - Order matters inside EffectComposer
111
+ - Effects are merged into a single pass (performant by design)
112
+
113
+ ---
114
+
115
+ ## Performance Patterns
116
+
117
+ | Pattern | When |
118
+ |---|---|
119
+ | `<Instances>` / `InstancedMesh` | 100+ identical meshes (particles, trees, crowds) |
120
+ | `<Detailed distances={[0, 50, 100]}>` | LOD: swap hi/lo models by distance |
121
+ | `dispose={null}` on `<primitive>` | Prevent auto-dispose when reusing shared geometry |
122
+ | `useGLTF` + Draco | Compress .glb models (70-90% size reduction) |
123
+ | `useTexture` + KTX2 | Compressed GPU textures (1/4 VRAM) |
124
+ | `frameloop="demand"` on Canvas | Only render when something changes (static scenes) |
125
+ | `invalidate()` from useThree | Trigger a render in demand mode |
126
+ | Offscreen canvas (`<Canvas eventSource={...}>`) | Run rendering off main thread |
127
+
128
+ **Target metrics:** < 100 draw calls, < 1M triangles, 60fps on mid-range GPU.
129
+ Use `stats-gl` or `r3f-perf` to monitor.
130
+
131
+ ---
132
+
133
+ ## Do Not
134
+
135
+ ### 1. Never setState in useFrame
136
+
137
+ Causes full React re-render 60x/second. Mutate refs directly.
138
+
139
+ ```tsx
140
+ // BAD
141
+ useFrame(() => {
142
+ setRotation(prev => prev + 0.01) // React re-render every frame
143
+ })
144
+
145
+ // GOOD
146
+ useFrame((_, delta) => {
147
+ meshRef.current.rotation.y += delta * 0.5 // Direct mutation, zero re-renders
148
+ })
149
+ ```
150
+
151
+ ### 2. Never allocate in the render loop
152
+
153
+ `new Vector3()` per frame = GC spikes = stutter.
154
+
155
+ ```tsx
156
+ // BAD
157
+ useFrame((state) => {
158
+ const target = new THREE.Vector3(0, Math.sin(state.clock.elapsedTime), 0)
159
+ meshRef.current.position.copy(target)
160
+ })
161
+
162
+ // GOOD
163
+ const _target = useMemo(() => new THREE.Vector3(), [])
164
+ useFrame((state) => {
165
+ _target.set(0, Math.sin(state.clock.elapsedTime), 0)
166
+ meshRef.current.position.copy(_target)
167
+ })
168
+ ```
169
+
170
+ ### 3. Never forget dispose (memory leak)
171
+
172
+ Three.js textures, geometries, and materials live on the GPU. Unmounting a React component does NOT free them.
173
+
174
+ ```tsx
175
+ // BAD -- texture stays in VRAM after unmount
176
+ const texture = useLoader(TextureLoader, '/big-texture.jpg')
177
+
178
+ // GOOD -- R3F auto-disposes when using JSX primitives
179
+ // For manual resources, dispose in cleanup:
180
+ useEffect(() => {
181
+ return () => {
182
+ texture.dispose()
183
+ geometry.dispose()
184
+ material.dispose()
185
+ }
186
+ }, [])
187
+ ```
188
+
189
+ ### 4. Never re-render the Canvas parent
190
+
191
+ State changes in the parent force the entire Canvas to remount = flash, lost state, reloaded assets.
192
+
193
+ ```tsx
194
+ // BAD
195
+ function App() {
196
+ const [uiState, setUiState] = useState(false) // re-renders remount Canvas
197
+ return (
198
+ <>
199
+ <button onClick={() => setUiState(!uiState)}>Toggle</button>
200
+ <Canvas><Scene config={uiState} /></Canvas>
201
+ </>
202
+ )
203
+ }
204
+
205
+ // GOOD -- isolate Canvas in its own component
206
+ function App() {
207
+ return (
208
+ <>
209
+ <UI />
210
+ <SceneCanvas />
211
+ </>
212
+ )
213
+ }
214
+ ```
215
+
216
+ ### 5. Never load assets without Suspense
217
+
218
+ Loaders (useGLTF, useTexture, useLoader) throw promises. Without Suspense, you get crashes.
219
+
220
+ ```tsx
221
+ // BAD
222
+ <Canvas>
223
+ <Model /> {/* useGLTF inside -- will throw */}
224
+ </Canvas>
225
+
226
+ // GOOD
227
+ <Canvas>
228
+ <Suspense fallback={<Loader />}>
229
+ <Model />
230
+ </Suspense>
231
+ </Canvas>
232
+ ```
233
+
234
+ ---
235
+
236
+ ## Quick Reference: Loading Sub-resources
237
+
238
+ | Need | Load |
239
+ |---|---|
240
+ | Scene boilerplate, lighting rigs, controls | `references/scene-setup.md` |
241
+ | Custom shaders, GLSL patterns, uniforms | `references/shaders.md` |
242
+ | Animation principles, easing, timing | `../motion-principles/SKILL.md` |
243
+ | GSAP + Three.js integration | `../gsap/SKILL.md` |
@@ -0,0 +1,392 @@
1
+ # Scene Setup Reference
2
+
3
+ > Complete R3F boilerplate patterns with TypeScript.
4
+ > Copy-paste ready. Adapt to your project.
5
+
6
+ ---
7
+
8
+ ## Minimal Canvas Setup
9
+
10
+ ```tsx
11
+ import { Canvas } from '@react-three/fiber'
12
+ import { Suspense } from 'react'
13
+
14
+ function App() {
15
+ return (
16
+ <div style={{ width: '100vw', height: '100vh' }}>
17
+ <Canvas
18
+ camera={{ position: [0, 2, 5], fov: 45, near: 0.1, far: 100 }}
19
+ dpr={[1, 2]}
20
+ gl={{ antialias: true, alpha: false, powerPreference: 'high-performance' }}
21
+ >
22
+ <Suspense fallback={null}>
23
+ <Scene />
24
+ </Suspense>
25
+ </Canvas>
26
+ </div>
27
+ )
28
+ }
29
+ ```
30
+
31
+ **Props breakdown:**
32
+ - `dpr={[1, 2]}` -- clamp device pixel ratio (retina without burning GPUs)
33
+ - `alpha: false` -- opaque background = faster compositing
34
+ - `powerPreference: 'high-performance'` -- request discrete GPU on laptops
35
+ - `frameloop="demand"` -- add for static scenes (render only on invalidate)
36
+
37
+ ---
38
+
39
+ ## Lighting Rigs
40
+
41
+ ### Studio (product shots, clean shadows)
42
+
43
+ ```tsx
44
+ function StudioLighting() {
45
+ return (
46
+ <>
47
+ <ambientLight intensity={0.4} />
48
+ <directionalLight
49
+ position={[5, 8, 3]}
50
+ intensity={1.2}
51
+ castShadow
52
+ shadow-mapSize-width={2048}
53
+ shadow-mapSize-height={2048}
54
+ shadow-camera-near={0.5}
55
+ shadow-camera-far={50}
56
+ shadow-camera-left={-10}
57
+ shadow-camera-right={10}
58
+ shadow-camera-top={10}
59
+ shadow-camera-bottom={-10}
60
+ />
61
+ <directionalLight position={[-3, 4, -5]} intensity={0.3} />
62
+ </>
63
+ )
64
+ }
65
+ ```
66
+
67
+ ### Studio with HDRI (easiest, best quality)
68
+
69
+ ```tsx
70
+ import { Environment } from '@react-three/drei'
71
+
72
+ function StudioHDRI() {
73
+ return (
74
+ <>
75
+ <Environment preset="studio" background={false} />
76
+ {/* Optional fill light to reduce contrast */}
77
+ <ambientLight intensity={0.2} />
78
+ </>
79
+ )
80
+ }
81
+ ```
82
+
83
+ **Environment presets:** `apartment`, `city`, `dawn`, `forest`, `lobby`, `night`, `park`, `studio`, `sunset`, `warehouse`
84
+
85
+ ### Outdoor (natural, directional sun)
86
+
87
+ ```tsx
88
+ function OutdoorLighting() {
89
+ return (
90
+ <>
91
+ <Environment preset="sunset" background />
92
+ <directionalLight
93
+ position={[10, 15, 5]}
94
+ intensity={2}
95
+ castShadow
96
+ shadow-mapSize={2048}
97
+ color="#ffeedd"
98
+ />
99
+ <hemisphereLight args={['#87CEEB', '#362907', 0.3]} />
100
+ </>
101
+ )
102
+ }
103
+ ```
104
+
105
+ ### Dramatic (high contrast, noir)
106
+
107
+ ```tsx
108
+ function DramaticLighting() {
109
+ return (
110
+ <>
111
+ <color attach="background" args={['#000000']} />
112
+ <fog attach="fog" args={['#000000', 5, 20]} />
113
+ <spotLight
114
+ position={[3, 8, 2]}
115
+ angle={0.3}
116
+ penumbra={0.8}
117
+ intensity={3}
118
+ castShadow
119
+ color="#ff6644"
120
+ />
121
+ <pointLight position={[-5, 2, -3]} intensity={0.5} color="#4466ff" />
122
+ {/* No ambient -- pure darkness outside lights */}
123
+ </>
124
+ )
125
+ }
126
+ ```
127
+
128
+ ---
129
+
130
+ ## Camera Configurations
131
+
132
+ ### Perspective (default, most scenes)
133
+
134
+ ```tsx
135
+ <Canvas camera={{ position: [0, 2, 5], fov: 45 }}>
136
+ ```
137
+
138
+ - **fov 35-45:** Natural, cinematic feel
139
+ - **fov 60-75:** Wider, more immersive
140
+ - **fov 20-30:** Telephoto, compressed depth
141
+
142
+ ### Orthographic (isometric, UI, 2D-in-3D)
143
+
144
+ ```tsx
145
+ <Canvas orthographic camera={{ position: [0, 5, 10], zoom: 50 }}>
146
+ ```
147
+
148
+ ### Animated Camera (smooth transitions)
149
+
150
+ ```tsx
151
+ import { useFrame, useThree } from '@react-three/fiber'
152
+ import { useMemo } from 'react'
153
+ import * as THREE from 'three'
154
+
155
+ function CameraRig({ target }: { target: [number, number, number] }) {
156
+ const _target = useMemo(() => new THREE.Vector3(), [])
157
+ const _position = useMemo(() => new THREE.Vector3(), [])
158
+
159
+ useFrame((state, delta) => {
160
+ // Smooth lerp to target
161
+ _target.set(...target)
162
+ state.camera.position.lerp(_position.set(target[0], target[1] + 2, target[2] + 5), delta * 2)
163
+ state.camera.lookAt(_target)
164
+ })
165
+
166
+ return null
167
+ }
168
+ ```
169
+
170
+ ---
171
+
172
+ ## Controls
173
+
174
+ ### OrbitControls (inspect / product viewer)
175
+
176
+ ```tsx
177
+ import { OrbitControls } from '@react-three/drei'
178
+
179
+ <OrbitControls
180
+ makeDefault
181
+ enableDamping
182
+ dampingFactor={0.05}
183
+ minDistance={2}
184
+ maxDistance={20}
185
+ minPolarAngle={0}
186
+ maxPolarAngle={Math.PI / 2} // prevent going below ground
187
+ autoRotate={false}
188
+ autoRotateSpeed={0.5}
189
+ />
190
+ ```
191
+
192
+ ### PresentationControls (drag-to-rotate, bounded)
193
+
194
+ ```tsx
195
+ import { PresentationControls } from '@react-three/drei'
196
+
197
+ <PresentationControls
198
+ global // listen on entire canvas
199
+ snap // snap back to rest
200
+ speed={1.5}
201
+ zoom={0.8}
202
+ rotation={[0, -Math.PI / 4, 0]} // initial angle
203
+ polar={[-Math.PI / 4, Math.PI / 4]}
204
+ azimuth={[-Math.PI / 4, Math.PI / 4]}
205
+ >
206
+ <Model />
207
+ </PresentationControls>
208
+ ```
209
+
210
+ ### MapControls (top-down, pan-based)
211
+
212
+ ```tsx
213
+ import { MapControls } from '@react-three/drei'
214
+
215
+ <MapControls
216
+ makeDefault
217
+ enableRotate={false}
218
+ minDistance={5}
219
+ maxDistance={50}
220
+ />
221
+ ```
222
+
223
+ ### Pointer-based camera (follow cursor)
224
+
225
+ ```tsx
226
+ function PointerCamera() {
227
+ useFrame((state) => {
228
+ const { x, y } = state.pointer // normalized -1 to 1
229
+ state.camera.position.x = THREE.MathUtils.lerp(state.camera.position.x, x * 2, 0.05)
230
+ state.camera.position.y = THREE.MathUtils.lerp(state.camera.position.y, y * 1.5 + 1, 0.05)
231
+ state.camera.lookAt(0, 0, 0)
232
+ })
233
+ return null
234
+ }
235
+ ```
236
+
237
+ ---
238
+
239
+ ## Loading Models
240
+
241
+ ### useGLTF (standard)
242
+
243
+ ```tsx
244
+ import { useGLTF } from '@react-three/drei'
245
+ import type { GLTF } from 'three-stdlib'
246
+
247
+ type ModelGLTF = GLTF & {
248
+ nodes: {
249
+ Body: THREE.Mesh
250
+ Eyes: THREE.Mesh
251
+ }
252
+ materials: {
253
+ skin: THREE.MeshStandardMaterial
254
+ eyes: THREE.MeshStandardMaterial
255
+ }
256
+ }
257
+
258
+ function Model(props: JSX.IntrinsicElements['group']) {
259
+ const { nodes, materials } = useGLTF('/model.glb') as ModelGLTF
260
+
261
+ return (
262
+ <group {...props} dispose={null}>
263
+ <mesh geometry={nodes.Body.geometry} material={materials.skin} />
264
+ <mesh geometry={nodes.Eyes.geometry} material={materials.eyes} />
265
+ </group>
266
+ )
267
+ }
268
+
269
+ useGLTF.preload('/model.glb')
270
+ ```
271
+
272
+ **Tip:** Use [gltf.pmnd.rs](https://gltf.pmnd.rs/) to auto-generate typed R3F components from .glb files.
273
+
274
+ ### useGLTF with Draco compression
275
+
276
+ ```tsx
277
+ import { useGLTF } from '@react-three/drei'
278
+
279
+ // Draco decoder loaded from CDN automatically
280
+ const { nodes } = useGLTF('/model-draco.glb', true) // second arg enables Draco
281
+
282
+ useGLTF.preload('/model-draco.glb', true)
283
+ ```
284
+
285
+ ### useTexture
286
+
287
+ ```tsx
288
+ import { useTexture } from '@react-three/drei'
289
+
290
+ function TexturedMesh() {
291
+ const [colorMap, normalMap, roughnessMap] = useTexture([
292
+ '/textures/color.jpg',
293
+ '/textures/normal.jpg',
294
+ '/textures/roughness.jpg',
295
+ ])
296
+
297
+ return (
298
+ <mesh>
299
+ <sphereGeometry args={[1, 64, 64]} />
300
+ <meshStandardMaterial
301
+ map={colorMap}
302
+ normalMap={normalMap}
303
+ roughnessMap={roughnessMap}
304
+ />
305
+ </mesh>
306
+ )
307
+ }
308
+
309
+ useTexture.preload(['/textures/color.jpg', '/textures/normal.jpg', '/textures/roughness.jpg'])
310
+ ```
311
+
312
+ ---
313
+
314
+ ## Responsive Canvas
315
+
316
+ ### Fill parent container
317
+
318
+ ```tsx
319
+ // Parent must have explicit dimensions
320
+ <div style={{ width: '100%', height: '100vh' }}>
321
+ <Canvas>
322
+ <Scene />
323
+ </Canvas>
324
+ </div>
325
+ ```
326
+
327
+ ### Respond to viewport size inside scene
328
+
329
+ ```tsx
330
+ function ResponsiveObject() {
331
+ const { viewport } = useThree()
332
+ // viewport.width/height = world units visible at z=0
333
+
334
+ return (
335
+ <mesh scale={viewport.width > 6 ? 1 : 0.6}>
336
+ <boxGeometry />
337
+ <meshStandardMaterial />
338
+ </mesh>
339
+ )
340
+ }
341
+ ```
342
+
343
+ ### Adaptive performance
344
+
345
+ ```tsx
346
+ import { PerformanceMonitor } from '@react-three/drei'
347
+
348
+ <Canvas>
349
+ <PerformanceMonitor
350
+ onIncline={() => setDpr(2)}
351
+ onDecline={() => setDpr(1)}
352
+ >
353
+ <Scene />
354
+ </PerformanceMonitor>
355
+ </Canvas>
356
+ ```
357
+
358
+ ---
359
+
360
+ ## Shadows Setup
361
+
362
+ ```tsx
363
+ <Canvas shadows>
364
+ <directionalLight castShadow shadow-mapSize={2048} />
365
+ <mesh castShadow>
366
+ <boxGeometry />
367
+ <meshStandardMaterial />
368
+ </mesh>
369
+ <mesh receiveShadow rotation-x={-Math.PI / 2} position-y={-1}>
370
+ <planeGeometry args={[20, 20]} />
371
+ <shadowMaterial opacity={0.3} />
372
+ </mesh>
373
+ </Canvas>
374
+ ```
375
+
376
+ - `shadows` on Canvas enables the shadow system
377
+ - `castShadow` on lights and meshes that cast
378
+ - `receiveShadow` on meshes that receive
379
+ - `<shadowMaterial>` for transparent ground shadows (product shots)
380
+ - `<ContactShadows>` from drei for soft baked-look shadows without shadow maps
381
+
382
+ ```tsx
383
+ import { ContactShadows } from '@react-three/drei'
384
+
385
+ <ContactShadows
386
+ position={[0, -1, 0]}
387
+ opacity={0.4}
388
+ scale={10}
389
+ blur={2}
390
+ far={4}
391
+ />
392
+ ```