feat: 移植 hyper-space 超空间区块(cursor.glb 条纹箭头 + 8vh 滚动叙事)与箭头全屏白模式
- HyperspaceModel.tsx:1:1 移植原站 cx——cursor.glb 合并几何、屏幕矩形追踪(12 帧缓存+滚动增量修正)、restScale 0.1→峰值 hypot(vw,vh)×1.64/radius 的吞噬缩放(damp 32/s)、shrink 折叠、条纹 shader(uStripeReveal 蓝底→黑底星空放射)、scaleSpinDegrees 180 收拢自旋、指针跟随高光 - HyperSpaceSection.tsx:8 视口高 + sticky,段位推进 seg0-primary/secondary(Innovate with purpose / human touch)→ seg1(进度环 + 四段主张)→ end(FUTURE-FIRST/ALWAYS);逐字符哈希延迟 stagger(hsstFadeIn/Out) - arrowFullscreen.ts:原站 module 1111 进度 store(setDampedScaleT 阈值翻转订阅,header 0.5 阈值白模式、section 0.5 白模式同步) - Header:箭头过阈值后整体转白(ARROW_FULLSCREEN_DOM_COLOR_TRANSITION) - 修复:main 不再是滚动容器(原站 sticky 依赖内部滚动,我们的 Lenis 是窗口级,sticky 永不钉住导致末段文案不出现) - scrollBus 增加 subscribeScroll/notifyScroll 供 DOM 侧响应式读取;useLightController 从 GlassModels 导出复用 - 验证:glError=0 无反馈环;段位推进/白模式触发与回落/区块顺序 全部 CDP 行为探针通过;build+tsc 通过
This commit is contained in:
@@ -5,6 +5,10 @@ import ScrambleReveal from "@/components/dom/ScrambleReveal";
|
||||
import { useShellMedia, type ThemeSetting } from "@/lib/shellMedia";
|
||||
import { useBgm } from "@/lib/useBgm";
|
||||
import { scrollEnv } from "@/lib/scrollEnv";
|
||||
import {
|
||||
useArrowFullscreenPastThreshold,
|
||||
ARROW_FULLSCREEN_DOM_COLOR_TRANSITION,
|
||||
} from "@/lib/arrowFullscreen";
|
||||
|
||||
/**
|
||||
* Header — ported from the original (chunk 2689132c4e070b68.js):
|
||||
@@ -48,6 +52,10 @@ function useBrowserName(): string {
|
||||
export default function Header() {
|
||||
const { theme, setTheme, soundEnabled, setSoundEnabled } = useShellMedia();
|
||||
useBgm(soundEnabled);
|
||||
// Arrow-fullscreen state: past the 0.5 reveal threshold the whole header
|
||||
// (and the hyper-space section) turn white over the black stripe base
|
||||
// (original X = useArrowFullscreenPastThreshold()).
|
||||
const arrowWhite = useArrowFullscreenPastThreshold();
|
||||
|
||||
const [time, setTime] = useState("--:--");
|
||||
const [coords, setCoords] = useState({ x: "0001", y: "0001" });
|
||||
@@ -180,7 +188,11 @@ export default function Header() {
|
||||
"inline-flex shrink-0 items-baseline gap-0 normal-case";
|
||||
|
||||
return (
|
||||
<header className="z-50 fixed inset-0 flex flex-col justify-between font-mono-2 pointer-events-none text-l1">
|
||||
<header
|
||||
className={`z-50 fixed inset-0 flex flex-col justify-between font-mono-2 pointer-events-none ${ARROW_FULLSCREEN_DOM_COLOR_TRANSITION} ${
|
||||
arrowWhite ? "text-white" : "text-l1"
|
||||
}`}
|
||||
>
|
||||
<div className="flex justify-between items-center px-4 lg:px-14 py-4 lg:py-7 text-base">
|
||||
<a
|
||||
className={`${dotted} p-2 font-sans font-bold uppercase pointer-events-auto transition-colors duration-300 ease-out`}
|
||||
@@ -273,7 +285,11 @@ export default function Header() {
|
||||
animation: "vh-fade-in 0.4s cubic-bezier(0.25, 1, 0.5, 1) both",
|
||||
}}
|
||||
>
|
||||
<div className="flex flex-col bg-be p-2 font-mono-2 text-l1 xl:basis-1/3 basis-1/2">
|
||||
<div
|
||||
className={`flex flex-col bg-be p-2 font-mono-2 xl:basis-1/3 basis-1/2 ${ARROW_FULLSCREEN_DOM_COLOR_TRANSITION} ${
|
||||
arrowWhite ? "text-white" : "text-l1"
|
||||
}`}
|
||||
>
|
||||
{/* Original hint-panel texts omit scrambleColors → the scramble
|
||||
component's default (true) applies: chars flash the lime
|
||||
phase colors #c0fe04 → #607F02 while revealing, and the
|
||||
|
||||
@@ -0,0 +1,574 @@
|
||||
"use client";
|
||||
|
||||
/**
|
||||
* HyperSpaceSection — 1:1 port of the original DOM section `fh` + `fp` +
|
||||
* `fm` + `fg` + `fv` + stagger text `fr` + ellipse-ring `c7` + SVG signature
|
||||
* `fC` (chunk 4d3f3b68dbbde33a.js):
|
||||
*
|
||||
* - The section is 8 viewport heights tall (style height: 8·vh) with a
|
||||
* sticky inner viewport (top-0, min-h 100vh). Scrolling through it maps
|
||||
* to segment index floor(scrollTopIntoSection / segmentH) clamped 0..7
|
||||
* where segmentH = sectionHeight/8.
|
||||
* - Stages: segments 0-1 → seg0-primary ["Innovate","with","purpose"],
|
||||
* 2-3 → seg0-secondary ["Innovate","with a","human touch"], 4-5 → seg1
|
||||
* (ring + four claims), 6-7 → end ["FUTURE-FIRST","ALWAYS"].
|
||||
* - The section element itself registers as the "hyper-space" image-layer
|
||||
* target so the WebGL arrow (HyperspaceModel) tracks its screen rect.
|
||||
* - Its text color follows the arrow-fullscreen progress store (white past
|
||||
* 0.5) via ARROW_FULLSCREEN_DOM_COLOR_TRANSITION.
|
||||
*/
|
||||
import {
|
||||
memo,
|
||||
useEffect,
|
||||
useId,
|
||||
useLayoutEffect,
|
||||
useMemo,
|
||||
useRef,
|
||||
useState,
|
||||
} from "react";
|
||||
import { useWindowSize } from "@/lib/useWindowSize";
|
||||
import {
|
||||
useArrowFullscreenPastThreshold,
|
||||
ARROW_FULLSCREEN_DOM_COLOR_TRANSITION,
|
||||
} from "@/lib/arrowFullscreen";
|
||||
import { subscribeScroll, scrollBus } from "@/lib/scrollBus";
|
||||
import { getLayerTarget } from "@/lib/imageLayers";
|
||||
|
||||
export const HYPER_SPACE_SECTION_ID = "hyper-space";
|
||||
|
||||
const STAGES = [
|
||||
{ range: [0, 1], stage: "seg0-primary" },
|
||||
{ range: [2, 3], stage: "seg0-secondary" },
|
||||
{ range: [4, 5], stage: "seg1" },
|
||||
{ range: [6, 7], stage: "end" },
|
||||
] as const;
|
||||
|
||||
type Stage = (typeof STAGES)[number]["stage"];
|
||||
|
||||
const SEG0_PRIMARY = ["Innovate", "with", "purpose"];
|
||||
const SEG0_SECONDARY = ["Innovate", "with a", "human touch"];
|
||||
const END_LINES = ["FUTURE-FIRST", "ALWAYS"];
|
||||
|
||||
const clamp = (v: number, min: number, max: number) =>
|
||||
Math.min(max, Math.max(min, v));
|
||||
|
||||
function stageForSegment(segment: number): Stage | null {
|
||||
for (const { range, stage } of STAGES) {
|
||||
const [lo, hi] = range;
|
||||
if (segment >= lo && segment <= hi) return stage;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/** Segment height: sectionHeight/8, falling back to viewport height. */
|
||||
function segmentHeight(sectionHeight: number | undefined, fallback: number) {
|
||||
const h = sectionHeight ? sectionHeight / 8 : 0;
|
||||
return h > 1 ? h : Math.max(1, fallback);
|
||||
}
|
||||
|
||||
// --- Ellipse ring (original c4/c5/c6/c8) ----------------------------------
|
||||
|
||||
/** 7 ellipse phase slots (original c4 scratch array). */
|
||||
const ringScratch = new Float32Array(7);
|
||||
const RING_ELLIPSES = [0, 1, 2, 3, 4, 5, 6];
|
||||
const RING_ENTER_SPAN = 300;
|
||||
const RING_EXIT_SPAN = 345;
|
||||
const RING_CYCLE_DIST = 300;
|
||||
const RING_TOTAL_DIST = RING_ENTER_SPAN + RING_CYCLE_DIST + RING_EXIT_SPAN;
|
||||
/** Semi-axis table for progress 0..300 (original c5): circle of radius 150. */
|
||||
const RING_AXIS = (() => {
|
||||
const table = new Float32Array(301);
|
||||
for (let d = 0; d <= 300; d++) {
|
||||
const t = d - 150;
|
||||
const r2 = 22500 - t * t;
|
||||
table[d] = r2 > 0 ? Math.sqrt(r2) : 0;
|
||||
}
|
||||
return table;
|
||||
})();
|
||||
|
||||
function axisAt(d: number): number {
|
||||
if (d <= 0 || d >= 300) return 0;
|
||||
const i = Math.floor(d);
|
||||
const frac = d - i;
|
||||
return frac <= 0 ? RING_AXIS[i] : RING_AXIS[i] + (RING_AXIS[i + 1] - RING_AXIS[i]) * frac;
|
||||
}
|
||||
|
||||
const Ring = memo(function Ring({
|
||||
progress01,
|
||||
size = 344,
|
||||
className = "",
|
||||
}: {
|
||||
progress01: number;
|
||||
size?: number;
|
||||
className?: string;
|
||||
}) {
|
||||
const id = useId().replace(/:/g, "");
|
||||
const refs = useRef<(SVGEllipseElement | null)[]>([]);
|
||||
|
||||
useLayoutEffect(() => {
|
||||
const p = progress01 < 0 ? 0 : progress01 > 1 ? 1 : progress01;
|
||||
let dist = p * RING_TOTAL_DIST;
|
||||
let phase = 0; // 0 enter, 1 cycle, 2 exit
|
||||
let d = dist;
|
||||
if (dist > RING_ENTER_SPAN) {
|
||||
if (dist <= RING_ENTER_SPAN + RING_CYCLE_DIST) {
|
||||
phase = 1;
|
||||
d = dist - RING_ENTER_SPAN;
|
||||
} else {
|
||||
phase = 2;
|
||||
d = dist - RING_ENTER_SPAN - RING_CYCLE_DIST;
|
||||
}
|
||||
}
|
||||
let completed = 0;
|
||||
for (let i = 0; i < 7; i++) {
|
||||
const el = refs.current[i];
|
||||
if (!el) continue;
|
||||
let dI = 0;
|
||||
let visible = false;
|
||||
if (phase === 0) {
|
||||
const group = Math.floor(d / 50);
|
||||
visible = d >= 50 * i;
|
||||
if (visible) {
|
||||
dI = d - (Math.min(group, 6) - i) * 50;
|
||||
visible = dI > 0 && dI < 300;
|
||||
}
|
||||
} else if (phase === 1) {
|
||||
dI = ((d + 50 * i) % RING_CYCLE_DIST + RING_CYCLE_DIST) % RING_CYCLE_DIST;
|
||||
visible = dI > 0 && dI < 300;
|
||||
} else {
|
||||
dI = d + 50 * i;
|
||||
visible = dI > 0 && dI < 300;
|
||||
}
|
||||
if (!visible) {
|
||||
el.style.visibility = "hidden";
|
||||
continue;
|
||||
}
|
||||
const rx = axisAt(dI);
|
||||
if (rx <= 0) {
|
||||
el.style.visibility = "hidden";
|
||||
continue;
|
||||
}
|
||||
// Debounce repeat phase values (original c4 dedupe).
|
||||
let dupe = false;
|
||||
for (let k = 0; k < completed; k++) {
|
||||
if (Math.abs(ringScratch[k] - dI) < 0.5) {
|
||||
dupe = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (dupe) {
|
||||
el.style.visibility = "hidden";
|
||||
continue;
|
||||
}
|
||||
ringScratch[completed] = dI;
|
||||
completed++;
|
||||
el.style.visibility = "visible";
|
||||
// Ellipse center rides down the ring box with distance (original cy
|
||||
// 22 + l); rx full, ry 10% — a squashed orbit sweeping the box.
|
||||
el.cx.baseVal.value = 172;
|
||||
el.cy.baseVal.value = 22 + dI;
|
||||
el.rx.baseVal.value = rx;
|
||||
el.ry.baseVal.value = 0.1 * rx;
|
||||
}
|
||||
}, [progress01]);
|
||||
|
||||
return (
|
||||
<div
|
||||
className={`pointer-events-none absolute top-1/2 left-1/2 z-0 size-(--sar-size) -translate-x-1/2 -translate-y-1/2 overflow-hidden contain-[layout_paint_style] ${className}`}
|
||||
style={{ "--sar-size": `${size}px` } as React.CSSProperties}
|
||||
aria-hidden
|
||||
>
|
||||
<svg
|
||||
width={size}
|
||||
height={size}
|
||||
viewBox="0 0 344 344"
|
||||
fill="none"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
className="size-full"
|
||||
shapeRendering="geometricPrecision"
|
||||
>
|
||||
<defs>
|
||||
<clipPath id={id}>
|
||||
<polygon points="20,22 324,22 324,322 20,322" />
|
||||
</clipPath>
|
||||
</defs>
|
||||
<g clipPath={`url(#${id})`}>
|
||||
{RING_ELLIPSES.map((i) => (
|
||||
<ellipse
|
||||
key={i}
|
||||
ref={(el) => {
|
||||
refs.current[i] = el;
|
||||
}}
|
||||
visibility="hidden"
|
||||
stroke="#C0FE04"
|
||||
strokeOpacity={1}
|
||||
strokeWidth={2}
|
||||
vectorEffect="non-scaling-stroke"
|
||||
/>
|
||||
))}
|
||||
</g>
|
||||
</svg>
|
||||
</div>
|
||||
);
|
||||
});
|
||||
|
||||
// --- Stagger text (original ft cache + fr) ---------------------------------
|
||||
|
||||
const staggerCache = new Map<string, number[]>();
|
||||
|
||||
/** Deterministic per-char delays (original ft: FNV-1a seeded LCG). */
|
||||
function charDelays(
|
||||
text: string,
|
||||
count: number,
|
||||
spreadMs: number,
|
||||
salt?: string
|
||||
): number[] {
|
||||
const key = `${text}\u0000${spreadMs}\u0000${salt ?? ""}`;
|
||||
const cached = staggerCache.get(key);
|
||||
if (cached) return cached;
|
||||
let h = 0x811c9dc5;
|
||||
const seedText = salt ? `${text}\u0000${salt}` : text;
|
||||
for (let i = 0; i < seedText.length; i++) {
|
||||
h = Math.imul(h ^ seedText.charCodeAt(i), 0x1000193);
|
||||
}
|
||||
let state = h >>> 0;
|
||||
const next = () => {
|
||||
state = (state + 0x6d2b79f5) | 0;
|
||||
state = Math.imul(state ^ (state >>> 15), 1 | state);
|
||||
state = (state ^ (state + Math.imul(state ^ (state >>> 7), 61 | state))) | 0;
|
||||
return ((state >>> 0) % 0x100000000) / 0x100000000;
|
||||
};
|
||||
const delays: number[] =
|
||||
count <= 0
|
||||
? []
|
||||
: count === 1
|
||||
? [0]
|
||||
: Array.from({ length: count }, (_, i) => {
|
||||
const linear = (i / (count - 1)) * spreadMs * 0.7;
|
||||
const jitter = next() * spreadMs * 0.35;
|
||||
return Math.min(spreadMs, linear + jitter);
|
||||
});
|
||||
staggerCache.set(key, delays);
|
||||
return delays;
|
||||
}
|
||||
|
||||
const StaggerText = memo(function StaggerText({
|
||||
text,
|
||||
className,
|
||||
durationSec = 0.23,
|
||||
staggerSpreadMs = 290,
|
||||
groupDelayMs = 0,
|
||||
play = true,
|
||||
}: {
|
||||
text: string;
|
||||
className?: string;
|
||||
durationSec?: number;
|
||||
staggerSpreadMs?: number;
|
||||
groupDelayMs?: number;
|
||||
play?: boolean;
|
||||
}) {
|
||||
const chars = useMemo(() => Array.from(text), [text]);
|
||||
const [inDelays, outDelays] = useMemo(
|
||||
() => [
|
||||
charDelays(text, chars.length, staggerSpreadMs),
|
||||
charDelays(text, chars.length, staggerSpreadMs, "out"),
|
||||
],
|
||||
[chars.length, staggerSpreadMs, text]
|
||||
);
|
||||
const playedRef = useRef(false);
|
||||
useEffect(() => {
|
||||
if (play) playedRef.current = true;
|
||||
}, [play]);
|
||||
if (!(play || playedRef.current)) {
|
||||
return (
|
||||
<span className={className} style={{ opacity: 0 }}>
|
||||
{text}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<span className={className}>
|
||||
{chars.map((ch, i) => {
|
||||
const delay = ((play ? inDelays[i] : outDelays[i]) + groupDelayMs) / 1e3;
|
||||
return (
|
||||
<span
|
||||
key={`${i}-${ch}`}
|
||||
className="hsst-char"
|
||||
style={{
|
||||
opacity: play ? 0 : 1,
|
||||
animationName: play ? "hsstFadeIn" : "hsstFadeOut",
|
||||
animationDuration: `${durationSec}s`,
|
||||
animationDelay: `${delay}s`,
|
||||
animationTimingFunction: "linear",
|
||||
animationFillMode: "forwards",
|
||||
}}
|
||||
>
|
||||
{ch === " " ? "\u00A0" : ch}
|
||||
</span>
|
||||
);
|
||||
})}
|
||||
</span>
|
||||
);
|
||||
});
|
||||
StaggerText.displayName = "HyperSpaceStaggerText";
|
||||
|
||||
// --- Stage scroll state (original fh's inline hook) --------------------------
|
||||
|
||||
function useHyperStage(sectionGeom: { top: number; height: number } | null) {
|
||||
const [segmentIndex, setSegmentIndex] = useState(0);
|
||||
const [stage, setStage] = useState<Stage | null>(() => stageForSegment(0));
|
||||
const [seg0Reveal, setSeg0Reveal] = useState(false);
|
||||
const [staggerGen, setStaggerGen] = useState(0);
|
||||
const [stageProgress01, setStageProgress01] = useState(0);
|
||||
const lastSegmentRef = useRef(0);
|
||||
const stageRef = useRef<Stage | null>(stageForSegment(0));
|
||||
const inSeg0Ref = useRef(false);
|
||||
const wasAboveRef = useRef<boolean | null>(null);
|
||||
const viewportHRef = useRef(0);
|
||||
|
||||
// Viewport height (original useWindowSize height).
|
||||
useEffect(() => {
|
||||
const update = () => {
|
||||
viewportHRef.current = window.innerHeight;
|
||||
};
|
||||
update();
|
||||
window.addEventListener("resize", update, { passive: true });
|
||||
return () => window.removeEventListener("resize", update);
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
const compute = () => {
|
||||
if (!sectionGeom) return;
|
||||
const segH = segmentHeight(sectionGeom.height, viewportHRef.current);
|
||||
const scrollTop = Math.max(0, scrollBus.current);
|
||||
const intoSection = scrollTop - sectionGeom.top;
|
||||
const seg = clamp(Math.floor(Math.max(0, intoSection) / segH), 0, 7);
|
||||
if (seg !== lastSegmentRef.current) {
|
||||
lastSegmentRef.current = seg;
|
||||
setSegmentIndex(seg);
|
||||
}
|
||||
const nextStage = stageForSegment(seg);
|
||||
if (nextStage !== stageRef.current) {
|
||||
stageRef.current = nextStage;
|
||||
setStage(nextStage);
|
||||
}
|
||||
if (!nextStage || (nextStage !== "seg0-primary" && nextStage !== "seg0-secondary")) {
|
||||
// Leaving seg0 clears the reveal latch (original v.current = false).
|
||||
if (inSeg0Ref.current) {
|
||||
inSeg0Ref.current = false;
|
||||
setSeg0Reveal(false);
|
||||
}
|
||||
wasAboveRef.current = null;
|
||||
} else {
|
||||
const above = intoSection >= -0.2 * segH;
|
||||
const prev = wasAboveRef.current;
|
||||
if (prev === null) {
|
||||
wasAboveRef.current = above;
|
||||
if (above) {
|
||||
inSeg0Ref.current = true;
|
||||
setSeg0Reveal(true);
|
||||
setStaggerGen((g) => g + 1);
|
||||
}
|
||||
} else if (above !== prev) {
|
||||
wasAboveRef.current = above;
|
||||
if (above) {
|
||||
inSeg0Ref.current = true;
|
||||
setSeg0Reveal(true);
|
||||
setStaggerGen((g) => g + 1);
|
||||
} else {
|
||||
inSeg0Ref.current = false;
|
||||
setSeg0Reveal(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Stage progress (original y): within-stage scroll position 0..1.
|
||||
if (nextStage) {
|
||||
const found = STAGES.find((s) => s.stage === nextStage);
|
||||
if (found) {
|
||||
const [lo, hi] = found.range;
|
||||
const start = lo * segH;
|
||||
const into = intoSection - start;
|
||||
const span = (hi + 1) * segH - start;
|
||||
setStageProgress01(clamp(into / Math.max(1, span), 0, 1));
|
||||
}
|
||||
} else {
|
||||
setStageProgress01(0);
|
||||
}
|
||||
};
|
||||
compute();
|
||||
return subscribeScroll(compute);
|
||||
}, [sectionGeom]);
|
||||
|
||||
return { segmentIndex, stage, seg0Reveal, staggerGen, stageProgress01 };
|
||||
}
|
||||
|
||||
// --- Viewport-enter hook (original useHasEnteredViewport, minimal) ----------
|
||||
|
||||
function useHasEnteredViewport<T extends Element>({
|
||||
once = false,
|
||||
threshold = 0,
|
||||
rootMargin = "0px",
|
||||
}: {
|
||||
once?: boolean;
|
||||
threshold?: number;
|
||||
rootMargin?: string;
|
||||
}) {
|
||||
const ref = useRef<T | null>(null);
|
||||
const [hasEntered, setHasEntered] = useState(false);
|
||||
useEffect(() => {
|
||||
const el = ref.current;
|
||||
if (!el) return;
|
||||
const io = new IntersectionObserver(
|
||||
([entry]) => {
|
||||
if (entry.isIntersecting) {
|
||||
setHasEntered(true);
|
||||
if (once) io.disconnect();
|
||||
} else if (!once) {
|
||||
setHasEntered(false);
|
||||
}
|
||||
},
|
||||
{ threshold, rootMargin }
|
||||
);
|
||||
io.observe(el);
|
||||
return () => io.disconnect();
|
||||
}, [once, threshold, rootMargin]);
|
||||
return { ref, hasEntered };
|
||||
}
|
||||
|
||||
// --- Stage renderers (original fm/fg/fv) -------------------------------------
|
||||
|
||||
function Seg0({
|
||||
stage,
|
||||
reveal,
|
||||
staggerGen,
|
||||
}: {
|
||||
stage: "seg0-primary" | "seg0-secondary";
|
||||
reveal: boolean;
|
||||
staggerGen: number;
|
||||
}) {
|
||||
const isPrimary = stage === "seg0-primary";
|
||||
const lines = isPrimary ? SEG0_PRIMARY : SEG0_SECONDARY;
|
||||
return (
|
||||
<div
|
||||
className="flex flex-col justify-center items-center col-span-12 row-span-6 font-bold text-[7.2svw] lg:text-[6.8svw] uppercase leading-none"
|
||||
style={{ fontVariationSettings: '"wdth" 120' }}
|
||||
>
|
||||
{lines.map((line, i) => (
|
||||
<StaggerText
|
||||
key={i === 0 ? `${staggerGen}-${isPrimary ? "primary" : "secondary"}-stable-0` : `${staggerGen}-${isPrimary ? "primary" : "secondary"}-${i}`}
|
||||
text={line}
|
||||
play={reveal}
|
||||
groupDelayMs={100 * i}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function Seg1({ ringProgress01 }: { ringProgress01: number }) {
|
||||
return (
|
||||
<>
|
||||
<Ring progress01={ringProgress01} />
|
||||
<div className="col-span-8 lg:col-span-4 col-start-1 lg:col-start-7 row-start-2 p-2 font-medium text-[5.6svw] lg:text-3xl leading-tight">
|
||||
<StaggerText text="Building tomorrow's" />
|
||||
<br />
|
||||
<StaggerText text="digital products." />
|
||||
</div>
|
||||
<div className="col-span-8 lg:col-span-4 col-start-5 lg:col-start-9 row-start-3 p-2 font-medium text-[5.6svw] lg:text-3xl leading-tight">
|
||||
<StaggerText text="Independent by" />
|
||||
<br />
|
||||
<StaggerText text="design & engineering." />
|
||||
</div>
|
||||
<div className="col-span-8 lg:col-span-4 col-start-1 lg:col-start-2 row-start-4 p-2 font-medium text-[5.6svw] lg:text-3xl leading-tight">
|
||||
<StaggerText text="Clarity first." />
|
||||
<br />
|
||||
<StaggerText text="Delight second." />
|
||||
</div>
|
||||
<div className="col-span-8 lg:col-span-4 col-start-5 lg:col-start-4 row-start-5 p-2 font-medium text-[5.6svw] lg:text-3xl leading-tight">
|
||||
<StaggerText text="Ship in small loops." />
|
||||
<br />
|
||||
<StaggerText text="Aim for long arcs." />
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function EndStage() {
|
||||
const { ref, hasEntered } = useHasEnteredViewport<HTMLDivElement>({ threshold: 0.35 });
|
||||
return (
|
||||
<div
|
||||
ref={ref}
|
||||
className="flex flex-col justify-center items-center col-span-12 row-span-6 font-bold text-[7.2svw] lg:text-[6.8svw] uppercase leading-none"
|
||||
style={{ fontVariationSettings: '"wdth" 120' }}
|
||||
>
|
||||
{END_LINES.map((line, i) => (
|
||||
<StaggerText key={line} text={line} play={hasEntered} groupDelayMs={100 * i} />
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// --- Section (original fh) ---------------------------------------------------
|
||||
|
||||
export default function HyperSpaceSection() {
|
||||
const sectionRef = useRef<HTMLElement | null>(null);
|
||||
const [geom, setGeom] = useState<{ top: number; height: number } | null>(null);
|
||||
const pastThreshold = useArrowFullscreenPastThreshold();
|
||||
const { height: viewportH } = useWindowSize();
|
||||
|
||||
// Live geometry (original: the shared section-map measures every section).
|
||||
useEffect(() => {
|
||||
const measure = () => {
|
||||
const el = sectionRef.current;
|
||||
if (el) setGeom({ top: el.offsetTop, height: el.offsetHeight });
|
||||
};
|
||||
measure();
|
||||
window.addEventListener("resize", measure);
|
||||
document.fonts?.ready?.then(measure).catch(() => {});
|
||||
const t = window.setTimeout(measure, 500);
|
||||
return () => {
|
||||
window.removeEventListener("resize", measure);
|
||||
window.clearTimeout(t);
|
||||
};
|
||||
}, []);
|
||||
|
||||
// The WebGL arrow (HyperspaceModel) tracks this section's screen rect via
|
||||
// the shared layer-registry target record — getLayerTarget creates it on
|
||||
// first access (the ref callback below fills .current). No texture def is
|
||||
// registered: unlike the work/about layers, this target is rect-only and
|
||||
// must NOT appear in the ImageLayers texture pipeline.
|
||||
|
||||
const { segmentIndex, stage, seg0Reveal, staggerGen, stageProgress01 } =
|
||||
useHyperStage(geom);
|
||||
|
||||
return (
|
||||
<section
|
||||
id={HYPER_SPACE_SECTION_ID}
|
||||
ref={(el) => {
|
||||
sectionRef.current = el;
|
||||
getLayerTarget("hyper-space").current = el;
|
||||
void el;
|
||||
}}
|
||||
className={`relative ${ARROW_FULLSCREEN_DOM_COLOR_TRANSITION} ${
|
||||
pastThreshold ? "text-white" : "text-l1"
|
||||
}`}
|
||||
style={{ height: `${8 * viewportH}px` }}
|
||||
>
|
||||
<div
|
||||
className="top-0 sticky grid grid-cols-12 grid-rows-6 px-4 lg:px-14 py-18 lg:py-24 w-full"
|
||||
style={{ minHeight: `${viewportH}px` }}
|
||||
>
|
||||
{stage === "seg0-primary" || stage === "seg0-secondary" ? (
|
||||
<Seg0 stage={stage} reveal={seg0Reveal} staggerGen={staggerGen} />
|
||||
) : stage === "seg1" ? (
|
||||
<Seg1 ringProgress01={stageProgress01} />
|
||||
) : stage === "end" ? (
|
||||
<EndStage />
|
||||
) : (
|
||||
<div className="col-span-12 row-span-6" data-segment={segmentIndex} />
|
||||
)}
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
import { useEffect } from 'react';
|
||||
import Lenis from 'lenis';
|
||||
import { scrollBus } from '@/lib/scrollBus';
|
||||
import { scrollBus, notifyScroll } from '@/lib/scrollBus';
|
||||
import { scrollEnv } from '@/lib/scrollEnv';
|
||||
|
||||
const clamp01 = (v: number) => Math.min(1, Math.max(0, v));
|
||||
@@ -67,6 +67,7 @@ export default function SmoothScroller() {
|
||||
scrollBus.velocity = e.velocity;
|
||||
scrollBus.progress = e.progress;
|
||||
updateCameraProgress();
|
||||
notifyScroll();
|
||||
});
|
||||
window.addEventListener('resize', updateCameraProgress);
|
||||
updateCameraProgress();
|
||||
|
||||
Reference in New Issue
Block a user