@istmx/skills 1.2.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 (111) hide show
  1. package/README.md +38 -20
  2. package/bin/cli.js +50 -24
  3. package/istm-animate/SKILL.md +31 -26
  4. package/istm-animate/core/motion-principles/SKILL.md +284 -0
  5. package/istm-animate/core/motion-principles/references/designers.md +127 -0
  6. package/istm-animate/core/motion-principles/references/easing-guide.md +231 -0
  7. package/istm-animate/core/motion-principles/references/enter-exit-recipes.md +466 -0
  8. package/istm-animate/frameworks/canvas-generative/SKILL.md +325 -0
  9. package/istm-animate/frameworks/canvas-generative/references/algorithms.md +925 -0
  10. package/istm-animate/frameworks/css-native/SKILL.md +319 -0
  11. package/istm-animate/frameworks/css-native/references/modern-css.md +465 -0
  12. package/istm-animate/frameworks/framer-motion/SKILL.md +187 -0
  13. package/istm-animate/frameworks/framer-motion/references/api.md +312 -0
  14. package/istm-animate/frameworks/gsap/SKILL.md +188 -0
  15. package/istm-animate/frameworks/gsap/references/core.md +218 -0
  16. package/istm-animate/frameworks/gsap/references/plugins.md +371 -0
  17. package/istm-animate/frameworks/gsap/references/scrolltrigger.md +325 -0
  18. package/istm-animate/frameworks/gsap/references/timeline.md +218 -0
  19. package/istm-animate/frameworks/threejs-r3f/SKILL.md +243 -0
  20. package/istm-animate/frameworks/threejs-r3f/references/scene-setup.md +392 -0
  21. package/istm-animate/frameworks/threejs-r3f/references/shaders.md +446 -0
  22. package/istm-animate/mobile/android/compose-graphics/SKILL.md +503 -0
  23. package/istm-animate/mobile/android/compose-graphics/references/agsl-recipes.md +356 -0
  24. package/istm-animate/mobile/android/compose-graphics/references/canvas-generative.md +282 -0
  25. package/istm-animate/mobile/android/compose-graphics/references/m3-expressive-deep.md +303 -0
  26. package/istm-animate/mobile/android/compose-motion/SKILL.md +359 -0
  27. package/istm-animate/mobile/android/compose-motion/references/gestures-compose.md +273 -0
  28. package/istm-animate/mobile/android/compose-motion/references/recomposition-and-anim.md +196 -0
  29. package/istm-animate/mobile/android/compose-motion/references/shared-transitions.md +281 -0
  30. package/istm-animate/mobile/android/compose-multiplatform/SKILL.md +311 -0
  31. package/istm-animate/mobile/android/compose-multiplatform/references/cmp-interop.md +288 -0
  32. package/istm-animate/mobile/android/compose-multiplatform/references/cmp-platform-quirks.md +156 -0
  33. package/istm-animate/mobile/apple/swiftui-graphics/SKILL.md +408 -0
  34. package/istm-animate/mobile/apple/swiftui-graphics/references/canvas-swiftui.md +239 -0
  35. package/istm-animate/mobile/apple/swiftui-graphics/references/liquid-glass-deep.md +252 -0
  36. package/istm-animate/mobile/apple/swiftui-graphics/references/metal-recipes.md +382 -0
  37. package/istm-animate/mobile/apple/swiftui-motion/SKILL.md +379 -0
  38. package/istm-animate/mobile/apple/swiftui-motion/references/gestures-swiftui.md +336 -0
  39. package/istm-animate/mobile/apple/swiftui-motion/references/phase-keyframe-deep.md +231 -0
  40. package/istm-animate/mobile/apple/swiftui-motion/references/springs-cheatsheet.md +129 -0
  41. package/istm-animate/references/animate.md +199 -0
  42. package/istm-animate/references/audit.md +115 -0
  43. package/istm-animate/references/design-engineering.md +674 -0
  44. package/istm-animate/references/improve.md +101 -0
  45. package/istm-animate/references/opportunities.md +132 -0
  46. package/istm-animate/references/plan-template.md +73 -0
  47. package/istm-animate/references/recipes.md +324 -0
  48. package/istm-animate/references/review.md +112 -0
  49. package/istm-animate/references/standards.md +187 -0
  50. package/istm-animate/references/vocabulary.md +173 -0
  51. package/istm-awwward-designer/SKILL.md +29 -17
  52. package/istm-design/SKILL.md +31 -59
  53. package/istm-design/core/design-audit/SKILL.md +248 -0
  54. package/istm-design/core/desktop-principles/SKILL.md +363 -0
  55. package/istm-design/core/desktop-principles/references/keyboard-patterns.md +137 -0
  56. package/istm-design/core/desktop-principles/references/multi-window.md +105 -0
  57. package/istm-design/core/mobile-principles/SKILL.md +289 -0
  58. package/istm-design/core/mobile-principles/references/accessibility-mobile.md +175 -0
  59. package/istm-design/core/mobile-principles/references/gestures-deep.md +220 -0
  60. package/istm-design/core/ui-ux-pro-max/SKILL.md +392 -0
  61. package/istm-design/core/ui-ux-pro-max/UPSTREAM.md +23 -0
  62. package/istm-design/core/ui-ux-pro-max/data/app-interface.csv +31 -0
  63. package/istm-design/core/ui-ux-pro-max/data/charts.csv +26 -0
  64. package/istm-design/core/ui-ux-pro-max/data/colors.csv +193 -0
  65. package/istm-design/core/ui-ux-pro-max/data/google-fonts.csv +1924 -0
  66. package/istm-design/core/ui-ux-pro-max/data/icons.csv +106 -0
  67. package/istm-design/core/ui-ux-pro-max/data/landing.csv +35 -0
  68. package/istm-design/core/ui-ux-pro-max/data/motion.csv +17 -0
  69. package/istm-design/core/ui-ux-pro-max/data/products.csv +193 -0
  70. package/istm-design/core/ui-ux-pro-max/data/react-performance.csv +45 -0
  71. package/istm-design/core/ui-ux-pro-max/data/stacks/angular.csv +51 -0
  72. package/istm-design/core/ui-ux-pro-max/data/stacks/astro.csv +54 -0
  73. package/istm-design/core/ui-ux-pro-max/data/stacks/avalonia.csv +57 -0
  74. package/istm-design/core/ui-ux-pro-max/data/stacks/flutter.csv +53 -0
  75. package/istm-design/core/ui-ux-pro-max/data/stacks/html-tailwind.csv +56 -0
  76. package/istm-design/core/ui-ux-pro-max/data/stacks/javafx.csv +76 -0
  77. package/istm-design/core/ui-ux-pro-max/data/stacks/jetpack-compose.csv +53 -0
  78. package/istm-design/core/ui-ux-pro-max/data/stacks/laravel.csv +51 -0
  79. package/istm-design/core/ui-ux-pro-max/data/stacks/nextjs.csv +53 -0
  80. package/istm-design/core/ui-ux-pro-max/data/stacks/nuxt-ui.csv +71 -0
  81. package/istm-design/core/ui-ux-pro-max/data/stacks/nuxtjs.csv +59 -0
  82. package/istm-design/core/ui-ux-pro-max/data/stacks/react-native.csv +52 -0
  83. package/istm-design/core/ui-ux-pro-max/data/stacks/react.csv +54 -0
  84. package/istm-design/core/ui-ux-pro-max/data/stacks/shadcn.csv +61 -0
  85. package/istm-design/core/ui-ux-pro-max/data/stacks/svelte.csv +54 -0
  86. package/istm-design/core/ui-ux-pro-max/data/stacks/swiftui.csv +51 -0
  87. package/istm-design/core/ui-ux-pro-max/data/stacks/threejs.csv +54 -0
  88. package/istm-design/core/ui-ux-pro-max/data/stacks/uno.csv +60 -0
  89. package/istm-design/core/ui-ux-pro-max/data/stacks/uwp.csv +56 -0
  90. package/istm-design/core/ui-ux-pro-max/data/stacks/vue.csv +50 -0
  91. package/istm-design/core/ui-ux-pro-max/data/stacks/winui.csv +60 -0
  92. package/istm-design/core/ui-ux-pro-max/data/stacks/wpf.csv +57 -0
  93. package/istm-design/core/ui-ux-pro-max/data/styles.csv +85 -0
  94. package/istm-design/core/ui-ux-pro-max/data/typography.csv +75 -0
  95. package/istm-design/core/ui-ux-pro-max/data/ui-reasoning.csv +162 -0
  96. package/istm-design/core/ui-ux-pro-max/data/ux-guidelines.csv +100 -0
  97. package/istm-design/core/ui-ux-pro-max/references/pro-rules.md +109 -0
  98. package/istm-design/core/ui-ux-pro-max/references/quick-reference.md +240 -0
  99. package/istm-design/core/ui-ux-pro-max/scripts/core.py +464 -0
  100. package/istm-design/core/ui-ux-pro-max/scripts/design_system.py +1371 -0
  101. package/istm-design/core/ui-ux-pro-max/scripts/search.py +162 -0
  102. package/istm-design/core/ui-ux-pro-max/scripts/tests/test_core.py +134 -0
  103. package/istm-design/core/ui-ux-pro-max/scripts/validate_data.py +114 -0
  104. package/istm-design/references/apple-design.md +282 -0
  105. package/istm-design/references/generation-guide.md +209 -0
  106. package/istm-design/references/pick-ui-library.md +77 -0
  107. package/istm-design/references/picker.md +197 -0
  108. package/istm-design/references/prototype.md +90 -0
  109. package/istm-design/references/schema.md +366 -0
  110. package/package.json +1 -1
  111. package/RELEASE_v1.2.0.md +0 -40
@@ -0,0 +1,446 @@
1
+ # Shaders Reference
2
+
3
+ > Common GLSL patterns for Three.js / R3F.
4
+ > All snippets work with `shaderMaterial` or `ShaderMaterial`.
5
+
6
+ ---
7
+
8
+ ## ShaderMaterial in R3F
9
+
10
+ ### Basic pattern with uniforms
11
+
12
+ ```tsx
13
+ import { useRef, useMemo } from 'react'
14
+ import { useFrame } from '@react-three/fiber'
15
+ import * as THREE from 'three'
16
+
17
+ const vertexShader = /* glsl */ `
18
+ varying vec2 vUv;
19
+ void main() {
20
+ vUv = uv;
21
+ gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
22
+ }
23
+ `
24
+
25
+ const fragmentShader = /* glsl */ `
26
+ uniform float uTime;
27
+ uniform vec3 uColor;
28
+ varying vec2 vUv;
29
+
30
+ void main() {
31
+ gl_FragColor = vec4(uColor * vUv.x, 1.0);
32
+ }
33
+ `
34
+
35
+ function ShaderPlane() {
36
+ const materialRef = useRef<THREE.ShaderMaterial>(null!)
37
+
38
+ const uniforms = useMemo(() => ({
39
+ uTime: { value: 0 },
40
+ uColor: { value: new THREE.Color('#ff6600') },
41
+ }), [])
42
+
43
+ useFrame((state) => {
44
+ materialRef.current.uniforms.uTime.value = state.clock.elapsedTime
45
+ })
46
+
47
+ return (
48
+ <mesh>
49
+ <planeGeometry args={[2, 2, 32, 32]} />
50
+ <shaderMaterial
51
+ ref={materialRef}
52
+ vertexShader={vertexShader}
53
+ fragmentShader={fragmentShader}
54
+ uniforms={uniforms}
55
+ />
56
+ </mesh>
57
+ )
58
+ }
59
+ ```
60
+
61
+ **Rules:**
62
+ - Always `useMemo` uniforms -- prevents creating new objects every render
63
+ - Update uniforms in `useFrame` via ref, never through props
64
+ - Use `/* glsl */` template tag for syntax highlighting in editors
65
+
66
+ ### Drei's shaderMaterial helper
67
+
68
+ ```tsx
69
+ import { shaderMaterial } from '@react-three/drei'
70
+ import { extend } from '@react-three/fiber'
71
+
72
+ const WaveMaterial = shaderMaterial(
73
+ // Uniforms (defaults)
74
+ {
75
+ uTime: 0,
76
+ uColor: new THREE.Color('#ff6600'),
77
+ uAmplitude: 0.3,
78
+ },
79
+ // Vertex
80
+ /* glsl */ `
81
+ uniform float uTime;
82
+ uniform float uAmplitude;
83
+ varying vec2 vUv;
84
+ void main() {
85
+ vUv = uv;
86
+ vec3 pos = position;
87
+ pos.z += sin(pos.x * 4.0 + uTime) * uAmplitude;
88
+ gl_Position = projectionMatrix * modelViewMatrix * vec4(pos, 1.0);
89
+ }
90
+ `,
91
+ // Fragment
92
+ /* glsl */ `
93
+ uniform vec3 uColor;
94
+ varying vec2 vUv;
95
+ void main() {
96
+ gl_FragColor = vec4(uColor, 1.0);
97
+ }
98
+ `
99
+ )
100
+
101
+ extend({ WaveMaterial })
102
+
103
+ // Usage in JSX:
104
+ // <waveMaterial ref={ref} uTime={0} uColor="hotpink" />
105
+ ```
106
+
107
+ **Advantage:** Uniforms become JSX props with auto-generated setters.
108
+
109
+ ---
110
+
111
+ ## Noise Functions
112
+
113
+ ### Simplex 2D (most common, cheap)
114
+
115
+ ```glsl
116
+ // Credit: Ashima Arts (MIT license)
117
+ vec3 mod289(vec3 x) { return x - floor(x * (1.0 / 289.0)) * 289.0; }
118
+ vec2 mod289(vec2 x) { return x - floor(x * (1.0 / 289.0)) * 289.0; }
119
+ vec3 permute(vec3 x) { return mod289(((x * 34.0) + 1.0) * x); }
120
+
121
+ float snoise(vec2 v) {
122
+ const vec4 C = vec4(0.211324865405187, 0.366025403784439,
123
+ -0.577350269189626, 0.024390243902439);
124
+ vec2 i = floor(v + dot(v, C.yy));
125
+ vec2 x0 = v - i + dot(i, C.xx);
126
+ vec2 i1 = (x0.x > x0.y) ? vec2(1.0, 0.0) : vec2(0.0, 1.0);
127
+ vec4 x12 = x0.xyxy + C.xxzz;
128
+ x12.xy -= i1;
129
+ i = mod289(i);
130
+ vec3 p = permute(permute(i.y + vec3(0.0, i1.y, 1.0)) + i.x + vec3(0.0, i1.x, 1.0));
131
+ vec3 m = max(0.5 - vec3(dot(x0, x0), dot(x12.xy, x12.xy), dot(x12.zw, x12.zw)), 0.0);
132
+ m = m * m;
133
+ m = m * m;
134
+ vec3 x = 2.0 * fract(p * C.www) - 1.0;
135
+ vec3 h = abs(x) - 0.5;
136
+ vec3 ox = floor(x + 0.5);
137
+ vec3 a0 = x - ox;
138
+ m *= 1.79284291400159 - 0.85373472095314 * (a0 * a0 + h * h);
139
+ vec3 g;
140
+ g.x = a0.x * x0.x + h.x * x0.y;
141
+ g.yz = a0.yz * x12.xz + h.yz * x12.yw;
142
+ return 130.0 * dot(m, g);
143
+ }
144
+ ```
145
+
146
+ ### Perlin 3D (classic, smooth)
147
+
148
+ ```glsl
149
+ // Use for volumetric effects, 3D displacement
150
+ // Import from lygia or use npm: glsl-noise
151
+ // Signature:
152
+ float cnoise(vec3 P); // classic noise, range [-1, 1]
153
+ float pnoise(vec3 P, vec3 rep); // periodic variant
154
+ ```
155
+
156
+ ### FBM (Fractal Brownian Motion)
157
+
158
+ Layer noise at different scales for organic, cloud-like patterns.
159
+
160
+ ```glsl
161
+ float fbm(vec2 p) {
162
+ float value = 0.0;
163
+ float amplitude = 0.5;
164
+ float frequency = 1.0;
165
+ // 6 octaves -- reduce for performance
166
+ for (int i = 0; i < 6; i++) {
167
+ value += amplitude * snoise(p * frequency);
168
+ frequency *= 2.0;
169
+ amplitude *= 0.5;
170
+ }
171
+ return value;
172
+ }
173
+ ```
174
+
175
+ **Usage:** terrain, clouds, water surfaces, organic textures.
176
+
177
+ ---
178
+
179
+ ## Fresnel Effect
180
+
181
+ Makes edges glow brighter than the center -- used for glass, energy shields, holographic UI.
182
+
183
+ ```glsl
184
+ // In vertex shader:
185
+ varying vec3 vNormal;
186
+ varying vec3 vViewDir;
187
+
188
+ void main() {
189
+ vec4 worldPos = modelMatrix * vec4(position, 1.0);
190
+ vNormal = normalize(normalMatrix * normal);
191
+ vViewDir = normalize(cameraPosition - worldPos.xyz);
192
+ gl_Position = projectionMatrix * viewMatrix * worldPos;
193
+ }
194
+
195
+ // In fragment shader:
196
+ varying vec3 vNormal;
197
+ varying vec3 vViewDir;
198
+ uniform float uFresnelPower; // typically 2.0 - 5.0
199
+ uniform vec3 uFresnelColor;
200
+
201
+ void main() {
202
+ float fresnel = pow(1.0 - dot(vNormal, vViewDir), uFresnelPower);
203
+ vec3 color = mix(vec3(0.0), uFresnelColor, fresnel);
204
+ gl_FragColor = vec4(color, fresnel); // use fresnel as alpha for ghostly effect
205
+ }
206
+ ```
207
+
208
+ ---
209
+
210
+ ## Gradient Mapping
211
+
212
+ Remap brightness to a color ramp -- useful for toon shading, heat maps, stylized rendering.
213
+
214
+ ```glsl
215
+ uniform sampler2D uGradientMap; // 1D gradient texture (256x1 px)
216
+ uniform vec3 uLightDir;
217
+ varying vec3 vNormal;
218
+
219
+ void main() {
220
+ float NdotL = dot(normalize(vNormal), normalize(uLightDir));
221
+ float brightness = NdotL * 0.5 + 0.5; // remap [-1,1] to [0,1]
222
+ vec3 color = texture2D(uGradientMap, vec2(brightness, 0.5)).rgb;
223
+ gl_FragColor = vec4(color, 1.0);
224
+ }
225
+ ```
226
+
227
+ ### Without texture (code-defined ramp)
228
+
229
+ ```glsl
230
+ vec3 gradientMap(float t) {
231
+ vec3 a = vec3(0.05, 0.0, 0.15); // shadow color
232
+ vec3 b = vec3(0.9, 0.3, 0.1); // mid color
233
+ vec3 c = vec3(1.0, 0.9, 0.6); // highlight color
234
+ if (t < 0.5) return mix(a, b, t * 2.0);
235
+ return mix(b, c, (t - 0.5) * 2.0);
236
+ }
237
+ ```
238
+
239
+ ---
240
+
241
+ ## Displacement
242
+
243
+ Push vertices along their normal based on a pattern.
244
+
245
+ ### Noise-based displacement (vertex shader)
246
+
247
+ ```glsl
248
+ uniform float uTime;
249
+ uniform float uAmplitude; // 0.1 - 0.5 typical
250
+ varying vec2 vUv;
251
+ varying float vDisplacement;
252
+
253
+ void main() {
254
+ vUv = uv;
255
+ float noise = snoise(vec2(position.x * 2.0 + uTime * 0.5, position.y * 2.0));
256
+ vDisplacement = noise * uAmplitude;
257
+ vec3 newPos = position + normal * vDisplacement;
258
+ gl_Position = projectionMatrix * modelViewMatrix * vec4(newPos, 1.0);
259
+ }
260
+ ```
261
+
262
+ ### Texture-based displacement
263
+
264
+ ```glsl
265
+ uniform sampler2D uDisplacementMap;
266
+ uniform float uScale;
267
+
268
+ void main() {
269
+ vUv = uv;
270
+ float displacement = texture2D(uDisplacementMap, uv).r;
271
+ vec3 newPos = position + normal * displacement * uScale;
272
+ gl_Position = projectionMatrix * modelViewMatrix * vec4(newPos, 1.0);
273
+ }
274
+ ```
275
+
276
+ **Important:** Geometry needs enough subdivisions. `planeGeometry args={[2, 2, 128, 128]}` or `sphereGeometry args={[1, 128, 128]}`.
277
+
278
+ ---
279
+
280
+ ## UV Manipulation
281
+
282
+ ### Scrolling UVs (flowing water, conveyor belt)
283
+
284
+ ```glsl
285
+ uniform float uTime;
286
+ varying vec2 vUv;
287
+
288
+ void main() {
289
+ vec2 uv = vUv;
290
+ uv.y += uTime * 0.1; // scroll vertically
291
+ uv = fract(uv); // repeat seamlessly
292
+ // sample texture with scrolled UVs
293
+ gl_FragColor = texture2D(uMap, uv);
294
+ }
295
+ ```
296
+
297
+ ### Polar coordinates (radial effects)
298
+
299
+ ```glsl
300
+ vec2 toPolar(vec2 uv) {
301
+ vec2 centered = uv - 0.5;
302
+ float angle = atan(centered.y, centered.x); // [-PI, PI]
303
+ float radius = length(centered);
304
+ return vec2(angle / (2.0 * 3.14159) + 0.5, radius * 2.0);
305
+ }
306
+ ```
307
+
308
+ ### Distortion (heat haze, underwater)
309
+
310
+ ```glsl
311
+ uniform float uTime;
312
+ uniform float uStrength; // 0.01 - 0.05
313
+ varying vec2 vUv;
314
+
315
+ void main() {
316
+ vec2 uv = vUv;
317
+ uv.x += sin(uv.y * 20.0 + uTime * 2.0) * uStrength;
318
+ uv.y += cos(uv.x * 15.0 + uTime * 1.5) * uStrength;
319
+ gl_FragColor = texture2D(uMap, uv);
320
+ }
321
+ ```
322
+
323
+ ### Tiling with scale + offset
324
+
325
+ ```glsl
326
+ vec2 tiledUV(vec2 uv, float scale, vec2 offset) {
327
+ return fract(uv * scale + offset);
328
+ }
329
+ ```
330
+
331
+ ---
332
+
333
+ ## Common Utility Functions
334
+
335
+ ```glsl
336
+ // Remap value from one range to another
337
+ float remap(float value, float inMin, float inMax, float outMin, float outMax) {
338
+ return outMin + (outMax - outMin) * (value - inMin) / (inMax - inMin);
339
+ }
340
+
341
+ // Smooth minimum (blend between shapes)
342
+ float smin(float a, float b, float k) {
343
+ float h = clamp(0.5 + 0.5 * (b - a) / k, 0.0, 1.0);
344
+ return mix(b, a, h) - k * h * (1.0 - h);
345
+ }
346
+
347
+ // Rotate 2D
348
+ vec2 rotate2D(vec2 uv, float angle) {
349
+ float s = sin(angle);
350
+ float c = cos(angle);
351
+ return mat2(c, -s, s, c) * uv;
352
+ }
353
+
354
+ // Circle SDF
355
+ float sdCircle(vec2 p, float r) {
356
+ return length(p) - r;
357
+ }
358
+
359
+ // Box SDF
360
+ float sdBox(vec2 p, vec2 b) {
361
+ vec2 d = abs(p) - b;
362
+ return length(max(d, 0.0)) + min(max(d.x, d.y), 0.0);
363
+ }
364
+
365
+ // Smooth step alternative (cubic)
366
+ float gain(float x, float k) {
367
+ float a = 0.5 * pow(2.0 * ((x < 0.5) ? x : 1.0 - x), k);
368
+ return (x < 0.5) ? a : 1.0 - a;
369
+ }
370
+ ```
371
+
372
+ ---
373
+
374
+ ## Putting It Together: Animated Blob
375
+
376
+ Complete example combining noise displacement + fresnel + time.
377
+
378
+ ```tsx
379
+ const vertexShader = /* glsl */ `
380
+ uniform float uTime;
381
+ uniform float uAmplitude;
382
+ varying vec3 vNormal;
383
+ varying vec3 vViewDir;
384
+ varying float vDisplacement;
385
+
386
+ ${simplex2DNoise} // paste snoise function here
387
+
388
+ void main() {
389
+ vNormal = normalize(normalMatrix * normal);
390
+ float noise = snoise(vec2(
391
+ position.x * 1.5 + uTime * 0.4,
392
+ position.y * 1.5 + uTime * 0.3
393
+ ));
394
+ vDisplacement = noise * uAmplitude;
395
+ vec3 newPos = position + normal * vDisplacement;
396
+
397
+ vec4 worldPos = modelMatrix * vec4(newPos, 1.0);
398
+ vViewDir = normalize(cameraPosition - worldPos.xyz);
399
+ gl_Position = projectionMatrix * viewMatrix * worldPos;
400
+ }
401
+ `
402
+
403
+ const fragmentShader = /* glsl */ `
404
+ uniform vec3 uColorA;
405
+ uniform vec3 uColorB;
406
+ uniform float uFresnelPower;
407
+ varying vec3 vNormal;
408
+ varying vec3 vViewDir;
409
+ varying float vDisplacement;
410
+
411
+ void main() {
412
+ float fresnel = pow(1.0 - dot(vNormal, vViewDir), uFresnelPower);
413
+ vec3 color = mix(uColorA, uColorB, vDisplacement + 0.5);
414
+ color += fresnel * 0.5;
415
+ gl_FragColor = vec4(color, 1.0);
416
+ }
417
+ `
418
+
419
+ function Blob() {
420
+ const ref = useRef<THREE.ShaderMaterial>(null!)
421
+
422
+ const uniforms = useMemo(() => ({
423
+ uTime: { value: 0 },
424
+ uAmplitude: { value: 0.3 },
425
+ uColorA: { value: new THREE.Color('#1a0533') },
426
+ uColorB: { value: new THREE.Color('#ff6600') },
427
+ uFresnelPower: { value: 3.0 },
428
+ }), [])
429
+
430
+ useFrame((state) => {
431
+ ref.current.uniforms.uTime.value = state.clock.elapsedTime
432
+ })
433
+
434
+ return (
435
+ <mesh>
436
+ <icosahedronGeometry args={[1.5, 64]} />
437
+ <shaderMaterial
438
+ ref={ref}
439
+ vertexShader={vertexShader}
440
+ fragmentShader={fragmentShader}
441
+ uniforms={uniforms}
442
+ />
443
+ </mesh>
444
+ )
445
+ }
446
+ ```