Public
Edited
Nov 13, 2024
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
scene = {
const scene = new THREE.Scene();
scene.add(sphere);
const light = new THREE.AmbientLight(0x666666); // Lowish ambient light.
scene.add(light);

const dLight = new THREE.DirectionalLight(0xffffcc, 4); // Single source of directional light.
dLight.position.set(10, 2, 0);
scene.add(dLight);

return scene;
}
Insert cell
Insert cell
Insert cell
Insert cell
earthImageUrl = FileAttachment("2k_earth_daymap.jpg").url()
Insert cell
Insert cell
sphere = {
const geometry = new THREE.SphereGeometry(0.7, 30, 15);
const material = new THREE.MeshStandardMaterial();
const sphereMesh = new THREE.Mesh(geometry, material);

// Load the texture
material.map = new THREE.TextureLoader().load(earthImageUrl); // Set the loaded texture as the material's map

// Create a wireframe for the cube
const wireframe = new THREE.EdgesGeometry(geometry);
const wireframeMaterial = new THREE.LineBasicMaterial({ color: 0xffffff });
const wireframeMesh = new THREE.LineSegments(wireframe, wireframeMaterial);

// Add wireframe as a child of the sphere mesh so they move together
sphereMesh.add(wireframeMesh);

return sphereMesh;
}
Insert cell
Type Markdown, then Shift-Enter. Ctrl-space for more options. Arrow ↑/↓ to switch modes.

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