Skip to content
The Chat Archive
deepseek-v3-0324· DeepSeek LMArena Human Preference 140K

Make the planet more "resolution".

  1. User

    Make the planet more "resolution".

  2. Assistant

    To increase the planet's resolution (more detailed voxels), we'll need to make several adjustments. Here's an improved version with higher resolution voxels while maintaining performance:

    <!DOCTYPE html>
    <html>
    <head>
        <title>High-Res Voxel Planet</title>
        <style>
            body { 
                margin: 0;
                overflow: hidden;
                background: #000;
            }
            canvas { 
                display: block;
            }
            #info {
                position: absolute;
                top: 10px;
                left: 10px;
                color: white;
                font-family: Arial, sans-serif;
                pointer-events: none;
            }
        </style>
    </head>
    <body>
        <div id="info">WASD: Move | Space/Shift: Up/Down | Mouse: Look | Left Click: Rotate</div>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>
        <script>
            // Main variables
            let scene, camera, renderer;
            let planet;
            const planetRadius = 20;  // Increased planet size
            const voxelSize = 0.5;    // Smaller voxels for higher resolution
            const noiseScale = 15;    // Adjusted noise scale
            
            // Performance optimization
            const maxVoxels = 20000;  // Limit to prevent browser crash
            let voxelCount = 0;
    
            // Initialize the scene
            function init() {
                // Setup Three.js scene
                scene = new THREE.Scene();
                camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
                renderer = new THREE.WebGLRenderer({ antialias: true });
                renderer.setPixelRatio(window.devicePixelRatio);
                renderer.setSize(window.innerWidth, window.innerHeight);
                document.body.appendChild(renderer.domElement);
    
                // Lighting
                const sun = new THREE.DirectionalLight(0xffffff, 1.2);
                sun.position.set(50, 50, 50);
                scene.add(sun);
                scene.add(new THREE.AmbientLight(0x404040));
    
                // Camera position
                camera.position.set(0, 0, 50);
                
                // Generate high-res planet
                generateHighResPlanet();
                
                // Add starfield background
                addStarfield();
                
                // Start animation loop
                animate();
                
                // Event listeners
                setupControls();
                window.addEventListener('resize', onWindowResize);
            }
    
            // Improved planet generation with higher resolution
            function generateHighResPlanet() {
                planet = new THREE.Group();
                
                // Materials for voxel types
                const materials = {
                    water: new THREE.MeshPhongMaterial({ 
                        color: 0x0077be,
                        specular: 0x111111,
                        shininess: 30
                    }),
                    sand: new THREE.MeshPhongMaterial({ 
                        color: 0xc2b280,
                        specular: 0x111111,
                        shininess: 5
                    }),
                    grass: new THREE.MeshPhongMaterial({ 
                        color: 0x567d46,
                        specular: 0x111111,
                        shininess: 10
                    })
                };
    
                // Shared geometry for performance
                const voxelGeometry = new THREE.BoxGeometry(voxelSize, voxelSize, voxelSize);
                
                // Calculate voxel grid size based on planet radius and voxel size
                const gridSize = Math.floor(planetRadius / voxelSize) * 2;
                
                // Generate voxels in layers for better performance
                for (let layer = 0; layer < gridSize; layer++) {
                    if (voxelCount >= maxVoxels) break;
                    
                    const y = -planetRadius + (layer * voxelSize);
                    
                    for (let x = -planetRadius; x <= planetRadius; x += voxelSize) {
                        for (let z = -planetRadius; z <= planetRadius; z += voxelSize) {
                            if (voxelCount >= maxVoxels) break;
                            
                            const position = new THREE.Vector3(x, y, z);
                            const distance = position.length();
                            
                            if (distance <= planetRadius) {
                                // Improved noise function for more natural terrain
                                const nx = x / noiseScale;
                                const nz = z / noiseScale;
                                const ny = y / (noiseScale * 0.5);
                                
                                // Layered noise for more interesting terrain
                                let noise = Math.abs(Math.sin(nx) * Math.cos(nz) * 0.7 + 
                                                   Math.sin(nx * 2) * Math.cos(nz * 2) * 0.3);
                                
                                // Adjust noise based on height (y position)
                                const heightFactor = (y + planetRadius) / (planetRadius * 2);
                                noise = noise * 0.7 + heightFactor * 0.3;
                                
                                // Determine voxel type
                                let material;
                                if (noise < 0.3) {
                                    material = materials.water;
                                } else if (noise < 0.6) {
                                    material = materials.sand;
                                } else {
                                    material = materials.grass;
                                }
                                
                                // Create voxel
                                const voxel = new THREE.Mesh(voxelGeometry, material);
                                voxel.position.copy(position);
                                planet.add(voxel);
                                voxelCount++;
                            }
                        }
                    }
                }
                
                scene.add(planet);
                console.log(`Generated ${voxelCount} voxels`);
            }
    
            // Starfield background
            function addStarfield() {
                const starsGeometry = new THREE.BufferGeometry();
                const starsMaterial = new THREE.PointsMaterial({
                    color: 0xFFFFFF,
                    size: 0.1,
                    transparent: true
                });
                
                const starVertices = [];
                for (let i = 0; i < 5000; i++) {
                    starVertices.push(
                        (Math.random() - 0.5) * 2000,
                        (Math.random() - 0.5) * 2000,
                        (Math.random() - 0.5) * 2000
                    );
                }
                
                starsGeometry.setAttribute('position', new THREE.Float32BufferAttribute(starVertices, 3));
                const stars = new THREE.Points(starsGeometry, starsMaterial);
                scene.add(stars);
            }
    
            // Controls
            const moveSpeed = 0.5;
            const rotateSpeed = 0.002;
            let isDragging = false;
            let previousMousePosition = { x: 0, y: 0 };
    
            function setupControls() {
                document.addEventListener('keydown', handleKeyDown);
                document.addEventListener('mousedown', () => isDragging = true);
                document.addEventListener('mouseup', () => isDragging = false);
                document.addEventListener('mousemove', handleMouseMove);
            }
    
            function handleKeyDown(event) {
                const speed = event.shiftKey ? moveSpeed * 2 : moveSpeed;
                
                switch(event.key.toLowerCase()) {
                    case 'w': camera.translateZ(-speed); break;
                    case 's': camera.translateZ(speed); break;
                    case 'a': camera.translateX(-speed); break;
                    case 'd': camera.translateX(speed); break;
                    case ' ': camera.translateY(speed); break;
                    case 'shift': camera.translateY(-speed); break;
                }
            }
    
            function handleMouseMove(event) {
                if (!isDragging) return;
                
                const deltaMove = {
                    x: event.clientX - previousMousePosition.x,
                    y: event.clientY - previousMousePosition.y
                };
                
                camera.rotation.y -= deltaMove.x * rotateSpeed;
                camera.rotation.x -= deltaMove.y * rotateSpeed;
                
                previousMousePosition = {
                    x: event.clientX,
                    y: event.clientY
                };
            }
    
            // Animation loop
            function animate() {
                requestAnimationFrame(animate);
                planet.rotation.y += 0.001;
                renderer.render(scene, camera);
            }
    
            // Handle window resize
            function onWindowResize() {
                camera.aspect = window.innerWidth / window.innerHeight;
                camera.updateProjectionMatrix();
                renderer.setSize(window.innerWidth, window.innerHeight);
            }
    
            // Start the application
            init();
        </script>
    </body>
    </html>
    

    Key Improvements for Higher Resolution:

    1. Smaller Voxel Size:

      • Reduced from 1.0 to 0.5 units for finer detail
      • Adjusted planet radius to 20 units (was 10) to maintain size
    2. Optimized Generation:

      • Added voxel count limit (20,000) to prevent browser crashes
      • Layered generation for better performance
      • Shared geometry for all voxels of the same type
    3. Improved Terrain:

      • Multi-layered noise for more natural terrain variation
      • Height-based noise adjustment for better biome distribution
      • Enhanced materials with specular highlights
    4. Better Controls:

      • Smoother camera movement
      • Added UI instructions
      • Improved mouse rotation
    5. Visual Enhancements:

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.