card-globe
ui-layouts-aiveilix/card-globeFreeComponent
ui-layouts publishes no description for this item.
Install it
npx shadcn@latest add https://raw.githubusercontent.com/jutt313/AIVEILIX-old/main/for ui/apps/ui-layout/public/r/card-globe.jsonSource
1'use client';2import React, { useEffect, useRef, useState } from 'react';3import createGlobe from 'cobe';4import { cn } from '@/lib/utils';5interface EarthProps {6 className?: string;7 theta?: number;8 dark?: number;9 scale?: number;10 diffuse?: number;11 mapSamples?: number;12 mapBrightness?: number;13 baseColor?: [number, number, number];14 markerColor?: [number, number, number];15 glowColor?: [number, number, number];16}17const Earth: React.FC<EarthProps> = ({18 className,19 theta = 0.25,20 dark = 1,21 scale = 1.1,22 diffuse = 1.2,23 mapSamples = 40000,24 mapBrightness = 6,25 baseColor = [0.4, 0.6509, 1],26 markerColor = [1, 0, 0],27 glowColor = [0.2745, 0.5765, 0.898],28}) => {29 const canvasRef = useRef<HTMLCanvasElement>(null);3031 useEffect(() => {32 let width = 0;33 const onResize = () =>34 canvasRef.current && (width = canvasRef.current.offsetWidth);35 window.addEventListener('resize', onResize);36 onResize();37 let phi = 0;3839 onResize();40 const globe = createGlobe(canvasRef.current!, {41 devicePixelRatio: 2,42 width: width * 2,43 height: width * 2,44 phi: 0,45 theta: theta,46 dark: dark,47 scale: scale,48 diffuse: diffuse,49 mapSamples: mapSamples,50 mapBrightness: mapBrightness,51 baseColor: baseColor,52 markerColor: markerColor,53 glowColor: glowColor,54 opacity: 1,55 offset: [0, 0],56 markers: [57 // longitude latitude58 ],59 onRender: (state: Record<string, any>) => {60 // Called on every animation frame.61 // `state` will be an empty object, return updated params.\62 state.phi = phi;63 phi += 0.003;64 },65 });6667 return () => {68 globe.destroy();69 };70 }, []);7172 return (73 <div74 className={cn(75 'flex items-center justify-center z-10 w-full max-w-[350px] mx-auto',76 className77 )}78 >79 <canvas80 ref={canvasRef}81 style={{82 width: '100%',83 height: '100%',84 maxWidth: '100%',85 aspectRatio: '1',86 }}87 />88 </div>89 );90};9192export default Earth;
What it pulls in
npm packages
Files it writes
More from ui-layouts
All 230 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| 3d-marquee3d-marquee | ui-layouts | Components | Free | no deps · 2 files | |
| accordionaccordion | ui-layouts | Components | Free | no deps | |
| align-slideralign-slider | ui-layouts | Components | Free | 6 deps · 2 files | |
| animal-imagemaskinganimal-imagemasking | ui-layouts | Components | Free | 1 dep | |
| animated-beamanimated-beam | ui-layouts | Components | Free | no deps | |
| animated-beam-bidirectionalanimated-beam-bidirectional | ui-layouts | Components | Free | no deps | |
| animated-beam-defaultanimated-beam-default | ui-layouts | Components | Free | no deps | |
| animated-beam-multiple-inputanimated-beam-multiple-input | ui-layouts | Components | Free | no deps |
