Add 2 files
Browse files- index.html +1 -19
- main.js +46 -0
index.html
CHANGED
|
@@ -1,19 +1 @@
|
|
| 1 |
-
|
| 2 |
-
<html>
|
| 3 |
-
<head>
|
| 4 |
-
<meta charset="utf-8" />
|
| 5 |
-
<meta name="viewport" content="width=device-width" />
|
| 6 |
-
<title>My static Space</title>
|
| 7 |
-
<link rel="stylesheet" href="style.css" />
|
| 8 |
-
</head>
|
| 9 |
-
<body>
|
| 10 |
-
<div class="card">
|
| 11 |
-
<h1>Welcome to your static Space!</h1>
|
| 12 |
-
<p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
|
| 13 |
-
<p>
|
| 14 |
-
Also don't forget to check the
|
| 15 |
-
<a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
|
| 16 |
-
</p>
|
| 17 |
-
</div>
|
| 18 |
-
</body>
|
| 19 |
-
</html>
|
|
|
|
| 1 |
+
<html><head><link href="https://cdn.jsdelivr.net/npm/daisyui@3.1.6/dist/full.css" rel="stylesheet" type="text/css" /><script defer src="https://cdn.jsdelivr.net/npm/alpinejs@3.x.x/dist/cdn.min.js"></script><script src="https://cdn.tailwindcss.com?plugins=forms,typography,aspect-ratio"></script><script defer src="https://cdnjs.cloudflare.com/ajax/libs/three.js/0.156.1/three.min.js"></script><script type="module" src="main.js"></script><title>π¨βπ» Multicolor Detailed 8K Portrait π©βπ»</title><H1>π©βπ» Multicolor Detailed 8K Portrait π©βπ»</H1><body></body></html>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
main.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
function rendererConfig() {
|
| 2 |
+
const canvas = document.createElement('canvas');
|
| 3 |
+
canvas.style.display = 'block';
|
| 4 |
+
canvas.style.margin = '0 auto';
|
| 5 |
+
document.body.appendChild(canvas);
|
| 6 |
+
|
| 7 |
+
const renderer = new THREE.WebGL1Renderer({
|
| 8 |
+
canvas: canvas,
|
| 9 |
+
antialias: true,
|
| 10 |
+
});
|
| 11 |
+
|
| 12 |
+
renderer.physicallyCorrectLights = true;
|
| 13 |
+
renderer.outputEncoding = THREE.sRGBEncoding;
|
| 14 |
+
renderer.shadowMap.enabled = true;
|
| 15 |
+
|
| 16 |
+
return renderer;
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
function loadResources() {
|
| 20 |
+
const loader = new THREE.GLTFLoader();
|
| 21 |
+
loader.load('https://assets-cdn.github.com/photo.glb', (glb) => {
|
| 22 |
+
const scene = glb.scene.toTreeView();
|
| 23 |
+
const renderer = rendererConfig();
|
| 24 |
+
scene.rotation.x = 0;
|
| 25 |
+
scene.rotation.y = 0;
|
| 26 |
+
scene.rotation.z = 0;
|
| 27 |
+
|
| 28 |
+
renderer.setScene(scene);
|
| 29 |
+
renderer.setsize(window.innerWidth, window.innerHeight);
|
| 30 |
+
|
| 31 |
+
window.addEventListener('resize', () => {
|
| 32 |
+
camera.aspect = window.innerWidth / window.innerHeight;
|
| 33 |
+
camera.updateProjectionMatrix();
|
| 34 |
+
renderer.setsize(window.innerWidth, window.innerHeight);
|
| 35 |
+
});
|
| 36 |
+
|
| 37 |
+
const controls = new THREE.OrbitControls(camera, renderer.domElement);
|
| 38 |
+
|
| 39 |
+
animation();
|
| 40 |
+
});
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
function animation() {
|
| 44 |
+
requestAnimationFrame(animation);
|
| 45 |
+
renderer.render(scene, camera);
|
| 46 |
+
}
|