-
Notifications
You must be signed in to change notification settings - Fork 0
/
vive.html
257 lines (214 loc) · 11.7 KB
/
vive.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
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
<html xmlns="http://www.w3.org/1999/xhtml"><head>
<meta charset="utf-8" />
<title>Magica-Voxel Scene - vive</title>
<!-- <script src="jslibrary/aframe.min.js"> </script> -->
<script src="jslibrary/build.js"> </script>
<script src="jslibrary/aframe-extras.loaders.min.js"> </script>
<script src="jslibrary/water.js"></script>
<script src="jslibrary/aframe-animation-component.js"></script>
<script src="jslibrary/aframe-travel-component.min.js"></script>
<script src="https://d3js.org/d3.v4.min.js"></script>
</head>
<body>
<a-scene>
<!------------------------------------------------------------------------------------------------------------------------------------------------------------->
<!--Camera Setup-->
<!-- <a-entity position="1 7.5 1" camera look-controls wasd-controls>
<a-cursor></a-cursor>
</a-entity> -->
<a-camera position="0 7.25 -2" class="subm"><a-cursor></a-cursor></a-camera>
<!--travel points-->
<a-sphere position="4 .5 3" radius="0.25" color="#4CC3D9" travel-node="transition: fade"></a-sphere>
<a-sphere position="4 0.5 -8" radius="0.25" color="#4CC3D9" travel-node="transition: fade"></a-sphere>
<!--Edited Code-->
<!----------------------------------------------------------------------------------------------------------------------------------------------------------------->
<!--Load Assets -->
<a-assets>
<a-asset-item id="myBedroom" src="modellibrary/magica_voxel/bed_room.ply"></a-asset-item>
<a-asset-item id="myBathroom" src="modellibrary/magica_voxel/bath_room.ply"></a-asset-item>
<a-asset-item id="mykitchen" src="modellibrary/magica_voxel/kitchen.ply"></a-asset-item>
<a-asset-item id="redcar" src="modellibrary/magica_voxel/red_car.ply"></a-asset-item>
<a-asset-item id="myWall" src="modellibrary/magica_voxel/plain_wall.ply"></a-asset-item>
<a-asset-item id="myFloor" src="modellibrary/magica_voxel/floor.ply"></a-asset-item>
<a-asset-item id="arrow-obj" src="arrow.obj"></a-asset-item>
<a-asset-item id="arrow-mtl" src="arrow.mtl"></a-asset-item>
<img id="zelda" src="images/poster3.jpg">
<img id="jack" src="images/poster2.jpg">
<img id="eye" src="images/poster1.jpg">
</a-assets>
<!--Water Test -->
<a-entity id="ocean" position="11.23614888234351 1 0" ocean="density:20;width:100;depth:100" material="color:#9CE3F9;opacity:0.75;roughness:1" rotation="-90 0 0">
</a-entity>
<!--Load Model-->
<a-entity ply-model="src:modellibrary/magica_voxel/bed_room.ply" rotation="-90 0 0" position="2.8606506106514367 -0.38149268996288477 0" scale="0.5 0.5 0.5">
<a-entity id="environmentSound" geometry="" sound="src:music/zelda_forest_saria_song.mp3;loop:true;volume:0.3"></a-entity></a-entity>
<a-entity ply-model="src:modellibrary/magica_voxel/bath_room.ply" rotation="-90 0 0" position="1.3122614508592694 -0.12096138524066191 -23.478461853190854" scale="0.5 0.5 0.5"></a-entity>
<a-entity ply-model="src:modellibrary/magica_voxel/kitchen.ply" rotation="-90 0 0" position="36.23535082726076 -0.12096138524066191 -21.568761799695306" scale="0.5 0.5 0.5"></a-entity>
<a-entity ply-model="src:modellibrary/magica_voxel/plain_wall.ply" rotation="-90 0 0" position="37.784666220435895 0 20.622" scale="0.6709547926014008 0.5 0.744250614380796"></a-entity>
<a-entity ply-model="src:modellibrary/magica_voxel/plain_wall.ply" rotation="-90 90 0" position="59.15742544196631 0 -13.165" scale="1.197 0.5 0.7412208988535162"></a-entity><a-entity ply-model="src:modellibrary/magica_voxel/plain_wall.ply" rotation="-90 90 0" position="-1.4457429188867756 0 -13.165" scale="1.197 0.5 0.741"></a-entity>
<a-entity ply-model="src:modellibrary/magica_voxel/plain_wall.ply" rotation="-90 0 0" position="20.04689909272449 0 -26.60249120052255" scale="1.4953123873240877 0.5 0.74"></a-entity><a-entity ply-model="src:modellibrary/magica_voxel/plain_wall.ply" rotation="-90 0 0" position="7.079128045969208 18.099912560446366 20.43476074435125" scale="0.8947749837762695 0.5 0.3"></a-entity>
<a-entity ply-model="src:modellibrary/magica_voxel/floor.ply" rotation="-90 0 0" position="20.662470380808497 26.76908430307794 -12.162913780119752" scale="1.5 1.2 0.5"></a-entity>
<a-entity ply-model="src:modellibrary/magica_voxel/floor.ply" rotation="-90 0 0" position="21.419810851902614 -0.1779357237363275 -12.74154307676053" scale="1.5 1.2 0.5"></a-entity>
<a-entity ply-model="src:modellibrary/magica_voxel/red_car.ply" scale="0.4 0.4 0.4" rotation="-90 29.999999999999996 14.999999999999998" position="3.2930301438922243 0.2 28.301849445121036"><a-animation attribute="position" from"3.2930301438922243="" 0.0="" 28.301849445121036"="" to="3.2930301438922243 0.2 28.301849445121036" delay="1000" dir="alternate" dur="1000" repeat="indefinite"></a-animation></a-entity>
<a-entity ply-model="src:modellibrary/magica_voxel/tree_stem.ply" scale="0.4 0.4 0.4" position="26.351812914450313 0.19996174858888602 -3.190670436596765"><a-animation attribute="position" from"26.351812914450313="" 0.0="" -3.190670436596765""="" to="26.351812914450313 0.2 -3.190670436596765" delay="50" dir="alternate" dur="1000" repeat="indefinite"></a-animation></a-entity>
<!--External Environment -->
<a-plane scale="100 100 100" material="color:#acca48" rotation="-90 0 0" geometry="" position="11.562746692591237 0 0"> </a-plane>
<!--Direction Light-->
<a-entity light="color:#EEE;intensity:0.5" position="1 1 0"></a-entity>
<a-entity light="type:ambient;color:#474242" intensity="0.4"></a-entity>
<!--point Lights-->
<a-entity light="type:point;intensity:0.7;distance:25;decay:2" position="-7 15 7"></a-entity>
<a-entity light="type:point;intensity:0.7;distance:25;decay:2" position="6 15 7"></a-entity>
<a-entity light="type:point;intensity:0.7;distance:25;decay:2" position="-7 15 -5.5"></a-entity>
<a-entity light="type:point;intensity:0.7;distance:25;decay:2" position="6 15 -5.5"></a-entity>
<!--images -->
<a-plane position="7.346272631048093 8.5 -11.8" scale="4.5 7.2 1" material="src:#zelda" geometry=""> </a-plane> <!--Zelda-->
<a-plane position="-0.5341706908703032 7.1 -11.8" scale="5 4.2 1" material="src:#eye" geometry=""> </a-plane> <!--Eye-->
<a-plane position="14.78555100215316 8.5 3.8057218733059064" scale="7 9.5 1" material="src:#jack" rotation="0 -90 0" geometry=""> </a-plane> <!--jack-->
<a-box position="9.101 6.286 -14.371"
color="tomato" depth="1" height="1" width="1"
scale="1.4414369186377378 0.3035338460623169 0.34488297971855175"
material="" geometry="">
<a-animation attribute="rotation" begin="click"
repeat="2" fill="forward" to="0 0 180"></a-animation></a-box>
<a-box position="9.09887001644167 6.299476505302487 -13.949561294106223" color="tomato" depth="1" height="1" width="1" scale="0.32594592196228156 0.23831836238786325 0.7061697030813416" material="color:#d3d3d3" geometry=""></a-box>
<!-- movement spheres -->
<a-entity class="front" obj-model="obj:#arrow-obj; mtl:#arrow-mtl" position="0 7.25 -1" scale="0.1 0.1 0.1" rotation="0 0 90"></a-entity>
<a-entity class="back" obj-model="obj:#arrow-obj; mtl:#arrow-mtl" position="0 7.25 -3" scale="0.1 0.1 0.1" rotation="0 180 90"></a-entity>
<a-entity class="left" obj-model="obj:#arrow-obj; mtl:#arrow-mtl" position="-1 7.25 -2" scale="0.1 0.1 0.1" rotation="0 -90 90"></a-entity>
<a-entity class="right" obj-model="obj:#arrow-obj; mtl:#arrow-mtl" position="1 7.25 -2" scale="0.1 0.1 0.1" rotation="0 90 90"></a-entity>
<!-- hands -->
<a-entity vive-controls="hand: left"></a-entity>
<a-entity id='cursor' vive-controls="hand: right" controller-cursor="color: red; radius: 0.01" raycaster="objects: .front .back .left .right"></a-entity>
</a-scene>
<script type="text/javascript">
var subm = d3.select('.subm');
var trigger = 1;
var speed = 0.2;
var padding = 2.5;
var front = d3.select('.front');
front.on('click', forward);
front.on('mouseenter', mouseenter);
front.on('mouseleave',mouseleave);
var back = d3.select('.back');
back.on('click', backward);
back.on('mouseenter', mouseenter);
back.on('mouseleave',mouseleave);
var left = d3.select('.left');
left.on('click', leftMove);
left.on('mouseenter', mouseenter);
left.on('mouseleave',mouseleave);
var right = d3.select('.right');
right.on('click', rightMove);
right.on('mouseenter', mouseenter);
right.on('mouseleave',mouseleave);
function mouseenter(){
console.log("Mouse Enter" + trigger)
trigger = 1;
}
function mouseleave(){
console.log("Mouse leave" + trigger)
trigger = 0;
}
function forward(){
console.log("Forward " + trigger)
var that = this;
setTimeout(function(){
console.log("MOVEING");
var currentPosition = that.getAttribute('position');
var sphere = d3.select(that);
console.log(currentPosition);
currentPosition["z"] += speed;
console.log(currentPosition);
sphere.attr('position', currentPosition);
currentPosition["z"] -= padding;
back.attr('position',currentPosition);
currentPosition["z"] += (padding/2);
subm.attr('position', currentPosition);
currentPosition["x"] -= (padding/2);
left.attr('position',currentPosition);
currentPosition["x"] += padding;
right.attr('position',currentPosition);
if(trigger){
forward.call(that);
}
}, 100)
}
function backward(){
console.log("Backward " + trigger)
var that = this;
setTimeout(function(){
console.log("MOVEING");
var currentPosition = that.getAttribute('position');
var oldPosition = that.getAttribute('position');
var sphere = d3.select(that);
console.log(currentPosition);
currentPosition["z"] -= speed;
console.log(currentPosition);
sphere.attr('position', currentPosition);
currentPosition["z"] += padding;
front.attr('position',currentPosition);
currentPosition["z"] -= (padding/2);
subm.attr('position', currentPosition);
currentPosition["x"] -= (padding/2);
left.attr('position',currentPosition);
currentPosition["x"] += padding;
right.attr('position',currentPosition);
if(trigger){
backward.call(that);
}
}, 100)
}
function leftMove(){
console.log("left " + trigger)
var that = this;
setTimeout(function(){
console.log("MOVEING");
var currentPosition = that.getAttribute('position');
var oldPosition = that.getAttribute('position');
var sphere = d3.select(that);
console.log(currentPosition);
currentPosition["x"] -= speed;
console.log(currentPosition);
sphere.attr('position', currentPosition);
currentPosition["x"] += padding;
right.attr('position', currentPosition);
currentPosition["x"] -= (padding/2);
subm.attr('position',currentPosition);
currentPosition["z"] -= (padding/2);
back.attr('position',currentPosition);
currentPosition["z"] += padding;
front.attr('position',currentPosition);
if(trigger){
leftMove.call(that);
}
}, 100)
}
function rightMove(){
console.log("right " + trigger)
var that = this;
setTimeout(function(){
console.log("MOVEING");
var currentPosition = that.getAttribute('position');
var oldPosition = that.getAttribute('position');
var sphere = d3.select(that);
console.log(currentPosition);
currentPosition["x"] += speed;
console.log(currentPosition);
sphere.attr('position', currentPosition);
currentPosition["x"] -= padding;
left.attr('position', currentPosition);
currentPosition["x"] += (padding/2);
subm.attr('position',currentPosition);
currentPosition["z"] -= (padding/2);
back.attr('position',currentPosition);
currentPosition["z"] += padding;
front.attr('position',currentPosition);
if(trigger){
rightMove.call(that);
}
}, 100)
}
</script>
</body>
</html>