Spaces:
Running
Running
| // Import AlpineJS and DaisyUI | |
| import alpine from "alpinejs"; | |
| import daisyui from "https://cdn.jsdelivr.net/npm/daisyui@3.1.6/dist/full.css"; | |
| // Import TailwindCSS | |
| import tailwind from "https://cdn.tailwindcss.com?plugins=forms,typography,aspect-ratio"; | |
| // Import Three.js | |
| import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.156.1/three.min.js"; | |
| // Initialize AlpineJS and DaisyUI | |
| alpine.default(); | |
| daisyui.default(); | |
| // Initialize TailwindCSS | |
| tailwind.default(); | |
| document.addEventListener("alpine:initialized", () => { | |
| // Create a scene | |
| const scene = new THREE.Scene(); | |
| // Create a camera | |
| const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000); | |
| // Create a renderer | |
| const renderer = new THREE.WebGLRenderer({ | |
| canvas: document.getElementById("3dModel"), | |
| }); | |
| // Set renderer size | |
| renderer.setSize(window.innerWidth, window.innerHeight); | |
| // Add a cube to the scene | |
| const cubeGeometry = new THREE.BoxGeometry(1, 1, 1); | |
| const cubeMaterial = new THREE.MeshBasicMaterial({ color: 0x00ff00 }); | |
| const cube = new THREE.Mesh(cubeGeometry, cubeMaterial); | |
| scene.add(cube); | |
| // Add a camera to the scene | |
| scene.add(camera); | |
| // Add directional light to the scene | |
| const directionalLight = new THREE.DirectionalLight(0xffffff, 1); | |
| directionalLight.position.set(0, 0, 1).normalize(); | |
| scene.add(directionalLight); | |
| // Show the scene | |
| renderer.render(scene, camera); | |
| // Animate the scene | |
| function animate() { | |
| requestAnimationFrame(animate); | |
| renderer.render(scene, camera); | |
| } | |
| animate(); | |
| }); | |
| from hugging_face import image_to_3d | |
| from pip import install | |
| import os | |
| from os.path import expandvars | |
| install(os) | |
| img_to_3d = image_to_3d(expandvars('%s.jpg')) | |
| print(img_to_3d.jpg_text) | |