-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathindex.html
More file actions
141 lines (127 loc) · 5.79 KB
/
index.html
File metadata and controls
141 lines (127 loc) · 5.79 KB
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>A-Frame Wevr Component</title>
<meta name="description" content="Example for Wevr component.">
<script src="https://aframe.io/releases/0.7.0/aframe.min.js"></script>
<script src="https://rawgit.com/feiss/aframe-environment-component/master/dist/aframe-environment-component.min.js"></script>
<script src="/dist/wevr.js"></script>
<script>
AFRAME.registerComponent('switch-environment', {
schema: {type: 'string'},
init: function () {
var self = this;
var up = (this.data == "up");
this.el.addEventListener('click', function (evt) {
self.system.switchEnvironment(up);
});
}
});
AFRAME.registerSystem('switch-environment', {
init: function () {
var self = this;
this.el.addEventListener("loaded", function () {
self.environment = document.querySelector("#environment");
self.name = document.querySelector("#name");
self.names = ['default', 'contact', 'egypt', 'checkerboard', 'forest', 'goaland', 'yavapai', 'goldmine', 'threetowers', 'poison', 'arches', 'tron', 'japan', 'dream', 'volcano', 'starry', 'osiris'];
self.curIndex = self.names.indexOf(self.environment.getAttribute("environment").preset);
self.name.setAttribute('text', 'value', self.names[self.curIndex]);
let wevrSystem = self.el.systems.wevr;
self.stateHandler = wevrSystem.stateHandler;
self.stateHandler.addStateListener("#environment", function (data) {
self.setEnvironmentIndex(data.envName);
});
});
},
switchEnvironment: function (up) {
if (up) {
if (++this.curIndex == this.names.length) {
this.curIndex = 0;
}
} else {
if (--this.curIndex == -1) {
this.curIndex = this.names.length - 1;
}
}
var name = this.names[this.curIndex];
this.setEnvironment(name);
var fields = {envName: name};
this.stateHandler.updateState("#environment", fields);
},
setEnvironmentIndex: function (name) {
if (name != this.environment.getAttribute("environment").preset) {
this.curIndex = this.names.indexOf(name);
this.setEnvironment(name);
}
},
setEnvironment: function (name) {
this.environment.setAttribute('environment', 'preset', name);
this.name.setAttribute('text', 'value', name);
}
});
</script>
</head>
<body>
<a-scene wevr="signalUrl:ws://localhost:9000/wevr;avatarTemplate:#avatarTemplate;avatarRHTemplate:#avatarHandTemplate;avatarLHTemplate:#avatarHandTemplate">
<assets>
<script id="avatarHandTemplate" type="text/html">
<a-sphere color="#ff8888" radius="0.1" ${rotation}><a-sphere position="0.09 0 0.02" scale="0.5 0.5 0.5" color="#5985ff" radius="0.1"></a-sphere>
<a-sphere position="0 0 -0.075" scale="0.35 0.35 1" color="#88ff88" radius="0.1"></a-sphere>
<a-sphere position="0.05 0 -0.075" rotation="0 -20 0" scale="0.35 0.35 1" color="#88ff88" radius="0.1"></a-sphere>
<a-sphere position="-0.05 0 -0.075" rotation="0 20 0" scale="0.25 0.25 0.75" color="#88ff88" radius="0.1"></a-sphere>
</a-sphere>
</script>
<script id="avatarTemplate" type="text/html">
<a-sphere class="head"
color="#88ff88"
position="0 -0.05 0"
scale="0.25 0.3 0.2">
<a-entity class="face"
position="0 0 -0.6">
<a-sphere position="0 0.05 -0.4"
color="#5985ff"
scale="0.18 0.18 0.18">
</a-sphere>
<a-sphere class="eye"
color="#efefef"
position="0.3 0.35 -0.3"
scale="0.15 0.15 0.15"
>
<a-sphere class="pupil"
color="#000"
position="0 0 -1"
scale="0.45 0.45 0.45"
></a-sphere>
</a-sphere>
<a-sphere class="eye"
color="#efefef"
position="-0.3 0.35 -0.3"
scale="0.15 0.15 0.15"
>
<a-sphere class="pupil"
color="#000"
position="0 0 -1"
scale="0.45 0.45 0.45"
></a-sphere>
</a-sphere>
</a-entity>
</a-sphere>
</script>
</assets>
<a-entity id="environment" environment="preset:japan"></a-entity>
<a-box depth="0.1" height="2" width="1" color="#282828" metalness="0.5" position="0 1 -3.5" rotation="0 0 0">
<a-entity text="value: Environment;color:#dddddd;anchor:center;baseline:center;width:1.5" scale="2 2 2"
position="1.1 0.75 0.05"></a-entity>
<a-triangle switch-environment="down" color="#ccc" position="-0.39 0.2 0.06" side="double"
scale="0.15 0.15 0.15" rotation="0 0 90"></a-triangle>
<a-triangle switch-environment="up" color="#ccc" position="0.39 0.2 0.06" side="double" scale="0.15 0.15 0.15"
rotation="0 0 -90"></a-triangle>
<a-entity id="name" text="value:name;color:#ccf;anchor:center;baseline:center;width:2;align:center"
position="0 0.2 0.06"></a-entity>
</a-box>
<a-light type="ambient" color="#445451"></a-light>
<a-light type="point" intensity="2" position="2 4 4"></a-light>
</a-scene>
</body>
</html>