BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/threecn/warp-tunnel

WarpTunnel

threecn/warp-tunnel
FreeComponent

Hyperspace star streaks racing past the camera, from --foreground heads to --primary tails.

Install it

npx shadcn@latest add https://threecn.dev/r/warp-tunnel.json

Source

components/threecn/warp-tunnel.tsxthreecn.dev/r/warp-tunnel.json
1"use client"
2
3import * as React from "react"
4import { useFrame } from "@react-three/fiber"
5import * as THREE from "three"
6
7import {
8 SceneContainer,
9 type SceneContainerProps,
10} from "@/components/threecn/scene-container"
11import {
12 useShadcnTheme,
13 type ThemeMode,
14} from "@/components/hooks/use-shadcn-theme"
15
16const NEAR_Z = 5
17const FAR_Z = -45
18
19function randomStreak(spread: number, out: Float32Array, offset: number, z?: number) {
20 // Bias stars away from the exact center so the camera has a clear "eye".
21 const r = 0.4 + Math.sqrt(Math.random()) * spread
22 const a = Math.random() * Math.PI * 2
23 const x = Math.cos(a) * r
24 const y = Math.sin(a) * r * 0.65
25 const zz = z ?? FAR_Z + Math.random() * (NEAR_Z - FAR_Z)
26 const len = 1 + Math.random() * 1.6
27 out[offset] = x
28 out[offset + 1] = y
29 out[offset + 2] = zz
30 out[offset + 3] = x
31 out[offset + 4] = y
32 out[offset + 5] = zz - len
33}
34
35function seedStreaks(count: number, spread: number) {
36 const positions = new Float32Array(count * 6)
37 for (let i = 0; i < count; i++) randomStreak(spread, positions, i * 6)
38 return positions
39}
40
41function Streaks({
42 count,
43 speed,
44 spread,
45 theme,
46}: {
47 count: number
48 speed: number
49 spread: number
50 theme: ThemeMode
51}) {
52 const { primaryColor, foregroundColor, isDark } = useShadcnTheme(theme)
53 const geoRef = React.useRef<THREE.BufferGeometry>(null)
54
55 const positions = React.useMemo(
56 () => seedStreaks(count, spread),
57 [count, spread]
58 )
59 const colors = React.useMemo(() => new Float32Array(count * 6), [count])
60
61 // Head = bright (foreground tinted with primary), tail = dim primary so
62 // additive blending fades the streak out naturally.
63 React.useLayoutEffect(() => {
64 const geo = geoRef.current
65 if (!geo) return
66 const colorAttr = geo.getAttribute("color") as THREE.BufferAttribute
67 const arr = colorAttr.array as Float32Array
68 const head = new THREE.Color()
69 .copy(foregroundColor)
70 .lerp(primaryColor, 0.4)
71 const tail = new THREE.Color()
72 .copy(primaryColor)
73 .multiplyScalar(isDark ? 0.12 : 0.55)
74 for (let i = 0; i * 6 < arr.length; i++) {
75 const o = i * 6
76 arr[o] = head.r
77 arr[o + 1] = head.g
78 arr[o + 2] = head.b
79 arr[o + 3] = tail.r
80 arr[o + 4] = tail.g
81 arr[o + 5] = tail.b
82 }
83 colorAttr.needsUpdate = true
84 }, [count, primaryColor, foregroundColor, isDark])
85
86 useFrame((_, delta) => {
87 const geo = geoRef.current
88 if (!geo) return
89// … truncated

What it pulls in

npm packages

  • three
  • @react-three/fiber
  • @react-three/drei

Files it writes

  • components/threecn/warp-tunnel.tsx
  • components/threecn/scene-container.tsx
  • components/hooks/use-shadcn-theme.ts

Facts

Registry
threecn
Type
registry:ui
Access
Free
Files written
3
Licence
MIT
First indexed
2026-08-03
Last confirmed
yesterday

Go to the source

threecn.dev ln-dev7/threecn on GitHub Raw registry item This item as JSON

More from threecn

All 28 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
AuroraRibbonsaurora-ribbonsthreecnComponentsFree3 deps · 3 files
BoidsboidsthreecnComponentsFree3 deps · 3 files
ClothcloththreecnComponentsFree3 deps · 3 files
CrystalcrystalthreecnComponentsFree3 deps · 3 files
CubeWavecube-wavethreecnComponentsFree3 deps · 3 files
CurlFlowcurl-flowthreecnComponentsFree3 deps · 3 files
DnaHelixdna-helixthreecnComponentsFree3 deps · 3 files
FloatingCard3Dfloating-card-3dthreecnComponentsFree3 deps · 3 files
BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex