하나의 HTML 파일로 3D 메카 고질라 만들어
- User
하나의 HTML 파일로 3D 메카 고질라 만들어
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
하나의 HTML 파일로 3D 메카 고질라 만들어
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
다음은 Three.js를 사용하여 3D 메카 고질라를 표시하는 단일 HTML 파일입니다. 이 코드는 메카 고질라의 기본적인 3D 모델을 생성하고 애니메이션을 적용합니다.
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>3D 메카 고질라</title>
<style>
body {
margin: 0;
overflow: hidden;
background-color: #000;
}
canvas {
display: block;
}
#info {
position: absolute;
top: 10px;
width: 100%;
text-align: center;
color: white;
font-family: Arial, sans-serif;
pointer-events: none;
}
</style>
</head>
<body>
<div id="info">3D 메카 고질라 - 마우스로 회전, 스크롤로 확대/축소</div>
<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>
// 장면 설정
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x000000);
// 카메라 설정
const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
camera.position.set(0, 5, 15);
// 렌더러 설정
const renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.shadowMap.enabled = true;
document.body.appendChild(renderer.domElement);
// 조명 설정
const ambientLight = new THREE.AmbientLight(0x404040, 0.5);
scene.add(ambientLight);
const directionalLight = new THREE.DirectionalLight(0xffffff, 0.8);
directionalLight.position.set(5, 10, 7);
directionalLight.castShadow = true;
directionalLight.shadow.mapSize.width = 1024;
directionalLight.shadow.mapSize.height = 1024;
scene.add(directionalLight);
// 바닥 생성
const floorGeometry = new THREE.PlaneGeometry(50, 50);
const floorMaterial = new THREE.MeshStandardMaterial({
color: 0x333333,
roughness: 0.8,
metalness: 0.2
});
const floor = new THREE.Mesh(floorGeometry, floorMaterial);
floor.rotation.x = -Math.PI / 2;
floor.receiveShadow = true;
scene.add(floor);
// 메카 고질라 그룹 생성
const mechaGodzilla = new THREE.Group();
scene.add(mechaGodzilla);
// 몸통 생성
const bodyGeometry = new THREE.BoxGeometry(4, 6, 3);
const bodyMaterial = new THREE.MeshStandardMaterial({
color: 0x222222,
metalness: 0.8,
roughness: 0.3
});
const body = new THREE.Mesh(bodyGeometry, bodyMaterial);
body.position.y = 3;
body.castShadow = true;
mechaGodzilla.add(body);
// 머리 생성
const headGeometry = new THREE.BoxGeometry(2, 2, 2);
const headMaterial = new THREE.MeshStandardMaterial({
color: 0x333333,
metalness: 0.9,
roughness: 0.2
});
const head = new THREE.Mesh(headGeometry, headMaterial);
head.position.set(0, 5.5, 0);
head.castShadow = true;
mechaGodzilla.add(head);
// 눈 생성
const eyeGeometry = new THREE.SphereGeometry(0.3, 16, 16);
const eyeMaterial = new THREE.MeshStandardMaterial({
color: 0xff0000,
emissive: 0xff0000,
emissiveIntensity: 0.5
});
const leftEye = new THREE.Mesh(eyeGeometry, eyeMaterial);
leftEye.position.set(-0.5, 5.5, 1.1);
mechaGodzilla.add(leftEye);
const rightEye = new THREE.Mesh(eyeGeometry, eyeMaterial);
rightEye.position.set(0.5, 5.5, 1.1);
mechaGodzilla.add(rightEye);
// 팔 생성
const armGeometry = new THREE.BoxGeometry(1, 4, 1);
const armMaterial = new THREE.MeshStandardMaterial({
color: 0x444444,
metalness: 0.7,
roughness: 0.4
});
const leftArm = new THREE.Mesh(armGeometry, armMaterial);
leftArm.position.set(-2.5, 3, 0);
leftArm.castShadow = true;
mechaGodzilla.add(leftArm);
const rightArm = new THREE.Mesh(armGeometry, armMaterial);
rightArm.position.set(2.5, 3, 0);
rightArm.castShadow = true;
mechaGodzilla.add(rightArm);
// 다리 생성
const legGeometry = new THREE.BoxGeometry(1, 4, 1);
const legMaterial = new THREE.MeshStandardMaterial({
color: 0x444444,
metalness: 0.7,
roughness: 0.4
});
const leftLeg = new THREE.Mesh(legGeometry, legMaterial);
leftLeg.position.set(-1, 0, 0);
leftLeg.castShadow = true;
mechaGodzilla.add(leftLeg);
const rightLeg = new THREE.Mesh(legGeometry, legMaterial);
rightLeg.position.set(1, 0, 0);
rightLeg.castShadow = true;
mechaGodzilla.add(rightLeg);
// 꼬리 생성
const tailGeometry = new THREE.ConeGeometry(0.5, 3, 8);
tailGeometry.rotateX(Math.PI / 2);
const tailMaterial = new THREE.MeshStandardMaterial({
color: 0x555555,
metalness: 0.6,
roughness: 0.5
});
const tail = new THREE.Mesh(tailGeometry, tailMaterial);
tail.position.set(0, 2, -2);
tail.castShadow = true;
mechaGodzilla.add(tail);
// 등판 생성
const spineGeometry = new THREE.ConeGeometry(0.8, 2, 6);
spineGeometry.rotateX(Math.PI / 2);
const spineMaterial = new THREE.MeshStandardMaterial({
color: 0x666666,
metalness: 0.7,
roughness: 0.3
});
const spine1 = new THREE.Mesh(spineGeometry, spineMaterial);
spine1.position.set(0, 4, -1);
spine1.castShadow = true;
mechaGodzilla.add(spine1);
const spine2 = new THREE.Mesh(spineGeometry, spineMaterial);
spine2.position.set(0, 3, -1.5);
spine2.castShadow = true;
mechaGodzilla.add(spine2);
// 컨트롤 설정
const controls = new THREE.OrbitControls(camera, renderer.domElement);
controls.enableDamping = true;
controls.dampingFactor = 0.05;
// 애니메이션 설정
let time = 0;
const animate = function() {
requestAnimationFrame(animate);
time += 0.01;
// 메카 고질라 애니메이션
mechaGodzilla.rotation.y = Math.sin(time) * 0.1;
leftArm.rotation.x = Math.sin(time * 2) * 0.3;
rightArm.rotation.x = Math.sin(time * 2) * 0.3;
leftLeg.rotation.x = Math.sin(time * 1.5) * 0.2;
rightLeg.rotation.x = -Math.sin(time * 1.5) * 0.2;
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>
.html 파일로 저장하세요.이 코드는 기본적인 메카 고질라 모델을 제공하며, 더 복잡한 모델을 원하시면 3D 모델링 소프트웨어로 모델을 제작한 후 Three.js에 임포트하는 것이 좋습니다.