globe
aceternity/globeUnverifiedComponent
aceternity publishes no description for this item.
Install it
npx shadcn@latest add https://raw.githubusercontent.com/rickhallett/becoming-diamond-nextjs/main/globe.jsonSource
1"use client";2import { useEffect, useRef, useState } from "react";3import { Color, Scene, Fog, PerspectiveCamera, Vector3 } from "three";4import ThreeGlobe from "three-globe";5import { useThree, Canvas, extend } from "@react-three/fiber";6import { OrbitControls } from "@react-three/drei";7import countries from "@/data/globe.json";8declare module "@react-three/fiber" {9 interface ThreeElements {10 threeGlobe: ThreeElements["mesh"] & {11 new (): ThreeGlobe;12 };13 }14}1516extend({ ThreeGlobe: ThreeGlobe });1718const RING_PROPAGATION_SPEED = 3;19const aspect = 1.2;20const cameraZ = 300;2122type Position = {23 order: number;24 startLat: number;25 startLng: number;26 endLat: number;27 endLng: number;28 arcAlt: number;29 color: string;30};3132export type GlobeConfig = {33 pointSize?: number;34 globeColor?: string;35 showAtmosphere?: boolean;36 atmosphereColor?: string;37 atmosphereAltitude?: number;38 emissive?: string;39 emissiveIntensity?: number;40 shininess?: number;41 polygonColor?: string;42 ambientLight?: string;43 directionalLeftLight?: string;44 directionalTopLight?: string;45 pointLight?: string;46 arcTime?: number;47 arcLength?: number;48 rings?: number;49 maxRings?: number;50 initialPosition?: {51 lat: number;52 lng: number;53 };54 autoRotate?: boolean;55 autoRotateSpeed?: number;56};5758interface WorldProps {59 globeConfig: GlobeConfig;60 data: Position[];61}6263let numbersOfRings = [0];6465export function Globe({ globeConfig, data }: WorldProps) {66 const globeRef = useRef<ThreeGlobe | null>(null);67 const groupRef = useRef();68 const [isInitialized, setIsInitialized] = useState(false);6970 const defaultProps = {71 pointSize: 1,72 atmosphereColor: "#ffffff",73 showAtmosphere: true,74 atmosphereAltitude: 0.1,75 polygonColor: "rgba(255,255,255,0.7)",76 globeColor: "#1d072e",77 emissive: "#000000",78 emissiveIntensity: 0.1,79 shininess: 0.9,80 arcTime: 2000,81 arcLength: 0.9,82 rings: 1,83 maxRings: 3,84 ...globeConfig,85 };8687 // Initialize globe only once88 useEffect(() => {89 if (!globeRef.current && groupRef.current) {90 globeRef.current = new ThreeGlobe();91 (groupRef.current as any).add(globeRef.current);92 setIsInitialized(true);93 }94 }, []);9596 // Build material when globe is initialized or when relevant props change97 useEffect(() => {98 if (!globeRef.current || !isInitialized) return;99100 const globeMaterial = globeRef.current.globeMaterial() as unknown as {101 color: Color;102 emissive: Color;103// … truncated
What it pulls in
npm packages
Files it writes
More from aceternity
All 89 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| 3d-card3d-card | aceternity | Components | Unverified | no deps | |
| 3d Globe3d-globe | aceternity | Components | Free | 3 deps | |
| 3d-marquee3d-marquee | aceternity | Components | Unverified | no deps | |
| 3d-pin3d-pin | aceternity | Components | Unverified | 1 dep | |
| animated-modalanimated-modal | aceternity | Components | Unverified | 1 dep | |
| animated-testimonialsanimated-testimonials | aceternity | Components | Unverified | 2 deps | |
| animated-tooltipanimated-tooltip | aceternity | Components | Unverified | 1 dep | |
| apple-cards-carouselapple-cards-carousel | aceternity | Components | Unverified | 2 deps |
