-
Notifications
You must be signed in to change notification settings - Fork 1
/
cycle.em
35 lines (29 loc) · 950 Bytes
/
cycle.em
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
var cycle;
function onPresenceConnected(presence) {
cycle = presence;
onCycleCreated();
cycle.orientation = new util.Quaternion();
cycle.modelOrientation = (new util.Quaternion(<0, 1, 0>, Math.PI / 2)).mul(
new util.Quaternion(<0, 0, 1>, -0.08));
}
system.onPresenceConnected(onPresenceConnected);
function stop() {
cycle.velocity = <0, 0, 0>;
}
stop << {'action':'stop':};
function start() {
cycle.velocity = cycle.orientation.mul(<0, 0, -5>);
}
start << {'action':'start':};
var left = new util.Quaternion(<0, 1, 0>, Math.PI / 2);
var right = new util.Quaternion(<0, -1, 0>, Math.PI / 2);
function turnLeft() {
cycle.orientation = cycle.orientation.mul(left);
cycle.velocity = left.mul(cycle.velocity);
}
turnLeft << {'action':'left':};
function turnRight() {
cycle.orientation = cycle.orientation.mul(right);
cycle.velocity = right.mul(cycle.velocity);
}
turnRight << {'action':'right':};