minimax-m1 LMArena Human Preference 140K
Create a 3D rotating globe.
- User
Create a 3D rotating globe.
- Assistant
Here's a complete HTML/JS implementation of a 3D rotating globe using Three.js:
<!DOCTYPE html> <html> <head> <title>3D Rotating Globe</title> <style> body { margin: 0; overflow: hidden; background-color: #000; } canvas { display: block; } </style> </head> <body> <script src="https://cdn.jsdelivr.net/npm/three@0.132.2/build/three.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/three@0.132.2/examples/js/controls/OrbitControls.js"></script> <script> // Initialize scene, camera, and renderer const scene = new THREE.Scene(); const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000); const renderer = new THREE.WebGLRenderer({ antialias: true }); renderer.setSize(window.innerWidth, window.innerHeight); document.body.appendChild(renderer.domElement); // Create globe geometry const globeGeometry = new THREE.SphereGeometry(5, 64, 64); // Load Earth texture const textureLoader = new THREE.TextureLoader(); const earthTexture = textureLoader.load('https://cdn.jsdelivr.net/gh/mrdoob/three.js@master/examples/textures/planets/earth_atmos_2048.jpg'); // Create material with texture const globeMaterial = new THREE.MeshPhongMaterial({ map: earthTexture, bumpMap: earthTexture, bumpScale: 0.05, }); // Create mesh and add to scene const globe = new THREE.Mesh(globeGeometry, globeMaterial); scene.add(globe); // Add lights const ambientLight = new THREE.AmbientLight(0x333333); scene.add(ambientLight); const directionalLight = new THREE.DirectionalLight(0xffffff, 1); directionalLight.position.set(5, 3, 5); scene.add(directionalLight); // Add stars background const starsGeometry = new THREE.BufferGeometry(); const starsMaterial = new THREE.PointsMaterial({ color: 0xffffff, size: 0.1 }); const starsVertices = []; for (let i = 0; i < 5000; i++) { const x = (Math.random() - 0.5) * 2000; const y = (Math.random() - 0.5) * 2000; const z = (Math.random() - 0.5) * 2000; starsVertices.push(x, y, z); } starsGeometry.setAttribute('position', new THREE.Float32BufferAttribute(starsVertices, 3)); const starField = new THREE.Points(starsGeometry, starsMaterial); scene.add(starField); // Position camera camera.position.z = 15; // Add orbit controls const controls = new THREE.OrbitControls(camera, renderer.domElement); controls.enableDamping = true; controls.dampingFactor = 0.05; // Animation loop function animate() { requestAnimationFrame(animate); // Auto-rotation globe.rotation.y += 0.005; controls.update(); renderer.render(scene, camera); } // Handle window resize window.addEventListener('resize', () => { camera.aspect = window.innerWidth / window.innerHeight; camera.updateProjectionMatrix(); renderer.setSize(window.innerWidth, window.innerHeight); }); animate(); </script> </body> </html>This implementation features:
- A detailed Earth texture with bump mapping for realistic surface features
- Automatic rotation around the Y-axis
- Interactive controls (zoom, pan, rotate using mouse/touch)
- A starfield background for better visual effect
- Responsive design that adapts to window size
- Proper lighting with ambient and directional lights
- Smooth animation using requestAnimationFrame
To use it:
- Save the code as an HTML file
- Open in a modern web browser
- Interact using:
- Left-click + drag to rotate
- Right-click + drag to pan
- Scroll to zoom
The globe will automatically rotate while still allowing manual interaction. The texture is loaded from a reliable CDN source, but you can replace the texture URL with any equirectangular Earth texture of your choice.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.