Spaces:
Running
Running
Download index.html from lukeclay17/undefined: direct link, hf CLI and curl.
- Browser
- Download file 34 kB
-
https://huggingface.co/spaces/lukeclay17/undefined/resolve/main/index.html
- Command line
-
hf download hf://spaces/lukeclay17/undefined/index.html
-
curl -L -o index.html https://huggingface.co/spaces/lukeclay17/undefined/resolve/main/index.html
34 kB
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>ThreadCraft Studio | 3D Apparel Design Tool</title> | |
| <script src="https://cdn.tailwindcss.com"></script> | |
| <script src="https://unpkg.com/feather-icons"></script> | |
| <script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></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> | |
| #canvas-container { | |
| position: relative; | |
| width: 100%; | |
| height: 70vh; | |
| border: 2px dashed #e2e8f0; | |
| border-radius: 16px; | |
| overflow: hidden; | |
| } | |
| .color-picker { | |
| width: 30px; | |
| height: 30px; | |
| border-radius: 50%; | |
| cursor: pointer; | |
| transition: transform 0.2s; | |
| } | |
| .color-picker:hover { | |
| transform: scale(1.1); | |
| } | |
| .tool-btn { | |
| transition: all 0.2s; | |
| } | |
| .tool-btn:hover { | |
| transform: translateY(-2px); | |
| box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1); | |
| } | |
| #loading-overlay { | |
| position: fixed; | |
| top: 0; | |
| left: 0; | |
| width: 100%; | |
| height: 100%; | |
| background: rgba(255, 255, 255, 0.9); | |
| display: flex; | |
| justify-content: center; | |
| align-items: center; | |
| z-index: 9999; | |
| } | |
| </style> | |
| </head> | |
| <body class="bg-gray-50"> | |
| <div id="loading-overlay"> | |
| <div class="text-center"> | |
| <div class="animate-spin rounded-full h-12 w-12 border-t-2 border-b-2 border-indigo-500 mx-auto"></div> | |
| <p class="mt-4 text-gray-700">Loading 3D engine...</p> | |
| </div> | |
| </div> | |
| <!-- Navigation --> | |
| <nav class="bg-white shadow-sm"> | |
| <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8"> | |
| <div class="flex justify-between h-16"> | |
| <div class="flex items-center"> | |
| <i data-feather="scissors" class="text-indigo-600 mr-2"></i> | |
| <span class="text-xl font-bold text-gray-900">ThreadCraft Studio</span> | |
| </div> | |
| <div class="flex items-center space-x-4"> | |
| <button class="px-4 py-2 rounded-md bg-indigo-600 text-white hover:bg-indigo-700 transition-colors"> | |
| <i data-feather="user" class="mr-2"></i> Sign In | |
| </button> | |
| </div> | |
| </div> | |
| </div> | |
| </nav> | |
| <!-- Main Content --> | |
| <main class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8"> | |
| <div class="flex flex-col lg:flex-row gap-8"> | |
| <!-- Tools Panel --> | |
| <div class="w-full lg:w-1/4 bg-white p-6 rounded-xl shadow-sm"> | |
| <h2 class="text-lg font-semibold mb-4 flex items-center"> | |
| <i data-feather="sliders" class="mr-2"></i> Design Tools | |
| </h2> | |
| <!-- Apparel Selection --> | |
| <div class="mb-6"> | |
| <h3 class="text-sm font-medium text-gray-700 mb-2">Choose Apparel</h3> | |
| <div class="grid grid-cols-2 gap-2"> | |
| <button class="tool-btn p-3 bg-gray-100 rounded-lg flex flex-col items-center" data-apparel="tshirt"> | |
| <i data-feather="shirt" class="text-indigo-600 mb-1"></i> | |
| <span class="text-xs">T-Shirt</span> | |
| </button> | |
| <button class="tool-btn p-3 bg-gray-100 rounded-lg flex flex-col items-center" data-apparel="hoodie"> | |
| <i data-feather="wind" class="text-indigo-600 mb-1"></i> | |
| <span class="text-xs">Hoodie</span> | |
| </button> | |
| <button class="tool-btn p-3 bg-gray-100 rounded-lg flex flex-col items-center" data-apparel="pants"> | |
| <i data-feather="watch" class="text-indigo-600 mb-1"></i> | |
| <span class="text-xs">Pants</span> | |
| </button> | |
| <button class="tool-btn p-3 bg-gray-100 rounded-lg flex flex-col items-center" data-apparel="jacket"> | |
| <i data-feather="truck" class="text-indigo-600 mb-1"></i> | |
| <span class="text-xs">Jacket</span> | |
| </button> | |
| </div> | |
| </div> | |
| <!-- Color Picker --> | |
| <div class="mb-6"> | |
| <h3 class="text-sm font-medium text-gray-700 mb-2">Base Color</h3> | |
| <div class="flex flex-wrap gap-2"> | |
| <div class="color-picker bg-white border border-gray-300" data-color="#ffffff"></div> | |
| <div class="color-picker bg-black" data-color="#000000"></div> | |
| <div class="color-picker bg-red-500" data-color="#ef4444"></div> | |
| <div class="color-picker bg-blue-500" data-color="#3b82f6"></div> | |
| <div class="color-picker bg-green-500" data-color="#10b981"></div> | |
| <div class="color-picker bg-yellow-500" data-color="#f59e0b"></div> | |
| <div class="color-picker bg-purple-500" data-color="#8b5cf6"></div> | |
| <div class="color-picker bg-pink-500" data-color="#ec4899"></div> | |
| <div class="color-picker bg-gray-400" data-color="#9ca3af"></div> | |
| </div> | |
| <input type="color" class="mt-2 w-full h-10 cursor-pointer" value="#3b82f6"> | |
| </div> | |
| <!-- Design Upload --> | |
| <div class="mb-6"> | |
| <h3 class="text-sm font-medium text-gray-700 mb-2">Add Design</h3> | |
| <div class="border-2 border-dashed border-gray-300 rounded-lg p-4 text-center cursor-pointer hover:bg-gray-50"> | |
| <i data-feather="upload" class="mx-auto text-gray-400 mb-2"></i> | |
| <p class="text-xs text-gray-500">Upload your design (PNG, SVG)</p> | |
| <input type="file" class="hidden" accept="image/*"> | |
| </div> | |
| </div> | |
| <!-- Tech Pack Options --> | |
| <div class="mb-6"> | |
| <h3 class="text-sm font-medium text-gray-700 mb-2">Tech Pack Details</h3> | |
| <div class="space-y-3"> | |
| <div> | |
| <label class="text-xs text-gray-600">Fabric Type</label> | |
| <select class="w-full p-2 border border-gray-300 rounded-md text-sm"> | |
| <option>Cotton</option> | |
| <option>Polyester</option> | |
| <option>Blend</option> | |
| <option>Linen</option> | |
| <option>Denim</option> | |
| </select> | |
| </div> | |
| <div> | |
| <label class="text-xs text-gray-600">Sizes</label> | |
| <div class="flex flex-wrap gap-1 mt-1"> | |
| <span class="px-2 py-1 bg-gray-100 text-xs rounded">XS</span> | |
| <span class="px-2 py-1 bg-gray-100 text-xs rounded">S</span> | |
| <span class="px-2 py-1 bg-gray-100 text-xs rounded">M</span> | |
| <span class="px-2 py-1 bg-gray-100 text-xs rounded">L</span> | |
| <span class="px-2 py-1 bg-gray-100 text-xs rounded">XL</span> | |
| <span class="px-2 py-1 bg-gray-100 text-xs rounded">XXL</span> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Action Buttons --> | |
| <div class="space-y-2"> | |
| <button class="w-full py-2 bg-indigo-600 text-white rounded-md hover:bg-indigo-700 flex items-center justify-center"> | |
| <i data-feather="save" class="mr-2"></i> Save Design | |
| </button> | |
| <button class="w-full py-2 border border-indigo-600 text-indigo-600 rounded-md hover:bg-indigo-50 flex items-center justify-center"> | |
| <i data-feather="download" class="mr-2"></i> Export Tech Pack | |
| </button> | |
| </div> | |
| </div> | |
| <!-- 3D Canvas --> | |
| <div class="w-full lg:w-3/4"> | |
| <div class="bg-white p-6 rounded-xl shadow-sm"> | |
| <div class="flex justify-between items-center mb-4"> | |
| <h2 class="text-lg font-semibold flex items-center"> | |
| <i data-feather="box" class="mr-2"></i> 3D Preview | |
| </h2> | |
| <div class="flex space-x-2"> | |
| <button class="p-2 bg-gray-100 rounded-md hover:bg-gray-200"> | |
| <i data-feather="rotate-cw"></i> | |
| </button> | |
| <button class="p-2 bg-gray-100 rounded-md hover:bg-gray-200"> | |
| <i data-feather="maximize"></i> | |
| </button> | |
| </div> | |
| </div> | |
| <div id="canvas-container"> | |
| <!-- 3D canvas will be injected here --> | |
| </div> | |
| <div class="mt-4 flex justify-between items-center"> | |
| <div class="text-sm text-gray-500"> | |
| <span class="font-medium">Current:</span> <span id="current-apparel">Basic T-Shirt (White)</span> | |
| </div> | |
| <div class="flex space-x-2"> | |
| <button class="p-2 bg-gray-100 rounded-md hover:bg-gray-200"> | |
| <i data-feather="share-2"></i> | |
| </button> | |
| <button class="p-2 bg-gray-100 rounded-md hover:bg-gray-200"> | |
| <i data-feather="settings"></i> | |
| </button> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Design History --> | |
| <div class="mt-6 bg-white p-6 rounded-xl shadow-sm"> | |
| <h2 class="text-lg font-semibold mb-4 flex items-center"> | |
| <i data-feather="clock" class="mr-2"></i> Recent Designs | |
| </h2> | |
| <div class="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 gap-4"> | |
| <div class="border p-2 rounded-lg cursor-pointer hover:border-indigo-300"> | |
| <div class="bg-gray-100 h-24 rounded-md mb-2"></div> | |
| <p class="text-xs font-medium">Summer Collection</p> | |
| <p class="text-xs text-gray-500">Modified 2h ago</p> | |
| </div> | |
| <div class="border p-2 rounded-lg cursor-pointer hover:border-indigo-300"> | |
| <div class="bg-gray-100 h-24 rounded-md mb-2"></div> | |
| <p class="text-xs font-medium">Brand Logo</p> | |
| <p class="text-xs text-gray-500">Modified 1d ago</p> | |
| </div> | |
| <div class="border p-2 rounded-lg cursor-pointer hover:border-indigo-300"> | |
| <div class="bg-gray-100 h-24 rounded-md mb-2"></div> | |
| <p class="text-xs font-medium">Team Hoodies</p> | |
| <p class="text-xs text-gray-500">Modified 3d ago</p> | |
| </div> | |
| <div class="border p-2 rounded-lg cursor-pointer hover:border-indigo-300"> | |
| <div class="bg-gray-100 h-24 rounded-md mb-2"></div> | |
| <p class="text-xs font-medium">New Arrival</p> | |
| <p class="text-xs text-gray-500">Modified 1w ago</p> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| </main> | |
| <!-- Footer --> | |
| <footer class="bg-white border-t mt-12"> | |
| <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8"> | |
| <div class="grid grid-cols-1 md:grid-cols-4 gap-8"> | |
| <div> | |
| <h3 class="text-sm font-semibold text-gray-900 mb-4">ThreadCraft Studio</h3> | |
| <p class="text-sm text-gray-500">The ultimate 3D apparel design tool for creators and manufacturers.</p> | |
| </div> | |
| <div> | |
| <h3 class="text-sm font-semibold text-gray-900 mb-4">Resources</h3> | |
| <ul class="space-y-2"> | |
| <li><a href="#" class="text-sm text-gray-500 hover:text-indigo-600">Tutorials</a></li> | |
| <li><a href="#" class="text-sm text-gray-500 hover:text-indigo-600">Templates</a></li> | |
| <li><a href="#" class="text-sm text-gray-500 hover:text-indigo-600">Design Guides</a></li> | |
| </ul> | |
| </div> | |
| <div> | |
| <h3 class="text-sm font-semibold text-gray-900 mb-4">Company</h3> | |
| <ul class="space-y-2"> | |
| <li><a href="#" class="text-sm text-gray-500 hover:text-indigo-600">About</a></li> | |
| <li><a href="#" class="text-sm text-gray-500 hover:text-indigo-600">Blog</a></li> | |
| <li><a href="#" class="text-sm text-gray-500 hover:text-indigo-600">Careers</a></li> | |
| </ul> | |
| </div> | |
| <div> | |
| <h3 class="text-sm font-semibold text-gray-900 mb-4">Legal</h3> | |
| <ul class="space-y-2"> | |
| <li><a href="#" class="text-sm text-gray-500 hover:text-indigo-600">Privacy</a></li> | |
| <li><a href="#" class="text-sm text-gray-500 hover:text-indigo-600">Terms</a></li> | |
| <li><a href="#" class="text-sm text-gray-500 hover:text-indigo-600">Cookie Policy</a></li> | |
| </ul> | |
| </div> | |
| </div> | |
| <div class="mt-8 pt-8 border-t border-gray-200 flex justify-between"> | |
| <p class="text-sm text-gray-500">© 2023 ThreadCraft Studio. All rights reserved.</p> | |
| <div class="flex space-x-6"> | |
| <a href="#" class="text-gray-400 hover:text-indigo-600"> | |
| <i data-feather="twitter"></i> | |
| </a> | |
| <a href="#" class="text-gray-400 hover:text-indigo-600"> | |
| <i data-feather="instagram"></i> | |
| </a> | |
| <a href="#" class="text-gray-400 hover:text-indigo-600"> | |
| <i data-feather="facebook"></i> | |
| </a> | |
| </div> | |
| </div> | |
| </div> | |
| </footer> | |
| <script> | |
| // Initialize Three.js scene after page loads | |
| document.addEventListener('DOMContentLoaded', function() { | |
| // Simulate loading delay | |
| setTimeout(() => { | |
| document.getElementById('loading-overlay').style.display = 'none'; | |
| // Initialize 3D scene | |
| const container = document.getElementById('canvas-container'); | |
| // Setup Three.js scene (placeholder - would be replaced with actual 3D implementation) | |
| const scene = new THREE.Scene(); | |
| const camera = new THREE.PerspectiveCamera(75, container.clientWidth / container.clientHeight, 0.1, 1000); | |
| const renderer = new THREE.WebGLRenderer({ antialias: true, alpha: true }); | |
| renderer.setSize(container.clientWidth, container.clientHeight); | |
| container.appendChild(renderer.domElement); | |
| // Basic lighting | |
| const ambientLight = new THREE.AmbientLight(0xffffff, 0.6); | |
| scene.add(ambientLight); | |
| const directionalLight = new THREE.DirectionalLight(0xffffff, 0.8); | |
| directionalLight.position.set(1, 1, 1); | |
| scene.add(directionalLight); | |
| // Create high-quality T-shirt model | |
| const shirtMaterial = new THREE.MeshPhongMaterial({ | |
| color: 0xffffff, | |
| side: THREE.DoubleSide, | |
| flatShading: true, | |
| shininess: 30 | |
| }); | |
| // Main body with curved shape | |
| const bodyGeometry = new THREE.CylinderGeometry(0.8, 1, 2, 32, 1, true); | |
| bodyGeometry.scale(1, 0.8, 1); | |
| const body = new THREE.Mesh(bodyGeometry, shirtMaterial); | |
| body.position.y = -0.1; | |
| scene.add(body); | |
| // Neck opening | |
| const neckGeometry = new THREE.TorusGeometry(0.25, 0.05, 16, 32); | |
| neckGeometry.scale(1, 0.5, 1); | |
| const neck = new THREE.Mesh(neckGeometry, shirtMaterial); | |
| neck.position.y = 0.9; | |
| scene.add(neck); | |
| // Sleeves with realistic shape | |
| const sleeveGeometry = new THREE.CylinderGeometry(0.2, 0.3, 1, 32, 1, true); | |
| const leftSleeve = new THREE.Mesh(sleeveGeometry, shirtMaterial); | |
| leftSleeve.position.set(-1, 0, 0); | |
| leftSleeve.rotation.z = Math.PI/2; | |
| leftSleeve.rotation.y = -0.2; | |
| scene.add(leftSleeve); | |
| const rightSleeve = new THREE.Mesh(sleeveGeometry, shirtMaterial); | |
| rightSleeve.position.set(1, 0, 0); | |
| rightSleeve.rotation.z = Math.PI/2; | |
| rightSleeve.rotation.y = 0.2; | |
| scene.add(rightSleeve); | |
| // Bottom hem | |
| const hemGeometry = new THREE.TorusGeometry(1.1, 0.05, 16, 32); | |
| hemGeometry.scale(1, 0.3, 1); | |
| const hem = new THREE.Mesh(hemGeometry, shirtMaterial); | |
| hem.position.y = -1.1; | |
| scene.add(hem); | |
| // Add some subtle wrinkles for realism | |
| const wrinkles = new THREE.Group(); | |
| for (let i = 0; i < 8; i++) { | |
| const wrinkleGeometry = new THREE.CylinderGeometry(0.01, 0.02, 0.5, 8); | |
| const wrinkle = new THREE.Mesh(wrinkleGeometry, shirtMaterial); | |
| wrinkle.position.set( | |
| (Math.random() - 0.5) * 1.5, | |
| (Math.random() - 0.5) * 1.5 - 0.5, | |
| (Math.random() - 0.3) * 0.2 | |
| ); | |
| wrinkle.rotation.set( | |
| Math.random() * Math.PI, | |
| Math.random() * Math.PI, | |
| Math.random() * Math.PI | |
| ); | |
| wrinkles.add(wrinkle); | |
| } | |
| scene.add(wrinkles); | |
| camera.position.z = 3; | |
| camera.position.y = 0.8; | |
| // Add orbit controls | |
| const controls = new THREE.OrbitControls(camera, renderer.domElement); | |
| controls.enableDamping = true; | |
| controls.dampingFactor = 0.25; | |
| // Animation loop | |
| function animate() { | |
| requestAnimationFrame(animate); | |
| controls.update(); | |
| renderer.render(scene, camera); | |
| } | |
| animate(); | |
| // Handle window resize | |
| window.addEventListener('resize', function() { | |
| camera.aspect = container.clientWidth / container.clientHeight; | |
| camera.updateProjectionMatrix(); | |
| renderer.setSize(container.clientWidth, container.clientHeight); | |
| }); | |
| // Apparel selection functionality | |
| document.querySelectorAll('[data-apparel]').forEach(btn => { | |
| btn.addEventListener('click', function() { | |
| const apparelType = this.getAttribute('data-apparel'); | |
| const apparelName = this.querySelector('span').textContent; | |
| document.getElementById('current-apparel').textContent = `Basic ${apparelName} (White)`; | |
| // Clear previous model | |
| while(scene.children.length > 0) { | |
| scene.remove(scene.children[0]); | |
| } | |
| // Re-add lighting | |
| scene.add(ambientLight); | |
| scene.add(directionalLight); | |
| // Load new model based on selection | |
| switch(apparelType) { | |
| case 'tshirt': | |
| createTShirtModel(); | |
| break; | |
| case 'hoodie': | |
| createHoodieModel(); | |
| break; | |
| case 'pants': | |
| createPantsModel(); | |
| break; | |
| case 'jacket': | |
| createJacketModel(); | |
| break; | |
| } | |
| }); | |
| }); | |
| function createTShirtModel() { | |
| // Existing T-Shirt creation code | |
| const shirtMaterial = new THREE.MeshPhongMaterial({ | |
| color: shirtMaterial ? shirtMaterial.color : 0xffffff, | |
| side: THREE.DoubleSide, | |
| flatShading: true, | |
| shininess: 30 | |
| }); | |
| const bodyGeometry = new THREE.CylinderGeometry(0.8, 1, 2, 32, 1, true); | |
| bodyGeometry.scale(1, 0.8, 1); | |
| const body = new THREE.Mesh(bodyGeometry, shirtMaterial); | |
| body.position.y = -0.1; | |
| scene.add(body); | |
| const neckGeometry = new THREE.TorusGeometry(0.25, 0.05, 16, 32); | |
| neckGeometry.scale(1, 0.5, 1); | |
| const neck = new THREE.Mesh(neckGeometry, shirtMaterial); | |
| neck.position.y = 0.9; | |
| scene.add(neck); | |
| const sleeveGeometry = new THREE.CylinderGeometry(0.2, 0.3, 1, 32, 1, true); | |
| const leftSleeve = new THREE.Mesh(sleeveGeometry, shirtMaterial); | |
| leftSleeve.position.set(-1, 0, 0); | |
| leftSleeve.rotation.z = Math.PI/2; | |
| leftSleeve.rotation.y = -0.2; | |
| scene.add(leftSleeve); | |
| const rightSleeve = new THREE.Mesh(sleeveGeometry, shirtMaterial); | |
| rightSleeve.position.set(1, 0, 0); | |
| rightSleeve.rotation.z = Math.PI/2; | |
| rightSleeve.rotation.y = 0.2; | |
| scene.add(rightSleeve); | |
| const hemGeometry = new THREE.TorusGeometry(1.1, 0.05, 16, 32); | |
| hemGeometry.scale(1, 0.3, 1); | |
| const hem = new THREE.Mesh(hemGeometry, shirtMaterial); | |
| hem.position.y = -1.1; | |
| scene.add(hem); | |
| addWrinkles(scene, shirtMaterial); | |
| } | |
| function createHoodieModel() { | |
| const hoodieMaterial = new THREE.MeshPhongMaterial({ | |
| color: shirtMaterial ? shirtMaterial.color : 0x333333, | |
| side: THREE.DoubleSide, | |
| flatShading: true, | |
| shininess: 20 | |
| }); | |
| // Main body | |
| const bodyGeometry = new THREE.CylinderGeometry(0.9, 1.1, 2, 32, 1, true); | |
| bodyGeometry.scale(1, 0.8, 1); | |
| const body = new THREE.Mesh(bodyGeometry, hoodieMaterial); | |
| body.position.y = -0.1; | |
| scene.add(body); | |
| // Hood | |
| const hoodGeometry = new THREE.SphereGeometry(0.7, 32, 32, 0, Math.PI, 0, Math.PI/2); | |
| const hood = new THREE.Mesh(hoodGeometry, hoodieMaterial); | |
| hood.position.set(0, 1.2, -0.3); | |
| hood.rotation.x = Math.PI/4; | |
| scene.add(hood); | |
| // Sleeves | |
| const sleeveGeometry = new THREE.CylinderGeometry(0.25, 0.35, 1.2, 32, 1, true); | |
| const leftSleeve = new THREE.Mesh(sleeveGeometry, hoodieMaterial); | |
| leftSleeve.position.set(-1.1, 0, 0); | |
| leftSleeve.rotation.z = Math.PI/2; | |
| leftSleeve.rotation.y = -0.2; | |
| scene.add(leftSleeve); | |
| const rightSleeve = new THREE.Mesh(sleeveGeometry, hoodieMaterial); | |
| rightSleeve.position.set(1.1, 0, 0); | |
| rightSleeve.rotation.z = Math.PI/2; | |
| rightSleeve.rotation.y = 0.2; | |
| scene.add(rightSleeve); | |
| // Bottom hem | |
| const hemGeometry = new THREE.TorusGeometry(1.2, 0.07, 16, 32); | |
| hemGeometry.scale(1, 0.3, 1); | |
| const hem = new THREE.Mesh(hemGeometry, hoodieMaterial); | |
| hem.position.y = -1.1; | |
| scene.add(hem); | |
| const pocketGeometry = new THREE.BoxGeometry(0.6, 0.4, 0.1); | |
| const pocket = new THREE.Mesh(pocketGeometry, hoodieMaterial); | |
| pocket.position.set(0, -0.3, 0.9); | |
| scene.add(pocket); | |
| addWrinkles(scene, hoodieMaterial); | |
| } | |
| function createPantsModel() { | |
| const pantsMaterial = new THREE.MeshPhongMaterial({ | |
| color: shirtMaterial ? shirtMaterial.color : 0x1e40af, | |
| side: THREE.DoubleSide, | |
| flatShading: true, | |
| shininess: 10 | |
| }); | |
| // Waist | |
| const waistGeometry = new THREE.CylinderGeometry(0.6, 0.8, 0.5, 32, 1, true); | |
| const waist = new THREE.Mesh(waistGeometry, pantsMaterial); | |
| waist.position.y = 0.5; | |
| scene.add(waist); | |
| // Legs | |
| const legGeometry = new THREE.CylinderGeometry(0.35, 0.4, 1.8, 32); | |
| const leftLeg = new THREE.Mesh(legGeometry, pantsMaterial); | |
| leftLeg.position.set(-0.3, -0.9, 0); | |
| scene.add(leftLeg); | |
| const rightLeg = new THREE.Mesh(legGeometry, pantsMaterial); | |
| rightLeg.position.set(0.3, -0.9, 0); | |
| scene.add(rightLeg); | |
| // Belt loops | |
| for (let i = 0; i < 6; i++) { | |
| const loopGeometry = new THREE.BoxGeometry(0.08, 0.15, 0.1); | |
| const loop = new THREE.Mesh(loopGeometry, pantsMaterial); | |
| loop.position.set( | |
| Math.cos(i * Math.PI/3) * 0.6, | |
| 0.7, | |
| Math.sin(i * Math.PI/3) * 0.6 | |
| ); | |
| loop.rotation.y = i * Math.PI/3; | |
| scene.add(loop); | |
| } | |
| } | |
| function createJacketModel() { | |
| const jacketMaterial = new THREE.MeshPhongMaterial({ | |
| color: shirtMaterial ? shirtMaterial.color : 0x1e3a8a, | |
| side: THREE.DoubleSide, | |
| flatShading: true, | |
| shininess: 25 | |
| }); | |
| // Main body | |
| const bodyGeometry = new THREE.CylinderGeometry(0.85, 1.2, 2.2, 32, 1, true); | |
| bodyGeometry.scale(1, 0.7, 1); | |
| const body = new THREE.Mesh(bodyGeometry, jacketMaterial); | |
| body.position.y = 0; | |
| scene.add(body); | |
| // Collar | |
| const collarGeometry = new THREE.TorusGeometry(0.3, 0.1, 16, 32); | |
| collarGeometry.scale(1, 0.5, 1); | |
| const collar = new THREE.Mesh(collarGeometry, jacketMaterial); | |
| collar.position.y = 1.3; | |
| scene.add(collar); | |
| // Sleeves | |
| const sleeveGeometry = new THREE.CylinderGeometry(0.25, 0.4, 1.5, 32, 1, true); | |
| const leftSleeve = new THREE.Mesh(sleeveGeometry, jacketMaterial); | |
| leftSleeve.position.set(-1.2, 0, 0); | |
| leftSleeve.rotation.z = Math.PI/2; | |
| leftSleeve.rotation.y = -0.2; | |
| scene.add(leftSleeve); | |
| const rightSleeve = new THREE.Mesh(sleeveGeometry, jacketMaterial); | |
| rightSleeve.position.set(1.2, 0, 0); | |
| rightSleeve.rotation.z = Math.PI/2; | |
| rightSleeve.rotation.y = 0.2; | |
| scene.add(rightSleeve); | |
| // Bottom hem | |
| const hemGeometry = new THREE.TorusGeometry(1.3, 0.1, 16, 32); | |
| hemGeometry.scale(1, 0.3, 1); | |
| const hem = new THREE.Mesh(hemGeometry, jacketMaterial); | |
| hem.position.y = -1.2; | |
| scene.add(hem); | |
| // Zipper | |
| for (let i = 0; i < 10; i++) { | |
| const zipperGeometry = new THREE.BoxGeometry(0.03, 0.05, 0.15); | |
| const zipper = new THREE.Mesh(zipperGeometry, new THREE.MeshPhongMaterial({ color: 0x000000 })); | |
| zipper.position.set(0, 1 - i * 0.2, 1.05); | |
| scene.add(zipper); | |
| } | |
| // Pockets | |
| const pocketGeometry = new THREE.BoxGeometry(0.4, 0.3, 0.1); | |
| const leftPocket = new THREE.Mesh(pocketGeometry, jacketMaterial); | |
| leftPocket.position.set(-0.5, 0, 0.95); | |
| scene.add(leftPocket); | |
| const rightPocket = new THREE.Mesh(pocketGeometry, jacketMaterial); | |
| rightPocket.position.set(0.5, 0, 0.95); | |
| scene.add(rightPocket); | |
| } | |
| function addWrinkles(scene, material) { | |
| const wrinkles = new THREE.Group(); | |
| for (let i = 0; i < 8; i++) { | |
| const wrinkleGeometry = new THREE.CylinderGeometry(0.01, 0.02, 0.5, 8); | |
| const wrinkle = new THREE.Mesh(wrinkleGeometry, material); | |
| wrinkle.position.set( | |
| (Math.random() - 0.5) * 1.5, | |
| (Math.random() - 0.5) * 1.5 - 0.5, | |
| (Math.random() - 0.3) * 0.2 | |
| ); | |
| wrinkle.rotation.set( | |
| Math.random() * Math.PI, | |
| Math.random() * Math.PI, | |
| Math.random() * Math.PI | |
| ); | |
| wrinkles.add(wrinkle); | |
| } | |
| scene.add(wrinkles); | |
| } | |
| // Initialize with T-Shirt | |
| createTShirtModel(); | |
| // Color picker functionality | |
| document.querySelectorAll('.color-picker').forEach(picker => { | |
| picker.addEventListener('click', function() { | |
| const color = this.getAttribute('data-color'); | |
| shirtMaterial.color.setStyle(color); | |
| }); | |
| }); | |
| // Custom color picker | |
| document.querySelector('input[type="color"]').addEventListener('input', function(e) { | |
| shirtMaterial.color.setStyle(e.target.value); | |
| }); | |
| // File upload preview | |
| const fileInput = document.querySelector('input[type="file"]'); | |
| fileInput.addEventListener('change', function(e) { | |
| if (e.target.files && e.target.files[0]) { | |
| const reader = new FileReader(); | |
| reader.onload = function(event) { | |
| // In a real implementation, this would apply the texture to the 3D model | |
| alert('Design uploaded successfully! This would apply to the 3D model in a full implementation.'); | |
| }; | |
| reader.readAsDataURL(e.target.files[0]); | |
| } | |
| }); | |
| }, 1500); | |
| // Initialize feather icons | |
| feather.replace(); | |
| }); | |
| </script> | |
| </body> | |
| </html> | |