Skip to content

Commit

Permalink
country list
Browse files Browse the repository at this point in the history
  • Loading branch information
harshcrop committed Dec 27, 2023
1 parent 0832971 commit f83e63a
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 46 deletions.
6 changes: 4 additions & 2 deletions assets/data/connections.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
data.connections = {
Colombia: [
"New York",
"Ashbern",
"Ecuador",
"Cuba",
// "Mexico",
"Peru",
"Venezuela, RB",
"Guyana",
"United States",
// "United States",
],
"South Sudan": [
"Nigeria",
Expand Down Expand Up @@ -44,7 +46,7 @@ data.connections = {
"Colombia",
"Peru",
"Venezuela, RB",
"United States",
// "United States",
],
Fiji: [
"Tuvalu",
Expand Down
24 changes: 12 additions & 12 deletions assets/data/countries.all.json
Original file line number Diff line number Diff line change
Expand Up @@ -3951,18 +3951,18 @@
"longitude": "-56.0675",
"latitude": "-34.8941"
},
{
"id": "USA",
"iso2Code": "US",
"name": "United States",
"region": { "id": "NAC", "iso2code": "XU", "value": "North America" },
"adminregion": { "id": "", "iso2code": "", "value": "" },
"incomeLevel": { "id": "HIC", "iso2code": "XD", "value": "High income" },
"lendingType": { "id": "LNX", "iso2code": "XX", "value": "Not classified" },
"capitalCity": "Washington D.C.",
"longitude": "-77.032",
"latitude": "38.8895"
},
// {
// "id": "USA",
// "iso2Code": "US",
// "name": "United States",
// "region": { "id": "NAC", "iso2code": "XU", "value": "North America" },
// "adminregion": { "id": "", "iso2code": "", "value": "" },
// "incomeLevel": { "id": "HIC", "iso2code": "XD", "value": "High income" },
// "lendingType": { "id": "LNX", "iso2code": "XX", "value": "Not classified" },
// "capitalCity": "Washington D.C.",
// "longitude": "-77.032",
// "latitude": "38.8895"
// },
{
"id": "UZB",
"iso2Code": "UZ",
Expand Down
2 changes: 1 addition & 1 deletion assets/data/countries.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ data.countries = [
{ name: "Denmark", latitude: "55.6763", longitude: "12.5681" },
{ name: "Romania", latitude: "44.4479", longitude: "26.0979" },
// { name: "Mexico", latitude: "19.427", longitude: "-99.1276" },
{ name: "United States", latitude: "38.8895", longitude: "-77.032" },
// { name: "United States", latitude: "38.8895", longitude: "-77.032" },
{ name: "Greenland", latitude: "64.1836", longitude: "-51.7214" },
{ name: "Iceland", latitude: "64.1353", longitude: "-21.8952" },
{ name: "Ecuador", latitude: "-0.229498", longitude: "-78.5243" },
Expand Down
4 changes: 2 additions & 2 deletions assets/data/processing.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const SouthAmerica = [
"Cuba",
];

const NorthAmerica = ["Mexico", "United States", "Greenland", "Iceland"];
// const NorthAmerica = ["Mexico", "United States", "Greenland", "Iceland"];

const Europe = [
"Norway",
Expand Down Expand Up @@ -99,7 +99,7 @@ const connections = {
"Peru",
"Venezuela, RB",
"Guyana",
"United States",
// "United States",
],
"South Sudan": [
"Nigeria",
Expand Down
48 changes: 28 additions & 20 deletions scripts/marker.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
class Marker {
constructor(material, geometry, label, cords, {
textColor = 'white',
pointColor = config.colors.globeMarkerColor,
glowColor = config.colors.globeMarkerGlow
} = {}) {
constructor(
material,
geometry,
label,
cords,
{
textColor = "white",
pointColor = config.colors.globeMarkerColor,
glowColor = config.colors.globeMarkerGlow,
} = {}
) {
this.material = material;
this.geometry = geometry;
this.labelText = label;
Expand All @@ -16,7 +22,7 @@ class Marker {
this.glowColor = new THREE.Color(glowColor);

this.group = new THREE.Group();
this.group.name = 'Marker';
this.group.name = "Marker";

this.createLabel();
this.createPoint();
Expand All @@ -32,13 +38,13 @@ class Marker {
texture.minFilter = THREE.LinearFilter;
textures.markerLabels.push(texture);

const material = new THREE.SpriteMaterial()
const material = new THREE.SpriteMaterial();
material.map = texture;
material.depthTest = false;
material.depthTest = true;
material.useScreenCoordinates = false;

this.label = new THREE.Sprite(material);
this.label.scale.set( 40, 20, 1 );
this.label.scale.set(40, 20, 1);
this.label.center.x = 0.25;
this.label.translateY(2);

Expand All @@ -47,32 +53,32 @@ class Marker {
}

createPoint() {
this.point = new THREE.Mesh( this.geometry, this.material );
this.point = new THREE.Mesh(this.geometry, this.material);
this.point.material.color.set(this.pointColor);
this.group.add(this.point);
elements.markerPoint.push(this.point);
}

createGlow() {
this.glow = new THREE.Mesh( this.geometry, this.material.clone() );
this.glow = new THREE.Mesh(this.geometry, this.material.clone());
this.glow.material.color.set(this.glowColor);
this.glow.material.opacity = 0.6;
this.group.add(this.glow);
elements.markerPoint.push(this.glow);
}

animateGlow() {
if(!this.isAnimating) {
if(Math.random() > 0.99) {
if (!this.isAnimating) {
if (Math.random() > 0.99) {
this.isAnimating = true;
}
} else if(this.isAnimating) {
} else if (this.isAnimating) {
this.glow.scale.x += 0.025;
this.glow.scale.y += 0.025;
this.glow.scale.z += 0.025;
this.glow.material.opacity -= 0.005;

if(this.glow.scale.x >= 4) {
if (this.glow.scale.x >= 4) {
this.glow.scale.x = 1;
this.glow.scale.y = 1;
this.glow.scale.z = 1;
Expand All @@ -83,17 +89,19 @@ class Marker {
}

setPosition() {
const {x, y, z} = this.cords
this.group.position.set(-x, y, -z)
const { x, y, z } = this.cords;
this.group.position.set(-x, y, -z);
}

createText() {
const element = document.createElement('canvas');
const element = document.createElement("canvas");
const canvas = new fabric.Canvas(element);

const text = new fabric.Text(this.labelText, {
left: 0, top: 0, fill: this.textColor,
fontFamily: 'Open Sans',
left: 0,
top: 0,
fill: this.textColor,
fontFamily: "Open Sans",
});

canvas.add(text);
Expand Down
22 changes: 13 additions & 9 deletions scripts/markers.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
class Markers {
constructor(countries, {
markerRadius = 2
} = {}) {
constructor(countries, { markerRadius = 2 } = {}) {
this.countries = countries;
this.radius = config.sizes.globe + config.sizes.globe * config.scale.markers;
this.radius =
config.sizes.globe + config.sizes.globe * config.scale.markers;

groups.markers = new THREE.Group();
groups.markers.name = 'GlobeMarkers';
groups.markers.name = "GlobeMarkers";

this.markerGeometry = new THREE.SphereGeometry(markerRadius, 15, 15);
this.markerMaterial = new THREE.MeshBasicMaterial();
Expand All @@ -17,16 +16,21 @@ class Markers {
}

create() {
for(let i = 0; i < this.countries.length; i++) {
for (let i = 0; i < this.countries.length; i++) {
const country = this.countries[i];
if(country.latitude && country.longitude) {
if (country.latitude && country.longitude) {
const lat = +country.latitude;
const lng = +country.longitude;

const cords = toSphereCoordinates(lat, lng, this.radius);
const marker = new Marker(this.markerMaterial, this.markerGeometry, country.name, cords);
const marker = new Marker(
this.markerMaterial,
this.markerGeometry,
country.name,
cords
);
elements.markers.push(marker);
}
}
}
}
}

0 comments on commit f83e63a

Please sign in to comment.