Skip to content

Commit

Permalink
add missing examples
Browse files Browse the repository at this point in the history
  • Loading branch information
alagrede committed Oct 11, 2022
1 parent a9b6e87 commit d889337
Show file tree
Hide file tree
Showing 7 changed files with 107,539 additions and 101,209 deletions.
32 changes: 32 additions & 0 deletions examples/d3-globe.md
@@ -0,0 +1,32 @@
# D3 World map

**Install**
- d3 - `https://d3js.org/d3.v7.min.js`
- topojson - `https://unpkg.com/topojson@3`

```js scripts=d3,topojson
//hide
const svg = d3.create("svg");
svg.attr("width", "100%")
svg.attr("height", "500px")

const projection = d3.geoNaturalEarth1();
const pathGenerator = d3.geoPath().projection(projection);

svg.append('path')
.style("fill", "#4242e4")
.attr('d', pathGenerator({type: 'Sphere'}));


d3.json('https://unpkg.com/world-atlas@1.1.4/world/110m.json')
.then(data => {
const countries = topojson.feature(data, data.objects.countries);
svg.selectAll('path').data(countries.features)
.enter().append('path')
.style("fill", "lightgreen")
.style("stroke", "black")
.style("stroke-opacity", "0.1")
.attr('d', pathGenerator);
print(svg.node().outerHTML)
});
```
208,630 changes: 107,422 additions & 101,208 deletions examples/data/modis-active-fire.csv

Large diffs are not rendered by default.

17 changes: 17 additions & 0 deletions examples/react-demo.md
@@ -0,0 +1,17 @@

## Install react
`npm i -S react`
`npm i -S react-dom`

```js
import React from 'react';
import ReactDOM from 'react-dom';

const LikeButton = (props) => {
return <h1>{props.name}</h1>;
}
ReactDOM.render(<LikeButton
name="Hello from React!" />
, htmlEl);
```

61 changes: 61 additions & 0 deletions examples/threeGlobe-basic.md
@@ -0,0 +1,61 @@
# ThreeGlobe World map

**Install**
- three - `https://unpkg.com/three@0.145.0/build/three.js`
- threeControls - `https://unpkg.com/three/examples/js/controls/TrackballControls.js`
- threeGlobe - `https://unpkg.com/three-globe@2.24.8/dist/three-globe.min.js`

```js scripts=three,threeControls,threeGlobe
//hide
// Gen random data
const N = 300;
const gData = [...Array(N).keys()].map(() => ({
lat: (Math.random() - 0.5) * 180,
lng: (Math.random() - 0.5) * 360,
size: Math.random() / 3,
color: ['red', 'white', 'blue', 'green'][Math.round(Math.random() * 3)]
}));

const Globe = new ThreeGlobe()
.globeImageUrl('https://unpkg.com/three-globe/example/img/earth-dark.jpg')
.bumpImageUrl('https://unpkg.com/three-globe/example/img/earth-topology.png')
.pointsData(gData)
.pointAltitude('size')
.pointColor('color');

setTimeout(() => {
gData.forEach(d => d.size = Math.random());
Globe.pointsData(gData);
}, 4000);

// Setup renderer
const renderer = new THREE.WebGLRenderer();
renderer.setSize(500, 500);
htmlEl.appendChild(renderer.domElement);

// Setup scene
const scene = new THREE.Scene();
scene.add(Globe);
scene.add(new THREE.AmbientLight(0xbbbbbb));
scene.add(new THREE.DirectionalLight(0xffffff, 0.6));

// Setup camera
const camera = new THREE.PerspectiveCamera();
camera.aspect = 500/500;
camera.updateProjectionMatrix();
camera.position.z = 500;

// Add camera controls
const tbControls = new THREE.TrackballControls(camera, renderer.domElement);
tbControls.minDistance = 101;
tbControls.rotateSpeed = 5;
tbControls.zoomSpeed = 0.8;

// Kick-off renderer
(function animate() { // IIFE
// Frame cycle
tbControls.update();
renderer.render(scene, camera);
requestAnimationFrame(animate);
})();
```
6 changes: 6 additions & 0 deletions examples/threeGlobe-satellite.md
@@ -1,5 +1,11 @@
# Satellites demo

**Install scripts**
- three - `https://unpkg.com/three@0.145.0/build/three.js`
- threeControls - `https://unpkg.com/three/examples/js/controls/TrackballControls.js`
- threeGlobe - `https://unpkg.com/three-globe@2.24.8/dist/three-globe.min.js`
- satellite - `https://unpkg.com/satellite.js/dist/satellite.min.js`

```js scripts=three,threeControls,threeGlobe,satellite
//hide
const EARTH_RADIUS_KM = 6371; // km
Expand Down
1 change: 1 addition & 0 deletions examples/znote-folder-backup-10-11-2022_11-43-24.json

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion examples/znote-folder-backup-10-9-2022_17-15-18.json

This file was deleted.

0 comments on commit d889337

Please sign in to comment.