58 lines
2.2 KiB
TypeScript
58 lines
2.2 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 ImageLayers from "@/components/canvas/ImageLayers";
|
|
import { useIsMobile } from "@/lib/useIsMobile";
|
|
|
|
/**
|
|
* Hero canvas: falling stickers + glass hello/cursor models.
|
|
*
|
|
* The glass shader refracts a scene texture rendered into an FBO with a
|
|
* layer-0 camera mask (stickers/background), matching the original
|
|
* "glass hosting section" FBO. Glass meshes enable layer 10 so they are
|
|
* excluded from their own refraction pass.
|
|
* Models animate only from scroll (entry/after targets, damp 6) — no
|
|
* time-based motion besides the desktop float bob.
|
|
*/
|
|
|
|
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.
|
|
Live on layer 0 — visible to the main camera and captured by the
|
|
glass FBO pass (which renders with a layer-0 camera mask). */}
|
|
<StickerDrop />
|
|
|
|
{/* DOM-tracked image layers (about section m3.png), rendered above
|
|
stickers via renderOrder 20. */}
|
|
<ImageLayers />
|
|
|
|
{/* Glass hero models (hello + blue cursor star), refractive tint shader */}
|
|
<HelloModel isMobile={isMobile} />
|
|
<CursorStar isMobile={isMobile} />
|
|
</Canvas>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
export default HeroScene;
|