npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

js-globe

v1.0.17

Published

A 3D globe library for adding locations and countries

Downloads

850

Readme

# js-globe

`js-globe` is a 3D globe visualization library built with Three.js, enabling interactive Earth representations with markers, countries, and labels. This library is perfect for showcasing data points on a global scale, visualizing geographic data, and creating interactive 3D environments.

## Table of Contents
- [Installation](#installation)
- [Usage](#usage)
- [Example](#example)
- [Configuration](#configuration)
- [Dependencies](#dependencies)
- [License](#license)

## Installation

Install `js-globe` using npm or yarn:

```bash
npm install js-globe
# or
yarn add js-globe

Ensure that you have three and @tweenjs/tween.js as peer dependencies, as this library relies on them.

Usage

Importing the Library

import Globe from 'js-globe';
import * as THREE from 'three';

Initializing the Globe

Create a new instance of the globe, set up your scene, camera, and renderer, and add the globe to your scene.

import Globe from 'js-globe';
import * as THREE from 'three';

const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
camera.position.z = 5;

const renderer = new THREE.WebGLRenderer();
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);

const globe = new Globe();
scene.add(globe);

function animate() {
  requestAnimationFrame(animate);
  globe.rotation.y += 0.001; // Rotate the globe
  renderer.render(scene, camera);
}

animate();

Adding Markers

To add custom markers to the globe, use latitude and longitude coordinates:

globe.addMarker({
  lat: 40.7128,
  lon: -74.0060,
  label: 'New York City',
});

Loading Country Borders

If you have a GeoJSON file of country borders, you can load and visualize it:

import countries from './path/to/countries.geo.json';

globe.loadCountryBorders(countries);

Example

import Globe from 'js-globe';
import * as THREE from 'three';
import countries from './countries.geo.json';

const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
camera.position.z = 3;

const renderer = new THREE.WebGLRenderer();
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);

const globe = new Globe();
scene.add(globe);

// Add markers
globe.addMarker({ lat: 29.3544, lon: 71.6911, label: 'Bahawalpur' });
globe.addMarker({ lat: 40.7128, lon: -74.0060, label: 'New York City' });

// Load country borders
globe.loadCountryBorders(countries);

function animate() {
  requestAnimationFrame(animate);
  globe.rotation.y += 0.001;
  renderer.render(scene, camera);
}

animate();

Configuration

You can customize various aspects of the globe:

  • Textures: Replace the default textures for Earth, moon, and clouds.
  • Camera Settings: Adjust camera angle, zoom, and controls for user interaction.
  • Country Borders: Use a GeoJSON file for country border data.
  • Markers and Labels: Place markers with labels at specific latitude/longitude coordinates.

Dependencies

Ensure these packages are installed for js-globe to function correctly.

License

MIT License. See LICENSE file for more details.


This `README.md` provides a complete guide to setting up, using, and configuring the library, as well as handling dependencies and examples. Let me know if you'd like to add more details!