-
Notifications
You must be signed in to change notification settings - Fork 4
/
aframe.html
89 lines (62 loc) · 2.61 KB
/
aframe.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<title>mesh-ui - aframe</title>
<script src="js/libs/aframe.js"></script>
</head>
<body>
<script src="js/libs/lodash.min.js"></script>
<script src="dist/aframe-mesh-ui.js"></script>
<script src="js/aframe-sky-gradient.js"></script>
<a-scene antialias="true">
<a-entity position="0 -1 1">
<a-entity id="pb1" progress="type: bar; values: 0.1 0.5 0.1; width: 3; thickness: 0.1; lit: true" position="0 1.2 0"></a-entity>
<a-entity id="pb2" progress="type: bar; values: 0.7; width: 3; thickness: 0.1; lit: true; gradient: true; colors: #9c27b0 #2196f3" position="0 1.4 0"></a-entity>
<a-entity id="pr1" progress="type: radial; segments: 32; values: 0.1 0.5 0.1; width: 1.3; thickness: 0.1; lit: true" position="0.75 2.2 0"></a-entity>
<a-entity id="pr2" progress="type: radial; segments: 32; values: 0.7; width: 1.3; thickness: 0.1; lit: true; gradient: true; colors: #9c27b0 #2196f3" position="-0.75 2.2 0"></a-entity>
</a-entity>
<a-entity camera look-controls wasd-controls position="0 1 3"></a-entity>
<a-entity sky-gradient="colors: #cccccc"></a-entity>
</a-scene>
<script src="js/libs/tween.min.js"></script>
<script>
'use strict';
var pb1 = document.getElementById('pb1');
var pb2 = document.getElementById('pb2');
var pr1 = document.getElementById('pr1');
var pr2 = document.getElementById('pr2');
// update
setInterval(function(){
update();
}, 3000);
function update() {
var curr = pb1.getAttribute('progress').values;
var values = [ Math.random(), Math.random(), Math.random() ];
var sum = _.sum(values);
values = _.map(values, function(v){ return v / 3 });
var value = _.sum(values);
var tween = new TWEEN.Tween( { v1: curr[0], v2: curr[1], v3: curr[2] } )
.to( { v1: values[0], v2: values[1], v3: values[2] },
400 )
.easing( TWEEN.Easing.Quintic.Out )
.onUpdate(function(){
var vals = [ this.v1, this.v2, this.v3 ];
var val = _.sum(vals);
pb1.setAttribute('progress', 'values', vals.join(' '));
pb2.setAttribute('progress', 'values', val.toString());
pr1.setAttribute('progress', 'values', vals.join(' '));
pr2.setAttribute('progress', 'values', val.toString());
/*pb1.components['progress'].progress.setValues( vals );
pb2.components['progress'].progress.setValues( vals );
pr1.components['progress'].progress.setValues( vals );
pr2.components['progress'].progress.setValues( vals );*/
})
.onComplete(function(){
})
.start();
}
</script>
</body>
</html>