Create a 3D rotating globe.
- User
Create a 3D rotating globe.
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Create a 3D rotating globe.
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Below is a complete, copy-paste-and-run example of a 3-D, auto-rotating globe built with Three.js (a lightweight WebGL wrapper).
Just drop the code into an .html file, open it in any modern browser, and voilà—an interactive Earth appears! 🌍
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>3-D Rotating Globe (Three.js)</title>
<style>
/* Zero-out margin so the canvas fills the viewport */
body { margin: 0; overflow: hidden; background: #000; }
#info {
position: absolute; top: 10px; left: 10px; z-index: 10;
color: #fff; font-family: sans-serif; font-size: 14px;
background: rgba(0,0,0,0.4); padding: 6px 10px; border-radius: 4px;
}
</style>
</head>
<body>
<div id="info">Drag (or pinch) to orbit • Scroll to zoom</div>
<!-- 1️⃣ Import Three.js & OrbitControls (from a CDN) -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r152/three.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/three@0.152/examples/js/controls/OrbitControls.js"></script>
<script>
/* ============ 2️⃣ Basic Three.js setup ============ */
const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera(
45, window.innerWidth / window.innerHeight, 0.1, 1000 );
const renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(window.devicePixelRatio);
document.body.appendChild(renderer.domElement);
/* Optional user interaction (pan / zoom / rotate) */
const controls = new THREE.OrbitControls(camera, renderer.domElement);
controls.enableDamping = true; // Smooth easing
controls.enablePan = false; // Disable panning (YMMV)
controls.minDistance = 7;
controls.maxDistance = 20;
/* ============ 3️⃣ Create the Globe mesh ============ */
const RADIUS = 5; // Earth radius in scene units
const SEGMENTS = 64; // # of horizontal segments
const RINGS = 64; // # of vertical segments
const geometry = new THREE.SphereGeometry(RADIUS, SEGMENTS, RINGS);
/* High-quality texture from NASA Blue Marble (public domain) */
const textureLoader = new THREE.TextureLoader();
const earthTexture = textureLoader.load(
'https://raw.githubusercontent.com/creativetimofficial/public-assets/master/creative-tim-globe/earthmap1k.jpg'
);
const normalMap = textureLoader.load(
'https://raw.githubusercontent.com/creativetimofficial/public-assets/master/creative-tim-globe/earth_normal_map.png'
);
const material = new THREE.MeshStandardMaterial({
map: earthTexture,
normalMap: normalMap,
roughness: 1, // Matte finish
metalness: 0
});
const globe = new THREE.Mesh(geometry, material);
scene.add(globe);
/* ============ 4️⃣ Lights & camera ============ */
scene.add(new THREE.AmbientLight(0xffffff, 0.5)); // Soft light
const pointLight = new THREE.PointLight(0xffffff, 1.2);
pointLight.position.set(20, 0, 20); // Sun-like light
scene.add(pointLight);
camera.position.set(0, 0, 10); // Pull back so globe is visible
/* ============ 5️⃣ Render / animation loop ============ */
function animate() {
requestAnimationFrame(animate);
globe.rotation.y += 0.002; // Auto-rotate (⬅️ adjust speed here)
controls.update(); // Update OrbitControls easing
renderer.render(scene, camera);
}
animate();
/* ============ 6️⃣ Handle resize events ============ */
window.addEventListener('resize', () => {
camera.aspect = innerWidth / innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(innerWidth, innerHeight);
});
</script>
</body>
</html>
How it works (quick rundown)
OrbitControls.js for drag-to-orbit interactivity.Scene, Camera, and Renderer—the mandatory trio for any Three.js project.SphereGeometry) and wrap it in two textures:map) showing land/water;normalMap to fake surface bumps (mountains/oceans).animate(), we:rotation.y += 0.002);renderer.render() to draw the next frame.Tweak ideas
• Swap in higher-resolution textures for crisper visuals (up to 8K Blue Marble).
• Add atmospheric glow by wrapping the globe in a slightly larger, semi-transparent sphere.
• Plot markers (e.g., cities, flight paths) using THREE.Sprite or tiny spheres.
• Animate clouds on a second transparent sphere rotating slightly faster than Earth.
• Replace OrbitControls with camera auto-rotation for a hands-free screensaver mode.
Enjoy exploring your very own pocket-size planet! 🌐