cobe-globe
eldoraui/cobe-globeFreeComponent
A cobe globe component.
Live preview
live · rendered by the registry
Rendered by eldoraui on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://eldoraui.site/r/cobe-globe.jsonSource
1"use client"23import { useCallback, useEffect, useRef, useState } from "react"4import createGlobe from "cobe"5import { useSpring } from "react-spring"67import { cn } from "@/lib/utils"8import { Button } from "@/components/ui/button"910type CobeVariant =11 | "default"12 | "draggable"13 | "auto-draggable"14 | "auto-rotation"15 | "rotate-to-location"16 | "scaled"1718interface Location {19 name: string20 lat?: number21 long?: number22 emoji?: string23}2425interface GeocodeResult {26 lat: number27 lng: number28 display_name: string29}3031interface CobeProps {32 variant?: CobeVariant33 className?: string34 style?: React.CSSProperties35 locations?: Location[]36 // Globe configuration settings37 phi?: number38 theta?: number39 mapSamples?: number40 mapBrightness?: number41 mapBaseBrightness?: number42 diffuse?: number43 dark?: number44 baseColor?: string45 markerColor?: string46 markerSize?: number47 glowColor?: string48 scale?: number49 offsetX?: number50 offsetY?: number51 opacity?: number52}5354type CobeState = Record<string, unknown>5556export function Cobe({57 variant = "default",58 className,59 style,60 locations = [61 { name: "San Francisco", emoji: "📍" },62 { name: "Berlin", emoji: "📍" },63 { name: "Tokyo", emoji: "📍" },64 { name: "Buenos Aires", emoji: "📍" },65 ],66 // Default values based on the original JSX version67 phi = 0,68 theta = 0.2,69 mapSamples = 16000,70 mapBrightness = 1.8,71 mapBaseBrightness = 0.05,72 diffuse = 3,73 dark = 1.0,74 baseColor = "#ffffff",75 markerColor = "#fb6415",76 markerSize = 0.05,77 glowColor = "#ffffff",78 scale = 1.0,79 offsetX = 0.0,80 offsetY = 0.0,81 opacity = 0.7,82}: CobeProps) {83 const canvasRef = useRef<HTMLCanvasElement>(null)84 const pointerInteracting = useRef<number | null>(null)85 const pointerInteractionMovement = useRef<number>(0)86 const focusRef = useRef<[number, number]>([0, 0])87 const [customLocations, setCustomLocations] = useState<Location[]>([])88 const [isInitializing, setIsInitializing] = useState(true)8990 const [{ r }, api] = useSpring<{ r: number }>(() => ({91 r: 0,92 config: {93 mass: 1,94 tension: 280,95 friction: 40,96 precision: 0.001,97 },98 }))99100 const locationToAngles = (lat: number, long: number): [number, number] => {101 return [102 Math.PI - ((long * Math.PI) / 180 - Math.PI / 2),103 (lat * Math.PI) / 180,104 ] as [number, number]105 }106107 const hexToRgb = (hex: string): [number, number, number] => {108// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from eldoraui
All 115 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| animated-badgeanimated-badge | eldoraui | Components | Free | 2 deps | |
| animated-frameworksanimated-frameworks | eldoraui | Components | Free | 2 deps | |
| animated-grid-patternanimated-grid-pattern | eldoraui | Components | Free | 3 deps | |
| animated-listanimated-list | eldoraui | Components | Free | 1 dep | |
| animated-shiny-buttonanimated-shiny-button | eldoraui | Components | Free | 1 dep | |
| blur-in-textblur-in-text | eldoraui | Components | Free | 3 deps | |
| browserbrowser | eldoraui | Components | Free | 2 deps | |
| card-flip-hovercard-flip-hover | eldoraui | Components | Free | 1 dep |
