undefined / models.html
daltiboi's picture
Okay, now I need it to be able to make the assets (especially the 3D ones) more detailed. I asked it to make a dragon and it made a cube
f7f76eb verified
Raw History Blame Contribute Delete
15.3 kB
<!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>