BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/threecn/tesseract

Tesseract

threecn/tesseract
FreeComponent

A 4D hypercube in double rotation projected into 3D — the inner cell endlessly swells through the outer, struts shading --accent to --primary by 4D depth.

Install it

npx shadcn@latest add https://threecn.dev/r/tesseract.json

Source

components/threecn/tesseract.tsxthreecn.dev/r/tesseract.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
16/** The 16 corners of a unit hypercube: every sign combination of (±1,±1,±1,±1). */
17const VERTS4: [number, number, number, number][] = Array.from(
18 { length: 16 },
19 (_, i) => [i & 1 ? 1 : -1, i & 2 ? 1 : -1, i & 4 ? 1 : -1, i & 8 ? 1 : -1]
20)
21
22/** The 32 edges connect corners that differ in exactly one coordinate. */
23const EDGES: [number, number][] = []
24for (let i = 0; i < 16; i++) {
25 for (let b = 0; b < 4; b++) {
26 const j = i | (1 << b)
27 if (j !== i) EDGES.push([i, j])
28 }
29}
30
31/** Distance of the virtual 4D "camera" used for the w-perspective projection. */
32const K = 3
33/** Shrinks the projection so the swelling outer cell stays in frame. */
34const BASE_SCALE = 0.62
35const UP = new THREE.Vector3(0, 1, 0)
36
37/**
38 * Per-frame scratch for each corner's normalized 4D depth. Written in full,
39 * then read, inside a single frame callback — safe to share at module level.
40 */
41const depths = new Float32Array(VERTS4.length)
42
43function Hypercube({
44 size,
45 speed,
46 thickness,
47 theme,
48}: {
49 size: number
50 speed: number
51 thickness: number
52 theme: ThemeMode
53}) {
54 const { primaryColor, accentColor } = useShadcnTheme(theme)
55 const groupRef = React.useRef<THREE.Group>(null)
56 const nodesRef = React.useRef<THREE.InstancedMesh>(null)
57 const strutsRef = React.useRef<THREE.InstancedMesh>(null)
58 const dummy = React.useMemo(() => new THREE.Object3D(), [])
59 const tmpColor = React.useMemo(() => new THREE.Color(), [])
60 const tmpDir = React.useMemo(() => new THREE.Vector3(), [])
61 const points = React.useMemo(() => VERTS4.map(() => new THREE.Vector3()), [])
62
63 useFrame(({ clock }) => {
64 const nodes = nodesRef.current
65 const struts = strutsRef.current
66 const group = groupRef.current
67 if (!nodes || !struts || !group) return
68 const t = clock.getElapsedTime() * speed
69 group.rotation.y = t * 0.16
70 group.rotation.x = 0.32 + Math.sin(t * 0.2) * 0.12
71
72 // Double rotation in two orthogonal 4D planes (XW and YZ) — the classic
73 // tesseract motion where the inner cell turns itself inside out.
74 const ca = Math.cos(t * 0.55)
75 const sa = Math.sin(t * 0.55)
76 const cb = Math.cos(t * 0.38)
77 const sb = Math.sin(t * 0.38)
78
79// … truncated

What it pulls in

npm packages

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

Files it writes

  • components/threecn/tesseract.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