File size: 15,339 Bytes
f7f76eb | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 | <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>BlockCraft Studio | 3D Models</title>
<link rel="icon" type="image/x-icon" href="/static/favicon.ico">
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
<script src="https://unpkg.com/feather-icons"></script>
<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 src="https://cdn.jsdelivr.net/npm/three@0.132.2/examples/js/loaders/GLTFLoader.js"></script>
<style>
.model-card:hover .model-preview {
transform: scale(1.03);
}
#viewport {
width: 100%;
height: 100%;
}
.category-btn.active {
background-color: #3b82f6;
color: white;
}
</style>
</head>
<body class="bg-slate-900 text-gray-100 min-h-screen">
<!-- Navbar -->
<nav class="bg-slate-800/80 border-b border-slate-700">
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
<div class="flex items-center justify-between h-16">
<div class="flex items-center">
<div class="flex-shrink-0">
<div class="flex items-center">
<i data-feather="box" class="text-blue-400 mr-2"></i>
<span class="text-xl font-bold bg-gradient-to-r from-blue-400 to-emerald-400 bg-clip-text text-transparent">BlockCraft Studio</span>
</div>
</div>
<div class="hidden md:block">
<div class="ml-10 flex items-baseline space-x-4">
<a href="index.html" class="text-gray-300 hover:bg-slate-700 hover:text-white px-3 py-2 rounded-md text-sm font-medium">Home</a>
<a href="editor.html" class="bg-slate-700 text-white px-3 py-2 rounded-md text-sm font-medium">AI Creator</a>
<a href="models.html" class="text-gray-300 hover:bg-slate-700 hover:text-white px-3 py-2 rounded-md text-sm font-medium">3D Models</a>
<a href="#" class="text-gray-300 hover:bg-slate-700 hover:text-white px-3 py-2 rounded-md text-sm font-medium">Tutorials</a>
</div>
</div>
</div>
<div class="hidden md:block">
<div class="ml-4 flex items-center md:ml-6">
<button class="bg-blue-500 hover:bg-blue-600 text-white px-4 py-2 rounded-md text-sm font-medium flex items-center">
<i data-feather="download" class="mr-2 w-4 h-4"></i>
Download
</button>
</div>
</div>
</div>
</div>
</nav>
<!-- Main Content -->
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
<div class="flex flex-col md:flex-row gap-8">
<!-- Model Preview -->
<div class="flex-1 bg-slate-800/80 border border-slate-700 rounded-xl p-4">
<div id="viewport" class="w-full h-96 rounded-lg overflow-hidden">
<div class="w-full h-full flex items-center justify-center">
<div class="text-center">
<i data-feather="box" class="w-16 h-16 mx-auto text-slate-500"></i>
<p class="text-slate-400 mt-2">Select a model to preview</p>
</div>
</div>
</div>
<div class="mt-4">
<h2 class="text-xl font-bold text-white" id="model-title">No Model Selected</h2>
<p class="text-gray-400 mt-1" id="model-description">Select a model from the library to preview it here</p>
<div class="mt-4 flex space-x-2">
<button id="import-btn" class="bg-blue-500 hover:bg-blue-600 text-white px-4 py-2 rounded-md text-sm font-medium flex items-center" disabled>
<i data-feather="plus" class="mr-2 w-4 h-4"></i>
Import to Editor
</button>
<button class="bg-slate-700 hover:bg-slate-600 text-white px-4 py-2 rounded-md text-sm font-medium flex items-center">
<i data-feather="download" class="mr-2 w-4 h-4"></i>
Download
</button>
</div>
</div>
</div>
<!-- Model Library -->
<div class="w-full md:w-80 bg-slate-800/80 border border-slate-700 rounded-xl p-4">
<div class="flex space-x-2 mb-4 overflow-x-auto pb-2">
<button class="category-btn active px-3 py-1 rounded-full text-sm bg-blue-500 text-white">All</button>
<button class="category-btn px-3 py-1 rounded-full text-sm bg-slate-700 text-gray-300">Creatures</button>
<button class="category-btn px-3 py-1 rounded-full text-sm bg-slate-700 text-gray-300">Structures</button>
<button class="category-btn px-3 py-1 rounded-full text-sm bg-slate-700 text-gray-300">Vehicles</button>
<button class="category-btn px-3 py-1 rounded-full text-sm bg-slate-700 text-gray-300">Furniture</button>
<button class="category-btn px-3 py-1 rounded-full text-sm bg-slate-700 text-gray-300">Weapons</button>
</div>
<div class="space-y-3 max-h-[32rem] overflow-y-auto">
<!-- Dragon Model -->
<div class="model-card bg-slate-700 rounded-lg p-3 cursor-pointer" data-model="dragon">
<div class="model-preview bg-slate-800 rounded h-24 flex items-center justify-center transition-transform">
<i data-feather="box" class="text-blue-400 w-8 h-8"></i>
</div>
<h3 class="text-sm font-medium text-white mt-2">Dragon</h3>
<p class="text-xs text-gray-400">Detailed winged creature with animations</p>
</div>
<!-- Castle Model -->
<div class="model-card bg-slate-700 rounded-lg p-3 cursor-pointer" data-model="castle">
<div class="model-preview bg-slate-800 rounded h-24 flex items-center justify-center transition-transform">
<i data-feather="box" class="text-blue-400 w-8 h-8"></i>
</div>
<h3 class="text-sm font-medium text-white mt-2">Medieval Castle</h3>
<p class="text-xs text-gray-400">Large structure with towers and walls</p>
</div>
<!-- Airship Model -->
<div class="model-card bg-slate-700 rounded-lg p-3 cursor-pointer" data-model="airship">
<div class="model-preview bg-slate-800 rounded h-24 flex items-center justify-center transition-transform">
<i data-feather="box" class="text-blue-400 w-8 h-8"></i>
</div>
<h3 class="text-sm font-medium text-white mt-2">Steampunk Airship</h3>
<p class="text-xs text-gray-400">Flying vehicle with propellers</p>
</div>
<!-- Robot Model -->
<div class="model-card bg-slate-700 rounded-lg p-3 cursor-pointer" data-model="robot">
<div class="model-preview bg-slate-800 rounded h-24 flex items-center justify-center transition-transform">
<i data-feather="box" class="text-blue-400 w-8 h-8"></i>
</div>
<h3 class="text-sm font-medium text-white mt-2">Mech Robot</h3>
<p class="text-xs text-gray-400">Animated robotic character</p>
</div>
<!-- Tree Model -->
<div class="model-card bg-slate-700 rounded-lg p-3 cursor-pointer" data-model="tree">
<div class="model-preview bg-slate-800 rounded h-24 flex items-center justify-center transition-transform">
<i data-feather="box" class="text-blue-400 w-8 h-8"></i>
</div>
<h3 class="text-sm font-medium text-white mt-2">Magic Tree</h3>
<p class="text-xs text-gray-400">Animated glowing tree</p>
</div>
</div>
</div>
</div>
</div>
<script>
// Initialize Three.js scene
let scene, camera, renderer, controls, currentModel;
function initViewport() {
const viewport = document.getElementById('viewport');
// Clear any existing content
viewport.innerHTML = '';
// Setup Three.js scene
scene = new THREE.Scene();
scene.background = new THREE.Color(0x0f172a);
// Add lights
const ambientLight = new THREE.AmbientLight(0x404040);
scene.add(ambientLight);
const directionalLight = new THREE.DirectionalLight(0xffffff, 1);
directionalLight.position.set(1, 1, 1).normalize();
scene.add(directionalLight);
// Setup camera
camera = new THREE.PerspectiveCamera(75, viewport.clientWidth / viewport.clientHeight, 0.1, 1000);
camera.position.z = 5;
// Setup renderer
renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setSize(viewport.clientWidth, viewport.clientHeight);
viewport.appendChild(renderer.domElement);
// Add orbit controls
controls = new THREE.OrbitControls(camera, renderer.domElement);
controls.enableDamping = true;
controls.dampingFactor = 0.25;
// Render loop
function animate() {
requestAnimationFrame(animate);
controls.update();
renderer.render(scene, camera);
}
animate();
}
// Load model function
function loadModel(modelName) {
// Remove existing model
if (currentModel) {
scene.remove(currentModel);
}
const viewport = document.getElementById('viewport');
viewport.innerHTML = '';
renderer.setSize(viewport.clientWidth, viewport.clientHeight);
viewport.appendChild(renderer.domElement);
// Show loading state
const loadingDiv = document.createElement('div');
loadingDiv.className = 'w-full h-full flex items-center justify-center';
loadingDiv.innerHTML = `
<div class="text-center">
<i data-feather="loader" class="w-8 h-8 mx-auto text-blue-400 animate-spin"></i>
<p class="text-blue-400 mt-2">Loading model...</p>
</div>
`;
viewport.appendChild(loadingDiv);
feather.replace();
// Simulate loading different models
setTimeout(() => {
viewport.removeChild(loadingDiv);
viewport.appendChild(renderer.domElement);
// In a real app, this would load actual GLTF models
let geometry;
switch(modelName) {
case 'dragon':
geometry = new THREE.BoxGeometry(1, 0.5, 2);
updateModelInfo('Dragon', 'A majestic flying creature with detailed wings and scales');
break;
case 'castle':
geometry = new THREE.BoxGeometry(2, 1, 1.5);
updateModelInfo('Medieval Castle', 'A grand castle with multiple towers and walls');
break;
case 'airship':
geometry = new THREE.BoxGeometry(1.5, 0.5, 0.8);
updateModelInfo('Steampunk Airship', 'A flying vehicle with rotating propellers');
break;
case 'robot':
geometry = new THREE.BoxGeometry(0.8, 1.2, 0.8);
updateModelInfo('Mech Robot', 'A mechanical warrior with animated joints');
break;
case 'tree':
geometry = new THREE.BoxGeometry(0.7, 1.5, 0.7);
updateModelInfo('Magic Tree', 'An enchanted tree with glowing leaves');
break;
default:
geometry = new THREE.BoxGeometry(1, 1, 1);
}
const material = new THREE.MeshPhongMaterial({
color: 0x3b82f6,
specular: 0x111111,
shininess: 30
});
currentModel = new THREE.Mesh(geometry, material);
scene.add(currentModel);
// Update import button
document.getElementById('import-btn').disabled = false;
}, 1500);
}
function updateModelInfo(title, description) {
document.getElementById('model-title').textContent = title;
document.getElementById('model-description').textContent = description;
}
// Initialize when DOM loads
document.addEventListener('DOMContentLoaded', () => {
initViewport();
feather.replace();
// Handle model selection
document.querySelectorAll('.model-card').forEach(card => {
card.addEventListener('click', () => {
loadModel(card.dataset.model);
});
});
// Handle category filtering
document.querySelectorAll('.category-btn').forEach(btn => {
btn.addEventListener('click', () => {
document.querySelector('.category-btn.active').classList.remove('active', 'bg-blue-500', 'text-white');
document.querySelector('.category-btn.active').classList.add('bg-slate-700', 'text-gray-300');
btn.classList.add('active', 'bg-blue-500', 'text-white');
btn.classList.remove('bg-slate-700', 'text-gray-300');
});
});
// Handle import to editor
document.getElementById('import-btn').addEventListener('click', () => {
// In a real app, this would send the model to the editor
alert('Model would be imported to editor in the full application');
});
});
</script>
</body>
</html> |