Skip to content
TheChatArchiveThe Chat Archive
Claudeclaude-3-7-sonnet-20250219-thinking-32k· AnthropicHugging Face LMArena Human Preference 140K

Make me a squishy interactive cube in a single html file

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with Mistralmistral-medium-2505’s answer.
  1. User

    Make me a squishy interactive cube in a single html file

  2. Claude Assistant
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Squishy Interactive Cube</title>
        <style>
            body {
                margin: 0;
                height: 100vh;
                display: flex;
                justify-content: center;
                align-items: center;
                background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
                overflow: hidden;
                perspective: 1000px;
            }
            
            .cube-container {
                width: 200px;
                height: 200px;
                position: relative;
                transform-style: preserve-3d;
                transform: rotateX(-15deg) rotateY(15deg);
                transition: transform 0.5s ease;
                cursor: pointer;
            }
            
            .cube {
                width: 100%;
                height: 100%;
                position: relative;
                transform-style: preserve-3d;
                transform-origin: center center;
                transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
            }
            
            .face {
                position: absolute;
                width: 100%;
                height: 100%;
                background-color: rgba(64, 128, 255, 0.7);
                border: 2px solid rgba(255, 255, 255, 0.7);
                display: flex;
                justify-content: center;
                align-items: center;
                font-family: Arial, sans-serif;
                font-size: 24px;
                color: white;
                text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.3);
                box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.2);
                border-radius: 8px;
                backface-visibility: visible;
                transition: transform 0.3s;
            }
            
            .front  { transform: translateZ(100px); background-color: rgba(64, 128, 255, 0.8); }
            .back   { transform: rotateY(180deg) translateZ(100px); background-color: rgba(64, 96, 255, 0.8); }
            .right  { transform: rotateY(90deg) translateZ(100px); background-color: rgba(64, 160, 255, 0.8); }
            .left   { transform: rotateY(-90deg) translateZ(100px); background-color: rgba(32, 128, 255, 0.8); }
            .top    { transform: rotateX(90deg) translateZ(100px); background-color: rgba(96, 128, 255, 0.8); }
            .bottom { transform: rotateX(-90deg) translateZ(100px); background-color: rgba(128, 160, 255, 0.8); }
            
            .squished .front, .squished .back {
                transform: scale(1.1, 0.9) translateZ(80px);
            }
            .squished .right, .squished .left {
                transform: rotateY(90deg) scale(0.9, 0.9) translateZ(80px);
            }
            .squished .top, .squished .bottom {
                transform: rotateX(90deg) scale(1.1, 1.1) translateZ(80px);
            }
            
            .shadow {
                position: absolute;
                width: 200px;
                height: 200px;
                background: rgba(0, 0, 0, 0.2);
                transform: rotateX(90deg) translateZ(-120px) scale(0.8);
                filter: blur(20px);
                border-radius: 50%;
            }
        </style>
    </head>
    <body>
        <div class="shadow"></div>
        <div class="cube-container">
            <div class="cube">
                <div class="face front">Front</div>
                <div class="face back">Back</div>
                <div class="face right">Right</div>
                <div class="face left">Left</div>
                <div class="face top">Top</div>
                <div class="face bottom">Bottom</div>
            </div>
        </div>
    
        <script>
            const cube = document.querySelector('.cube');
            const container = document.querySelector('.cube-container');
            let isDragging = false;
            let previousMousePosition = { x: 0, y: 0 };
            let rotation = { x: -15, y: 15 };
            let currentScale = { x: 1, y: 1, z: 1 };
            let squishTimeout;
            
            // Handle mouse events for rotation
            container.addEventListener('mousedown', (e) => {
                isDragging = true;
                previousMousePosition = { x: e.clientX, y: e.clientY };
                
                // Squish effect on click
                squish();
            });
            
            document.addEventListener('mousemove', (e) => {
                if (!isDragging) return;
                
                const deltaMove = {
                    x: e.clientX - previousMousePosition.x,
                    y: e.clientY - previousMousePosition.y
                };
                
                // Adjust rotation based on mouse movement
                rotation.y += deltaMove.x * 0.5;
                rotation.x -= deltaMove.y * 0.5;
                
                // Apply the rotation
                container.style.transform = `rotateX(${rotation.x}deg) rotateY(${rotation.y}deg)`;
                
                previousMousePosition = { x: e.clientX, y: e.clientY };
            });
            
            document.addEventListener('mouseup', () => {
                isDragging = false;
                unSquish();
            });
            
            // Touch events for mobile
            container.addEventListener('touchstart', (e) => {
                previousMousePosition = { x: e.touches[0].clientX, y: e.touches[0].clientY };
                squish();
            });
            
            document.addEventListener('touchmove', (e) => {
                const deltaMove = {
                    x: e.touches[0].clientX - previousMousePosition.x,
                    y: e.touches[0].clientY - previousMousePosition.y
                };
                
                rotation.y += deltaMove.x * 0.5;
                rotation.x -= deltaMove.y * 0.5;
                
                container.style.transform = `rotateX(${rotation.x}deg) rotateY(${rotation.y}deg)`;
                
                previousMousePosition = { x: e.touches[0].clientX, y: e.touches[0].clientY };
            });
            
            document.addEventListener('touchend', () => {
                unSquish();
            });
            
            // Squish and unsquish functions
            function squish() {
                clearTimeout(squishTimeout);
                cube.classList.add('squished');
                
                // Add some spring wobble
                wobble();
            }
            
            function unSquish() {
                squishTimeout = setTimeout(() => {
                    cube.classList.remove('squished');
                }, 150);
            }
            
            function wobble() {
                let wobbleCount = 0;
                let wobbleAmount = 1.05;
                
                const wobbleInterval = setInterval(() => {
                    wobbleCount++;
                    wobbleAmount = wobbleAmount > 1 ? 0.97 : 1.03;
                    
                    cube.style.transform = `scale(${wobbleAmount}, ${2-wobbleAmount}, ${wobbleAmount})`;
                    
                    if (wobbleCount > 5) {
                        clearInterval(wobbleInterval);
                        cube.style.transform = '';
                    }
                }, 100);
            }
            
            // Automatic gentle rotation for when not interacting
            let autoRotate = true;
            
            function startAutoRotation() {
                if (!autoRotate) return;
                
                rotation.y += 0.2;
                container.style.transform = `rotateX(${rotation.x}deg) rotateY(${rotation.y}deg)`;
                requestAnimationFrame(startAutoRotation);
            }
            
            startAutoRotation();
            
            // Stop auto-rotation when interacting
            container.addEventListener('mousedown', () => {
                autoRotate = false;
            });
            
            // Double click to reset and resume auto-rotation
            container.addEventListener('dblclick', () => {
                rotation = { x: -15, y: 15 };
                container.style.transform = `rotateX(${rotation.x}deg) rotateY(${rotation.y}deg)`;
                autoRotate = true;
                startAutoRotation();
            });
        </script>
    </body>
    </html>
    

    Would you like me to explain or break down this code?

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