For Tailwind CSS v3 docs, click here.

旋转地球

A 3D interactive globe visualization with customizable arcs, points, and animation options inspired from Github.

通过 CLI 安装

npm
pnpm
bun
yarn
npx shadcn-vue@latest add "https://registry.inspira-ui.com/github-globe.json"

手动安装

Install the dependencies

npm
pnpm
bun
yarn
npm install three postprocessing three-globe
npm install -D @types/three

复制并粘贴以下代码:

GithubGlobe.vue

Download GeoJSON file

Download a GeoJSON file containing the globe's geographical data from GeoJSON Maps by customizing the continents and detail level. Save the downloaded file as globe.json in the same folder as your component.

API

Prop 名称类型默认值描述
globeConfigobject{}Configuration options for the globe, including colors, atmosphere, rotation speed, and lighting.
dataPosition[][]Array of positions representing arcs and points on the globe, with latitude, longitude, color, etc.
classstring""Additional CSS classes for custom styling.

globeConfig Properties

Property类型默认值描述
pointSizenumber1Size of individual points on the globe.
globeColorstring"#1d072e"Color of the globe surface.
showAtmospherebooleantrueWhether to display atmosphere around the globe.
atmosphereColorstring"#ffffff"Color of the atmosphere around the globe.
atmosphereAltitudenumber0.1Altitude of the atmosphere layer.
emissivestring"#000000"Emissive color for the globe material.
emissiveIntensitynumber0.1Intensity of the emissive color.
shininessnumber0.9Shininess of the globe material.
polygonColorstringrgba(255,255,255,0.7)Color of polygon boundaries on the globe.
arcTimenumber2000Duration for arcs animation.
arcLengthnumber0.9Length of arcs on the globe.
ringsnumber1Number of rings to display per point.
maxRingsnumber3Maximum rings around each point.
initialPositionobject{ lat: 0, lng: 0 }Initial latitude and longitude for the globe's position.
autoRotatebooleanfalseAutomatically rotate the globe.
autoRotateSpeednumber0.8Speed of auto-rotation when enabled.

data Structure (Position)

Field类型描述
ordernumberOrder of the point or arc for sequencing.
startLatnumberStarting latitude for an arc.
startLngnumberStarting longitude for an arc.
endLatnumberEnding latitude for an arc.
endLngnumberEnding longitude for an arc.
arcAltnumberAltitude of the arc (determines arc height).
colorstringColor of the arc or point in hex or RGB format.

功能特性

  • 3D Interactive Globe: A Three.js-based globe with interactive controls and orbit support.
  • Customizable Globe & Atmosphere: Allows configuration of globe color, atmosphere visibility, and colors.
  • Arcs & Points Visualization: Display arcs and points on the globe, simulating connections and locations.
  • Auto-Rotate and Zoom: Supports auto-rotation, zoom, and customizable controls for a dynamic experience.
  • Responsive Design: Adapts to container size and maintains performance with WebGL rendering.

感谢

  • Built with Three.js and Three Globe libraries, designed for global data visualizations and dynamic effects.
  • Ported from Aceternity UI.