jake2004 commited on
Commit
02ba551
·
verified ·
1 Parent(s): dd9338b

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +65 -18
index.html CHANGED
@@ -1,19 +1,66 @@
1
- <!doctype html>
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
+ <!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>GLB Model Viewer</title>
7
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>
8
+ <script src="https://cdn.jsdelivr.net/npm/three/examples/js/loaders/GLTFLoader.js"></script>
9
+ <script src="https://cdn.jsdelivr.net/npm/three/examples/js/controls/OrbitControls.js"></script>
10
+ <style>
11
+ body { margin: 0; }
12
+ canvas { display: block; }
13
+ </style>
14
+ </head>
15
+ <body>
16
+ <script>
17
+ let scene, camera, renderer, controls;
18
+
19
+ function init() {
20
+ scene = new THREE.Scene();
21
+ camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
22
+ camera.position.set(0, 2, 5);
23
+
24
+ renderer = new THREE.WebGLRenderer({ antialias: true });
25
+ renderer.setSize(window.innerWidth, window.innerHeight);
26
+ document.body.appendChild(renderer.domElement);
27
+
28
+ controls = new THREE.OrbitControls(camera, renderer.domElement);
29
+ controls.enableDamping = true;
30
+ controls.dampingFactor = 0.05;
31
+ controls.screenSpacePanning = false;
32
+ controls.minDistance = 1;
33
+ controls.maxDistance = 10;
34
+
35
+ const light = new THREE.DirectionalLight(0xffffff, 1);
36
+ light.position.set(5, 10, 5).normalize();
37
+ scene.add(light);
38
+
39
+ const loader = new THREE.GLTFLoader();
40
+ loader.load('model.glb', function (gltf) {
41
+ let model = gltf.scene;
42
+ model.scale.set(2, 2, 2);
43
+ model.position.y = 0;
44
+ scene.add(model);
45
+ }, undefined, function (error) {
46
+ console.error('An error happened', error);
47
+ });
48
+
49
+ window.addEventListener('resize', () => {
50
+ camera.aspect = window.innerWidth / window.innerHeight;
51
+ camera.updateProjectionMatrix();
52
+ renderer.setSize(window.innerWidth, window.innerHeight);
53
+ });
54
+ }
55
+
56
+ function animate() {
57
+ requestAnimationFrame(animate);
58
+ controls.update();
59
+ renderer.render(scene, camera);
60
+ }
61
+
62
+ init();
63
+ animate();
64
+ </script>
65
+ </body>
66
  </html>