멋진 요청이네요! HTML만으로 3D 메카 고질라를 완전히 만드는 것은 한계가 있지만, Three.js라는 자바스크립트 3D 라이브러리를 사용하면 하나의 HTML 파일에서 간단한 3D 메카 고질라를 만들 수 있습니다.
아래는 Three.js를 CDN으로 불러와서, 간단한 도형(박스, 원통, 구 등)으로 메카 고질라를 조립하는 예시입니다.
(실제 고질라와 똑같이 정교하진 않지만, 로봇 공룡 느낌의 3D 모델을 만듭니다.)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>3D Mecha Godzilla</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>
// 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);
// Light
const light = new THREE.DirectionalLight(0xffffff, 1.2);
light.position.set(10, 20, 10);
scene.add(light);
const ambient = new THREE.AmbientLight(0x888888);
scene.add(ambient);
// 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 yellow = new THREE.MeshStandardMaterial({color: 0xffff00, metalness: 0.7, roughness: 0.2});
// Body
const body = new THREE.Mesh(new THREE.CylinderGeometry(1.5, 2, 5, 16), metal);
body.position.y = 3;
scene.add(body);
// Head
const head = new THREE.Mesh(new THREE.SphereGeometry(1.1, 16, 16), metal);
head.position.set(0, 6.2, 0.5);
scene.add(head);
// Jaw
const jaw = new THREE.Mesh(new THREE.BoxGeometry(1.2, 0.4, 1), metal);
jaw.position.set(0, 5.4, 1.1);
scene.add(jaw);
// Eyes
const eyeL = new THREE.Mesh(new THREE.SphereGeometry(0.15, 8, 8), red);
eyeL.position.set(-0.4, 6.4, 1.2);
scene.add(eyeL);
const eyeR = eyeL.clone();
eyeR.position.x = 0.4;
scene.add(eyeR);
// Spikes (back)
for(let i=0; i<5; i++) {
const spike = new THREE.Mesh(new THREE.ConeGeometry(0.3, 1.2, 8), metal);
spike.position.set(0, 2.5 + i*0.7, -1.2 - i*0.2);
spike.rotation.x = -Math.PI/2.5;
scene.add(spike);
}
// Arms
function createArm(side) {
const arm = new THREE.Group();
const upper = new THREE.Mesh(new THREE.CylinderGeometry(0.25, 0.35, 1.5, 8), metal);
upper.position.y = -0.75;
upper.rotation.z = side * Math.PI/6;
arm.add(upper);
const lower = new THREE.Mesh(new THREE.CylinderGeometry(0.2, 0.25, 1.2, 8), metal);
lower.position.y = -1.6;
lower.rotation.z = side * Math.PI/8;
arm.add(lower);
const claw = new THREE.Mesh(new THREE.SphereGeometry(0.18, 8, 8), yellow);
claw.position.y = -2.2;
arm.add(claw);
arm.position.set(side*1.8, 4.2, 0.2);
arm.rotation.z = side * Math.PI/8;
scene.add(arm);
}
createArm(1);
createArm(-1);
// Legs
function createLeg(side) {
const leg = new THREE.Group();
const upper = new THREE.Mesh(new THREE.CylinderGeometry(0.4, 0.5, 2, 8), metal);
upper.position.y = -1;
leg.add(upper);
const lower = new THREE.Mesh(new THREE.CylinderGeometry(0.3, 0.4, 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.y = -3;
foot.position.z = 0.3;
leg.add(foot);
leg.position.set(side*1, 0.5, 0.2);
scene.add(leg);
}
createLeg(1);
createLeg(-1);
// Tail
for(let i=0; i<6; i++) {
const tailSeg = new THREE.Mesh(new THREE.CylinderGeometry(0.4-0.05*i, 0.3-0.04*i, 1, 8), metal);
tailSeg.position.set(0, 0.5-i*0.5, -2-i*0.7);
tailSeg.rotation.x = -Math.PI/10;
scene.add(tailSeg);
}
// Tail tip
const tailTip = new THREE.Mesh(new THREE.SphereGeometry(0.18, 8, 8), red);
tailTip.position.set(0, -2, -6.2);
scene.add(tailTip);
// Animation
function animate() {
requestAnimationFrame(animate);
scene.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 메카 고질라가 회전하는 모습을 볼 수 있습니다.
참고:
- 이 코드는 Three.js의 기본 도형만 사용해서 만든 단순한 메카 고질라입니다.
- 더 정교한 모델링은 Blender 등에서 모델링 후 glTF 등으로 불러와야 합니다.
- 이 예시는 "하나의 HTML 파일"에서 동작하도록 설계되었습니다.
필요에 따라 색상, 크기, 디테일을 더 추가해보세요!
궁금한 점이나 추가 요청이 있으면 언제든 말씀해 주세요.