Published
Edited
Jun 21, 2018
5 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
renderer = {
const renderer = this || new T.WebGLRenderer({antialias: true});
renderer.setPixelRatio(window.devicePixelRatio);
renderer.setSize(width, height);
return renderer;
}
Insert cell
Insert cell
scene = {
const scene = this || new T.Scene();
scene.background = new T.Color(background);
return scene;
}
Insert cell
Insert cell
sphereGeom = {
if (this) this.dispose();
return new T.SphereBufferGeometry(10, globeDetail, globeDetail);
}
Insert cell
Insert cell
textures = {
const textureLoader = new T.TextureLoader;
function texture(name) {
return new T.MeshLambertMaterial({map: textureLoader.load(urls[name])})
}
return {
"light-pollution": texture("light-pollution"),
"night-lights": texture("night-lights"),
};
}
Insert cell
Insert cell
globe = {
let globe = this;
if (!globe) {
globe = new T.Mesh();
scene.add(globe);
}
globe.geometry = sphereGeom;
globe.material = textures[display];
return globe;
}
Insert cell
Insert cell
light = {
if (this) scene.remove(this);
const l = new T.AmbientLight(ambientLight)
scene.add(l);
return l;
}
Insert cell
Insert cell
camera = {
let camera = this;
if (!camera) {
camera = new T.PerspectiveCamera(30, 1, 1, 1000);
camera.position.set(0, 15, 37);
}
camera.aspect = aspectRatio;
camera.updateProjectionMatrix();
return camera;
}
Insert cell
Insert cell
controls = {
const controls = this || new T.OrbitControls(camera, renderer.domElement);
controls.enablePan = false;
controls.minDistance = 20;
controls.maxDistance = 500;
controls.enableZoom = allowZoom == "on";
controls.autoRotate = autoRotate == "on";
controls.autoRotateSpeed = rotationSpeed;
return controls;
}
Insert cell
Insert cell
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more