awacke1 commited on
Commit
c0fd12b
·
1 Parent(s): 6744e6e

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +139 -16
index.html CHANGED
@@ -1,19 +1,142 @@
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>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>Aframe and Three.js Keyboard Interaction Demo</title>
6
+ <script src="https://aframe.io/releases/1.2.0/aframe.min.js"></script>
7
+ <script src="https://threejs.org/build/three.js"></script>
8
+ </head>
9
+ <body>
10
+ <a-scene keyboard-shortcuts>
11
+ <a-entity position="0 1.6 0">
12
+ <a-entity id="camera" camera look-controls wasd-controls></a-entity>
13
+ </a-entity>
14
+
15
+ <a-sky color="#0000ff"></a-sky>
16
+
17
+ <a-entity id="lettersContainer"></a-entity>
18
+ </a-scene>
19
+
20
+ <script>
21
+ AFRAME.registerComponent('keyboard-shortcuts', {
22
+ init: function () {
23
+ window.addEventListener('keydown', (event) => {
24
+ const key = event.key.toLowerCase();
25
+ if (key.length === 1 && /^[a-z]+$/.test(key)) {
26
+ this.generateLetter(key);
27
+ }
28
+ });
29
+ },
30
+ generateLetter: function (key) {
31
+ const lettersContainer = document.querySelector('#lettersContainer');
32
+ const letter = document.createElement('a-entity');
33
+ letter.setAttribute('text', {
34
+ value: key.toUpperCase(),
35
+ align: 'center',
36
+ font: 'https://cdn.aframe.io/fonts/Exo2SemiBold.fnt',
37
+ width: 2
38
+ });
39
+ letter.setAttribute('position', '0 1 -5');
40
+ letter.setAttribute('rotation', '0 0 0');
41
+ letter.setAttribute('scale', '1 1 1');
42
+ letter.setAttribute('letter', '');
43
+ lettersContainer.appendChild(letter);
44
+ }
45
+ });
46
+
47
+ AFRAME.registerComponent('letter', {
48
+ init: function () {
49
+ this.el.setAttribute('animation', {
50
+ property: 'rotation',
51
+ to: '0 360 0',
52
+ dur: 2000,
53
+ easing: 'linear',
54
+ loop: true
55
+ });
56
+ this.el.setAttribute('animation__position', {
57
+ property: 'position',
58
+ to: '0 1 20',
59
+ dur: 2000,
60
+ easing: 'linear',
61
+ loop: true
62
+ });
63
+ }
64
+ });
65
+ </script>
66
+ </body>
67
  </html>
68
+ Here's an example of an A-Frame and Three.js demonstration that includes keyboard interaction, dynamically generated 3D letters, camera and WASD control, and a skybox with blue, yellow, and white chaos-driven visuals. Additionally, it includes a function to call a web service and display the results.
69
+
70
+ ```html
71
+ <!DOCTYPE html>
72
+ <html>
73
+ <head>
74
+ <meta charset="utf-8">
75
+ <title>Aframe and Three.js Keyboard Interaction Demo</title>
76
+ <script src="https://aframe.io/releases/1.2.0/aframe.min.js"></script>
77
+ <script src="https://threejs.org/build/three.js"></script>
78
+ </head>
79
+ <body>
80
+ <a-scene keyboard-shortcuts>
81
+ <a-entity position="0 1.6 0">
82
+ <a-entity id="camera" camera look-controls wasd-controls></a-entity>
83
+ </a-entity>
84
+ <a-sky color="#0000ff"></a-sky>
85
+ <a-entity id="lettersContainer"></a-entity>
86
+ </a-scene>
87
+
88
+ <script>
89
+ AFRAME.registerComponent('keyboard-shortcuts', {
90
+ init: function () {
91
+ window.addEventListener('keydown', (event) => {
92
+ const key = event.key.toLowerCase();
93
+ if (key.length === 1 && /^[a-z]+$/.test(key)) {
94
+ this.generateLetter(key);
95
+ }
96
+ });
97
+ },
98
+
99
+ generateLetter: function (key) {
100
+ const lettersContainer = document.querySelector('#lettersContainer');
101
+ const letter = document.createElement('a-entity');
102
+ letter.setAttribute('text', {
103
+ value: key.toUpperCase(),
104
+ align: 'center',
105
+ font: 'https://cdn.aframe.io/fonts/Exo2SemiBold.fnt',
106
+ width: 2
107
+ });
108
+ letter.setAttribute('position', '0 1 -5');
109
+ letter.setAttribute('rotation', '0 0 0');
110
+ letter.setAttribute('scale', '1 1 1');
111
+ letter.setAttribute('letter', '');
112
+ lettersContainer.appendChild(letter);
113
+ }
114
+ });
115
+
116
+ AFRAME.registerComponent('letter', {
117
+ init: function () {
118
+ this.el.setAttribute('animation', {
119
+ property: 'rotation',
120
+ to: '0 360 0',
121
+ dur: 2000,
122
+ easing: 'linear',
123
+ loop: true
124
+ });
125
+ this.el.setAttribute('animation__position', {
126
+ property: 'position',
127
+ to: '0 1 20',
128
+ dur: 2000,
129
+ easing: 'linear',
130
+ loop: true
131
+ });
132
+ }
133
+ });
134
+
135
+ // Call web service and display results
136
+ fetch('https://api11.salmonground-a8f39f59.centralus.azurecontainerapps.io/selftest')
137
+ .then(response => response.json())
138
+ .then(data => console.log(data));
139
+
140
+ </script>
141
+ </body>
142
+ </html>