744ec0becc
- Introduced GlassModels component with custom vertex and fragment shaders for realistic glass effects. - Updated HeroScene to include HelloModel and CursorStar components, utilizing the new glass shader. - Enhanced Header component with ScrambleReveal for dynamic text display and local clock functionality. - Implemented useIsMobile hook to adapt rendering based on screen size. - Adjusted StickerLayer to ensure falling stickers are captured in the glass models' FBO pass.
51 lines
1.9 KiB
TypeScript
51 lines
1.9 KiB
TypeScript
"use client";
|
|
|
|
import { useEffect, useMemo, useRef } from "react";
|
|
import { Canvas, useFrame, useThree } from "@react-three/fiber";
|
|
import { PerspectiveCamera } from "@react-three/drei";
|
|
import * as THREE from "three";
|
|
|
|
import { StickerDrop, StickerCamera } from "@/components/canvas/StickerDrop";
|
|
import { HelloModel, CursorStar } from "@/components/canvas/GlassModels";
|
|
import { useIsMobile } from "@/lib/useIsMobile";
|
|
|
|
/**
|
|
* Hero canvas: falling stickers + glass hello/cursor models.
|
|
*
|
|
* The glass shader refracts a scene texture rendered into an FBO from layer 1.
|
|
* BackgroundGrid lives in the DOM (below the canvas), so it can't be refracted;
|
|
* the FBO pass still captures the sticker particles, giving the glass its
|
|
* refraction content — the same hierarchy the original achieves with its
|
|
* "glass hosting section" FBO.
|
|
*/
|
|
|
|
export function HeroScene() {
|
|
const isMobile = useIsMobile();
|
|
|
|
return (
|
|
// z-30 keeps it above the BackgroundGrid (z-20) to prevent mix-blend-difference from making it gray
|
|
<div className="z-30 fixed inset-0 w-full h-full pointer-events-none">
|
|
<Canvas
|
|
dpr={[1, 2]}
|
|
gl={{ alpha: true, antialias: true }}
|
|
>
|
|
{/* Camera rig: horizontal FOV 60/38 + scroll-driven distance lerp(24, 32).
|
|
StickerCamera drives fov/aspect/z every frame; PerspectiveCamera is the
|
|
makeDefault camera it mutates. */}
|
|
<PerspectiveCamera makeDefault position={[0, 0, 24]} near={0.1} far={200} />
|
|
<StickerCamera />
|
|
|
|
{/* Falling stickers: 1:1 re-implementation of the original particle system.
|
|
Rendered on layer 1 so the glass FBO pass can capture them. */}
|
|
<StickerDrop />
|
|
|
|
{/* Glass hero models (hello + blue cursor star), refractive tint shader */}
|
|
<HelloModel isMobile={isMobile} />
|
|
<CursorStar isMobile={isMobile} />
|
|
</Canvas>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
export default HeroScene;
|