Spaces:
Running
Running
Manual changes saved
Browse files- model-viewer.html +0 -103
model-viewer.html
CHANGED
|
@@ -1,103 +0,0 @@
|
|
| 1 |
-
<!DOCTYPE html>
|
| 2 |
-
<html lang="en">
|
| 3 |
-
<head>
|
| 4 |
-
<meta charset="UTF-8">
|
| 5 |
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
-
<title>Advanced 3D Model Viewer</title>
|
| 7 |
-
<script src="https://cdn.tailwindcss.com"></script>
|
| 8 |
-
<script src="https://unpkg.com/feather-icons"></script>
|
| 9 |
-
<script src="https://cdn.jsdelivr.net/npm/three@0.132.2/build/three.min.js"></script>
|
| 10 |
-
<script src="https://cdn.jsdelivr.net/npm/three@0.132.2/examples/js/controls/OrbitControls.js"></script>
|
| 11 |
-
<style>
|
| 12 |
-
body { margin: 0; overflow: hidden; }
|
| 13 |
-
#model-container { width: 100%; height: 100vh; }
|
| 14 |
-
#loading {
|
| 15 |
-
position: absolute;
|
| 16 |
-
top: 50%;
|
| 17 |
-
left: 50%;
|
| 18 |
-
transform: translate(-50%, -50%);
|
| 19 |
-
color: white;
|
| 20 |
-
font-size: 1.5rem;
|
| 21 |
-
}
|
| 22 |
-
</style>
|
| 23 |
-
</head>
|
| 24 |
-
<body class="bg-gray-900">
|
| 25 |
-
<div id="model-container"></div>
|
| 26 |
-
<div id="loading">Loading 3D Model...</div>
|
| 27 |
-
|
| 28 |
-
<script>
|
| 29 |
-
let scene, camera, renderer, model, controls;
|
| 30 |
-
|
| 31 |
-
init();
|
| 32 |
-
animate();
|
| 33 |
-
|
| 34 |
-
function init() {
|
| 35 |
-
// Create scene
|
| 36 |
-
scene = new THREE.Scene();
|
| 37 |
-
scene.background = new THREE.Color(0x222222);
|
| 38 |
-
|
| 39 |
-
// Add lights
|
| 40 |
-
const ambientLight = new THREE.AmbientLight(0x404040);
|
| 41 |
-
scene.add(ambientLight);
|
| 42 |
-
|
| 43 |
-
const directionalLight = new THREE.DirectionalLight(0xffffff, 1);
|
| 44 |
-
directionalLight.position.set(1, 1, 1);
|
| 45 |
-
scene.add(directionalLight);
|
| 46 |
-
|
| 47 |
-
// Create camera
|
| 48 |
-
camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
|
| 49 |
-
camera.position.z = 5;
|
| 50 |
-
|
| 51 |
-
// Create renderer
|
| 52 |
-
renderer = new THREE.WebGLRenderer({ antialias: true });
|
| 53 |
-
renderer.setSize(window.innerWidth, window.innerHeight);
|
| 54 |
-
document.getElementById('model-container').appendChild(renderer.domElement);
|
| 55 |
-
|
| 56 |
-
// Add controls
|
| 57 |
-
controls = new THREE.OrbitControls(camera, renderer.domElement);
|
| 58 |
-
controls.enableDamping = true;
|
| 59 |
-
controls.dampingFactor = 0.25;
|
| 60 |
-
|
| 61 |
-
// Load a model (placeholder - in a real app, you'd load an actual model)
|
| 62 |
-
const geometry = new THREE.IcosahedronGeometry(1, 1);
|
| 63 |
-
const material = new THREE.MeshPhongMaterial({
|
| 64 |
-
color: 0x00a8ff,
|
| 65 |
-
shininess: 100
|
| 66 |
-
});
|
| 67 |
-
model = new THREE.Mesh(geometry, material);
|
| 68 |
-
scene.add(model);
|
| 69 |
-
|
| 70 |
-
// Hide loading after delay
|
| 71 |
-
setTimeout(() => {
|
| 72 |
-
document.getElementById('loading').style.display = 'none';
|
| 73 |
-
}, 1500);
|
| 74 |
-
|
| 75 |
-
// Handle window resize
|
| 76 |
-
window.addEventListener('resize', onWindowResize, false);
|
| 77 |
-
}
|
| 78 |
-
|
| 79 |
-
function onWindowResize() {
|
| 80 |
-
camera.aspect = window.innerWidth / window.innerHeight;
|
| 81 |
-
camera.updateProjectionMatrix();
|
| 82 |
-
renderer.setSize(window.innerWidth, window.innerHeight);
|
| 83 |
-
}
|
| 84 |
-
|
| 85 |
-
function animate() {
|
| 86 |
-
requestAnimationFrame(animate);
|
| 87 |
-
controls.update();
|
| 88 |
-
renderer.render(scene, camera);
|
| 89 |
-
}
|
| 90 |
-
|
| 91 |
-
feather.replace();
|
| 92 |
-
</script>
|
| 93 |
-
</body>
|
| 94 |
-
</html>
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
Note: In a real implementation, you would want to:
|
| 98 |
-
1. Use actual 3D model files (GLTF/GLB format recommended)
|
| 99 |
-
2. Implement proper loading states and error handling
|
| 100 |
-
3. Add more interactive controls and features
|
| 101 |
-
4. Consider using a library like Three.js with React (react-three-fiber) for more complex applications
|
| 102 |
-
|
| 103 |
-
The above code provides a foundational structure that you can build upon with actual 3D assets and more advanced features.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|