← All components Next componentTerrain Divider→
Extras · Loader
Gyroscopic Loader
Nested chrome rings spinning in sync around a levitating core that lights them, surging while work is in progress.
<GyroscopicLoader3D />Live
Pass loading={false} to let it settle
Customize
Rings#e4e4e7
Core#a78bfa
Installation
Use it in your project
Or skip the copy-paste
One command: writes the file and installs the dependencies.
$ npx deepui-cli add gyroscopic-loader
01
Install
The 3D packages this component is built on.
$ npm install three @react-three/fiber @react-three/drei && npm install -D @types/three
02
Add the component
One self-contained file: create components/GyroscopicLoader3D.tsx and paste it in.
components/GyroscopicLoader3D.tsx
1"use client";23import { memo, useEffect, useMemo, useRef, useState, type CSSProperties, type ReactNode } from "react";4import * as THREE from "three";5import { Canvas, useFrame, type CanvasProps } from "@react-three/fiber";6import { Environment, Lightformer } from "@react-three/drei";78/**9 * The shared props API of DeepUI's individual 3D components (not the full-page templates, which keep10 * their own tailored scenes).11 *12 * The props are grouped by concern. A component extends ONLY the groups it really applies, so its13 * type never advertises a knob that does nothing (a card has no particles, a background has no tilt):14 *15 * interface MyCardProps extends CursorProps, TiltProps, MaterialProps, PerformanceProps { … }16 *17 * `Base3DComponentProps` is every group at once, for tooling that handles any component. Same name,18 * same unit and same meaning everywhere; the default values live in DEFAULT_3D_PROPS. These files are19 * inlined into each component's single-file bundle (lib/bundle-source.mjs), only what it uses.20 */2122/** Which rotation axes follow the pointer. "x-only": the object nods (up / down); "y-only": it turns (left / right). */23export type TiltAxis = "both" | "x-only" | "y-only" | "none";2425/** 1. Cursor: how the pointer pulls, pushes and drags the object. */26interface CursorProps {27 /** 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). */28 cursorRadius?: number;29 /** Positive pulls things towards the pointer, negative pushes them away (repulsion, shockwave). Default 1. */30 cursorForce?: number;31 /** How far the object slides towards the pointer, 0 (stays put) to 1 (follows closely). Default 0. */32 magneticStrength?: number;33 /** Share of the remaining distance the motion closes each frame (at 60 fps), 0.01 (heavy, slow) to 1 (instant). Default 0.1. */34 cursorDamping?: number;35}3637/** 2. Tilt and parallax: the object leans towards the pointer, its layers slide against each other. */38interface TiltProps {39 /** Largest lean towards the pointer, in degrees. Default 15. */40 maxTiltAngle?: number;41 /** Axes that follow the pointer. Default "both". */42 tiltAxis?: TiltAxis;43 /** Lean away from the pointer instead of towards it. Default false. */44 invertTilt?: boolean;45 /** How far apart the depth layers slide when the object tilts, 0 (flat) to 2. Default 1. */46 parallaxOffset?: number;47}4849/** 3. Text and 3D typography, for components that draw a label. */50interface Text3DProps {51 /** The label drawn by the component. */52 text?: string;53 /** Scale of the lettering. Default 1. */54 fontSize?: number;55 /** Extrusion depth of 3D letters. Default 0.2. */56 textDepth?: number;57 /** Bevelled, light-catching edges on 3D letters. Default true. */58 bevelEnabled?: boolean;59 /** Custom font: a .woff / .ttf (flat text) or a typeface .json (extruded text). */60 fontUrl?: string;61}6263/** 4. Rendering, materials and glow. */64interface MaterialProps {65 /** Main color of the object. Default "#6366f1". */66 primaryColor?: string;67 /** Color of the glow. Default "#00f0ff". */68 emissiveColor?: string;69 /** Strength of the glow, 0 (none) to 3. Default 1. */70 emissiveIntensity?: number;71 /** 0 (mirror, glass) to 1 (matte). Default 0.3. */72 roughness?: number;73 /** 0 (plastic, organic) to 1 (metal). Default 0.5. */74 metalness?: number;75 /** 0 (opaque) to 1 (clear glass): see-through, refracting surfaces. Default 0. */76 transmission?: number;77 /** Technical wireframe rendering. Default false. */78 wireframe?: boolean;79}8081/** 5. Particles, idle motion and shader animation. */82interface MotionProps {83 /** Number of instanced elements. Default depends on the component. */84 particleCount?: number;85 /** Spin on its own, in radians per second (negative: the other way; 0.5 ≈ one turn in 12 s). Default 0. */86 autoRotateSpeed?: number;87 /** Pulses or ripples per second. Default 1. */88 pulseRate?: number;89 /** Amplitude of the noise deformation, 0 (none) to 2. Default 1. */90 displacementScale?: number;91}9293/** 6. Environment and camera. */94interface EnvironmentProps {95 /** Camera field of view, in degrees. Default depends on the component. */96 cameraFov?: number;97 /** Color of the depth fog. Default "#0a0a0a". */98 fogColor?: string;99 /** Thickness of the fog, 0 (none) to 0.2. Default 0. */100 fogDensity?: number;101}102103/** 7. Performance and accessibility. */104interface PerformanceProps {105 /** Lighter rendering for weak devices: pixel ratio 1, fewer instances, smaller environment maps. Default false. */106 lowPowerMode?: boolean;107 /** Under the OS "reduce motion" setting, stop idle spin, pulses and deformation (pointer feedback stays). Default true. */108 respectReducedMotion?: boolean;109 /** Stop the render loop while the component is scrolled out of view. Default true. */110 pauseWhenOffscreen?: boolean;111}112113/** Every group at once. Components extend only the groups they apply (see the top of this file). */114interface Base3DComponentProps115 extends CursorProps,116 TiltProps,117 Text3DProps,118 MaterialProps,119 MotionProps,120 EnvironmentProps,121 PerformanceProps {}122123type Defaults = Required<Omit<Base3DComponentProps, "text" | "fontUrl" | "particleCount" | "cameraFov">>;124125/** The values a prop takes when it is left out. A component may override one, and then documents it. */126const DEFAULT_3D_PROPS: Defaults = {127 cursorRadius: 220,128 cursorForce: 1,129 magneticStrength: 0,130 cursorDamping: 0.1,131 maxTiltAngle: 15,132 tiltAxis: "both",133 invertTilt: false,134 parallaxOffset: 1,135 fontSize: 1,136 textDepth: 0.2,137 bevelEnabled: true,138 primaryColor: "#6366f1",139 emissiveColor: "#00f0ff",140 emissiveIntensity: 1,141 roughness: 0.3,142 metalness: 0.5,143 transmission: 0,144 wireframe: false,145 autoRotateSpeed: 0,146 pulseRate: 1,147 displacementScale: 1,148 fogColor: "#0a0a0a",149 fogDensity: 0,150 lowPowerMode: false,151 respectReducedMotion: true,152 pauseWhenOffscreen: true,153};154155/** Inline widget: fills its positioned parent and receives pointer events. */156const FILL_STYLE: CSSProperties = { position: "absolute", top: 0, left: 0, width: "100%", height: "100%" };157158/** Cursor overlay: covers the viewport, above everything, never intercepts the page's events. */159const OVERLAY_STYLE: CSSProperties = {160 position: "fixed",161 top: 0,162 left: 0,163 width: "100%",164 height: "100%",165 pointerEvents: "none",166 zIndex: 9999,167};168169interface UICanvasProps extends Omit<CanvasProps, "children" | "style" | "gl">, Pick<PerformanceProps, "pauseWhenOffscreen" | "lowPowerMode"> {170 children: ReactNode;171 /** Full-viewport, click-through overlay (cursors) instead of an inline widget. */172 overlay?: boolean;173}174175/**176 * Ready-to-use <Canvas>: pauses its render loop while scrolled out of view (pauseWhenOffscreen), pixel177 * ratio 1 in lowPowerMode; R3F disposes the renderer and its WebGL context on unmount.178 */179function UICanvas({ children, overlay = false, dpr = [1, 2], pauseWhenOffscreen = DEFAULT_3D_PROPS.pauseWhenOffscreen, lowPowerMode = DEFAULT_3D_PROPS.lowPowerMode, ...canvasProps }: UICanvasProps) {180 const containerRef = useRef<HTMLDivElement>(null);181 // In view at first: the first frame is always drawn before the loop can be paused182 const [inView, setInView] = useState(true);183 useEffect(() => {184 const el = containerRef.current;185 if (!el || !pauseWhenOffscreen) return undefined;186 const observer = new IntersectionObserver(([entry]) => setInView(entry.isIntersecting));187 observer.observe(el);188 return () => observer.disconnect();189 }, [pauseWhenOffscreen]);190 return (191 <div ref={containerRef} style={overlay ? OVERLAY_STYLE : FILL_STYLE} aria-hidden="true">192 <Canvas193 dpr={lowPowerMode ? 1 : dpr}194 frameloop={inView || !pauseWhenOffscreen ? "always" : "never"}195 gl={{ antialias: true, alpha: true, powerPreference: "high-performance" }}196 style={overlay ? { pointerEvents: "none" } : undefined}197 {...canvasProps}198 >199 {children}200 </Canvas>201 </div>202 );203}204205export interface GyroscopicLoaderProps extends Pick<MaterialProps, "primaryColor" | "emissiveColor">, Pick<PerformanceProps, "pauseWhenOffscreen" | "lowPowerMode"> {206 primaryColor?: string;207 /** @deprecated Use `primaryColor`. */208 ringColor?: string;209 emissiveColor?: string;210 /** @deprecated Use `emissiveColor`. */211 coreColor?: string;212 /** Spin speed multiplier. Default 1. */213 speed?: number;214 /** Number of nested rings, 2–6. Default 3. */215 ringCount?: number;216 /** While true, the rings accelerate in waves (work in progress); false settles them to an idle spin. Default true. */217 loading?: boolean;218 /** Accessible label. Default "Loading". */219 label?: string;220}221222const OUTER_RADIUS = 1.45;223const RING_STEP = 0.27;224const TUBE = 0.055;225// Each ring turns on its own axis; the speed ratios are simple fractions, so the rings stay in phase226const AXES: ("x" | "y" | "z")[] = ["x", "y", "z"];227const RATIOS = [1, -1.5, 2, -2.5, 3, -3.5];228229const glowFragment = /* glsl */ `230uniform vec3 uColor;231uniform float uPulse;232varying vec2 vUv;233void main() {234 float d = length(vUv - 0.5) * 2.0;235 float glow = exp(-d * d * 7.0) * (0.75 + uPulse * 0.5) + exp(-d * 2.6) * 0.25;236 gl_FragColor = vec4(uColor * glow, glow);237 #include <colorspace_fragment>238}239`;240241const Gyroscope = memo(function Gyroscope({ ringColor, coreColor, speed, ringCount, loading }: Required<Omit<GyroscopicLoaderProps, "primaryColor" | "emissiveColor" | "pauseWhenOffscreen" | "lowPowerMode" | "label">>) {242 const count = THREE.MathUtils.clamp(Math.round(ringCount), 2, 6);243 const ringRefs = useRef<(THREE.Mesh | null)[]>([]);244 const assembly = useRef<THREE.Group>(null);245 const core = useRef<THREE.Group>(null);246 const light = useRef<THREE.PointLight>(null);247 const motion = useRef({ phase: 0, boost: 0 });248249 const geometries = useMemo(250 () => Array.from({ length: count }, (_, i) => new THREE.TorusGeometry(OUTER_RADIUS - i * RING_STEP, TUBE, 24, 128)),251 [count]252 );253 const ringMaterial = useMemo(() => new THREE.MeshPhysicalMaterial({ metalness: 1, roughness: 0.12, clearcoat: 1, envMapIntensity: 1.4 }), []);254 const coreGeometry = useMemo(() => new THREE.SphereGeometry(0.2, 32, 32), []);255 const coreMaterial = useMemo(() => new THREE.MeshBasicMaterial({ toneMapped: false }), []);256 const glowGeometry = useMemo(() => new THREE.PlaneGeometry(1.8, 1.8), []);257 const glowMaterial = useMemo(258 () =>259 new THREE.ShaderMaterial({260 uniforms: { uColor: { value: new THREE.Color() }, uPulse: { value: 0 } },261 vertexShader: /* glsl */ `262 varying vec2 vUv;263 void main() { vUv = uv; gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0); }264 `,265 fragmentShader: glowFragment,266 transparent: true,267 depthWrite: false,268 blending: THREE.AdditiveBlending,269 }),270 []271 );272273 useEffect(() => {274 ringMaterial.color.set(ringColor);275 coreMaterial.color.set(coreColor).multiplyScalar(1.6);276 (glowMaterial.uniforms.uColor.value as THREE.Color).set(coreColor);277 light.current?.color.set(coreColor);278 }, [ringMaterial, coreMaterial, glowMaterial, ringColor, coreColor]);279 useEffect(() => () => geometries.forEach((g) => g.dispose()), [geometries]);280 useEffect(281 () => () => {282 [ringMaterial, coreMaterial, glowMaterial].forEach((m) => m.dispose());283 coreGeometry.dispose();284 glowGeometry.dispose();285 },286 [ringMaterial, coreMaterial, glowMaterial, coreGeometry, glowGeometry]287 );288289 useFrame((state, delta) => {290 const dt = Math.min(delta, 1 / 30);291 const t = state.clock.elapsedTime;292 const m = motion.current;293294 // Loading: the spin surges in waves; idle: it settles to a calm turn295 const surge = loading ? 0.5 + 0.9 * Math.pow(0.5 + 0.5 * Math.sin(t * 1.4), 3) : 0;296 m.boost = THREE.MathUtils.damp(m.boost, surge, 3, dt);297 m.phase += dt * speed * (0.8 + m.boost * 2.2);298299 ringRefs.current.forEach((ring, i) => {300 if (!ring) return;301 ring.rotation[AXES[i % 3]] = m.phase * RATIOS[i];302 });303 if (assembly.current) {304 assembly.current.rotation.x = 0.35 + Math.sin(t * 0.3) * 0.08;305 assembly.current.rotation.y = t * 0.15 * speed;306 }307308 // The core levitates and pulses with the surges309 if (core.current) {310 core.current.position.y = Math.sin(t * 2) * 0.06;311 core.current.scale.setScalar(1 + m.boost * 0.18 + Math.sin(t * 6) * 0.03);312 }313 glowMaterial.uniforms.uPulse.value = m.boost;314 if (light.current) light.current.intensity = 6 + m.boost * 10;315 });316317 return (318 <>319 <group ref={assembly}>320 {geometries.map((geometry, i) => (321 // Nested groups: a fixed base orientation per ring, then its own spin322 <group key={i} rotation={[i * 0.6, i * 0.9, i * 0.3]}>323 <mesh324 ref={(mesh) => {325 ringRefs.current[i] = mesh;326 }}327 geometry={geometry}328 material={ringMaterial}329 />330 </group>331 ))}332 </group>333 <group ref={core}>334 <mesh geometry={coreGeometry} material={coreMaterial} />335 <mesh geometry={glowGeometry} material={glowMaterial} />336 {/* The core lights the inside of the rings in its own color */}337 <pointLight ref={light} intensity={6} distance={4} decay={2} />338 </group>339 </>340 );341});342343/** Self-contained loader: fills its positioned parent; announced to screen readers as a busy status. */344function GyroscopicLoader3D({345 primaryColor,346 ringColor = primaryColor ?? "#e4e4e7",347 emissiveColor,348 coreColor = emissiveColor ?? "#a78bfa",349 speed = 1,350 ringCount = 3,351 loading = true,352 label = "Loading",353 pauseWhenOffscreen,354 lowPowerMode,355}: GyroscopicLoaderProps) {356 return (357 <div role="status" aria-live="polite" aria-busy={loading} aria-label={label} style={{ position: "absolute", inset: 0 }}>358 <UICanvas pauseWhenOffscreen={pauseWhenOffscreen} lowPowerMode={lowPowerMode} camera={{ position: [0, 0, 6], fov: 35 }}>359 <Environment resolution={128} frames={1}>360 <Lightformer form="rect" intensity={3} position={[0, 4, 3]} rotation-x={Math.PI / 2} scale={[8, 2, 1]} />361 <Lightformer form="rect" intensity={1.5} position={[-4, 0, 2]} rotation-y={Math.PI / 2} scale={[1, 6, 1]} />362 <Lightformer form="ring" intensity={3} position={[3, -1, 4]} scale={1.5} />363 </Environment>364 <Gyroscope ringColor={ringColor} coreColor={coreColor} speed={speed} ringCount={ringCount} loading={loading} />365 </UICanvas>366 </div>367 );368}369370export default memo(GyroscopicLoader3D);
03
Drop it in a page
Updated live with the settings above.
app/page.tsx
1import GyroscopicLoader3D from "@/components/GyroscopicLoader3D";23export default function Section() {4 return (5 // The component fills this box: give it a position and a height6 <div style={{ position: "relative", width: "100%", height: "100vh" }}>7 <GyroscopicLoader3D8 ringCount={3}9 speed={1}10 primaryColor="#e4e4e7"11 emissiveColor="#a78bfa"12 />13 </div>14 );15}