Published
Edited
Dec 10, 2018
1 star
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

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more