Skip to content
The Chat Archive
claude-3-7-sonnet-20250219-thinking-32k· Anthropic LMArena Human Preference 140K

하나의 HTML 파일로 3D 메카 고질라 만들어

  1. User

    하나의 HTML 파일로 3D 메카 고질라 만들어

  2. Assistant

    다음은 하나의 HTML 파일로 간단한 3D 메카 고질라를 만드는 코드입니다:

    <!DOCTYPE html>
    <html>
    <head>
        <meta charset="utf-8">
        <title>3D 메카 고질라</title>
        <style>
            body { margin: 0; overflow: hidden; }
            canvas { display: block; }
        </style>
    </head>
    <body>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>
        <script src="https://cdn.jsdelivr.net/npm/three@0.128.0/examples/js/controls/OrbitControls.min.js"></script>
        <script>
            // 장면 설정
            const scene = new THREE.Scene();
            scene.background = new THREE.Color(0x111111);
    
            // 카메라 설정
            const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
            camera.position.z = 15;
            camera.position.y = 5;
    
            // 렌더러 설정
            const renderer = new THREE.WebGLRenderer({ antialias: true });
            renderer.setSize(window.innerWidth, window.innerHeight);
            document.body.appendChild(renderer.domElement);
    
            // 조명 설정
            const ambientLight = new THREE.AmbientLight(0x404040);
            scene.add(ambientLight);
    
            const directionalLight = new THREE.DirectionalLight(0xffffff, 1);
            directionalLight.position.set(1, 1, 1);
            scene.add(directionalLight);
    
            // 메카 고질라 몸체 생성
            function createMechaGodzilla() {
                const group = new THREE.Group();
    
                // 몸통
                const bodyGeometry = new THREE.CylinderGeometry(1.5, 2, 4, 8);
                const bodyMaterial = new THREE.MeshPhongMaterial({ color: 0x7a7a7a, shininess: 100 });
                const body = new THREE.Mesh(bodyGeometry, bodyMaterial);
                body.position.y = 2;
                group.add(body);
    
                // 머리
                const headGeometry = new THREE.BoxGeometry(2, 1.5, 2.5);
                const headMaterial = new THREE.MeshPhongMaterial({ color: 0x8a8a8a, shininess: 100 });
                const head = new THREE.Mesh(headGeometry, headMaterial);
                head.position.y = 5;
                head.position.z = 0.5;
                group.add(head);
    
                // 목
                const neckGeometry = new THREE.CylinderGeometry(0.7, 1, 1, 8);
                const neckMaterial = new THREE.MeshPhongMaterial({ color: 0x6a6a6a, shininess: 100 });
                const neck = new THREE.Mesh(neckGeometry, neckMaterial);
                neck.position.y = 4;
                neck.position.z = 0.2;
                group.add(neck);
    
                // 눈
                const eyeGeometry = new THREE.SphereGeometry(0.2, 16, 16);
                const eyeMaterial = new THREE.MeshPhongMaterial({ color: 0xff0000, shininess: 100, emissive: 0xff0000 });
                
                const leftEye = new THREE.Mesh(eyeGeometry, eyeMaterial);
                leftEye.position.set(-0.6, 5.2, 1.3);
                group.add(leftEye);
                
                const rightEye = new THREE.Mesh(eyeGeometry, eyeMaterial);
                rightEye.position.set(0.6, 5.2, 1.3);
                group.add(rightEye);
    
                // 왼쪽 팔
                const leftArmGroup = new THREE.Group();
                
                const upperArmGeometry = new THREE.CylinderGeometry(0.5, 0.4, 2, 8);
                const armMaterial = new THREE.MeshPhongMaterial({ color: 0x6a6a6a, shininess: 100 });
                const leftUpperArm = new THREE.Mesh(upperArmGeometry, armMaterial);
                leftUpperArm.position.y = -1;
                leftUpperArm.rotation.x = 0.3;
                leftArmGroup.add(leftUpperArm);
                
                const lowerArmGeometry = new THREE.CylinderGeometry(0.4, 0.3, 2, 8);
                const leftLowerArm = new THREE.Mesh(lowerArmGeometry, armMaterial);
                leftLowerArm.position.y = -3;
                leftLowerArm.rotation.x = 0.5;
                leftArmGroup.add(leftLowerArm);
                
                leftArmGroup.position.set(-2.5, 3, 0);
                group.add(leftArmGroup);
    
                // 오른쪽 팔
                const rightArmGroup = new THREE.Group();
                
                const rightUpperArm = new THREE.Mesh(upperArmGeometry, armMaterial);
                rightUpperArm.position.y = -1;
                rightUpperArm.rotation.x = 0.3;
                rightArmGroup.add(rightUpperArm);
                
                const rightLowerArm = new THREE.Mesh(lowerArmGeometry, armMaterial);
                rightLowerArm.position.y = -3;
                rightLowerArm.rotation.x = 0.5;
                rightArmGroup.add(rightLowerArm);
                
                rightArmGroup.position.set(2.5, 3, 0);
                group.add(rightArmGroup);
    
                // 다리
                const legGeometry = new THREE.CylinderGeometry(0.6, 0.4, 3, 8);
                const legMaterial = new THREE.MeshPhongMaterial({ color: 0x5a5a5a, shininess: 100 });
                
                const leftLeg = new THREE.Mesh(legGeometry, legMaterial);
                leftLeg.position.set(-1.2, -1.5, 0);
                group.add(leftLeg);
                
                const rightLeg = new THREE.Mesh(legGeometry, legMaterial);
                rightLeg.position.set(1.2, -1.5, 0);
                group.add(rightLeg);
    
                // 꼬리
                const tailGroup = new THREE.Group();
                
                const tailGeometry1 = new THREE.CylinderGeometry(0.7, 0.5, 2, 8);
                const tailMaterial = new THREE.MeshPhongMaterial({ color: 0x7a7a7a, shininess: 100 });
                const tail1 = new THREE.Mesh(tailGeometry1, tailMaterial);
                tailGroup.add(tail1);
                
                const tailGeometry2 = new THREE.CylinderGeometry(0.5, 0.3, 2, 8);
                const tail2 = new THREE.Mesh(tailGeometry2, tailMaterial);
                tail2.position.z = 2;
                tailGroup.add(tail2);
                
                const tailGeometry3 = new THREE.CylinderGeometry(0.3, 0.1, 2, 8);
                const tail3 = new THREE.Mesh(tailGeometry3, tailMaterial);
                tail3.position.z = 4;
                tailGroup.add(tail3);
                
                tailGroup.rotation.x = -Math.PI / 2;
                tailGroup.position.set(0, 2, -2);
                group.add(tailGroup);
    
                return group;
            }
    
            const mechaGodzilla = createMechaGodzilla();
            scene.add(mechaGodzilla);
    
            // 바닥 추가
            const floorGeometry = new THREE.PlaneGeometry(20, 20);
            const floorMaterial = new THREE.MeshPhongMaterial({ color: 0x333333, side: THREE.DoubleSide });
            const floor = new THREE.Mesh(floorGeometry, floorMaterial);
            floor.rotation.x = Math.PI / 2;
            floor.position.y = -3;
            scene.add(floor);
    
            // 컨트롤 추가
            const controls = new THREE.OrbitControls(camera, renderer.domElement);
            controls.enableDamping = true;
            controls.dampingFactor = 0.05;
    
            // 애니메이션
            function animate() {
                requestAnimationFrame(animate);
                mechaGodzilla.rotation.y += 0.005;
                controls.update();
                renderer.render(scene, camera);
            }
    
            // 화면 크기 조정
            window.addEventListener('resize', function() {
                camera.aspect = window.innerWidth / window.innerHeight;
                camera.updateProjectionMatrix();
                renderer.setSize(window.innerWidth, window.innerHeight);
            });
    
            animate();
        </script>
    </body>
    </html>
    

    이 코드를 실행하면 어떻게 작동하는지 설명해 드릴까요?

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