<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>Zep 3D Quiz</title>
<script src="https://cdn.jsdelivr.net/npm/three@0.132.2/build/three.min.js"></script>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
background: linear-gradient(135deg, #667eea, #764ba2);
font-family: 'Arial', sans-serif;
height: 100vh;
overflow: hidden;
}
.container {
max-width: 500px;
margin: 0 auto;
background: white;
border-radius: 20px;
box-shadow: 0 15px 35px rgba(0,0,0,0.2);
overflow: hidden;
display: flex;
flex-direction: column;
height: 90vh;
}
.header {
background: #6a11cb;
color: white;
padding: 15px;
text-align: center;
font-weight: bold;
font-size: 18px;
}
.content {
flex: 1;
display: flex;
flex-direction: column;
padding: 20px;
}
.question {
font-size: 18px;
color: #333;
margin-bottom: 20px;
text-align: center;
}
.options {
display: flex;
flex-direction: column;
gap: 10px;
margin-bottom: 20px;
}
.option {
padding: 12px;
background: #f0f0f0;
border: none;
border-radius: 12px;
cursor: pointer;
transition: 0.3s;
}
.option:hover {
background: #e0e0ff;
transform: scale(1.02);
}
#canvas-container {
width: 100%;
height: 200px;
background: #f8f9fa;
border-radius: 12px;
margin-bottom: 20px;
overflow: hidden;
}
.result {
display: none;
text-align: center;
}
.result h2 {
color: #6a11cb;
margin: 15px 0;
}
.result p {
color: #555;
line-height: 1.6;
}
</style>
</head>
<body>
<div class="container">
<div class="header">Zep 3D Quiz</div>
<div class="content">
<div id="canvas-container"></div>
<div id="quiz">
<div class="question" id="question"></div>
<div class="options" id="options"></div>
</div>
<div class="result" id="result">
<h2 id="result-title">결과: chill zep</h2>
<p id="result-desc">당신은 균형 잡힌 성격! 아바타도 중간의 매력을 뽐내요.</p>
</div>
</div>
</div>
<script>
// 🎮 Three.js 3D 아바타 설정
const container = document.getElementById('canvas-container');
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xf8f9fa);
const camera = new THREE.PerspectiveCamera(75, container.clientWidth / container.clientHeight, 0.1, 1000);
camera.position.z = 5;
const renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setSize(container.clientWidth, container.clientHeight);
container.appendChild(renderer.domElement);
// 아바타 (큐브로 대체 - 실제론 GLTF 모델 가능)
const geometry = new THREE.BoxGeometry(1, 1.5, 0.8);
const material = new THREE.MeshPhongMaterial({ color: 0x3498db });
const avatar = new THREE.Mesh(geometry, material);
avatar.position.y = -0.5;
scene.add(avatar);
// 조명
const light = new THREE.DirectionalLight(0xffffff, 1);
light.position.set(1, 1, 1).normalize();
scene.add(light);
const ambientLight = new THREE.AmbientLight(0xffffff, 0.5);
scene.add(ambientLight);
// 애니메이션 루프
let rotationSpeed = 0.01;
function animate() {
requestAnimationFrame(animate);
avatar.rotation.y += rotationSpeed;
renderer.render(scene, camera);
}
animate();
// 🧠 퀴즈 데이터
const quizData = [
{ question: "주말엔 주로?", options: ["집에서 쉬기", "밖에서 놀기"] },
{ question: "감정 표현은?", options: ["숨김", "표현함"] },
{ question: "새로운 것 도전?", options: ["조심스럽게", "즉흥적으로"] },
{ question: "사진 찍을 땐?", options: ["자연스럽게", "포즈 각 잡고"] },
{ question: "음악 스타일은?", options: ["힙합", "팝"] }
];
// 결과 매핑 (A=0, B=1)
const results = [
{ title: "calm zep", desc: "평온한 에너지를 가진 당신", color: 0x9C27B0 }, // 대부분 0
{ title: "vibe zep", desc: "에너제틱한 당신!", color: 0xFF5722 }, // 대부분 1
{ title: "chill zep", desc: "균형 잡힌 당신", color: 0x4CAF50 } // 혼합
];
// 상태
let currentQuestion = 0;
let answerCount = { 0: 0, 1: 0 };
// DOM 요소
const questionEl = document.getElementById("question");
const optionsEl = document.getElementById("options");
const quizEl = document.getElementById("quiz");
const resultEl = document.getElementById("result");
const resultTitle = document.getElementById("result-title");
const resultDesc = document.getElementById("result-desc");
// 질문 표시
function showQuestion() {
const q = quizData[currentQuestion];
questionEl.textContent = q.question;
optionsEl.innerHTML = "";
q.options.forEach((text, index) => {
const button = document.createElement("button");
button.classList.add("option");
button.textContent = text;
button.onclick = () => {
answerCount[index]++;
currentQuestion++;
if (currentQuestion < quizData.length) {
showQuestion();
} else {
showResult();
}
};
optionsEl.appendChild(button);
});
}
// 결과 표시 + 아바타 변화
function showResult() {
quizEl.style.display = "none";
resultEl.style.display = "block";
const totalA = answerCount[0];
const totalB = answerCount[1];
let result;
if (totalA >= 4) {
result = results[0]; // calm
} else if (totalB >= 4) {
result = results[1]; // vibe
} else {
result = results[2]; // chill
}
// 아바타 색상 변경
avatar.material.color.set(result.color);
rotationSpeed = totalB > totalA ? 0.03 : 0.005; // 활발하면 더 빨리 회전
resultTitle.textContent = result.title;
resultDesc.textContent = result.desc;
}
// 시작
showQuestion();
// 리사이즈 대응
window.addEventListener('resize', () => {
camera.aspect = container.clientWidth / container.clientHeight;
camera.updateProjectionMatrix();
renderer.setSize(container.clientWidth, container.clientHeight);
});
</script>
</body>
</html>