Spaces:
Running
Running
Update index.html
Browse files- index.html +66 -22
index.html
CHANGED
@@ -1,24 +1,68 @@
|
|
1 |
<!DOCTYPE html>
|
2 |
<html>
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
<!DOCTYPE html>
|
2 |
<html>
|
3 |
+
<head>
|
4 |
+
<title>Dynamic Lights - A-Frame</title>
|
5 |
+
<meta name="description" content="Dynamic Lights - A-Frame">
|
6 |
+
<script src="https://aframe.io/releases/1.0.4/aframe.min.js"></script>
|
7 |
+
<script src="https://unpkg.com/aframe-randomizer-components@3.0.2/dist/aframe-randomizer-components.min.js"></script>
|
8 |
+
<script src="https://unpkg.com/aframe-entity-generator-component@3.0.1/dist/aframe-entity-generator-component.min.js"></script>
|
9 |
+
<script>
|
10 |
+
AFRAME.registerComponent('random-material', {
|
11 |
+
init: function () {
|
12 |
+
this.el.setAttribute('material', {
|
13 |
+
color: this.getRandomColor(),
|
14 |
+
metalness: Math.random(),
|
15 |
+
roughness: Math.random()
|
16 |
+
});
|
17 |
+
},
|
18 |
+
|
19 |
+
getRandomColor: function () {
|
20 |
+
var letters = '0123456789ABCDEF'.split('');
|
21 |
+
var color = '#';
|
22 |
+
for (var i = 0; i < 6; i++) {
|
23 |
+
color += letters[Math.floor(Math.random() * 16)];
|
24 |
+
}
|
25 |
+
return color;
|
26 |
+
}
|
27 |
+
});
|
28 |
+
|
29 |
+
AFRAME.registerComponent('random-torus-knot', {
|
30 |
+
init: function () {
|
31 |
+
this.el.setAttribute('geometry', {
|
32 |
+
primitive: 'torusKnot',
|
33 |
+
radius: Math.random() * 10,
|
34 |
+
radiusTubular: Math.random() * .75,
|
35 |
+
p: Math.round(Math.random() * 10),
|
36 |
+
q: Math.round(Math.random() * 10)
|
37 |
+
});
|
38 |
+
}
|
39 |
+
});
|
40 |
+
</script>
|
41 |
+
</head>
|
42 |
+
<body>
|
43 |
+
<a-scene background="color: #111">
|
44 |
+
<a-assets>
|
45 |
+
<a-mixin id="light"
|
46 |
+
geometry="primitive: sphere; radius: 1.5"
|
47 |
+
material="color: #FFF; shader: flat"
|
48 |
+
light="color: #DDDDFF; distance: 120; intensity: 2; type: point"></a-mixin>
|
49 |
+
<a-mixin id="torusKnot"
|
50 |
+
random-torus-knot
|
51 |
+
random-material
|
52 |
+
random-position="min: -60 -60 -80; max: 60 60 40"></a-mixin>
|
53 |
+
</a-assets>
|
54 |
+
|
55 |
+
<!-- Use entity-generator component to generate 120 entities with the torusKnot mixin. -->
|
56 |
+
<a-entity entity-generator="mixin: torusKnot; num: 120"></a-entity>
|
57 |
+
|
58 |
+
<!-- Lights. -->
|
59 |
+
<a-entity animation="property: rotation; to: 0 0 360; dur: 4000; easing: linear; loop: true">
|
60 |
+
<a-entity mixin="light" position="30 0 0"></a-entity>
|
61 |
+
</a-entity>
|
62 |
+
|
63 |
+
<a-entity animation="property: rotation; to: 360 0 0; dur: 4000; easing: linear; loop: true">
|
64 |
+
<a-entity mixin="light" position="0 0 40"></a-entity>
|
65 |
+
</a-entity>
|
66 |
+
</a-scene>
|
67 |
+
</body>
|
68 |
+
</html>
|