This repository has been archived by the owner on Dec 7, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bus-broadcast-legacy.html
602 lines (535 loc) · 40 KB
/
bus-broadcast-legacy.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
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Magic Matta - Peeps on the Bus</title>
<meta name="description" content="Magic Matta - Peeps on the Bus">
<script src="https://aframe.io/releases/0.9.2/aframe.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/mayognaise/aframe-gif-shader/dist/aframe-gif-shader.min.js"></script>
<script src="https://unpkg.com/[email protected]/dist/aframe-environment-component.min.js"></script>
<script src="https://unpkg.com/[email protected]/dist/aframe-slice9-component.min.js"></script>
<script src="https://unpkg.com/[email protected]/dist/aframe-template-component.min.js"></script>
<script src="https://unpkg.com/aframe-log-component/dist/aframe-log-component.min.js"></script>
<script src="https://unpkg.com/[email protected]/dist/aframe-look-at-component.min.js"></script>
<script src="https://unpkg.com/[email protected]/dist/aframe-state-component.min.js"></script>
<script src="https://unpkg.com/[email protected]/dist/aframe-meshline-component.min.js"></script>
<script src="https://unpkg.com/[email protected]/dist/aframe-layout-component.min.js"></script>
<script src="https://unpkg.com/[email protected]/dist/aframe-proxy-event-component.min.js"></script>
<script src="https://unpkg.com/[email protected]/dist/aframe-render-order-component.min.js"></script>
<script src="https://unpkg.com/[email protected]/dist/aframe-orbit-controls.min.js"></script>
<script src="js/aframe-broadcast-component.js"></script>
<script src="js/ortho.js"></script>
<script src="forward.js"></script>
<script src="clock.js"></script>
<!-- State definition. -->
<script src="js/state.js"></script>
<!-- Application components. -->
<!-- <script src="button-colors.js"></script> -->
<script>AFRAME.registerComponent('raycastable', {});</script>
<style>
.menu-overlay {
z-index: 99999;
position: fixed;
top: 20px;
right: 20px;
box-sizing: border-box;
padding: 1.5em;
width: 60px;
height: 60px;
padding-bottom: 0px;
background: rgba(0, 0, 0, 0.5) url(./assets/images/hamburger-white.png) center no-repeat;
background-size: 40px 40px;
font-family: Source Sans Pro, Helvetica Neue, Helvetica, Arial, sans-serif;
}
.menu-overlay:hover {
background: rgba(0, 0, 0, 0.2) url(./assets/images/hamburger-white.png) center no-repeat;
background-size: 40px 40px;
}
</style>
<script>
// handle visual display of bus stop peeps based on number of peeps
AFRAME.registerComponent('draw-stop-peeps', {
schema: {
stopPeeps: {type: 'number', default: 0},
boardingPeepId: {type: 'string'}
},
init: function () {
// really inity
this.myTimer = 0;
},
update: function (oldData) {
var peepsDelta = this.data.stopPeeps - oldData.stopPeeps;
if (peepsDelta === 1) {
document.getElementById(this.data.boardingPeepId).removeAttribute("animation__alight");
document.getElementById(this.data.boardingPeepId).setAttribute("animation__alight", "property: object3D.position.x; easing: linear; from: -4; to: 0; dur: 1000");
if (this.myTimer) {
clearTimeout(this.myTimer);
}
var that = this;
this.myTimer = setTimeout(
function() {
that.removePeeps()
that.buildPeeps()
}, 1000);
return;
}
this.removePeeps()
this.buildPeeps()
if (peepsDelta === -1) {
document.getElementById(this.data.boardingPeepId).emit('startBoarding');
}
},
remove: function () {
this.removePeeps();
},
buildPeeps: function () {
for (i=0; i < this.data.stopPeeps; i++) {
var peepEl = document.createElement('a-entity');
peepEl.setAttribute("mixin", "peep1 bounce");
this.el.appendChild(peepEl);
peepEl.setAttribute("class", "peeps");
peepEl.setAttribute("position", "0 0.2 " + i);
peepEl.setAttribute("rotation", "0 270 0");
}
},
removePeeps: function () {
// var myNode = document.getElementById("peepsParent");
var myNode = this.el;
while (myNode.firstChild) {
myNode.removeChild(myNode.firstChild);
// console.log("ONE REMOVED");
}
}
});
// passengers board the bus if bus is within threshold distance of target bus stop
AFRAME.registerComponent('board', {
schema: {
delay: {type: 'number', default: 1000},
target: {type: 'string', default: "bus-stop"},
distance: {type: 'number', default: 2},
capacity: {type: 'number', default: 10},
busPeeps: {type: 'number', default: 0},
stopPeeps: {type: 'number', default: 0}
},
init: function () {
this.throttledFunction = AFRAME.utils.throttle(this.everySecond, this.data.delay, this);
this.comparisonVector = new THREE.Vector3();
this.positionDelta = Number(this.data.distance) + 1;
this.targetEl = document.querySelector("#" + this.data.target);
this.positionThis = new THREE.Vector3();
this.positionTarget = new THREE.Vector3();
},
everySecond: function() {
// if distance between this element and the target element are less than distance
// AND if current passengers is less than capacity
// THEN subtract 1 passenger from target bus stop and add 1 passenger to bus
// Set positionThis and positionTarget based on current location
this.el.object3D.getWorldPosition(this.positionThis);
this.targetEl.object3D.getWorldPosition(this.positionTarget);
this.comparisonVector.subVectors(this.positionThis, this.positionTarget);
this.positionDelta = this.comparisonVector.length();
// console.log(this.positionDelta);
// if bus is close enough to bus stop
if (this.positionDelta < Number(this.data.distance)) {
var busFull = Number(this.data.busPeeps) == Number(this.data.capacity);
if (!busFull) {
var stopEmpty = Number(this.data.stopPeeps) == 0;
if (!stopEmpty) {
AFRAME.scenes[0].emit('increaseBus1Peeps');
AFRAME.scenes[0].emit('decreaseStop1Peeps');
AFRAME.log("1 PEEPS BOARDED", 'bus1');
} else {
AFRAME.log("Stop Empty", 'bus1');
}
} else {
AFRAME.log("Bus Full", 'bus1');
}
}
},
tick: function(){
this.throttledFunction(); // Called once a second.
},
});
// passengers alight the bus if bus is within threshold distance (in m) of target bus stop
AFRAME.registerComponent('alight', {
schema: {
delay: {type: 'number', default: 1000},
target: {type: 'string', default: "bus-stop"},
distance: {type: 'number', default: 2},
busPeeps: {type: 'number', default: 0}
},
init: function () {
this.throttledFunction = AFRAME.utils.throttle(this.everySecond, this.data.delay, this);
this.comparisonVector = new THREE.Vector3();
this.positionDelta = Number(this.data.distance) + 1;
this.targetEl = document.querySelector("#" + this.data.target);
this.positionThis = new THREE.Vector3();
this.positionTarget = new THREE.Vector3();
},
everySecond: function() {
// if distance between this element and the target element are less than distance
// AND if current passengers > 0
// THEN subtract 1 passenger from this bus and add 1 to target bus stop
// Set positionThis and positionTarget based on current location
this.el.object3D.getWorldPosition(this.positionThis);
this.targetEl.object3D.getWorldPosition(this.positionTarget);
this.comparisonVector.subVectors(this.positionThis, this.positionTarget);
this.positionDelta = this.comparisonVector.length();
// console.log(this.positionDelta);
// if bus is close enough to bus stop
if (this.positionDelta < Number(this.data.distance)) {
var busEmpty = Number(this.data.busPeeps) <= 0;
if (!busEmpty) {
AFRAME.scenes[0].emit('decreaseBusPeeps', {target: "bus1"});
AFRAME.scenes[0].emit('increaseStop2Peeps', {target: "stop2"});
AFRAME.scenes[0].emit('increaseBus1Score', {target: "bus1"});
AFRAME.log("1 PEEPS ALIGHTED", 'bus1');
} else {
AFRAME.log("Bus Empty!", 'bus1');
}
}
},
tick: function(){
this.throttledFunction(); // Called once a second.
},
});
AFRAME.registerComponent('position-log', {
schema: {
},
init: function() {
this.throttledFunction = AFRAME.utils.throttle(this.everySecond, 1000, this);
// this.last = this.el.getAttribute('position');
this.lastPosition = new THREE.Vector3();
this.lastPosition.copy(this.el.object3D.position);
this.velocity = new THREE.Vector3();
this.speed = 0;
this.lastSpeed = 0;
this.passengers = 0;
this.acceleration = 0;
},
everySecond: function() {
AFRAME.log("******* ENTITY CONSOLE LOG *******\nCurrent Position", 'bus1');
AFRAME.log(this.el.object3D.position, 'bus1');
// AFRAME.log("Previous Position");
// AFRAME.log(this.lastPosition);
AFRAME.log("Velocity (m/s)", 'bus1');
this.velocity.subVectors(this.el.object3D.position, this.lastPosition);
AFRAME.log(this.velocity, 'bus1');
this.speed = this.velocity.length()
AFRAME.log("Speed: " + this.speed + " m/s", 'bus1');
this.acceleration = this.speed - this.lastSpeed;
AFRAME.log("Acceleration: " + this.acceleration + " m/s^2", 'bus1');
AFRAME.log("Passengers: " + AFRAME.scenes[0].systems.state.state.game.bus1Peeps, 'bus1');
// this.speed = Math.sqrt(Math.pow(this.velocity.getComponent(0), 2) + Math.pow(this.velocity.getComponent(1), 2) + Math.pow(this.velocity.getComponent(2), 2));
// AFRAME.log(this.speed);
this.lastPosition.copy(this.el.object3D.position);
this.lastSpeed = this.speed;
},
tick: function(){
this.throttledFunction(); // Called once a second.
},
});
</script>
</head>
<body>
<a-scene loading-screen="backgroundColor: #da95f1" log="console: false" stats background="color: #ECECEC" broadcast="url: http://192.168.1.3:12000; interval: 10">
<!-- note: camera is placed here against best practices because of https://github.com/aframevr/aframe/issues/3921 -->
<a-entity camera look-controls position="0 1 0"></a-entity>
<a-assets>
<a-mixin id="bounce"
animation__1="property: object3D.rotation.z; easing: linear; from: -45; to: 45; dir: alternate; dur: 500; loop: true"
animation__2="property: object3D.position.y; easing: linear; from: 0.2; to: 1; dir: alternate; dur: 250; loop: true"></a-mixin>
<a-mixin id="peep1" scale="0.1 0.1 0.1" obj-model="obj: url(models/city-builder-obj/chr_worker1.obj); mtl: url(models/city-builder-obj/chr_worker1.mtl)"></a-mixin>
<a-mixin id="peep2" scale="0.1 0.1 0.1" obj-model="obj: url(models/city-builder-obj/chr_worker2.obj); mtl: url(models/city-builder-obj/chr_worker2.mtl)"></a-mixin>
<a-mixin id="peep3" scale="0.1 0.1 0.1" obj-model="obj: url(models/city-builder-obj/chr_worker3.obj); mtl: url(models/city-builder-obj/chr_worker3.mtl)"></a-mixin>
<img id="sky" src="images/sky3.jpg" />
<!-- Menu Images. -->
<img id="pageIconImg" src="images/arrowDownIcon.png" crossorigin>
<img id="sliceImg" src="images/slice9_tooltip.png" crossorigin>
<!-- <img id="logoImg" src="images/magic-matta-square.png" crossorigin> -->
<img id="headerImg" src="images/header-magic-matta.png" crossorigin>
<img id="gameImg" src="images/game-logo-peeps-on-the-bus.png" crossorigin>
<!-- Menu Base mixins. -->
<a-mixin id="font" text="font: roboto"></a-mixin>
<!-- <a-mixin id="slice" slice9="color: #050505; transparent: true; opacity: 0.9; src: #sliceImg; left: 50; right: 52; top: 50; bottom: 52; padding: 0.15"></a-mixin> -->
<a-mixin id="slice" slice9="transparent: true; opacity: 0.9; src: #sliceImg; left: 15; right: 52; top: 15; bottom: 52; padding: 0.055"></a-mixin>
<!-- Menu and button mixins. Mixins can be composed from other mixins. -->
<a-mixin id="buttonBackground" mixin="slice" slice9="width: 1.3; height: 0.3; color: #030303" render-order="button"></a-mixin>
<a-mixin
id="buttonHoverEffect"
animation__mouseenter="property: components.slice9.material.color; type: color; from: #030303; to: #FFF; easing: easeOutCubic; dur: 150; startEvents: mouseenter"
animation__mouseleave="property: components.slice9.material.color; type: color; from: #FFF; to: #030303; easing: easeOutCubic; dur: 150; startEvents: mouseleave"></a-mixin>
<a-mixin id="buttonText" mixin="font" text="align: center; width: 2.5; zOffset: 0.01; color: #333"></a-mixin>
<a-mixin id="button" mixin="buttonBackground buttonHoverEffect buttonText" render-order="button" proxy-event="event: click; to: a-scene; captureBubbles: true"></a-mixin>
<a-mixin id="pageButton" geometry="primitive: plane; width: 0.15; height: 0.15" material="src: #pageIconImg; shader: flat; transparent: true; color: #111"
animation__mouseenter="property: components.material.material.color; type: color; from: #111; to: #FFF; dur: 200; startEvents: mouseenter"
animation__mouseleave="property: components.material.material.color; type: color; from: #FFF; to: #111; dur: 200; startEvents: mouseleave"></a-mixin>
<!-- Bus Template - template component style -->
<script id="bustemplate" type="text/html">
<a-plane class="bus-front" src="url(images/bus-front.png)" material="alphaTest: 0.5;" position="0 0.181 5.979" rotation="-8 0 0" width="2.59" height="2.7186" shadow="receive:false"></a-plane>
<a-plane class="bus-top" src="url(images/bus-top-4278.png)" material="alphaTest: 0.5;" position="0 1.485 -0.1" rotation="-90 -90 0" width="11.879" height="2.59" shadow="receive:false"></a-plane>
<a-plane class="bus-right" src="url(images/bus-right.png)" material="alphaTest: 0.5;" position="-1.295 0 0" rotation="0 -90 0" width="12.459" height="3.001" shadow="receive:false"></a-plane>
<a-plane class="bus-left" src="url(images/bus-left.png)" material="alphaTest: 0.5;" position="1.295 0 0" rotation="0 90 0" width="12.459" height="3.001" shadow="receive:false"></a-plane>
<a-plane class="bus-back" src="url(images/bus-back.png)" material="alphaTest: 0.5;" position="0 0.181 -6.040" rotation="0 180 0" width="2.59" height="2.7186" shadow="receive:false"></a-plane>
<a-plane class="bus-shadow" src="url(images/bus-shadow.png)" material="alphaTest: 0.5;transparent:true;metalness:1;roughness:1;" position="0 -1.489 -0.1" rotation="-90 -90 0" width="11.879" height="2.59" scale="1.2 1.2 0"></a-plane>
<a-plane class="destination-led-front" position="0 1.23 5.84" rotation="-7.2 0 0" height="0.19" width="1.66" material="shader:gif;src:#destination-queens;"></a-plane>
<a-plane class="destination-led-side" position="-1.3 0.98 3.75" rotation="0 -90 0" height="0.15" width="1.32" material="shader:gif;src:#destination-queens;"></a-plane>
<a-text class="destination-led-back" position="-0.44 1.34 -6.06" value="Q9A" color="#ffbf00" text="font:dejavu" rotation="0 180 0" scale="0.9 0.9 0.9"></a-text>
<a-image class="lensflare-headlight-left" src="url(images/light_PNG14436.png)" material="alphaTest:0" position="1.08 -0.72 6.18" scale="1.5 1.5 0"></a-image>
<a-image class="lensflare-headlight-right" src="url(images/light_PNG14436.png)" material="alphaTest:0" position="-1.11 -0.72 6.18" scale="1.5 1.5 0"></a-image>
<a-image class="lensflare-tail-light-left" src="url(images/tail-light.png)" position="1.07 -0.16 -6.06" rotation="0 180 0" scale="2 2 0"></a-image>
<a-image class="lensflare-tail-light-right" src="url(images/tail-light.png)" position="-1.08 -0.16 -6.06" rotation="0 180 0" scale="2 2 0"></a-image>
<a-entity class="light-tail-light-right" light="type:spot;angle:17.35;penumbra:0.39;color:#ff0000;intensity:5.5;distance:20" position="-1.1 -0.8 -4.22"></a-entity>
<a-entity class="light-tail-light-left" light="type:spot;angle:17.35;penumbra:0.39;color:#ff0000;intensity:5.5;distance:20" position="1.1 -0.8 -4.22"></a-entity>
<a-entity class="light-headlight-left" light="type:spot;angle:17.35;penumbra:0.39;color:#ffffff;intensity:14.2;distance:20" rotation="0 180 0" position="1.1 -0.9 4.82"></a-entity>
<a-entity class="light-headlight-right" light="type:spot;angle:17.35;penumbra:0.39;color:#ffffff;intensity:14.2;distance:20" rotation="0 180 0" position="-1.1 -0.9 4.82"></a-entity>
</script>
<img id="destination-queens" src="images/Q9ALimitedOrangeLED.gif" />
<a-asset-item id="new-bus" src="models/new-bus/GLTF/BUS.gltf"></a-asset-item>
<a-asset-item id="vive-tracker" src="models/tracker/HTC_Vive_Tracker.gltf"></a-asset-item>
<a-asset-item id="vive-controller-obj" src="https://cdn.aframe.io/controllers/vive/vr_controller_vive.obj"></a-asset-item>
<a-asset-item id="vive-controller-mtl" src="https://cdn.aframe.io/controllers/vive/vr_controller_vive.mtl"></a-asset-item>
</a-assets>
<!-- Menu container. -->
<a-entity id="menu" position="0 1 -0.75" rotation="0 0 0" scale="0.25 0.25 0.25">
<a-entity id="menuBackground" mixin="slice" slice9="height: 3; width: 5.3333" render-order="menuBackground"></a-entity>
<a-entity id="menuBack" mixin="pageButton" scale="1.5 1.5 1.5" position="-0.8 1.15 0.02" rotation="0 0 -90" proxy-event="event: click; to: a-scene; as: menuBack" bind-toggle__raycastable="game.menu !== 'main'" bind__visible="game.menu !== 'main'" render-order="menuItem"></a-entity>
<!-- Main menu. -->
<a-mixin id="buttonMain" mixin="button" bind-toggle__raycastable="game.menu === 'main'"></a-mixin>
<a-entity id="mainMenu" bind__visible="game.menu === 'main'">
<a-entity id="header" geometry="primitive: plane; width: 5.25; height: 0.625" material="src: #headerImg; transparent: true; shader: flat" position="0 1.56 0.01" render-order="menuitem"></a-entity>
<a-entity id="game" geometry="primitive: plane; width: 2; height: 2" material="src: #gameImg; transparent: true; shader: flat" position="-1.4 -0.2 0.02" render-order="menuitem"></a-entity>
<a-entity class="buttons" layout="type: box; columns: 4; marginRow: -0.5" position="-1.39 1 0.02">
<a-entity mixin="buttonMain" text="value: Game Reset; color: #53E033" proxy-event="as: resetGameState"></a-entity>
</a-entity>
<a-entity class="buttons" layout="type: box; columns: 1; marginRow: -0.5" position="0 1 0.02">
<a-entity mixin="buttonMain" text="value: Controls & Setup; color: #e0cb49" proxy-event="as: menuController"></a-entity>
</a-entity>
<a-entity class="buttons" layout="type: box; columns: 1; marginRow: -0.5" position="1.39 1 0.02">
<a-entity mixin="buttonMain" text="value: Make Projector; color: #F85333" onclick="makeProjector()"></a-entity>
</a-entity>
<a-entity class="playerScoreboard" position="0 0 0">
<a-entity class="row" position="0 0.7 0.01">
<a-entity class="menuKey" text="value: PLAYER 1; color: #FAFAFA; width: 7.5; align: right" position="-2.6 -0.1 0" render-order="menuItem"></a-entity>
<a-entity class="menuValue" bind__text="value: gameSettings.bus1Color; color: gameSettings.bus1Color" text="width: 7.5; align: left" position="5 -0.1 0" render-order="menuItem"></a-entity>
</a-entity>
<a-entity class="row" position="0 0.4 0.01">
<a-entity class="menuKey" text="value: Peeps; color: #FAFAFA; width: 7.5; align: right" position="-2.6 -0.1 0" render-order="menuItem"></a-entity>
<a-entity class="menuValue" bind__text="value: game.bus1Peeps" text="color: #FAFAFA; width: 7.5; align: left" position="5 -0.1 0" render-order="menuItem"></a-entity>
</a-entity>
<a-entity class="row" position="0 0.1 0.01">
<a-entity class="menuKey" text="value: Score; color: #FAFAFA; width: 7.5; align: right" position="-2.6 -0.1 0" render-order="menuItem"></a-entity>
<a-entity class="menuValue" bind__text="value: game.bus1Score; color: gameSettings.bus1Color" text="width: 7.5; align: left" position="5 -0.1 0" render-order="menuItem"></a-entity>
</a-entity>
</a-entity>
<a-entity class="playerScoreboard" position="0 -1 0">
<a-entity class="row" position="0 0.7 0.01">
<a-entity class="menuKey" text="value: PLAYER 2; color: #FAFAFA; width: 7.5; align: right" position="-2.6 -0.1 0" render-order="menuItem"></a-entity>
<a-entity class="menuValue" bind__text="value: gameSettings.bus2Color; color: gameSettings.bus2Color" text="width: 7.5; align: left" position="5 -0.1 0" render-order="menuItem"></a-entity>
</a-entity>
<a-entity class="row" position="0 0.4 0.01">
<a-entity class="menuKey" text="value: Peeps; color: #FAFAFA; width: 7.5; align: right" position="-2.6 -0.1 0" render-order="menuItem"></a-entity>
<a-entity class="menuValue" bind__text="value: game.bus2Peeps" text="color: #FAFAFA; width: 7.5; align: left" position="5 -0.1 0" render-order="menuItem"></a-entity>
</a-entity>
<a-entity class="row" position="0 0.1 0.01">
<a-entity class="menuKey" text="value: Score; color: #FAFAFA; width: 7.5; align: right" position="-2.6 -0.1 0" render-order="menuItem"></a-entity>
<a-entity class="menuValue" bind__text="value: game.bus2Score; color: gameSettings.bus2Color" text="width: 7.5; align: left" position="5 -0.1 0" render-order="menuItem"></a-entity>
</a-entity>
</a-entity>
</a-entity>
<!-- Control Mapping menu. -->
<a-entity id="controllerMenu" bind__visible="game.menu === 'controller'">
<a-entity id="controlHeader" text="value: Controls & Setup; color: #FAFAFA; width: 4; align: center" position="0 1.2 0.01" render-order="menuItem"></a-entity>
<!-- object1 -->
<a-entity class="row" position="0 0.7 0.01">
<a-entity class="menuKey" text="value: Device Mode; color: #FAFAFA; width: 2.5; align: center" position="-0.5 0 0" render-order="menuItem"></a-entity>
<a-entity class="menuValue" bind__text="value: thisDevice.mode" text="color: #FAFAFA; width: 2.5; align: center" position="0.5 0 0" render-order="menuItem"></a-entity>
</a-entity>
<a-entity class="row" position="0 0.4 0.01">
<a-entity class="menuKey" text="value: Bus1 Controller ID; color: #FAFAFA; width: 2.5; align: center" position="-0.5 0 0" render-order="menuItem"></a-entity>
<a-entity class="menuValue" bind__text="value: controls.bus1ControllerId" text="color: #FAFAFA; width: 2.5; align: center" position="0.5 0 0" render-order="menuItem"></a-entity>
<a-entity class="buttonDecrease" mixin="pageButton" position="0.25 0 0" rotation="0 0 -90" proxy-event="event: click; to: a-scene; as: decreaseBus1ControllerId" bind-toggle__raycastable="game.menu === 'controller'"></a-entity>
<a-entity class="buttonIncrease" mixin="pageButton" position="0.75 0 0" rotation="0 0 90" proxy-event="event: click; to: a-scene; as: increaseBus1ControllerId" bind-toggle__raycastable="game.menu === 'controller'" ></a-entity>
</a-entity>
<a-entity class="row" position="0 0.1 0.01">
<a-entity class="menuKey" text="value: Layout Position Y; color: #FAFAFA; width: 2.5; align: center" position="-0.5 0 0" render-order="menuItem"></a-entity>
<a-entity class="menuValue" bind__text="value: layout.positionY" text="color: #FAFAFA; width: 2.5; align: center" position="0.5 0 0" render-order="menuItem"></a-entity>
<a-entity class="buttonDecrease" mixin="pageButton" position="0.25 0 0" rotation="0 0 -90" proxy-event="event: click; to: a-scene; as: decreaseLayoutPositionY" bind-toggle__raycastable="game.menu === 'controller'"></a-entity>
<a-entity class="buttonIncrease" mixin="pageButton" position="0.75 0 0" rotation="0 0 90" proxy-event="event: click; to: a-scene; as: increaseLayoutPositionY" bind-toggle__raycastable="game.menu === 'controller'" ></a-entity>
</a-entity>
<a-entity class="row" position="0 -0.2 0.01">
<a-entity class="menuKey" text="value: Layout Rotation Y; color: #FAFAFA; width: 2.5; align: center" position="-0.5 0 0" render-order="menuItem"></a-entity>
<a-entity class="menuValue" bind__text="value: layout.rotationY" text="color: #FAFAFA; width: 2.5; align: center" position="0.5 0 0" render-order="menuItem"></a-entity>
<a-entity class="buttonDecrease" mixin="pageButton" position="0.25 0 0" rotation="0 0 -90" proxy-event="event: click; to: a-scene; as: decreaseLayoutRotationY" bind-toggle__raycastable="game.menu === 'controller'"></a-entity>
<a-entity class="buttonIncrease" mixin="pageButton" position="0.75 0 0" rotation="0 0 90" proxy-event="event: click; to: a-scene; as: increaseLayoutRotationY" bind-toggle__raycastable="game.menu === 'controller'" ></a-entity>
</a-entity>
</a-entity>
</a-entity>
<!-- Mouse cursor so we can click on the scene with mouse or touch. -->
<a-entity id="mouseCursor" cursor="rayOrigin: mouse" raycaster="objects: [raycastable]"></a-entity>
<a-entity id="leftHand" laser-controls="hand: left" raycaster="objects: [raycastable]">
<a-entity obj-model="obj: #vive-controller-obj; mtl: #vive-controller-mtl" scale="1 1 1" bind__visible="thisDevice.mode !== 'server'"></a-entity>
</a-entity>
<a-entity id="rightHand" laser-controls="hand: right" raycaster="objects: [raycastable]">
<a-entity obj-model="obj: #vive-controller-obj; mtl: #vive-controller-mtl" scale="1 1 1" bind__visible="thisDevice.mode !== 'server'"></a-entity>
</a-entity>
<!-- Bus1 Entity including tracker controller -->
<!-- <a-entity id="bus1-controller" tracked-controls="idPrefix: OpenVR; controller: 2; orientationOffset:-90 180 0" position-log> -->
<a-entity id="bus1-controller" position-log>
<a-entity id="tracker-model" gltf-model="#vive-tracker" visible="false" rotation="0 0 0" scale="0.001 0.001 0.001"></a-entity>
<!-- <a-entity id="bus1" position-log wasd-controls="acceleration: 260;" position="0 0 10"> -->
<a-entity id="bus1" position="0 -0.065 0.045" bind__scale="computedScaleString">
<a-text class="busPeepsLabel" look-at="[camera]" position="0 6 3" rotation="0 270 0" scale="15 15 15" bind__value="game.bus1Peeps" color="cyan" font="aileronsemibold"></a-text>
<a-ring class="bus-door-marker" color="cyan" position="2 -1.25 -5.315" radius-inner="0.4" radius-outer="0.5" rotation="-90 0 0" material="shader:flat"
board="target: bus-stop-1-marker" bind__board="busPeeps: game.bus1Peeps; stopPeeps: game.stop1Peeps; capacity: gameSettings.busCapacity; distance: computedDistance"
alight="target: bus-stop-2-marker" bind__alight="busPeeps: game.bus1Peeps; distance: computedDistance"></a-ring>
<a-ring class="bus-door-marker" color="cyan" position="2 -0.75 -5.315" radius-inner="0.4" radius-outer="0.5" rotation="-90 0 0" material="shader:flat"></a-ring>
<a-ring class="bus-door-marker" color="cyan" position="2 -0.25 -5.315" radius-inner="0.4" radius-outer="0.5" rotation="-90 0 0" material="shader:flat"></a-ring>
<a-entity class="log" look-at="[camera]" log="max: 10;" scale="6 6 6" geometry="primitive: plane;" material="color: #111; shader: flat" text="color: lightgreen" position="-6 3 0"></a-entity>
<!-- <a-entity gltf-model="#new-bus" rotation="0 270 0" scale="0.4 0.4 0.4"></a-entity> -->
<a-entity class="bus-model" template="src: #bustemplate" position="0 0 0" rotation="0 180 0" ></a-entity>
</a-entity>
</a-entity>
<a-entity id="game-world" bind__position="computedPositionString" bind__rotation="computedRotationString" bind__scale="computedScaleString" broadcast="send: position, rotation, scale">
<a-cylinder id="grass-ground" material="src:images/grass01.jpg;normalMap:images/grass01_n.jpg;metalnessMap:images/grass01_s.jpg;displacementTextureRepeat:30 30;normalTextureRepeat:30 30;repeat:30 30;metalnessTextureRepeat:30 30;color:#f6ff49;" rotation="0 0 0" position="0 -5 0" height="10" scale="1 1 1" radius="200"></a-cylinder>
<a-entity environment="seed: 8;
skyType: gradient;
skyColor: #24b5ff;
horizonColor: #eff9f7;
lighting: distant;
lightPosition: { x: -1.2, y: 0.88, z: -0.55};
fog: false;
flatShading: false;
ground: noise;
groundTexture: squares;
groundColor: #939a24;
groundColor2: #989d2e;
dressing: trees;
dressingAmount: 200;
dressingColor: #888b1d;
dressingScale: 4.5;
dressingOnPlayArea: false;
grid: none;
gridColor: #c5a543;
shadow: false" position="0 -0.1 0" scale="8 8 8"></a-entity>
<a-entity class="model-streetlight" gltf-model="models/streetlightmodel.gltf" position="-3.6 -1.9 8.2" rotation="0 180 0" scale="1.5 1.5 1.5"></a-entity>
<a-entity class="light-streetlight" light="type:spot;angle:57.85;penumbra:0.19" position="-3 4.5 7" rotation="-90 0 0"></a-entity>
<a-entity id="messageboard" position="0 0 -12">
<a-entity class="messageboard-pole" gltf-model="models/streetlightmodel.gltf" position="4.5 -1.9 3.4" scale="1.5 1.5 1.5"></a-entity>
<a-entity class="messageboard-sign" material="color:black" geometry="depth:0.33;width:3.54" position="1.961 4.160 4.66" ></a-entity>
<a-entity clock="font: sourcecodepro; color: #ffbf00; position: 0.381 4.03 4.859"></a-entity>
<a-text position="0.381 4.36 4.859" value="Howard St Closed at 3rd" color="#ffbf00" font="monoid"></a-text>
</a-entity>
<a-entity meshline="lineWidth: 2; path: -2 -1 0, 0 -2 0, 2 -1; color: #E20049" position="0 10 0"></a-entity>
<a-entity id="bus-stop-1" class="bus-stop" position="4.5 0 25">
<a-text class="stopPeepsLabel" look-at="[camera]" position="2 6 0" rotation="0 270 0" scale="15 15 15" bind__value="game.stop1Peeps" color="yellow" font="aileronsemibold"></a-text>
<a-entity id="boardingPeep1" visible="true" class="peeps" mixin="peep1 bounce" position="0 0.2 -1" rotation="0 270 0"
animation__board="property: object3D.position.x; easing: linear; from: 0; to: -4; dur: 900; startEvents: startBoarding"
animation__flee="property: object3D.position.x; easing: linear; from: -4; to: 999; dur: 1; startEvents: animationcomplete__board"
></a-entity>
<a-entity id="peepsParent1" draw-stop-peeps="boardingPeepId: boardingPeep1" bind__draw-stop-peeps="stopPeeps: game.stop1Peeps" position="0 0 -1">
</a-entity>
<a-entity class="bus-stop-sidewalk" geometry="primitive:plane;height:5;width:15" position="1.5 0.26 3" rotation="270 0 90" material="src:images/cobblestone-sidewalk.jpg;repeat:9 3;color:#f4fff7;metalness:1;roughness:0.84"></a-entity>
<a-image class="bus-stop-stencil" src="url(images/stop-bus.png)" material="alphaTest:0;opacity:0.5;" rotation="270 270 90" position="-4.7 0.02 3" scale="6 8 6"></a-image>
<a-entity class="bus-stop-shelter" gltf-model="models/ccFO2EGGIq9-bus-stop/bust stop 1.gltf" position="1 0.25 0" rotation="-90 0 0" scale="0.001 -0.001 0.001"></a-entity>
<a-entity class="bus-stop-advert" geometry="primitive:plane;height:2.5;width:2" position="0.24 1.53 2.07" material="src:images/carrot-advert-lighting.jpg;shader:flat"></a-entity>
<a-entity id="bus-stop-1-marker" bind__visible="game.stop1Peeps !== 0" position="-2.536 0.5 -0.932">
<a-ring class="marker-pulsating" color="yellow"
animation__1="property: radius-inner; from: 2; to: 7; dir: alternate; dur: 1000; loop: true"
animation__2="property: radius-outer; from: 2.2; to: 9; dir: alternate; dur: 1000; loop: true"
rotation="-90 0 0" material="shader:flat" radius-inner="3" radius-outer="4" ></a-ring>
<a-ring class="marker-door-zone" color="yellow" rotation="-90 0 0" material="shader:flat" radius-inner="1.8" radius-outer="2" ></a-ring>
</a-entity>
</a-entity>
<a-entity id="bus-stop-2" class="bus-stop" position="4.5 0 -30">
<a-text class="stopPeepsLabel" look-at="[camera]" position="2 6 0" rotation="0 270 0" scale="15 15 15" bind__value="game.stop2Peeps" color="yellow" font="aileronsemibold"></a-text>
<a-entity id="alightingPeep2" visible="true" class="peeps" mixin="peep1 bounce" position="0 0.2 -1" rotation="0 90 0"></a-entity>
<a-entity id="peepsParent2" draw-stop-peeps="boardingPeepId: alightingPeep2" bind__draw-stop-peeps="stopPeeps: game.stop2Peeps" position="0 0 -1">
<!-- PEEPS GO HERE -->
<!-- <a-entity id="bob" mixin="peep1 bounce" position="0 0.2 0" rotation="0 270 0"></a-entity>
<a-entity id="roberta" mixin="peep2 bounce" position="0 0.2 -1" rotation="0 270 0"></a-entity>
<a-entity id="tom" mixin="peep3 bounce" position="0 0.2 1" rotation="0 270 0"></a-entity> -->
</a-entity>
<a-entity class="bus-stop-sidewalk" geometry="primitive:plane;height:5;width:15" position="1.5 0.26 3" rotation="270 0 90" material="src:images/cobblestone-sidewalk.jpg;repeat:9 3;color:#f4fff7;metalness:1;roughness:0.84"></a-entity>
<a-image class="bus-stop-stencil" src="url(images/stop-bus.png)" material="alphaTest:0;opacity:0.5;" rotation="270 270 90" position="-4.7 0.02 3" scale="6 8 6"></a-image>
<a-entity class="bus-stop-shelter" gltf-model="models/ccFO2EGGIq9-bus-stop/bust stop 1.gltf" position="1 0.25 0" rotation="-90 0 0" scale="0.001 -0.001 0.001"></a-entity>
<a-entity class="bus-stop-advert" geometry="primitive:plane;height:2.5;width:2" position="0.24 1.53 2.07" material="src:images/carrot-advert-lighting.jpg;shader:flat"></a-entity>
<a-entity id="bus-stop-2-marker" bind__visible="game.bus1Peeps > 0" position="-2.536 0.5 -0.932">
<a-ring class="marker-pulsating" color="yellow"
animation__1="property: radius-inner; from: 2; to: 7; dir: alternate; dur: 1000; loop: true"
animation__2="property: radius-outer; from: 2.2; to: 9; dir: alternate; dur: 1000; loop: true"
rotation="-90 0 0" material="shader:flat" radius-inner="3" radius-outer="4" ></a-ring>
<a-ring class="marker-door-zone" color="yellow" rotation="-90 0 0" material="shader:flat" radius-inner="1.8" radius-outer="2" ></a-ring>
</a-entity>
</a-entity>
<a-entity id="lane-northbound">
<a-entity class="street" position="2.2 0.25 0" rotation="90 0 0" scale="0.5 0.5 0.5">
<a-entity gltf-model="models/street-7aKNh-4MGdK/scene.gltf" scale="0.001 0.001 0.001"></a-entity>
</a-entity>
<a-entity class="street" position="2.2 0.25 -28.68" rotation="90 0 0" scale="0.5 0.5 0.5">
<a-entity gltf-model="models/street-7aKNh-4MGdK/scene.gltf" scale="0.001 0.001 0.001"></a-entity>
</a-entity>
<a-entity class="street" position="2.2 0.25 28.68" rotation="90 0 0" scale="0.5 0.5 0.5">
<a-entity gltf-model="models/street-7aKNh-4MGdK/scene.gltf" scale="0.001 0.001 0.001"></a-entity>
</a-entity>
</a-entity>
<a-entity id="lane-southbound" position="-6.3 0 0" rotation="0 180 0">
<a-entity class="street" position="2.2 0.25 0" rotation="90 0 0" scale="0.5 0.5 0.5">
<a-entity gltf-model="models/street-7aKNh-4MGdK/scene.gltf" scale="0.001 0.001 0.001"></a-entity>
</a-entity>
<a-entity class="street" position="2.2 0.25 -28.68" rotation="90 0 0" scale="0.5 0.5 0.5">
<a-entity gltf-model="models/street-7aKNh-4MGdK/scene.gltf" scale="0.001 0.001 0.001"></a-entity>
</a-entity>
<a-entity class="street" position="2.2 0.25 28.68" rotation="90 0 0" scale="0.5 0.5 0.5">
<a-entity gltf-model="models/street-7aKNh-4MGdK/scene.gltf" scale="0.001 0.001 0.001"></a-entity>
</a-entity>
</a-entity>
<a-entity id="median" geometry="primitive:plane;height:1.3;width:85.9" position="-3.08 0.26 0" rotation="270 0 90" material="src:images/cobblestone-sidewalk.jpg;repeat:30 1;color:#f4fff7;metalness:1;roughness:0.84"></a-entity>
<a-entity light="intensity:0.6;castShadow:true" position="-0.5 1 1"></a-entity>
<a-entity id="ambient" light="color:#BBB;type:ambient;intensity:0.1"></a-entity>
</a-entity> <!-- closing game-world entity -->
</a-scene>
<a onclick="AFRAME.scenes[0].emit('resetGameState');"><div class="menu-overlay btn btn-outline-secondary"></div></a>
<script>
console.log("Run `makeWASD();` if you need to use a keyboard without a WebVR browser.");
function makeProjector() {
AFRAME.scenes[0].setAttribute("orbit-controls", "target: 0 0 0; initialPosition: 0 0.5 0;");
document.getElementsByClassName("a-enter-vr-button")[0].hidden = true;
// Disabled, not sure why this causes controllers to disappear :(
// AFRAME.scenes[0].emit('setClientMode');
}
function makeOrtho() {
var cameraEl = document.querySelector("[camera]");
cameraEl.setAttribute("ortho", "width: 2.61; height 1.65; near: -100; far: 100");
cameraEl.setAttribute("rotation", "-90 0 0");
}
function makeWASD() {
// find bus object - make it located reasonable location // detach tracker binding?
var controllerEl = document.querySelector("#bus1-controller");
controllerEl.removeAttribute("tracked-controls");
controllerEl.setAttribute("position", "0 0.1 0");
controllerEl.setAttribute("wasd-controls", "acceleration: 6");
var cameraEl = document.querySelectorAll("[camera]");
cameraEl[0].removeAttribute("wasd-controls");
AFRAME.scenes[0].setAttribute("orbit-controls", "target: 0 0 0; initialPosition: 0 0.5 0;");
AFRAME.scenes[0].emit('setClientMode');
}
function makeServer() {
// add tracked controller to above thing
// tracked-controls="idPrefix: OpenVR; controller: 2; orientationOffset:-90 180 0"
var controllerEl = document.querySelector("#bus1-controller");
controllerEl.setAttribute("tracked-controls", "idPrefix: OpenVR; orientationOffset:-90 0 0");
controllerEl.setAttribute("bind__tracked-controls", "controller: controls.bus1ControllerId");
document.querySelector("#tracker-model").setAttribute("visible", "true");
controllerEl.setAttribute("broadcast", "send: position, rotation");
document.getElementById("leftHand").setAttribute("broadcast", "send: position, rotation");
document.getElementById("rightHand").setAttribute("broadcast", "send: position, rotation");
AFRAME.scenes[0].emit('setServerMode');
}
document.querySelector('a-scene').addEventListener('enter-vr', function () {
console.log("ENTERED VR");
makeServer();
});
</script>
</body>
</html>