하나의 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.
아래는 단일 HTML 파일로 3D 메카 고질라(메카 고지라)를 간단히 구현한 예시입니다. Three.js 라이브러리를 사용하여 기본적인 3D 구조와 애니메이션을 구현했습니다. 실제 메카 고지라 모델은 복잡한 3D 파일이 필요하지만, 이 예제는 기본적인 형태와 시각 효과를 보여줍니다.
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<title>3D 메카 고질라</title>
<style>
body { margin: 0; overflow: hidden; }
canvas { display: block; }
</style>
</head>
<body>
<!-- Three.js CDN -->
<script src="https://cdn.jsdelivr.net/npm/three@0.158.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(
75, window.innerWidth/window.innerHeight, 0.1, 1000
);
camera.position.set(0, 10, 20);
const renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);
// 조명 추가
const ambientLight = new THREE.AmbientLight(0xffffff, 0.5);
scene.add(ambientLight);
const directionalLight = new THREE.DirectionalLight(0xffffff, 1);
directionalLight.position.set(10, 20, 10);
scene.add(directionalLight);
// 메카 고지라 기본 구조 (큐브로 대체)
const bodyGeometry = new THREE.BoxGeometry(5, 3, 2);
const bodyMaterial = new THREE.MeshStandardMaterial({ color: 0x888888 });
const body = new THREE.Mesh(bodyGeometry, bodyMaterial);
scene.add(body);
const headGeometry = new THREE.SphereGeometry(1, 16, 16);
const headMaterial = new THREE.MeshStandardMaterial({ color: 0xff0000 });
const head = new THREE.Mesh(headGeometry, headMaterial);
head.position.y = 3;
scene.add(head);
const legGeometry = new THREE.BoxGeometry(0.5, 2, 0.5);
const legMaterial = new THREE.MeshStandardMaterial({ color: 0x444444 });
// 다리 생성
const leftLeg = new THREE.Mesh(legGeometry, legMaterial);
leftLeg.position.set(-1.25, 0, 0);
scene.add(leftLeg);
const rightLeg = new THREE.Mesh(legGeometry, legMaterial);
rightLeg.position.set(1.25, 0, 0);
scene.add(rightLeg);
// 터렛 추가
const turretGeometry = new THREE.CylinderGeometry(0.3, 0.3, 1, 16);
const turretMaterial = new THREE.MeshStandardMaterial({ color: 0x00ff00 });
const turret = new THREE.Mesh(turretGeometry, turretMaterial);
turret.position.y = 3.5;
scene.add(turret);
// 카메라 제어 (OrbitControls)
const controls = new THREE.OrbitControls(camera, renderer.domElement);
controls.enableDamping = true;
// 애니메이션 루프
function animate() {
requestAnimationFrame(animate);
// 간단한 애니메이션
body.rotation.y += 0.01;
head.rotation.y += 0.02;
turret.rotation.z += 0.01;
controls.update();
renderer.render(scene, camera);
}
animate();
// 창 크기 조정
window.addEventListener('resize', () => {
camera.aspect = window.innerWidth/window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
});
</script>
</body>
</html>
실제 메카 고지라 모델을 GLTFLoader로 불러오고 싶다면:
import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js';
(CDN으로 GLTFLoader를 별도로 로드해야 함)
텍스처, 물리 엔진, 복잡한 애니메이션 추가 가능
이 코드는 기본적인 3D 구조를 보여주며, 실제 메카 고지라 모델은 별도의 3D 모델 파일(예: .glb, .gltf)이 필요합니다. 필요에 따라 더 복잡한 구조나 효과를 추가할 수 있습니다.