1- /* eslint-disable @typescript-eslint/no-explicit-any */
21"use client"
3- import React , { useEffect , useRef } from "react"
2+ import { useEffect , useRef } from "react"
43
54interface ColorRGB {
65 r : number
@@ -53,30 +52,31 @@ function pointerPrototype(): Pointer {
5352 }
5453}
5554
56- export function SplashCursor ( {
55+ export default function SplashCursor ( {
5756 SIM_RESOLUTION = 128 ,
58- DYE_RESOLUTION = 256 ,
57+ DYE_RESOLUTION = 1440 ,
5958 CAPTURE_RESOLUTION = 512 ,
60- DENSITY_DISSIPATION = 3 ,
61- VELOCITY_DISSIPATION = 1.5 ,
59+ DENSITY_DISSIPATION = 3.5 ,
60+ VELOCITY_DISSIPATION = 2 ,
6261 PRESSURE = 0.1 ,
6362 PRESSURE_ITERATIONS = 20 ,
6463 CURL = 3 ,
65- SPLAT_RADIUS = 0.1 ,
64+ SPLAT_RADIUS = 0.2 ,
6665 SPLAT_FORCE = 6000 ,
67- SHADING = false ,
68- COLOR_UPDATE_SPEED = 5 ,
69- BACK_COLOR = { r : 0 , g : 0 , b : 0 } ,
66+ SHADING = true ,
67+ COLOR_UPDATE_SPEED = 10 ,
68+ BACK_COLOR = { r : 0.5 , g : 0 , b : 0 } ,
7069 TRANSPARENT = true ,
7170} : SplashCursorProps ) {
7271 const canvasRef = useRef < HTMLCanvasElement > ( null )
7372
7473 useEffect ( ( ) => {
7574 const canvas = canvasRef . current
7675 if ( ! canvas ) return
77- const pointers : Pointer [ ] = [ pointerPrototype ( ) ]
7876
79- const config = {
77+ let pointers : Pointer [ ] = [ pointerPrototype ( ) ]
78+
79+ let config = {
8080 SIM_RESOLUTION : SIM_RESOLUTION ! ,
8181 DYE_RESOLUTION : DYE_RESOLUTION ! ,
8282 CAPTURE_RESOLUTION : CAPTURE_RESOLUTION ! ,
@@ -233,7 +233,7 @@ export function SplashCursor({
233233 gl . shaderSource ( shader , shaderSource )
234234 gl . compileShader ( shader )
235235 if ( ! gl . getShaderParameter ( shader , gl . COMPILE_STATUS ) ) {
236- // console.trace(gl.getShaderInfoLog(shader))
236+ console . trace ( gl . getShaderInfoLog ( shader ) )
237237 }
238238 return shader
239239 }
@@ -246,13 +246,13 @@ export function SplashCursor({
246246 gl . attachShader ( program , fragmentShader )
247247 gl . linkProgram ( program )
248248 if ( ! gl . getProgramParameter ( program , gl . LINK_STATUS ) ) {
249- // console.trace(gl.getProgramInfoLog(program))
249+ console . trace ( gl . getProgramInfoLog ( program ) )
250250 }
251251 return program
252252 }
253253
254254 function getUniforms ( program : WebGLProgram ) {
255- const uniforms : Record < string , WebGLUniformLocation | null > = { }
255+ let uniforms : Record < string , WebGLUniformLocation | null > = { }
256256 const uniformCount = gl . getProgramParameter ( program , gl . ACTIVE_UNIFORMS )
257257 for ( let i = 0 ; i < uniformCount ; i ++ ) {
258258 const uniformInfo = gl . getActiveUniform ( program , i )
@@ -784,7 +784,7 @@ export function SplashCursor({
784784 const w = gl . drawingBufferWidth
785785 const h = gl . drawingBufferHeight
786786 const aspectRatio = w / h
787- const aspect = aspectRatio < 1 ? 1 / aspectRatio : aspectRatio
787+ let aspect = aspectRatio < 1 ? 1 / aspectRatio : aspectRatio
788788 const min = Math . round ( resolution )
789789 const max = Math . round ( resolution * aspect )
790790 if ( w > h ) {
@@ -1139,24 +1139,24 @@ export function SplashCursor({
11391139 return ( ( value - min ) % range ) + min
11401140 }
11411141
1142- window . addEventListener ( "pointerdown " , ( e ) => {
1142+ window . addEventListener ( "mousedown " , ( e ) => {
11431143 const pointer = pointers [ 0 ]
11441144 const posX = scaleByPixelRatio ( e . clientX )
11451145 const posY = scaleByPixelRatio ( e . clientY )
11461146 updatePointerDownData ( pointer , - 1 , posX , posY )
11471147 clickSplat ( pointer )
11481148 } )
11491149
1150- function handleFirstMouseMove ( e : PointerEvent ) {
1150+ function handleFirstMouseMove ( e : MouseEvent ) {
11511151 const pointer = pointers [ 0 ]
11521152 const posX = scaleByPixelRatio ( e . clientX )
11531153 const posY = scaleByPixelRatio ( e . clientY )
11541154 const color = generateColor ( )
11551155 updateFrame ( )
11561156 updatePointerMoveData ( pointer , posX , posY , color )
1157- document . body . removeEventListener ( "pointermove " , handleFirstMouseMove )
1157+ document . body . removeEventListener ( "mousemove " , handleFirstMouseMove )
11581158 }
1159- document . body . addEventListener ( "pointermove " , handleFirstMouseMove )
1159+ document . body . addEventListener ( "mousemove " , handleFirstMouseMove )
11601160
11611161 window . addEventListener ( "mousemove" , ( e ) => {
11621162 const pointer = pointers [ 0 ]
@@ -1231,5 +1231,9 @@ export function SplashCursor({
12311231 TRANSPARENT ,
12321232 ] )
12331233
1234- return < canvas ref = { canvasRef } id = "fluid" className = "pointer-events-none fixed top-0 left-0 z-50 h-full w-full opacity-20" />
1234+ return (
1235+ < div className = "pointer-events-none fixed top-0 left-0 z-50 h-full w-full" >
1236+ < canvas ref = { canvasRef } id = "fluid" className = "block h-screen w-screen" > </ canvas >
1237+ </ div >
1238+ )
12351239}
0 commit comments