1"use client"
2
3import { useCallback, useEffect, useRef, useState } from "react"
4import { atom, useAtom } from "jotai"
5import { motion } from "motion/react"
6import { useTheme } from "next-themes"
7import * as THREE from "three"
8
9const fragmentShader = `
10varying vec2 v_texcoord;
11
12uniform vec2 u_mouse;
13uniform vec2 u_resolution;
14uniform float u_pixelRatio;
15uniform float u_time;
16uniform vec3 u_color1;
17uniform vec3 u_color2;
18uniform vec3 u_color3;
19uniform vec3 u_color4;
20uniform float u_hoverStrength;
21uniform bool u_invertMouse;
22uniform bool u_isDarkMode;
23
24#define PI 3.1415926535897932384626433832795
25#define TWO_PI 6.2831853071795864769252867665590
26
27vec2 coord(in vec2 p) {
28 p = p / u_resolution.xy;
29 if (u_resolution.x > u_resolution.y) {
30 p.x *= u_resolution.x / u_resolution.y;
31 p.x += (u_resolution.y - u_resolution.x) / u_resolution.y / 2.0;
32 } else {
33 p.y *= u_resolution.y / u_resolution.x;
34 p.y += (u_resolution.x - u_resolution.y) / u_resolution.x / 2.0;
35 }
36 p -= 0.5;
37 p *= vec2(-1.0, 1.0);
38 return p;
39}
40
41#define st0 coord(gl_FragCoord.xy)
42#define mx coord(u_mouse * u_pixelRatio)
43
44float sdRoundRect(vec2 p, vec2 b, float r) {
45 vec2 d = abs(p - 0.5) * 4.2 - b + vec2(r);
46 return min(max(d.x, d.y), 0.0) + length(max(d, 0.0)) - r;
47}
48
49float sdCircle(in vec2 st, in vec2 center) {
50 return length(st - center) * 2.0;
51}
52
53float sdPoly(in vec2 p, in float w, in int sides) {
54 float a = atan(p.x, p.y) + PI;
55 float r = TWO_PI / float(sides);
56 float d = cos(floor(0.5 + a / r) * r - a) * length(max(abs(p) * 1.0, 0.0));
57 return d * 2.0 - w;
58}
59
60float aastep(float threshold, float value) {
61 float afwidth = length(vec2(dFdx(value), dFdy(value))) * 0.70710678118654757;
62 return smoothstep(threshold - afwidth, threshold + afwidth, value);
63}
64
65float fill(float x, float size, float edge) {
66 return 1.0 - smoothstep(size - edge, size + edge, x);
67}
68
69float stroke(float x, float size, float w, float edge) {
70 float d = smoothstep(size - edge, size + edge, x + w * 0.5) - smoothstep(size - edge, size + edge, x - w * 0.5);
71 return clamp(d, 0.0, 1.0);
72}
73
74void main() {
75 vec2 st = st0 + 0.5;
76 vec2 posMouse = mx + 0.5;
77
78 float size = 1.2 + sin(u_time) * 0.1;
79 float roundness = 0.4 + sin(u_time * 0.5) * 0.1;
80 float borderSize = 0.05 + sin(u_time * 0.7) * 0.02;
81 float circleSize = 0.3 + sin(u_time * 0.8) * 0.05;
82 float circleEdge = 0.5 + sin(u_time * 0.6) * 0.1;
83
84 float sdfCircle = fill(
85 sdCircle(st, posMouse),
86 circleSize,
87 circleEdge
88 );
89
90 float sdf;
91 if (VAR == 0) {
92 sdf = sdRoundRect(st, vec2(size), roundness);
93 sdf = stroke(sdf, 0.0, borderSize, sdfCircle) * 4.0;
94 } else if (VAR == 1) {
95 sdf = sdCircle(st, vec2(0.5));
96 sdf = fill(sdf, 0.6, sdfCircle) * 1.2;
97 } else if (VAR == 2) {
98 sdf = sdCircle(st, vec2(0.5));
99 sdf = stroke(sdf, 0.58, 0.02, sdfCircle) * 4.0;
100 } else if (VAR == 3) {
101 sdf = sdPoly(st - vec2(0.5, 0.45), 0.3, 3);
102 sdf = fill(sdf, 0.05, sdfCircle) * 1.4;
103 }
104
105 vec3 gradient = mix(
106 mix(u_color1, u_color2, 0.5 + 0.5 * cos(u_time + st.x + 0.0)),
107 mix(u_color3, u_color4, 0.5 + 0.5 * cos(u_time + st.y + 2.0)),
108 0.5 + 0.5 * cos(u_time + st.x + st.y + 4.0)
109 );
110
111 vec3 shapeColor = sdf * gradient;
112
113 float mouseEffect = u_invertMouse ? 1.0 - sdfCircle : sdfCircle;
114 shapeColor = mix(shapeColor, vec3(1.0) - shapeColor, u_hoverStrength * mouseEffect);
115
116 if (u_isDarkMode) {
117 shapeColor = mix(shapeColor, vec3(1.0), 0.2);
118 } else {
119 shapeColor = mix(shapeColor, vec3(0.0), 0.1);
120 }
121
122 gl_FragColor = vec4(shapeColor, sdf);
123}
124`
125
126interface ShaderConfig {
127 variation: number
128 color1: string
129 color2: string
130 color3: string
131 color4: string
132 enableHover: boolean
133 invertMouse: boolean
134 width: string
135 height: string
136}
137
138const initialState: ShaderConfig = {
139 variation: 3,
140 color1: "#D5F981",
141 color2: "#A1BBE7",
142 color3: "#F2BAE2",
143 color4: "#68E8FA",
144 enableHover: true,
145 invertMouse: true,
146 width: "100%",
147 height: "400px",
148}
149
150export const configAtom = atom<ShaderConfig>(initialState)
151
152export function ShaderLensBlur() {
153 const [config] = useAtom(configAtom)
154 const containerRef = useRef<HTMLDivElement>(null)
155 const canvasRef = useRef<HTMLCanvasElement>(null)
156 const rendererRef = useRef<THREE.WebGLRenderer | null>(null)
157 const sceneRef = useRef<THREE.Scene | null>(null)
158 const cameraRef = useRef<THREE.OrthographicCamera | null>(null)
159 const materialRef = useRef<THREE.ShaderMaterial | null>(null)
160 const rafRef = useRef<number | null>(null)
161 const pixelRatioRef = useRef(1)
162 const [isInteracting, setIsInteracting] = useState(false)
163 const { theme } = useTheme()
164
165 const updateSize = useCallback(() => {
166 if (
167 !containerRef.current ||
168 !canvasRef.current ||
169 !rendererRef.current ||
170 !cameraRef.current ||
171 !materialRef.current
172 )
173 return
174
175 const { clientWidth: w, clientHeight: h } = containerRef.current
176 const aspect = w / h
177
178 cameraRef.current.left = -aspect
179 cameraRef.current.right = aspect
180 cameraRef.current.top = 1
181 cameraRef.current.bottom = -1
182 cameraRef.current.updateProjectionMatrix()
183
184 const pixelRatio = Math.min(window.devicePixelRatio || 1, 2)
185 pixelRatioRef.current = pixelRatio
186
187 rendererRef.current.setPixelRatio(pixelRatio)
188 rendererRef.current.setSize(w, h)
189
190 const drawingBufferSize = rendererRef.current.getDrawingBufferSize(
191 new THREE.Vector2()
192 )
193 materialRef.current.uniforms.u_resolution.value.copy(drawingBufferSize)
194 materialRef.current.uniforms.u_pixelRatio.value = pixelRatio
195 }, [])
196
197 const updateMousePosition = useCallback(
198 (x: number, y: number) => {
199 if (!containerRef.current || !materialRef.current) return
200 const rect = containerRef.current.getBoundingClientRect()
201 const mouseX = x - rect.left
202 const mouseY = y - rect.top
203 if (isInteracting || config.enableHover) {
204 materialRef.current.uniforms.u_mouse.value.set(
205 mouseX,
206 rect.height - mouseY
207 )
208 }
209 },
210 [isInteracting, config.enableHover]
211 )
212
213 const animate = useCallback(
214 (time: number) => {
215 if (
216 !rendererRef.current ||
217 !sceneRef.current ||
218 !cameraRef.current ||
219 !materialRef.current
220 )
221 return
222
223 const pixelRatio = Math.min(window.devicePixelRatio || 1, 2)
224 if (pixelRatio !== pixelRatioRef.current) {
225 updateSize()
226 }
227
228 materialRef.current.uniforms.u_time.value = time * 0.001
229 materialRef.current.uniforms.u_hoverStrength.value =
230 isInteracting || config.enableHover ? 0.3 : 0
231
232 rendererRef.current.render(sceneRef.current, cameraRef.current)
233 rafRef.current = requestAnimationFrame(animate)
234 },
235 [config.enableHover, isInteracting, updateSize]
236 )
237
238 useEffect(() => {
239 if (!containerRef.current || !canvasRef.current) return
240
241 const scene = new THREE.Scene()
242 sceneRef.current = scene
243
244 const camera = new THREE.OrthographicCamera(-1, 1, 1, -1, 0.1, 1000)
245 camera.position.z = 1
246 cameraRef.current = camera
247
248 const renderer = new THREE.WebGLRenderer({
249 canvas: canvasRef.current,
250 antialias: true,
251 alpha: true,
252 })
253 renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2))
254 renderer.setClearColor(0x000000, 0)
255 rendererRef.current = renderer
256
257 const geometry = new THREE.PlaneGeometry(2, 2)
258 const material = new THREE.ShaderMaterial({
259 vertexShader: `
260 varying vec2 v_texcoord;
261 void main() {
262 gl_Position = vec4(position, 1.0);
263 v_texcoord = uv;
264 }
265 `,
266 fragmentShader,
267 uniforms: {
268 u_mouse: { value: new THREE.Vector2() },
269 u_resolution: { value: new THREE.Vector2() },
270 u_pixelRatio: { value: Math.min(window.devicePixelRatio, 2) },
271 u_time: { value: 0 },
272 u_color1: { value: new THREE.Color(config.color1) },
273 u_color2: { value: new THREE.Color(config.color2) },
274 u_color3: { value: new THREE.Color(config.color3) },
275 u_color4: { value: new THREE.Color(config.color4) },
276 u_hoverStrength: { value: 0 },
277 u_invertMouse: { value: config.invertMouse },
278 u_isDarkMode: { value: theme === "dark" },
279 },
280 defines: {
281 VAR: config.variation,
282 },
283 transparent: true,
284 blending: THREE.NormalBlending,
285 })
286 materialRef.current = material
287
288 const mesh = new THREE.Mesh(geometry, material)
289 scene.add(mesh)
290
291 updateSize()
292 rafRef.current = requestAnimationFrame(animate)
293
294 const resizeObserver = new ResizeObserver(updateSize)
295 resizeObserver.observe(containerRef.current)
296
297 return () => {
298 if (rafRef.current) cancelAnimationFrame(rafRef.current)
299 if (rendererRef.current) rendererRef.current.dispose()
300 if (containerRef.current) resizeObserver.unobserve(containerRef.current)
301 }
302 }, [config, updateSize, animate, theme])
303
304 useEffect(() => {
305 const container = containerRef.current
306 if (!container) return
307
308 const handlePointerMove = (event: PointerEvent) =>
309 updateMousePosition(event.clientX, event.clientY)
310 const handleTouchMove = (event: TouchEvent) => {
311 if (event.touches.length > 0) {
312 const touch = event.touches[0]
313 updateMousePosition(touch.clientX, touch.clientY)
314 }
315 }
316 const handlePointerDown = () => setIsInteracting(true)
317 const handlePointerUp = () => setIsInteracting(false)
318 const handleTouchStart = () => setIsInteracting(true)
319 const handleTouchEnd = () => setIsInteracting(false)
320
321 container.addEventListener("pointermove", handlePointerMove)
322 container.addEventListener("touchmove", handleTouchMove)
323 container.addEventListener("pointerdown", handlePointerDown)
324 container.addEventListener("pointerup", handlePointerUp)
325 container.addEventListener("touchstart", handleTouchStart)
326 container.addEventListener("touchend", handleTouchEnd)
327
328 return () => {
329 container.removeEventListener("pointermove", handlePointerMove)
330 container.removeEventListener("touchmove", handleTouchMove)
331 container.removeEventListener("pointerdown", handlePointerDown)
332 container.removeEventListener("pointerup", handlePointerUp)
333 container.removeEventListener("touchstart", handleTouchStart)
334 container.removeEventListener("touchend", handleTouchEnd)
335 }
336 }, [updateMousePosition])
337
338 useEffect(() => {
339 if (materialRef.current) {
340 materialRef.current.uniforms.u_color1.value.set(config.color1)
341 materialRef.current.uniforms.u_color2.value.set(config.color2)
342 materialRef.current.uniforms.u_color3.value.set(config.color3)
343 materialRef.current.uniforms.u_color4.value.set(config.color4)
344 materialRef.current.uniforms.u_invertMouse.value = config.invertMouse
345 materialRef.current.uniforms.u_isDarkMode.value = theme === "dark"
346 materialRef.current.defines.VAR = config.variation
347 materialRef.current.needsUpdate = true
348 }
349 }, [config, theme])
350
351 return (
352 <motion.div
353 ref={containerRef}
354 initial={{ opacity: 0 }}
355 animate={{ opacity: 1 }}
356 transition={{ duration: 0.5 }}
357 className="relative"
358 style={{
359 width: config.width,
360 height: config.height,
361 backgroundColor: "black",
362 borderRadius: "8px",
363 }}
364 >
365 <canvas ref={canvasRef} className="w-full h-full touch-none" />
366 <div
367 className={`absolute bottom-4 left-4 text-sm ${
368 theme === "dark" ? "text-neutral-300" : "text-neutral-200"
369 }`}
370 >
371 {config.enableHover
372 ? `${
373 config.invertMouse ? "Inverted mouse" : "Normal mouse"
374 } interaction`
375 : "Interact with the animation"}{" "}
376 using mouse or touch
377 </div>
378 </motion.div>
379 )
380}
381
382export default ShaderLensBlur
383// "use client"
384
385// // npm install jotai three
386// import React, { useCallback, useEffect, useRef, useState } from "react"
387// import { motion } from "motion/react"
388// import { atom, useAtom } from "jotai"
389// import * as THREE from "three"
390
391// const fragmentShader = `
392// varying vec2 v_texcoord;
393
394// uniform vec2 u_mouse;
395// uniform vec2 u_resolution;
396// uniform float u_pixelRatio;
397// uniform float u_time;
398// uniform vec3 u_color1;
399// uniform vec3 u_color2;
400// uniform vec3 u_color3;
401// uniform vec3 u_color4;
402// uniform float u_hoverStrength;
403// uniform bool u_invertMouse;
404
405// #define PI 3.1415926535897932384626433832795
406// #define TWO_PI 6.2831853071795864769252867665590
407
408// vec2 coord(in vec2 p) {
409// p = p / u_resolution.xy;
410// if (u_resolution.x > u_resolution.y) {
411// p.x *= u_resolution.x / u_resolution.y;
412// p.x += (u_resolution.y - u_resolution.x) / u_resolution.y / 2.0;
413// } else {
414// p.y *= u_resolution.y / u_resolution.x;
415// p.y += (u_resolution.x - u_resolution.y) / u_resolution.x / 2.0;
416// }
417// p -= 0.5;
418// p *= vec2(-1.0, 1.0);
419// return p;
420// }
421
422// #define st0 coord(gl_FragCoord.xy)
423// #define mx coord(u_mouse)
424
425// float sdRoundRect(vec2 p, vec2 b, float r) {
426// vec2 d = abs(p - 0.5) * 4.2 - b + vec2(r);
427// return min(max(d.x, d.y), 0.0) + length(max(d, 0.0)) - r;
428// }
429
430// float sdCircle(in vec2 st, in vec2 center) {
431// return length(st - center) * 2.0;
432// }
433
434// float sdPoly(in vec2 p, in float w, in int sides) {
435// float a = atan(p.x, p.y) + PI;
436// float r = TWO_PI / float(sides);
437// float d = cos(floor(0.5 + a / r) * r - a) * length(max(abs(p) * 1.0, 0.0));
438// return d * 2.0 - w;
439// }
440
441// float aastep(float threshold, float value) {
442// float afwidth = length(vec2(dFdx(value), dFdy(value))) * 0.70710678118654757;
443// return smoothstep(threshold - afwidth, threshold + afwidth, value);
444// }
445
446// float fill(float x, float size, float edge) {
447// return 1.0 - smoothstep(size - edge, size + edge, x);
448// }
449
450// float stroke(float x, float size, float w, float edge) {
451// float d = smoothstep(size - edge, size + edge, x + w * 0.5) - smoothstep(size - edge, size + edge, x - w * 0.5);
452// return clamp(d, 0.0, 1.0);
453// }
454
455// void main() {
456// vec2 st = st0 + 0.5;
457// vec2 posMouse = mx + 0.5;
458
459// float size = 1.2 + sin(u_time) * 0.1;
460// float roundness = 0.4 + sin(u_time * 0.5) * 0.1;
461// float borderSize = 0.05 + sin(u_time * 0.7) * 0.02;
462// float circleSize = 0.3 + sin(u_time * 0.8) * 0.05;
463// float circleEdge = 0.5 + sin(u_time * 0.6) * 0.1;
464
465// float sdfCircle = fill(
466// sdCircle(st, posMouse),
467// circleSize,
468// circleEdge
469// );
470
471// float sdf;
472// if (VAR == 0) {
473// sdf = sdRoundRect(st, vec2(size), roundness);
474// sdf = stroke(sdf, 0.0, borderSize, sdfCircle) * 4.0;
475// } else if (VAR == 1) {
476// sdf = sdCircle(st, vec2(0.5));
477// sdf = fill(sdf, 0.6, sdfCircle) * 1.2;
478// } else if (VAR == 2) {
479// sdf = sdCircle(st, vec2(0.5));
480// sdf = stroke(sdf, 0.58, 0.02, sdfCircle) * 4.0;
481// } else if (VAR == 3) {
482// sdf = sdPoly(st - vec2(0.5, 0.45), 0.3, 3);
483// sdf = fill(sdf, 0.05, sdfCircle) * 1.4;
484// }
485
486// vec3 gradient = mix(
487// mix(u_color1, u_color2, 0.5 + 0.5 * cos(u_time + st.x + 0.0)),
488// mix(u_color3, u_color4, 0.5 + 0.5 * cos(u_time + st.y + 2.0)),
489// 0.5 + 0.5 * cos(u_time + st.x + st.y + 4.0)
490// );
491
492// vec3 shapeColor = sdf * gradient;
493
494// float mouseEffect = u_invertMouse ? 1.0 - sdfCircle : sdfCircle;
495// shapeColor = mix(shapeColor, vec3(1.0) - shapeColor, u_hoverStrength * mouseEffect);
496
497// gl_FragColor = vec4(shapeColor, sdf);
498// }
499// `
500
501// interface ShaderConfig {
502// variation: number
503// color1: string
504// color2: string
505// color3: string
506// color4: string
507// enableHover: boolean
508// invertMouse: boolean
509// width: string
510// height: string
511// }
512
513// const initialState: ShaderConfig = {
514// variation: 0,
515// color1: "#ff0000",
516// color2: "#00ff00",
517// color3: "#0000ff",
518// color4: "#ffff00",
519// enableHover: true,
520// invertMouse: true,
521// width: "100%",
522// height: "400px",
523// }
524
525// export const configAtom = atom<ShaderConfig>(initialState)
526
527// export function ShaderLensBlur() {
528// const [config] = useAtom(configAtom)
529// const containerRef = useRef<HTMLDivElement>(null)
530// const canvasRef = useRef<HTMLCanvasElement>(null)
531// const rendererRef = useRef<THREE.WebGLRenderer | null>(null)
532// const sceneRef = useRef<THREE.Scene | null>(null)
533// const cameraRef = useRef<THREE.OrthographicCamera | null>(null)
534// const materialRef = useRef<THREE.ShaderMaterial | null>(null)
535// const rafRef = useRef<number | null>(null)
536// const [isInteracting, setIsInteracting] = useState(false)
537
538// const updateSize = useCallback(() => {
539// if (
540// !containerRef.current ||
541// !canvasRef.current ||
542// !rendererRef.current ||
543// !cameraRef.current ||
544// !materialRef.current
545// )
546// return
547
548// const { clientWidth: w, clientHeight: h } = containerRef.current
549// const aspect = w / h
550
551// cameraRef.current.left = -aspect
552// cameraRef.current.right = aspect
553// cameraRef.current.top = 1
554// cameraRef.current.bottom = -1
555// cameraRef.current.updateProjectionMatrix()
556
557// rendererRef.current.setSize(w, h)
558// materialRef.current.uniforms.u_resolution.value.set(w, h)
559// }, [])
560
561// const updateMousePosition = useCallback(
562// (x: number, y: number) => {
563// if (!containerRef.current || !materialRef.current) return
564// const rect = containerRef.current.getBoundingClientRect()
565// const mouseX = x - rect.left
566// const mouseY = y - rect.top
567// if (isInteracting || config.enableHover) {
568// materialRef.current.uniforms.u_mouse.value.set(
569// mouseX,
570// rect.height - mouseY
571// )
572// }
573// },
574// [isInteracting, config.enableHover]
575// )
576
577// const animate = useCallback(
578// (time: number) => {
579// if (
580// !rendererRef.current ||
581// !sceneRef.current ||
582// !cameraRef.current ||
583// !materialRef.current
584// )
585// return
586
587// materialRef.current.uniforms.u_time.value = time * 0.001
588// materialRef.current.uniforms.u_hoverStrength.value =
589// isInteracting || config.enableHover ? 0.3 : 0
590
591// rendererRef.current.render(sceneRef.current, cameraRef.current)
592// rafRef.current = requestAnimationFrame(animate)
593// },
594// [config.enableHover, isInteracting]
595// )
596
597// useEffect(() => {
598// if (!containerRef.current || !canvasRef.current) return
599
600// const scene = new THREE.Scene()
601// sceneRef.current = scene
602
603// const camera = new THREE.OrthographicCamera(-1, 1, 1, -1, 0.1, 1000)
604// camera.position.z = 1
605// cameraRef.current = camera
606
607// const renderer = new THREE.WebGLRenderer({
608// canvas: canvasRef.current,
609// antialias: true,
610// alpha: true,
611// })
612// renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2))
613// renderer.setClearColor(0x000000, 0)
614// rendererRef.current = renderer
615
616// const geometry = new THREE.PlaneGeometry(2, 2)
617// const material = new THREE.ShaderMaterial({
618// vertexShader: `
619// varying vec2 v_texcoord;
620// void main() {
621// gl_Position = vec4(position, 1.0);
622// v_texcoord = uv;
623// }
624// `,
625// fragmentShader,
626// uniforms: {
627// u_mouse: { value: new THREE.Vector2() },
628// u_resolution: { value: new THREE.Vector2() },
629// u_pixelRatio: { value: Math.min(window.devicePixelRatio, 2) },
630// u_time: { value: 0 },
631// u_color1: { value: new THREE.Color(config.color1) },
632// u_color2: { value: new THREE.Color(config.color2) },
633// u_color3: { value: new THREE.Color(config.color3) },
634// u_color4: { value: new THREE.Color(config.color4) },
635// u_hoverStrength: { value: 0 },
636// u_invertMouse: { value: config.invertMouse },
637// },
638// defines: {
639// VAR: config.variation,
640// },
641// transparent: true,
642// blending: THREE.NormalBlending,
643// })
644// materialRef.current = material
645
646// const mesh = new THREE.Mesh(geometry, material)
647// scene.add(mesh)
648
649// updateSize()
650// rafRef.current = requestAnimationFrame(animate)
651
652// const resizeObserver = new ResizeObserver(updateSize)
653// resizeObserver.observe(containerRef.current)
654
655// return () => {
656// if (rafRef.current) cancelAnimationFrame(rafRef.current)
657// if (rendererRef.current) rendererRef.current.dispose()
658// if (containerRef.current) resizeObserver.unobserve(containerRef.current)
659// }
660// }, [config, updateSize, animate])
661
662// useEffect(() => {
663// const container = containerRef.current
664// if (!container) return
665
666// const handlePointerMove = (event: PointerEvent) =>
667// updateMousePosition(event.clientX, event.clientY)
668// const handleTouchMove = (event: TouchEvent) => {
669// if (event.touches.length > 0) {
670// const touch = event.touches[0]
671// updateMousePosition(touch.clientX, touch.clientY)
672// }
673// }
674
675// container.addEventListener("pointermove", handlePointerMove)
676// container.addEventListener("touchmove", handleTouchMove)
677// container.addEventListener("pointerdown", () => setIsInteracting(true))
678// container.addEventListener("pointerup", () => setIsInteracting(false))
679// container.addEventListener("touchstart", () => setIsInteracting(true))
680// container.addEventListener("touchend", () => setIsInteracting(false))
681
682// return () => {
683// container.removeEventListener("pointermove", handlePointerMove)
684// container.removeEventListener("touchmove", handleTouchMove)
685// container.removeEventListener("pointerdown", () => setIsInteracting(true))
686// container.removeEventListener("pointerup", () => setIsInteracting(false))
687// container.removeEventListener("touchstart", () => setIsInteracting(true))
688// container.removeEventListener("touchend", () => setIsInteracting(false))
689// }
690// }, [updateMousePosition])
691
692// useEffect(() => {
693// if (materialRef.current) {
694// materialRef.current.uniforms.u_color1.value.set(config.color1)
695// materialRef.current.uniforms.u_color2.value.set(config.color2)
696// materialRef.current.uniforms.u_color3.value.set(config.color3)
697// materialRef.current.uniforms.u_color4.value.set(config.color4)
698// materialRef.current.uniforms.u_invertMouse.value = config.invertMouse
699// materialRef.current.defines.VAR = config.variation
700// materialRef.current.needsUpdate = true
701// }
702// }, [config])
703
704// return (
705// <motion.div
706// ref={containerRef}
707// initial={{ opacity: 0 }}
708// animate={{ opacity: 1 }}
709// transition={{ duration: 0.5 }}
710// className="relative"
711// style={{
712// width: config.width,
713// height: config.height,
714// backgroundColor: "transparent",
715// borderRadius: "8px",
716// }}
717// >
718// <canvas ref={canvasRef} className="w-full h-full touch-none" />
719// <div className="absolute bottom-4 left-4 text-white text-sm">
720// {config.enableHover
721// ? `${
722// config.invertMouse ? "Inverted mouse" : "Normal mouse"
723// } interaction`
724// : "Interact with the animation"}{" "}
725// using mouse or touch
726// </div>
727// </motion.div>
728// )
729// }
730
731// export default ShaderLensBlur
732