Commit 0aad1860 authored by Jérémie Garcia's avatar Jérémie Garcia
Browse files

cleaning update

Added comments + structure to the code
Ongoing
parent 06d4a2c1
......@@ -12,29 +12,32 @@
<link rel="stylesheet" href="libs/jquery.mobile-1.4.5/jquery.mobile-1.4.5.min.css">
<link rel="stylesheet" type="text/css" href="css/jquery.range.css">
<link rel="stylesheet" type="text/css" href="css/index.css" />
<!-- External Scripts -->
<script type="text/javascript" src='interface.js'></script>
<script type="text/javascript" src="libs/fastclick.min.js"></script>
<script type="text/javascript" src="libs/jquery-2.0.3.min.js"></script>
<script type="text/javascript" src="libs/jquery.mobile-1.4.5/jquery.mobile-1.4.5.min.js"></script>
<script type="text/javascript" src='libs/jquery.range.js'></script>
<script type="text/javascript" src='libs/simplify.js'></script>
<script type="text/javascript" src="js/index.js"></script>
<script type="text/javascript" src="js/TimedCurve.js"></script>
<script type="text/javascript" src="js/Session.js"></script>
<script type="text/javascript" src="js/OSC-spat.js"></script>
<script type="text/javascript" src="js/TrajManager.js"></script>
<script type="text/javascript" src="js/Utils.js"></script>
<script type="text/javascript" src="js/View.js"></script>
<script type="text/javascript" src="js/EventManager.js"></script>
<script type="text/javascript" src="js/Player.js"></script>
<script type="text/javascript" src="js/HTMLFunction.js"></script>
<script type="text/javascript" src="libs/hammer.js"></script>
<!-- Internal Scripts -->
<script type="text/javascript" src="js/index.js"></script>
<script type="text/javascript" src="js/osc.js"></script>
<script type="text/javascript" src="js/timedCurve.js"></script>
<script type="text/javascript" src="js/player.js"></script>
<script type="text/javascript" src="js/view.js"></script>
<script type="text/javascript" src="js/utils.js"></script>
<script type="text/javascript" src="js/session.js"></script>
<script type="text/javascript" src="js/manager.js"></script>
<script type="text/javascript" src="js/events.js"></script>
<title>Trajectoires</title>
</head>
<body onresize="javascript:Traj.View.traj_initCanvas()">
<body onresize="javascript:Traj.View.initCanvas()">
<!-- Start of first page -->
<div id="main-page" data-role="page" data-theme="a">
......@@ -50,12 +53,12 @@
</div>
<label>Speakers Pos: </label>
<input type="number" id="speaker_dist" name="distHP" value="1" onchange="javascript:setHpDistance()" data-inline="true" />
<input type="number" id="speaker_dist" name="distHP" value="1" onchange="javascript:Traj.View.updateHpDistance()" data-inline="true" />
<form>
<label for="flip-curvesinback">Draw Curves in Background:</label>
<select name="flip-curvesinback" id="flip-curvesinback" data-role="slider" data-theme="b" onchange="javascript:setDrawCurvesInBackground()">
<select name="flip-curvesinback" id="flip-curvesinback" data-role="slider" data-theme="b" onchange="javascript:Traj.View.updateDrawCurvesInBackground()">
<option value="off">No</option>
<option value="on" selected="selected">Yes</option>
</select>
......@@ -63,14 +66,14 @@
<form>
<label for="flip-loop">Loop Mode:</label>
<select name="flip-loop" id="flip-loop" data-role="slider" data-theme="b" onchange="javascript:setLoopMode()">
<select name="flip-loop" id="flip-loop" data-role="slider" data-theme="b" onchange="javascript:Traj.Player.updateLoopMode()">
<option value="off" selected="selected">Off</option>
<option value="on">On</option>
</select>
</form>
<form>
<label for="flip-orientation">Stream Orientation:</label>
<select name="flip-orientation" id="flip-orientation" data-role="slider" data-theme="b" onchange="javascript:setOrientationMode()">
<select name="flip-orientation" id="flip-orientation" data-role="slider" data-theme="b" onchange="javascript:Traj.Events.updateOrientationMode()">
<option value="off" selected="selected">Off</option>
<option value="on">On</option>
</select>
......@@ -78,7 +81,7 @@
<form>
<label for="flip-timeSlider">Show Time Slider:</label>
<select name="flip-timeSlider" id="flip-timeSlider" data-role="slider" data-theme="b" onchange="javascript:setTimeSliderMode()">
<select name="flip-timeSlider" id="flip-timeSlider" data-role="slider" data-theme="b" onchange="javascript:Traj.Events.updateTimeSliderMode()">
<option value="off">Off</option>
<option value="on" selected="selected">On</option>
</select>
......@@ -86,7 +89,7 @@
<form>
<label for="flip-zSlider">Show Z Slider:</label>
<select name="flip-zSlider" id="flip-zSlider" data-role="slider" data-theme="b" onchange="javascript:setZSliderMode()">
<select name="flip-zSlider" id="flip-zSlider" data-role="slider" data-theme="b" onchange="javascript:Traj.View.updateZSliderMode()">
<option value="off" selected="selected">Off</option>
<option value="on">On</option>
</select>
......@@ -160,9 +163,9 @@
<div id="divCurveMenu" class="left">
<a href="#" onClick="javascript:selectPreviousCurve();" data-mini="true" data-role="button" data-iconpos="notext" data-icon="arrow-l" data-inline="true">Previous</a>
<a href="#" onClick="javascript:Traj.Manager.selectPreviousCurve();" data-mini="true" data-role="button" data-iconpos="notext" data-icon="arrow-l" data-inline="true">Previous</a>
<a id="lbl_current_curve" data-role="button" data-mini="true" data-inline="true" style="background: rgba(255, 255, 255, 0.7);" data-inline="true">0</a>
<a href="#" onClick="javascript:selectNextCurve();" data-mini="true" data-role="button" data-iconpos="notext" data-icon="arrow-r" data-inline="true">Next</a>
<a href="#" onClick="javascript:Traj.Manager.selectNextCurve();" data-mini="true" data-role="button" data-iconpos="notext" data-icon="arrow-r" data-inline="true">Next</a>
<div id="divCurveOptions" class="ui-bar ui-bar-a">
<div class="curveMenuButtonDiv">
<a id='action' class="curveMenuButton" data-mini="true" data-role="none">Actions</a>
......@@ -171,16 +174,16 @@
</div>
<div id="divCurveAction" class="ui-bar ui-bar-a">
<a href="#" onClick="javascript:deleteCurrentCurve();" data-mini="true" data-role="button" data-icon="delete">Remove</a>
<a href="#" onClick="javascript:modeSelectEdit();" data-mini="true" data-role="button" data-icon="edit">Select and redraw</a>
<a href="#" onClick="javascript:duplicateCurrentCurve();" data-mini="true" data-role="button">Duplicate</a>
<a href="#" onClick="javascript:copyCurrentCurve();" data-mini="true" data-role="button">Copy</a>
<a href="#" onClick="javascript:pasteInCurrentCurve();" data-mini="true" data-role="button">Paste</a>
<a href="#" onClick="javascript:Traj.manager.deleteCurrentCurve();" data-mini="true" data-role="button" data-icon="delete">Remove</a>
<a href="#" onClick="javascript:Traj.Manager.updateModeSelectEdit();" data-mini="true" data-role="button" data-icon="edit">Select and redraw</a>
<a href="#" onClick="javascript:Traj.manager.duplicateCurrentCurve();" data-mini="true" data-role="button">Duplicate</a>
<a href="#" onClick="javascript:Traj.manager.copyCurrentCurve();" data-mini="true" data-role="button">Copy</a>
<a href="#" onClick="javascript:Traj.manager.pasteInCurrentCurve();" data-mini="true" data-role="button">Paste</a>
<div class="ui-bar ui-bar-a">
<label>Simplify Curve</label>
<fieldset data-role="controlgroup" data-type="horizontal">
<a onclick="javascript:simplifyCurrentCurve(0.01)" data-inline="true" data-mini="true" data-role="button"> Soft </a>
<a onclick="javascript:simplifyCurrentCurve(0.1)" data-inline="true" data-mini="true" data-role="button"> Hard </a>
<a onclick="javascript:Traj.Manager.simplifyCurrentCurve(0.01)" data-inline="true" data-mini="true" data-role="button"> Soft </a>
<a onclick="javascript:Traj.Manager.simplifyCurrentCurve(0.1)" data-inline="true" data-mini="true" data-role="button"> Hard </a>
</fieldset>
</div>
</div>
......@@ -199,17 +202,17 @@
<div data-inline="true" style="float:left">
<fieldset data-role="controlgroup" data-type="vertical">
<a class="content" data-role="none">y </a>
<a onClick="javascript:changeScale('y',1.2);" class="miniButton" data-role="button" data-theme="a"> + </a>
<a onClick="javascript:changeScale('y',0.8);" class="miniButton" data-role="button" data-theme="a"> - </a>
<a onClick="javascript:Traj.Manager.changeScale('y',1.2);" class="miniButton" data-role="button" data-theme="a"> + </a>
<a onClick="javascript:Traj.Manager.changeScale('y',0.8);" class="miniButton" data-role="button" data-theme="a"> - </a>
<a onClick="javascript:mirror('y');" class="miniButtonText" data-role="button" data-theme="a"> Mirror </a>
</fieldset>
</div>
<div data-inline="true" style="float:left">
<fieldset data-role="controlgroup" data-type="vertical">
<a class="content" data-role="none">z </a>
<a onClick="javascript:changeScale('z',1.2);" class="miniButton" data-role="button" data-theme="a"> + </a>
<a onClick="javascript:changeScale('z',0.8);" class="miniButton" data-role="button" data-theme="a"> - </a>
<a onClick="javascript:mirror('z');" class="miniButtonText" data-role="button" data-theme="a"> Mirror </a>
<a onClick="javascript:Traj.Manager.changeScale('z',1.2);" class="miniButton" data-role="button" data-theme="a"> + </a>
<a onClick="javascript:Traj.Manager.changeScale('z',0.8);" class="miniButton" data-role="button" data-theme="a"> - </a>
<a onClick="javascript:Traj.Manager.mirror('z');" class="miniButtonText" data-role="button" data-theme="a"> Mirror </a>
</fieldset>
</div>
<div data-inline="true" style="float:left">
......@@ -223,13 +226,13 @@
<div id="timeStretchDiv" class="ui-bar ui-bar-a" style="float:left">
<label>Time stretch</label>
<input type="number" data-role='none' id="timeStretch" data-inline="true" value="1" onchange="javascript:changeTime()" style="width:80px;" /> ms
<a onClick="javascript:mirror('t');" data-inline="true" class="miniButtonText" data-role="button" data-theme="a"> Reverse </a>
<a onClick="javascript:Traj.Manager.mirror('t');" data-inline="true" class="miniButtonText" data-role="button" data-theme="a"> Reverse </a>
</div>
<div id="positionDiv" class="ui-bar ui-bar-a" style="float:left">
<label>First point position</label>
<input data-role='none' type="number" id="xOriPos" value="1" data-inline="true" onchange="javascript:translateCurve()" />x
<input data-role='none' type="number" id="yOriPos" value="1" data-inline="true" onchange="javascript:translateCurve()" />y
<input data-role='none' type="number" id="zOriPos" value="1" data-inline="true" onchange="javascript:translateCurve()" />z
<input data-role='none' type="number" id="xOriPos" value="1" data-inline="true" onchange="javascript:Traj.Manager.translateCurve()" />x
<input data-role='none' type="number" id="yOriPos" value="1" data-inline="true" onchange="javascript:Traj.Manager.translateCurve()" />y
<input data-role='none' type="number" id="zOriPos" value="1" data-inline="true" onchange="javascript:Traj.Manager.translateCurve()" />z
</div>
</div>
......@@ -237,10 +240,10 @@
<div id="divCurveMulti" class="ui-bar ui-bar-a">
<div class="ui-bar ui-bar-a">
<label>Source controled</label>
<input data-role='none' type="number" id="sourceControled" value="1" onchange="javascript:changeSourceControled()" />
<input data-role='none' type="number" id="sourceControled" value="1" onchange="javascript:Traj.Manager.changeSourceControled()" />
</div>
<label>
<input type="checkbox" id="checkPlay" onchange="javascript:activeMultiPlay()"> Active
<input type="checkbox" id="checkPlay" onchange="javascript:Traj.Manager.activeMultiPlay()"> Active
</label>
<label>
<a data-role="button" onclick="javascript:removeMultiPlay()">Remove all </a>
......@@ -265,8 +268,8 @@
<div class="canvas-left-overlay" id="playDiv">
<div data-role="controlgroup" data-type="horizontal" >
<a onClick="javascript:setCanvasZoom(0.8);" data-role="button" data-theme="a" data-inline="true" style="background: rgba(250, 250, 250, 0.5);"> - </a>
<a onClick="javascript:setCanvasZoom(1.2);" data-role="button" data-theme="a" data-inline="true" style="background: rgba(250, 250, 250, 0.5);"> + </a>
<a onClick="javascript:Traj.View.setCanvasZoom(0.8);" data-role="button" data-theme="a" data-inline="true" style="background: rgba(250, 250, 250, 0.5);"> - </a>
<a onClick="javascript:Traj.View.setCanvasZoom(1.2);" data-role="button" data-theme="a" data-inline="true" style="background: rgba(250, 250, 250, 0.5);"> + </a>
</div>
<div data-role="controlgroup" data-type="vertical">
<a id="playButton" data-role="button" data-theme="a" style="background: rgba(250, 250, 250, 0.5); padding: 5px; width:50px; height:30px; line-height: 30px;">Play</a>
......@@ -287,11 +290,11 @@
<div id="longTouchMenu" style="position:absolute;top:100px;left 300px">
<a href="#" onClick="javascript:deleteCurrentCurve();" data-mini="true" data-role="button" data-icon="delete">Remove</a>
<a href="#" onClick="javascript:modeSelectEdit();" data-mini="true" data-role="button" data-icon="edit">Select and redraw</a>
<a href="#" onClick="javascript:duplicateCurrentCurve();" data-mini="true" data-role="button">Duplicate</a>
<a href="#" onClick="javascript:copyCurrentCurve();" data-mini="true" data-role="button">Copy</a>
<a href="#" onClick="javascript:pasteInCurrentCurve();" data-mini="true" data-role="button">Paste</a>
<a href="#" onClick="javascript:Traj.Manager.deleteCurrentCurve();" data-mini="true" data-role="button" data-icon="delete">Remove</a>
<a href="#" onClick="javascript:Traj.Manager.modeSelectEdit();" data-mini="true" data-role="button" data-icon="edit">Select and redraw</a>
<a href="#" onClick="javascript:Traj.Manager.duplicateCurrentCurve();" data-mini="true" data-role="button">Duplicate</a>
<a href="#" onClick="javascript:Traj.Manager.copyCurrentCurve();" data-mini="true" data-role="button">Copy</a>
<a href="#" onClick="javascript:Traj.Manager.pasteInCurrentCurve();" data-mini="true" data-role="button">Paste</a>
</div>
......@@ -307,7 +310,7 @@
<div id=footer data-role="footer">
<div class="right" id="options-div">
<a href="#" onClick="javascript:exportCurrentCurve();" data-mini="true" data-role="button">Export</a>
<a href="#" onClick="javascript:Traj.Session.exportCurrentCurve();" data-mini="true" data-role="button">Export</a>
<!--<a href="#" onClick="javascript:exportCurrentCurveAsAntescofoNIM();" data-mini="true" data-role="button">AntescofoNIM</a> -->
</div>
......
// this function are called by html elements.
// TODO : create events on each html elements
function sendTrigger(message) {}
//Functions called from Html interface
function deleteCurrentCurve() {
Traj.TrajManager.deleteCurve(Traj.TrajManager.currentCurveIndex);
Traj.EventManager.hideLongTouchMenu();
}
function selectNextCurve() {
Traj.TrajManager.selectCurve((Traj.TrajManager.currentCurveIndex + 1) % Traj.TrajManager.trajectories.length);
}
function selectPreviousCurve() {
Traj.TrajManager.selectCurve((Traj.TrajManager.currentCurveIndex - 1 + Traj.TrajManager.trajectories.length) % Traj.TrajManager.trajectories.length);
}
function sendTriggerPlay() {
Traj.OSC.sendPlay("Play");
}
function sendTriggerRecord() {
Traj.OSC.sendRecord("Record");
}
//Getters and Setters
function setCanvasZoom(factor) {
//if (logger) writtraj_canvasog("traj_canvas Zoom " + factor);
Traj.View.scaleFactor = Traj.View.scaleFactor / factor;
Traj.View.pixToValue = Traj.View.scaleFactor / Traj.View.minWH;
Traj.View.repaintAll();
}
function setDrawCurvesInBackground() {
Traj.View.backgroundCurve = document.getElementById("flip-curvesinback").value == 'on';
Traj.View.traj_repaint();
Traj.View.dyn_repaint();
}
function setLoopMode() {
Traj.Player.loopMode = document.getElementById("flip-loop").value == 'on';
}
function setOrientationMode() {
Traj.EventManager.stream_orientation = document.getElementById("flip-orientation").value == 'on';
}
function setHpDistance() {
Traj.View.SPEAKER_DIST = document.getElementById("speaker_dist").value;
Traj.View.bg_repaint();
}
function exportCurrentCurve(){
exportCurrentCurveAsAntescofoNIM();
if(Traj.TrajManager.trajectories[Traj.TrajManager.currentCurveIndex]){
if(Traj.TrajManager.trajectories[Traj.TrajManager.currentCurveIndex].X.length <1000){
Traj.OSC.sendCurveSingleMessageOSC(Traj.TrajManager.trajectories[Traj.TrajManager.currentCurveIndex], Traj.TrajManager.currentCurveIndex);
}else{
Traj.OSC.sendCurveOSC(Traj.TrajManager.trajectories[Traj.TrajManager.currentCurveIndex], Traj.TrajManager.currentCurveIndex);
}
}
Traj.Session.saveInSelectedSession();
}
function exportCurrentCurveAsAntescofoNIM(){
var manager = Traj.TrajManager;
if(manager.trajectories[manager.currentCurveIndex]){
Traj.OSC.saveAntescofo(manager.trajectories[manager.currentCurveIndex], manager.currentCurveIndex, Traj.Session.currentSession);
}
}
function setTimeSliderMode() {
if (document.getElementById("flip-timeSlider").value == 'on') {
$("#slider-div").show();
} else {
$("#slider-div").hide();
}
}
function simplifyCurrentCurve(tolerance) {
var currentCurve = Traj.TrajManager.trajectories[Traj.TrajManager.currentCurveIndex];
if (currentCurve != undefined) {
var newCurve = Traj.Utils.simplifyCurve(currentCurve,tolerance);
Traj.TrajManager.trajectories.push(newCurve);
Traj.TrajManager.selectCurve(Traj.TrajManager.trajectories.length-1);
}
}
function changeSourceControled() {
var curveIdx = Traj.TrajManager.currentCurveIndex;
var curve = Traj.TrajManager.trajectories[curveIdx];
if (curve != undefined) {
var source = Number(document.getElementById("sourceControled").value);
curve.changeSource(source);
Traj.View.current_repaint();
Traj.View.traj_repaint();
Traj.View.dyn_repaint();
}
}
function activeMultiPlay() {
var curveIdx = Traj.TrajManager.currentCurveIndex;
if (Traj.TrajManager.trajectories[curveIdx]) {
Traj.TrajManager.trajectories[curveIdx].multiPlay = document.getElementById("checkPlay").checked;
Traj.TrajManager.multiPlayChanged(0);
}
}
function removeMultiPlay() {
var trajectories = Traj.TrajManager.trajectories;
for (var k=0;k<trajectories.length;k++) {
trajectories[k].multiPlay = false;
}
Traj.TrajManager.playedCurves = [];
Traj.EventManager.refreshCurveInfo();
Traj.TrajManager.multiPlayChanged();
}
function modeSelectEdit() {
var curveIdx = Traj.TrajManager.currentCurveIndex;
if (Traj.TrajManager.trajectories[curveIdx]) {
Traj.EventManager.initSlider(true)
$("#divCurveOptions").hide();
$("#divCurveOptions").removeClass( "show" ).addClass( "hide" );
$("#playDiv").show();
Traj.View.bg_repaint(true);
}
Traj.EventManager.hideLongTouchMenu();
}
function setZSliderMode() {
if (document.getElementById("flip-zSlider").value == 'on') {
$("#ZSliderDiv").show();
} else {
$("#ZSliderDiv").hide();
}
}
function changeScale(axis,scale) {
var curve = Traj.TrajManager.trajectories[Traj.TrajManager.currentCurveIndex];
if (curve != undefined) {
if (axis == 'x') {
curve.changeXScale(scale);
} else if (axis == 'y') {
curve.changeYScale(scale);
} else if (axis == 'z') {
curve.changeZScale(scale);
}
Traj.TrajManager.selectCurve(Traj.TrajManager.currentCurveIndex);
}
}
function changeTime() {
var curve = Traj.TrajManager.trajectories[Traj.TrajManager.currentCurveIndex];
if (curve != undefined) {
var inputTime = document.getElementById('timeStretch');
curve.changeTotalTime(Number(inputTime.value));
Traj.TrajManager.selectCurve(Traj.TrajManager.currentCurveIndex);
Traj.EventManager.initSlider(false);
}
}
function translateCurve() {
var curve = Traj.TrajManager.trajectories[Traj.TrajManager.currentCurveIndex];
if (curve != undefined) {
var inputX = document.getElementById('xOriPos').value;
var inputY = document.getElementById('yOriPos').value;
var inputZ = document.getElementById('zOriPos').value;
curve.translate(Number(inputX),Number(inputY),Number(inputZ));
Traj.TrajManager.selectCurve(Traj.TrajManager.currentCurveIndex);
}
}
function copyCurrentCurve() {
var curve = Traj.TrajManager.trajectories[Traj.TrajManager.currentCurveIndex];
if (curve != undefined) {
Traj.TrajManager.copyCurrentCurve(0,curve.X.length-1);
Traj.EventManager.hideLongTouchMenu();
}
}
function pasteInCurrentCurve() {
var curve = Traj.TrajManager.trajectories[Traj.TrajManager.currentCurveIndex];
if (curve != undefined) {
var beginTime = Traj.EventManager.getSliderValue();
var beginIdx = Traj.Utils.findPointIdx(beginTime,curve);
Traj.TrajManager.pasteInCurve(curve,beginIdx,beginIdx);
Traj.EventManager.hideLongTouchMenu();
//Traj.TrajManager.selectCurve(Traj.TrajManager.trajectories.length-1);
}
}
function duplicateCurrentCurve() {
var curve = Traj.TrajManager.trajectories[Traj.TrajManager.currentCurveIndex];
if (curve != undefined) {
var newCurve = curve.clone();
var XYZ = [newCurve.X[0]+0.1,newCurve.Y[0]-0.1,newCurve.Z[0]];
newCurve.translate(XYZ[0],XYZ[1],XYZ[2]);
Traj.TrajManager.trajectories.push(newCurve);
Traj.TrajManager.selectCurve(Traj.TrajManager.trajectories.length-1);
Traj.EventManager.hideLongTouchMenu();
}
}
function mirror(type) {
var curve = Traj.TrajManager.trajectories[Traj.TrajManager.currentCurveIndex];
if (curve != undefined) {
if (type == 'x') {
curve.xMiror();
} else if (type == 'y') {
curve.yMiror();
} else if (type == 'z') {
curve.zMiror();
} else if (type == 't') {
curve.tMiror();
}
Traj.TrajManager.selectCurve(Traj.TrajManager.currentCurveIndex);
}
}
////////////////////////////////////////////////////////////
///////////////////////// OSC /////////////////////////////
Traj.OSC = {
//OSC Protocol
spat_address : '/spat',
traj_address : '/traj',
pos_address : '/traj/posxyz',
trajpoint_address : '/traj/trajpoint',
traj_new_address : '/traj/newtraj',
traj_suffix : '/traj',
play_address : '/traj/play',
record_address : '/traj/record',
orientation_address : '/traj/orientation',
draw_address : '/traj/draw',
// SENDING MESSAGES
isInteger : function(value) {
if ((undefined === value) || (null === value)) {
return false;
}
return value % 1 == 0;
},
getTypeForElement : function(elem){
var type = typeof elem;
switch (type) {
case 'string':
return 's';
break;
case 'boolean':
return 'b';
break;
case 'number':
return Traj.OSC.isInteger(elem) ? 'i' : 'f';;
break;
default:
return 'f';
}
},
getTypesForArgs : function(args){
var tt = '';
if(typeof args === 'string')
return 's';
for(var i = 0; i < args.length; i++) {
tt += Traj.OSC.getTypeForElement(args[i]);
}
return tt;
},
sendMessage : function(address, msg) {
var tt = Traj.OSC.getTypesForArgs(msg);
Interface.OSC.send(address, tt, msg );
},
//RECEIVING MESSAGE
processMessages : function(msg) {
var address = msg.address;
var split = address.split('/');
//test for the correct namespace
console.log(split[1]);
if(split[1].indexOf("spat") != -1 ){
console.log(split[2]);
if(split[2].indexOf("source") != -1){
var nb = (split[2].replace("source",""));
var sourcenb = Number(nb);
var curve = new TimedCurve();
for (var k =0; k<msg.parameters.length/4;k++) {
curve.addTimedPoint(msg.parameters[4*k],msg.parameters[4*k+1],msg.parameters[4*k+2],msg.parameters[4*k+3]);
}
var manager = Traj.TrajManager;
manager.trajectories.push(curve);
curve.changeSource(sourcenb); // care : to change the source of a curve, the curve need to be already pushed in trajectories
Traj.View.traj_repaint();
//manager.selectCurve(manager.trajectories.length-1);
}
}
},
//FACILITIES
sendPosxyzMsg : function(msg) {
Traj.OSC.sendMessage(Traj.OSC.pos_address, msg);
},
sendSpatMessage: function(msg){
Traj.OSC.sendMessage(Traj.OSC.spat_address,msg);
},
sendTrajPoint : function(msg) {
Traj.OSC.sendMessage(Traj.OSC.trajpoint_address, msg);
},
//OLD VERSION
// sendTraj : function(msg) {
// Traj.OSC.sendMessage(Traj.OSC.traj_address, msg);
//},
sendTraj : function(number, msg) {
Traj.OSC.sendMessage(Traj.OSC.traj_address + "/source" + number + Traj.OSC.traj_suffix, msg);
},
sendPlay : function(msg) {
Traj.OSC.sendMessage(Traj.OSC.play_address, msg);
},
sendRecord : function(msg) {
Traj.OSC.sendMessage(Traj.OSC.record_address, msg);
},
sendOrientation : function(msg){
Traj.OSC.sendMessage(Traj.OSC.orientation_address, msg);
},
sendNewTraj : function(msg){
Traj.OSC.sendMessage(Traj.OSC.traj_new_address, msg);
},
sendDraw : function(msg) {
Traj.OSC.sendMessage(Traj.OSC.draw_address, msg);
},
streamCurveLastPoint : function(curve) {
var last_index = curve.X.length - 1;
this.streamCurvePoint(curve, last_index);
},
streamNewCurve : function(index){
Traj.OSC.sendNewTraj(index);
},
streamCurvePoint : function(curve, index) {
//ussing Spat formatting source ID xyz x y z
Traj.OSC.sendSpatMessage( ['source', curve.sourceNumber, 'xyz',curve.X[index], curve.Y[index], curve.Z[index]]);