Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

three-globe

Package Overview
Dependencies
Maintainers
1
Versions
226
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

three-globe

Globe data visualization as a ThreeJS reusable 3D object

  • 1.4.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
40K
increased by23.84%
Maintainers
1
Weekly downloads
 
Created
Source

ThreeJS Globe Visualization

NPM

Largely inspired by WebGL Globe, this is a ThreeJS WebGL class to represent data visualization layers on a globe, using a spherical projection.

Quick start

import ThreeGlobe from 'three-globe';

or

const ThreeGlobe = require('three-globe');

or even

<script src="//unpkg.com/three-globe"></script>

then

const myGlobe = new ThreeGlobe()
    .globeImageUrl(<imageUrl>)
    .pointsData(<myData>);

const myScene = new THREE.Scene();
myScene.add(myGlobe);

API reference

Initialisation

new ThreeGlobe({ configOptions })(<domElement>)
Config optionsDescriptionDefault
animateIn: booleanWhether to animate the globe initialization, by scaling and rotating the globe into its inital position.true

Globe Layer

MethodDescriptionDefault
globeImageUrl([url])Getter/setter for the URL of the image used in the material that wraps the globe. If no image is provided, the globe is represented as a black sphere.null
bumpImageUrl([url])Getter/setter for the URL of the image used to create a bump map in the material, to represent the globe's terrain.null
showAtmosphere([boolean])Getter/setter for whether to show a bright halo surrounding the globe, representing the atmosphere.true
showGraticules([boolean])Getter/setter for whether to show a graticule grid demarking latitude and longitude lines at every 10 degrees.false

Points Layer

MethodDescriptionDefault
pointsData([array])Getter/setter for the list of points to represent in the points map layer. Each point is displayed as a cylindrical 3D object rising perpendicularly from the surface of the globe.[]
pointLat([num, str or fn])Point object accessor function, attribute or a numeric constant for the cylinder's center latitude coordinate.lat
pointLng([num, str or fn])Point object accessor function, attribute or a numeric constant for the cylinder's center longitude coordinate.lat
pointColor([str or fn])Point object accessor function or attribute for the cylinder color.() => '#ffffaa'
pointAltitude([num, str or fn])Point object accessor function, attribute or a numeric constant for the cylinder's altitude in terms of globe radius units (0 = 0 altitude (flat circle), 1 = globe radius).0.1
pointRadius([num, str or fn])Point object accessor function, attribute or a numeric constant for the cylinder's radius, in angular degrees.0.25
pointResolution([num])Getter/setter for the radial geometric resolution of each cylinder, expressed in how many slice segments to divide the circumference. Higher values yield smoother cylinders.12
pointsMerge([boolean])Getter/setter for whether to merge all the point meshes into a single ThreeJS object, for improved rendering performance. Visually both options are equivalent, setting this option only affects the internal organization of the ThreeJS objects.false
pointsTransitionDuration([num])Getter/setter for duration (ms) of the transition to animate point changes involving geometry modifications. A value of 0 will move the objects immediately to their final position. New objects are animated by scaling them from the ground up. Only works if pointsMerge=false.1000

Arcs Layer

MethodDescriptionDefault
arcsData([array])Getter/setter for the list of links to represent in the arcs map layer. Each link is displayed as an arc line that rises from the surface of the globe, connecting the start to the end coordinates.[]
arcStartLat([num, str or fn])Arc object accessor function, attribute or a numeric constant for the line's start latitude coordinate.startLat
arcStartLng([num, str or fn])Arc object accessor function, attribute or a numeric constant for the line's start longitude coordinate.startLng
arcEndLat([num, str or fn])Arc object accessor function, attribute or a numeric constant for the line's end latitude coordinate.endLat
arcEndLng([num, str or fn])Arc object accessor function, attribute or a numeric constant for the line's end longitude coordinate.endLng
arcColor([str or fn])Arc object accessor function or attribute for the line's color.() => '#ffffaa'
arcAltitude([num, str or fn])Arc object accessor function, attribute or a numeric constant for the arc's maximum altitude (ocurring at the half-way distance between the two points) in terms of globe radius units (0 = 0 altitude (ground line), 1 = globe radius). If a value of null or undefined is used, the altitude is automatically set proportionally to the distance between the two points, according to the scale set in arcAltitudeAutoScale.null
arcAltitudeAutoScale([num, str or fn])Arc object accessor function, attribute or a numeric constant for the scale of the arc's automatic altitude, in terms of units of the great-arc distance between the two points. A value of 1 indicates the arc should be as high as its length on the ground. Only applicable if arcAltitude is not set.0.5
arcStroke([num, str or fn])Arc object accessor function, attribute or a numeric constant for the line's diameter, in angular degrees. A value of null or undefined will render a ThreeJS Line whose width is constant (1px) regardless of the camera distance. Otherwise, a TubeGeometry is used.null
arcCurveResolution([num])Getter/setter for the arc's curve resolution, expressed in how many straight line segments to divide the curve by. Higher values yield smoother curves.64
arcCircularResolution([num])Getter/setter for the radial geometric resolution of each line, expressed in how many slice segments to divide the tube's circumference. Only applicable when using Tube geometries (defined arcStroke).6
arcsTransitionDuration([num])Getter/setter for duration (ms) of the transition to animate arc changes involving geometry modifications. A value of 0 will move the objects immediately to their final position. New arcs are animated by rising them from the ground up.1000

Custom Layer

MethodDescriptionDefault
customLayerData([array])Getter/setter for the list of items to represent in the custom map layer. Each item is rendered according to the customThreeObject method.[]
customThreeObject([Object3d, str or fn])Object accessor function or attribute for generating a custom 3d object to render as part of the custom map layer. Should return an instance of ThreeJS Object3d. The callback method's signature includes the object's data as well as the globe radius: customThreeObject((objData, globeRadius) => { ... }).null
customThreeObjectUpdate([str or fn])Object accessor function or attribute for updating an existing custom 3d object with new data. This can be used for performance improvement on data updates as the objects don't need to be removed and recreated at each update. The callback method's signature includes the object to be update, its new data and the globe radius: customThreeObjectUpdate((obj, objData, globeRadius) => { ... }).null

Utility

MethodDescriptionDefault
getCoords(lat, lng [,altitude])Utility method to translate spherical coordinates. Given a pair of latitude/longitude coordinates and optionally altitude (in terms of globe radius units), returns the equivalent {x, y, z} cartesian spatial coordinates.
toGeoCoords({ x, y, z)Utility method to translate cartesian coordinates to the geographic domain. Given a set of 3D cartesian coordinates {x, y, z}, returns the equivalent {lat, lng, altitude} spherical coordinates. Altitude is defined in terms of globe radius units.

Keywords

FAQs

Package last updated on 02 Apr 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc