Skip to content

Commit de84019

Browse files
committed
disable WebGL effect
1 parent 249dc31 commit de84019

File tree

3 files changed

+28
-24
lines changed

3 files changed

+28
-24
lines changed

app/components/SplashCursor.tsx

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
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

54
interface 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
}

app/layout.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { Analytics } from "@vercel/analytics/next"
99
import { bodyAttributes } from "@zero-ui/attributes"
1010
import { ViewTransitions } from "./utils/ViewTransition"
1111
import { BottomBlurOverlay } from "./ui/BlurBottomOverlay"
12-
import { LazySplashCursor } from "./utils/lazy-splash-cursor"
12+
// import { LazySplashCursor } from "./utils/lazy-splash-cursor"
1313
import { DesktopCursor } from "./utils/lazy-dot-cursor"
1414
import { siteGraph } from "@/config/schemas"
1515
import Script from "next/script"
@@ -36,7 +36,7 @@ const RootLayout = ({ children }: { children: React.ReactNode }) => {
3636
<MotionWrapper>
3737
<DesktopCursor />
3838
<ViewTransitions />
39-
<LazySplashCursor />
39+
4040
<div className="custom:mx-auto xxs:mx-3.5 pointer-events-none absolute inset-0 z-1 max-w-6xl [background-image:url('/assets/framer-noise.png')] [background-size:128px] bg-repeat opacity-6 md:mx-5 lg:mx-8" />
4141
<div className={`${switzer.variable} font-switzer subpixel-antialiased`}>
4242
<div className="custom:mx-auto xxs:border-x pointer-events-none absolute inset-0 z-0 mx-3.5 max-w-6xl border-gray-200 md:mx-5 lg:mx-8" />

app/utils/lazy-splash-cursor.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { useEffect, useState } from "react"
55
import { TiltedWrapperProps } from "../ui/TiltedWrapper"
66

77
// hoist this to module scope (not inside the component)
8-
export const SplashCursor = /*#__PURE__*/ dynamic(() => import("../components/SplashCursor").then((m) => m.SplashCursor), {
8+
export const SplashCursor = /*#__PURE__*/ dynamic(() => import("../components/SplashCursor").then((m) => m.default), {
99
ssr: false,
1010
loading: () => null,
1111
})

0 commit comments

Comments
 (0)