멋진 요청이네요!
하나의 HTML 파일로 3D 메카 고질라를 만드는 것은 꽤 도전적인 작업입니다.
여기서는 Three.js라는 유명한 3D JavaScript 라이브러리를 사용해서,
간단한 형태의 "메카 고질라"를 만들어보겠습니다.
아래 코드는
- 별도의 설치 없이
- 하나의 HTML 파일로
- 브라우저에서 바로 실행할 수 있습니다.
참고:
실제 영화 속 메카 고질라처럼 정교하진 않지만,
박스, 원통, 구 등 기본 도형을 조합해 "메카 고질라" 느낌을 내는 예제입니다.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>3D Mecha Godzilla (Three.js)</title>
<style>
body { margin: 0; background: #222; }
canvas { display: block; }
</style>
</head>
<body>
<script src="https://cdn.jsdelivr.net/npm/three@0.153.0/build/three.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/three@0.153.0/examples/js/controls/OrbitControls.js"></script>
<script>
// Scene, Camera, Renderer
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x222222);
const camera = new THREE.PerspectiveCamera(60, window.innerWidth/window.innerHeight, 0.1, 1000);
camera.position.set(0, 5, 18);
const renderer = new THREE.WebGLRenderer({antialias: true});
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);
// Controls
const controls = new THREE.OrbitControls(camera, renderer.domElement);
// Light
const light = new THREE.DirectionalLight(0xffffff, 1.2);
light.position.set(10, 20, 10);
scene.add(light);
scene.add(new THREE.AmbientLight(0x888888, 0.7));
// Materials
const metal = new THREE.MeshStandardMaterial({color: 0x888888, metalness: 0.8, roughness: 0.3});
const red = new THREE.MeshStandardMaterial({color: 0xff2222, metalness: 0.7, roughness: 0.2});
const blue = new THREE.MeshStandardMaterial({color: 0x22aaff, metalness: 0.7, roughness: 0.2});
const yellow = new THREE.MeshStandardMaterial({color: 0xffee00, metalness: 0.7, roughness: 0.2});
// Group for Mecha Godzilla
const godzilla = new THREE.Group();
// Body
const body = new THREE.Mesh(new THREE.CylinderGeometry(1.8, 2.2, 5, 16), metal);
body.position.y = 3;
godzilla.add(body);
// Chest Plate
const chest = new THREE.Mesh(new THREE.BoxGeometry(2.5, 1.2, 1.2), metal);
chest.position.set(0, 4.2, 1.1);
godzilla.add(chest);
// Head
const head = new THREE.Mesh(new THREE.SphereGeometry(1.1, 16, 16), metal);
head.position.set(0, 6.2, 0.2);
godzilla.add(head);
// Jaw
const jaw = new THREE.Mesh(new THREE.BoxGeometry(1.2, 0.4, 1), metal);
jaw.position.set(0, 5.5, 0.5);
godzilla.add(jaw);
// Eyes
const eyeL = new THREE.Mesh(new THREE.SphereGeometry(0.15, 8, 8), red);
eyeL.position.set(-0.4, 6.5, 1);
godzilla.add(eyeL);
const eyeR = eyeL.clone();
eyeR.position.x = 0.4;
godzilla.add(eyeR);
// Spikes (back)
for(let i=0; i<5; i++) {
const spike = new THREE.Mesh(new THREE.ConeGeometry(0.4, 1.2, 8), blue);
spike.position.set(0, 2.2 + i*0.8, -1.5 - i*0.2);
spike.rotation.x = -Math.PI/2.5;
godzilla.add(spike);
}
// Arms
function createArm(side = 1) {
const arm = new THREE.Group();
const upper = new THREE.Mesh(new THREE.CylinderGeometry(0.3, 0.4, 1.6, 8), metal);
upper.position.y = -0.8;
upper.rotation.z = side * Math.PI/8;
arm.add(upper);
const lower = new THREE.Mesh(new THREE.CylinderGeometry(0.25, 0.3, 1.2, 8), metal);
lower.position.y = -1.7;
lower.rotation.z = side * Math.PI/10;
arm.add(lower);
const hand = new THREE.Mesh(new THREE.SphereGeometry(0.32, 8, 8), metal);
hand.position.y = -2.3;
arm.add(hand);
arm.position.set(side*2.1, 4.2, 0.2);
arm.rotation.z = side * Math.PI/8;
return arm;
}
godzilla.add(createArm(1));
godzilla.add(createArm(-1));
// Legs
function createLeg(side = 1) {
const leg = new THREE.Group();
const upper = new THREE.Mesh(new THREE.CylinderGeometry(0.5, 0.6, 2, 8), metal);
upper.position.y = -1;
leg.add(upper);
const lower = new THREE.Mesh(new THREE.CylinderGeometry(0.4, 0.5, 1.5, 8), metal);
lower.position.y = -2.2;
leg.add(lower);
const foot = new THREE.Mesh(new THREE.BoxGeometry(0.7, 0.3, 1.2), metal);
foot.position.set(0, -3, 0.3);
leg.add(foot);
leg.position.set(side*1.1, 0.5, 0.2);
return leg;
}
godzilla.add(createLeg(1));
godzilla.add(createLeg(-1));
// Tail
for(let i=0; i<7; i++) {
const tailSeg = new THREE.Mesh(new THREE.CylinderGeometry(0.5-0.06*i, 0.4-0.05*i, 1, 8), metal);
tailSeg.position.set(0, 0.5-i*0.2, -2.2-i*0.8);
tailSeg.rotation.x = -Math.PI/10;
godzilla.add(tailSeg);
}
// Tail tip
const tailTip = new THREE.Mesh(new THREE.ConeGeometry(0.18, 0.6, 8), yellow);
tailTip.position.set(0, -0.7, -7.2);
tailTip.rotation.x = -Math.PI/10;
godzilla.add(tailTip);
// Add to scene
scene.add(godzilla);
// Animation loop
function animate() {
requestAnimationFrame(animate);
godzilla.rotation.y += 0.005;
renderer.render(scene, camera);
}
animate();
// Responsive
window.addEventListener('resize', () => {
camera.aspect = window.innerWidth/window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
});
</script>
</body>
</html>
사용법
- 위 코드를 복사해서
.html 파일로 저장하세요.
- 크롬, 엣지, 파이어폭스 등 브라우저로 열면 3D 메카 고질라가 나타납니다!
- 마우스로 드래그해서 회전, 휠로 확대/축소할 수 있습니다.
더 정교한 모델링은 Blender 등 3D 툴에서 직접 모델링한 뒤 Three.js로 불러와야 합니다.
이 예제는 "기본 도형 조합"으로 만드는 간단한 버전입니다.
필요하다면 더 멋지게 커스터마이즈해보세요! 🚀