← All components Next componentIsometric Roadmap→
Sections · Roadmap
Snake Roadmap
Pinned roadmap: a glowing line snakes through 3D space as the camera rides it, each milestone swinging to the front as a frosted-glass card.
Installation
Use it in your project
Or skip the copy-paste
One command: writes the file and installs the dependencies.
$ npx deepui-cli add snake-roadmap
01
Install
The 3D packages this component is built on.
$ npm install three @react-three/fiber gsap && npm install -D @types/three
02
Add the component
One self-contained file: create components/PinnedSnakeRoadmap3D.tsx and paste it in.
components/PinnedSnakeRoadmap3D.tsx
1"use client";23import {4 memo,5 useEffect,6 useMemo,7 useRef,8 useState,9 type CSSProperties,10 type ReactNode,11 type RefObject,12} from "react";13import * as THREE from "three";14import { Canvas, useFrame, useThree, type CanvasProps } from "@react-three/fiber";15import gsap from "gsap";16import { ScrollTrigger } from "gsap/ScrollTrigger";1718/**19 * The shared props API of DeepUI's individual 3D components (not the full-page templates, which keep20 * their own tailored scenes).21 *22 * The props are grouped by concern. A component extends ONLY the groups it really applies, so its23 * type never advertises a knob that does nothing (a card has no particles, a background has no tilt):24 *25 * interface MyCardProps extends CursorProps, TiltProps, MaterialProps, PerformanceProps { … }26 *27 * `Base3DComponentProps` is every group at once, for tooling that handles any component. Same name,28 * same unit and same meaning everywhere; the default values live in DEFAULT_3D_PROPS. These files are29 * inlined into each component's single-file bundle (lib/bundle-source.mjs), only what it uses.30 */3132/** Which rotation axes follow the pointer. "x-only": the object nods (up / down); "y-only": it turns (left / right). */33export type TiltAxis = "both" | "x-only" | "y-only" | "none";3435/** 1. Cursor: how the pointer pulls, pushes and drags the object. */36interface CursorProps {37 /** Reach of the pointer's influence, in the component's own space: CSS pixels for pixel-laid-out widgets, world units for 3D scenes (each component says which). Default 220 (px). */38 cursorRadius?: number;39 /** Positive pulls things towards the pointer, negative pushes them away (repulsion, shockwave). Default 1. */40 cursorForce?: number;41 /** How far the object slides towards the pointer, 0 (stays put) to 1 (follows closely). Default 0. */42 magneticStrength?: number;43 /** Share of the remaining distance the motion closes each frame (at 60 fps), 0.01 (heavy, slow) to 1 (instant). Default 0.1. */44 cursorDamping?: number;45}4647/** 2. Tilt and parallax: the object leans towards the pointer, its layers slide against each other. */48interface TiltProps {49 /** Largest lean towards the pointer, in degrees. Default 15. */50 maxTiltAngle?: number;51 /** Axes that follow the pointer. Default "both". */52 tiltAxis?: TiltAxis;53 /** Lean away from the pointer instead of towards it. Default false. */54 invertTilt?: boolean;55 /** How far apart the depth layers slide when the object tilts, 0 (flat) to 2. Default 1. */56 parallaxOffset?: number;57}5859/** 3. Text and 3D typography, for components that draw a label. */60interface Text3DProps {61 /** The label drawn by the component. */62 text?: string;63 /** Scale of the lettering. Default 1. */64 fontSize?: number;65 /** Extrusion depth of 3D letters. Default 0.2. */66 textDepth?: number;67 /** Bevelled, light-catching edges on 3D letters. Default true. */68 bevelEnabled?: boolean;69 /** Custom font: a .woff / .ttf (flat text) or a typeface .json (extruded text). */70 fontUrl?: string;71}7273/** 4. Rendering, materials and glow. */74interface MaterialProps {75 /** Main color of the object. Default "#6366f1". */76 primaryColor?: string;77 /** Color of the glow. Default "#00f0ff". */78 emissiveColor?: string;79 /** Strength of the glow, 0 (none) to 3. Default 1. */80 emissiveIntensity?: number;81 /** 0 (mirror, glass) to 1 (matte). Default 0.3. */82 roughness?: number;83 /** 0 (plastic, organic) to 1 (metal). Default 0.5. */84 metalness?: number;85 /** 0 (opaque) to 1 (clear glass): see-through, refracting surfaces. Default 0. */86 transmission?: number;87 /** Technical wireframe rendering. Default false. */88 wireframe?: boolean;89}9091/** 5. Particles, idle motion and shader animation. */92interface MotionProps {93 /** Number of instanced elements. Default depends on the component. */94 particleCount?: number;95 /** Spin on its own, in radians per second (negative: the other way; 0.5 ≈ one turn in 12 s). Default 0. */96 autoRotateSpeed?: number;97 /** Pulses or ripples per second. Default 1. */98 pulseRate?: number;99 /** Amplitude of the noise deformation, 0 (none) to 2. Default 1. */100 displacementScale?: number;101}102103/** 6. Environment and camera. */104interface EnvironmentProps {105 /** Camera field of view, in degrees. Default depends on the component. */106 cameraFov?: number;107 /** Color of the depth fog. Default "#0a0a0a". */108 fogColor?: string;109 /** Thickness of the fog, 0 (none) to 0.2. Default 0. */110 fogDensity?: number;111}112113/** 7. Performance and accessibility. */114interface PerformanceProps {115 /** Lighter rendering for weak devices: pixel ratio 1, fewer instances, smaller environment maps. Default false. */116 lowPowerMode?: boolean;117 /** Under the OS "reduce motion" setting, stop idle spin, pulses and deformation (pointer feedback stays). Default true. */118 respectReducedMotion?: boolean;119 /** Stop the render loop while the component is scrolled out of view. Default true. */120 pauseWhenOffscreen?: boolean;121}122123/** Every group at once. Components extend only the groups they apply (see the top of this file). */124interface Base3DComponentProps125 extends CursorProps,126 TiltProps,127 Text3DProps,128 MaterialProps,129 MotionProps,130 EnvironmentProps,131 PerformanceProps {}132133type Defaults = Required<Omit<Base3DComponentProps, "text" | "fontUrl" | "particleCount" | "cameraFov">>;134135/** The values a prop takes when it is left out. A component may override one, and then documents it. */136const DEFAULT_3D_PROPS: Defaults = {137 cursorRadius: 220,138 cursorForce: 1,139 magneticStrength: 0,140 cursorDamping: 0.1,141 maxTiltAngle: 15,142 tiltAxis: "both",143 invertTilt: false,144 parallaxOffset: 1,145 fontSize: 1,146 textDepth: 0.2,147 bevelEnabled: true,148 primaryColor: "#6366f1",149 emissiveColor: "#00f0ff",150 emissiveIntensity: 1,151 roughness: 0.3,152 metalness: 0.5,153 transmission: 0,154 wireframe: false,155 autoRotateSpeed: 0,156 pulseRate: 1,157 displacementScale: 1,158 fogColor: "#0a0a0a",159 fogDensity: 0,160 lowPowerMode: false,161 respectReducedMotion: true,162 pauseWhenOffscreen: true,163};164165/** Fills the positioned parent. */166const FILL: CSSProperties = { position: "absolute", top: 0, left: 0, width: "100%", height: "100%" };167168interface PinnedScrollOptions {169 /** Scroll distance of the pin, in screen heights. Default 3. */170 length?: number;171 /** Disable the pin (the progress then runs while the section crosses the screen). */172 pin?: boolean;173}174175/**176 * Pins the section with GSAP ScrollTrigger (`pin: true`, scrubbed) for `length` screens of scroll and177 * returns a ref to the progress, 0 → 1. Read it in useFrame: scrolling never re-renders React. The178 * trigger is killed on unmount. Works with Lenis or any smooth scroll that updates ScrollTrigger.179 */180function usePinnedProgress(section: RefObject<HTMLElement | null>, { length = 3, pin = true }: PinnedScrollOptions = {}) {181 const progress = useRef(0);182 useEffect(() => {183 const el = section.current;184 if (!el) return undefined;185 gsap.registerPlugin(ScrollTrigger);186 const trigger = ScrollTrigger.create({187 trigger: el,188 start: pin ? "top top" : "top bottom",189 end: () => (pin ? `+=${window.innerHeight * length}` : "bottom top"),190 pin,191 scrub: 1,192 invalidateOnRefresh: true,193 onUpdate: (self) => {194 progress.current = self.progress;195 },196 });197 return () => trigger.kill();198 }, [section, length, pin]);199 return progress;200}201202interface SectionCanvasProps extends Omit<CanvasProps, "children" | "style" | "gl" | "frameloop">, Pick<PerformanceProps, "pauseWhenOffscreen" | "lowPowerMode"> {203 children: ReactNode;204 /** Pointer events for the 3D (raycasting). The canvas is click-through otherwise. */205 interactive?: boolean;206 /** Hidden from screen readers (default). Turn off when real HTML lives inside the canvas (drei <Html>). */207 decorative?: boolean;208}209210/** Touch screens (phones, tablets): far less GPU memory than a desktop, the tab is killed when it runs out. */211function isTouchDevice() {212 return typeof window !== "undefined" && window.matchMedia("(pointer: coarse)").matches;213}214215/**216 * Canvas filling its positioned parent: alpha, render loop paused while it is scrolled out of view.217 *218 * Memory, for pages that stack many of these (the templates have up to 9): the canvas only exists while219 * its section is within a screen of the viewport. Further away it is unmounted, and R3F disposes the220 * renderer and releases its WebGL context; it comes back, rebuilt, before it scrolls into view. On touch221 * screens the pixel ratio is capped at 1.5 and antialiasing is off: on an iPhone (ratio 3) a full-screen222 * canvas with MSAA takes hundreds of MB, and a few of them make Safari kill the tab ("a problem223 * repeatedly occurred").224 */225function SectionCanvas({ children, interactive = false, decorative = true, dpr, pauseWhenOffscreen = DEFAULT_3D_PROPS.pauseWhenOffscreen, lowPowerMode = DEFAULT_3D_PROPS.lowPowerMode, ...canvasProps }: SectionCanvasProps) {226 const ref = useRef<HTMLDivElement>(null);227 const [inView, setInView] = useState(true);228 const [near, setNear] = useState(false);229 const [touch] = useState(isTouchDevice);230 useEffect(() => {231 const el = ref.current;232 if (!el) return undefined;233 const visible = new IntersectionObserver(([entry]) => setInView(entry.isIntersecting));234 // One screen of margin above and below: built before it shows, released once well past235 const nearby = new IntersectionObserver(([entry]) => setNear(entry.isIntersecting), { rootMargin: "100% 0px" });236 visible.observe(el);237 nearby.observe(el);238 return () => {239 visible.disconnect();240 nearby.disconnect();241 };242 }, []);243 const maxDpr = lowPowerMode ? 1 : touch ? 1.5 : 2;244 const range: [number, number] = Array.isArray(dpr) ? [dpr[0], Math.min(dpr[1], maxDpr)] : [1, Math.min(typeof dpr === "number" ? dpr : 2, maxDpr)];245 return (246 <div ref={ref} aria-hidden={decorative ? "true" : undefined} style={{ ...FILL, pointerEvents: interactive ? "auto" : "none" }}>247 {near && (248 <Canvas249 dpr={range}250 frameloop={inView || !pauseWhenOffscreen ? "always" : "never"}251 gl={{ antialias: !touch, alpha: true, powerPreference: "high-performance" }}252 style={{ pointerEvents: interactive ? "auto" : "none", touchAction: "pan-y" }}253 {...canvasProps}254 >255 {children}256 </Canvas>257 )}258 </div>259 );260}261262/** True under 768px: scenes recompose (camera farther, layouts in columns). */263function useIsMobile() {264 const [mobile, setMobile] = useState(false);265 useEffect(() => {266 const query = window.matchMedia("(max-width: 767px)");267 const sync = () => setMobile(query.matches);268 sync();269 query.addEventListener("change", sync);270 return () => query.removeEventListener("change", sync);271 }, []);272 return mobile;273}274275const projected = new THREE.Vector3();276277/**278 * Moves HTML elements (cards, labels, counters) onto 3D points every frame, by transform only: the279 * text stays real HTML — crisp, selectable, read by screen readers, styled with your CSS. `points(i)`280 * returns the world position of anchor i (or null to hide it); `style(i, el, screen)` can add opacity,281 * scale… The elements must be absolutely positioned at the top-left of the canvas' container.282 */283function useAnchors(284 elements: RefObject<(HTMLElement | null)[]>,285 points: (i: number, target: THREE.Vector3) => THREE.Vector3 | null,286 style?: (i: number, el: HTMLElement, screen: { x: number; y: number; z: number }) => void287) {288 const camera = useThree((s) => s.camera);289 const size = useThree((s) => s.size);290 const target = useRef(new THREE.Vector3());291 useFrame(() => {292 const list = elements.current ?? [];293 list.forEach((el, i) => {294 if (!el) return;295 const p = points(i, target.current);296 if (!p) {297 el.style.visibility = "hidden";298 return;299 }300 projected.copy(p).project(camera);301 const behind = projected.z > 1;302 const x = (projected.x * 0.5 + 0.5) * size.width;303 const y = (-projected.y * 0.5 + 0.5) * size.height;304 el.style.visibility = behind ? "hidden" : "visible";305 el.style.transform = `translate3d(${x.toFixed(1)}px, ${y.toFixed(1)}px, 0) translate(-50%, -50%)`;306 style?.(i, el, { x, y, z: projected.z });307 });308 });309}310311/** Absolutely positioned at the top-left of the container: useAnchors moves it. */312const ANCHOR: CSSProperties = { position: "absolute", top: 0, left: 0, willChange: "transform", visibility: "hidden" };313314// Shared by the roadmap sections: the milestone shape and sample content.315316interface RoadmapMilestone {317 /** Short tag, e.g. "Q1 2026". */318 label: string;319 title: string;320 description?: string;321}322323const DEFAULT_MILESTONES: RoadmapMilestone[] = [324 { label: "Q1 2026", title: "Private beta", description: "The first 200 teams build with the core scenes." },325 { label: "Q2 2026", title: "Public launch", description: "Open sign-ups, the full component library and docs." },326 { label: "Q3 2026", title: "Team workspaces", description: "Shared presets, roles and a design token sync." },327 { label: "Q4 2026", title: "Visual editor", description: "Compose whole pages in 3D without writing code." },328 { label: "2027", title: "Marketplace", description: "Publish and sell your own scenes to the community." },329];330331export type { RoadmapMilestone };332333export interface PinnedSnakeRoadmapProps extends Pick<MaterialProps, "emissiveColor">, Pick<PerformanceProps, "pauseWhenOffscreen" | "lowPowerMode"> {334 milestones?: RoadmapMilestone[];335 /** Section title shown while the road unrolls. */336 heading?: string;337 /** Color of the lit path and of the active card's glow. Default "#a78bfa". */338 emissiveColor?: string;339 /** @deprecated Use `emissiveColor`. */340 accentColor?: string;341 /** Scroll length of the pinned section, in screen heights. Default 4. */342 scrollLength?: number;343}344345const SEGMENT = 9; // world units of path between two milestones346347/** A snake winding forward (toward -z), one bend per milestone. */348function snakePath(count: number) {349 const points: THREE.Vector3[] = [];350 const steps = (count + 1) * 2;351 for (let i = 0; i <= steps; i++) {352 const z = -i * (SEGMENT / 2);353 points.push(new THREE.Vector3(Math.sin(i * 1.1) * 4.5, Math.sin(i * 0.7) * 1.2 - 1, z));354 }355 return new THREE.CatmullRomCurve3(points, false, "catmullrom", 0.5);356}357358const pathVertex = /* glsl */ `359varying float vAlong;360varying vec3 vNormal;361void main() {362 vAlong = uv.x;363 vNormal = normalize(normalMatrix * normal);364 gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);365}366`;367const pathFragment = /* glsl */ `368uniform vec3 uColor;369uniform float uProgress; // how far along the path is lit (0..1)370uniform float uTime;371varying float vAlong;372varying vec3 vNormal;373void main() {374 float lit = 1.0 - smoothstep(uProgress - 0.004, uProgress + 0.004, vAlong);375 // A pulse runs along the lit part; the head glows brightest376 float pulse = 0.6 + 0.4 * sin(vAlong * 120.0 - uTime * 6.0);377 float head = exp(-abs(vAlong - uProgress) * 160.0) * 2.5;378 float rim = pow(1.0 - abs(vNormal.z), 2.0) * 0.4;379 vec3 dim = vec3(0.09, 0.09, 0.13) + rim * 0.15;380 vec3 color = mix(dim, uColor * (1.2 * pulse + rim), lit) + uColor * head;381 gl_FragColor = vec4(color, 1.0);382 #include <colorspace_fragment>383}384`;385386interface SceneProps {387 milestones: RoadmapMilestone[];388 accentColor: string;389 progress: RefObject<number>;390 cards: RefObject<(HTMLElement | null)[]>;391 mobile: boolean;392}393394const Snake = memo(function Snake({ milestones, accentColor, progress, cards, mobile }: SceneProps) {395 const curve = useMemo(() => snakePath(milestones.length), [milestones.length]);396 const geometry = useMemo(() => new THREE.TubeGeometry(curve, 400, 0.09, 12, false), [curve]);397 const node = useMemo(() => new THREE.SphereGeometry(0.28, 24, 16), []);398 const material = useMemo(399 () =>400 new THREE.ShaderMaterial({401 uniforms: { uColor: { value: new THREE.Color() }, uProgress: { value: 0 }, uTime: { value: 0 } },402 vertexShader: pathVertex,403 fragmentShader: pathFragment,404 }),405 []406 );407 const nodeMaterial = useMemo(() => new THREE.MeshBasicMaterial({ toneMapped: false }), []);408 useEffect(() => {409 (material.uniforms.uColor.value as THREE.Color).set(accentColor);410 nodeMaterial.color.set(accentColor);411 }, [material, nodeMaterial, accentColor]);412 useEffect(() => () => geometry.dispose(), [geometry]);413 useEffect(414 () => () => {415 node.dispose();416 material.dispose();417 nodeMaterial.dispose();418 },419 [node, material, nodeMaterial]420 );421422 // Path parameter of each milestone (by arc length) and its point423 const stops = useMemo(() => milestones.map((_, i) => (i + 1) / (milestones.length + 1)), [milestones]);424 const points = useMemo(() => stops.map((t) => curve.getPointAt(t)), [curve, stops]);425 const nodes = useRef<(THREE.Mesh | null)[]>([]);426 const smooth = useRef(0);427 const look = useMemo(() => new THREE.Vector3(), []);428 const eye = useMemo(() => new THREE.Vector3(), []);429430 useFrame((state, delta) => {431 const dt = Math.min(delta, 1 / 30);432 smooth.current = THREE.MathUtils.damp(smooth.current, progress.current ?? 0, 6, dt);433 // The lit head travels from just before the first milestone to just after the last434 const t = THREE.MathUtils.lerp(stops[0] - 0.08, stops[stops.length - 1] + 0.04, smooth.current);435 material.uniforms.uProgress.value = t;436 material.uniforms.uTime.value = state.clock.elapsedTime;437438 // The camera rides behind and above the head, looking a little ahead439 const head = curve.getPointAt(THREE.MathUtils.clamp(t, 0, 1));440 const ahead = curve.getPointAt(THREE.MathUtils.clamp(t + 0.06, 0, 1));441 const back = mobile ? 9 : 7;442 eye.set(head.x * 0.4, head.y + (mobile ? 4.2 : 3.2), head.z + back);443 state.camera.position.lerp(eye, 1 - Math.exp(-4 * dt));444 look.lerp(ahead, 1 - Math.exp(-4 * dt));445 state.camera.lookAt(look);446447 nodes.current.forEach((mesh, i) => {448 if (!mesh) return;449 const reached = t >= stops[i] - 0.004;450 const s = THREE.MathUtils.damp(mesh.scale.x, reached ? 1.25 : 0.6, 8, dt);451 mesh.scale.setScalar(s);452 });453 });454455 // Cards ride above their milestone; the one being reached pivots to face the visitor456 useAnchors(457 cards,458 (i, target) => target.copy(points[i]).add(new THREE.Vector3(0, 1.6, 0)),459 (i, el) => {460 const t = THREE.MathUtils.lerp(stops[0] - 0.08, stops[stops.length - 1] + 0.04, smooth.current);461 const d = (t - stops[i]) / (1 / (milestones.length + 1));462 const focus = Math.max(0, 1 - Math.abs(d) * 1.4);463 const turn = THREE.MathUtils.clamp(-d * 70, -70, 70) * (1 - focus);464 el.style.opacity = String(Math.min(1, 0.15 + focus * 1.2) * (d > 1.6 ? 0.3 : 1));465 el.style.transform += ` perspective(800px) rotateY(${turn.toFixed(1)}deg) scale(${(0.82 + focus * 0.18).toFixed(3)})`;466 el.style.zIndex = String(Math.round(focus * 10));467 el.dataset.active = focus > 0.6 ? "true" : "false";468 }469 );470471 return (472 <>473 <mesh geometry={geometry} material={material} />474 {points.map((p, i) => (475 <mesh476 key={i}477 ref={(m) => {478 nodes.current[i] = m;479 }}480 geometry={node}481 material={nodeMaterial}482 position={p}483 />484 ))}485 </>486 );487});488489/**490 * Pinned roadmap: the section holds the screen while the visitor scrolls; a glowing line snakes491 * through 3D space, lighting up as the camera rides along it, and each milestone swings to the front492 * as a frosted-glass card when the light reaches it. Cards are real HTML (readable, accessible).493 */494function PinnedSnakeRoadmap3D({ milestones = DEFAULT_MILESTONES, heading = "Where we're headed", emissiveColor, accentColor = emissiveColor ?? "#a78bfa", scrollLength = 4, pauseWhenOffscreen, lowPowerMode }: PinnedSnakeRoadmapProps) {495 const section = useRef<HTMLElement>(null);496 const cards = useRef<(HTMLElement | null)[]>([]);497 const progress = usePinnedProgress(section, { length: scrollLength });498 const mobile = useIsMobile();499500 return (501 // Stable wrapper: the GSAP pin wraps the <section> in a pin-spacer502 <div>503 <section ref={section} className="relative h-svh w-full overflow-hidden bg-[#06060a] text-white" aria-label={heading}>504 <SectionCanvas pauseWhenOffscreen={pauseWhenOffscreen} lowPowerMode={lowPowerMode} camera={{ position: [0, 3, 8], fov: 50 }}>505 <fog attach="fog" args={["#06060a", 10, 34]} />506 <Snake milestones={milestones} accentColor={accentColor} progress={progress} cards={cards} mobile={mobile} />507 </SectionCanvas>508 <div className="pointer-events-none absolute inset-x-0 top-0 px-[6%] pt-20 sm:pt-24">509 <p className="font-mono text-xs uppercase tracking-[0.25em] text-white/50">Roadmap</p>510 <h2 className="mt-3 max-w-xl text-4xl font-bold leading-[0.95] tracking-tighter sm:text-6xl">{heading}</h2>511 </div>512 <ol className="absolute inset-0 m-0 list-none p-0">513 {milestones.map((m, i) => (514 <li515 key={`${m.label}-${i}`}516 ref={(el) => {517 cards.current[i] = el;518 }}519 style={{ ...ANCHOR, boxShadow: `0 20px 60px -20px ${accentColor}66` }}520 className="w-[min(78vw,280px)] rounded-2xl border border-white/15 bg-white/[0.08] p-5 backdrop-blur-xl"521 >522 <p className="font-mono text-xs uppercase tracking-[0.2em]" style={{ color: accentColor }}>523 {m.label}524 </p>525 <h3 className="mt-2 text-xl font-bold tracking-tight">{m.title}</h3>526 {m.description && <p className="mt-2 text-sm leading-relaxed text-white/65">{m.description}</p>}527 </li>528 ))}529 </ol>530 </section>531 </div>532 );533}534535export default memo(PinnedSnakeRoadmap3D);
03
Drop it in a page
It fills the box you put it in.
app/page.tsx
1import PinnedSnakeRoadmap3D from "@/components/PinnedSnakeRoadmap3D";23export default function Page() {4 return (5 <main>6 {/* …your other sections */}7 {/* A full-width section: it brings its own height (and its pinned scroll) */}8 <PinnedSnakeRoadmap3D />9 {/* …the rest of the page */}10 </main>11 );12}