Commit bf861121 authored by Jens-Christian Fischer's avatar Jens-Christian Fischer
Browse files

implement P5, scale acceleration/orientation values

parent 18b71adf
......@@ -6,10 +6,11 @@
"watch": "brunch watch --stdin"
},
"dependencies": {
"interface": "git://github.com/charlieroberts/interface.js.git",
"jquery": ">= 2.1",
"p5": "^0.5.8",
"phoenix": "file:deps/phoenix",
"phoenix_html": "file:deps/phoenix_html",
"jquery" : ">= 2.1",
"interface" : "git://github.com/charlieroberts/interface.js.git",
"underscore": "~ 1.8.3"
},
"devDependencies": {
......
......@@ -48,32 +48,34 @@ let AccelerationPanel = {
let nrSliders = this.slider_titles.length;
this.slider_titles.forEach( (s, idx) => {
this.sliders[s] = new Interface.Slider({
bounds: [(1/nrSliders) * idx, .1, 1 / nrSliders, .5],
label: s
});
a.add(this.sliders[s]);
this.sliders[s] = new Interface.Slider({
bounds: [(1/nrSliders) * idx, .1, 1 / nrSliders, .5],
label: s,
min: -3.0,
max: 3.0
});
a.add(this.sliders[s]);
});
a.background = 'black';
console.log("initialized acceleration");
a.background = 'black';
console.log("initialized acceleration");
},
send_value(values) {
let scaled = values.map(function(i) {
return parseInt(i * 127);
});
if (!_.isEqual(scaled, this.old_values)) {
// console.log(scaled);
let payload = {x: scaled[0],
y: scaled[1],
z: scaled[2]
};
this.acclerationChannel.push("acceleration", payload)
.receive("error", e => console.log(e));
this.old_values = scaled;
}
let scaled = values.map(function(i) {
return i;
});
if (!_.isEqual(scaled, this.old_values)) {
console.log(scaled);
let payload = {x: scaled[0],
y: scaled[1],
z: scaled[2]
};
this.accelerationChannel.push("acceleration", payload)
.receive("error", e => console.log(e));
this.old_values = scaled;
}
......
......@@ -22,10 +22,15 @@ import OrientationPanel from "./orientation";
import AccelerationPanel from "./acceleration";
import BpmPanel from "./bpm.js";
import PresenceSketch from "./presencesketch";
SliderPanel.init(socket, "sliderPanel", ["s1", "s2", "s3"]);
OrientationPanel.init(socket, "orientationPanel");
AccelerationPanel.init(socket, "accelerationPanel");
BpmPanel.init(socket, "bpmPanel");
PresenceSketch.init("sketch");
// Presence
......
......@@ -50,8 +50,9 @@ let OrientationPanel = {
this.slider_titles.forEach( (s, idx) => {
this.sliders[s] = new Interface.Slider({
bounds: [(1/nrSliders) * idx, .1, 1 / nrSliders, .5],
label: s
bounds: [(1/nrSliders) * idx, .1, 1 / nrSliders, .5],
label: s,
});
console.log(s);
......@@ -64,7 +65,7 @@ let OrientationPanel = {
send_value(values) {
let scaled = values.map(function(i) {
return i; // parseInt(i * 127);
return 2*(i - 0.5) * Math.PI; // parseInt(i * 127);
});
if (!_.isEqual(scaled, this.old_values)) {
// console.log(scaled);
......
import p5 from "p5";
let PresenceSketch = {
width: 720,
height: 400,
boids: [],
p5: {},
sketch(s) {
s.setup = function() {
s.createCanvas(this.width, this.height);
s.background(10)
};
s.draw = function() {};
},
init(domId) {
if (!document.getElementById(domId)) {
return;
}
new p5(this.sketch, domId);
}
}
export default PresenceSketch;
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment