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

update and bug fix

New player Multi ok in loop mode
Confirmation asked before existing the page
Clear all for a session$Deleteing the only session creates a new one
Removed Undo slow mechanism
parent eb7211b5
......@@ -108,7 +108,6 @@ serverRow : function( server ) {
var json = [];
var serverRows = $("#serverTableBody tr");
////console.log(serverRows);
for(var i = 0; i < global.interface.servers.length; i++) {
var _server = global.interface.servers[i],
server = {};
......
......@@ -97,11 +97,12 @@
</div>
<div id="TopMenu" >
<div class="left">
<a href="#" onClick="javascript:Traj.Manager.selectPreviousCurve();" data-role="button" data-iconpos="notext" data-icon="arrow-l" data-inline="true">Previous</a>
<div data-role = "controlgroup" class="left" data-mini="true" data-type="horizontal">
<a href="#" onClick="javascript:Traj.Manager.selectPreviousCurve();" data-role="button" data-iconpos="notext" data-inline="true" data-icon="arrow-l">Previous</a>
<a id="lbl_current_curve" data-role="button" data-inline="true" style="background: rgba(255, 255, 255, 0.7);" data-inline="true">0</a>
<a href="#" onClick="javascript:Traj.Manager.selectNextCurve();" data-role="button" data-iconpos="notext" data-icon="arrow-r" data-inline="true">Next</a>
<a href="#" onClick="javascript:Traj.Manager.deleteCurrentCurve();" data-role="button" data-iconpos="notext" data-icon="delete" data-inline="true">Remove</a>
<a href="#" onClick="javascript:Traj.Manager.deleteAllCurves();" data-role="button" data-iconpos="notext" data-icon="refresh" data-inline="true">Refresh</a>
</div>
<div class="top-right">
......@@ -138,7 +139,7 @@
<div id='drawZone' data-role="none">
<div style="margin-top: 40px">Hold to draw a new curve</div>
<div style="margin-top: 40px" unselectable="on" class="unselectable" >Hold to draw a new curve</div>
</div>
<div id="sessionDiv">
......
......@@ -22,6 +22,14 @@ body {
width: 100%;
}
.unselectable{
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.vertical-spacer {
......
......@@ -112,12 +112,14 @@ Traj.OSC = {
Traj.OSC.sendMessage(Traj.OSC.record_address, msg);
},
orientation_rate : 3, //used to send orientaiton events one time over the rate
sendOrientation : function(msg){
//ussing Spat formatting source ID xyz x y z
Traj.OSC.sendSpatMessage(['source', curve.sourceNumber, 'yaw',msg[0]]);
Traj.OSC.sendSpatMessage(['source', curve.sourceNumber, 'pitch',msg[1]]);
//Traj.OSC.sendSpatMessage(['source', curve.sourceNumber, 'roll',msg[2]]);
// Traj.OSC.sendMessage(Traj.OSC.orientation_address, msg);
if(rate%3 === 0){
Traj.OSC.sendSpatMessage(['source',Traj.Manager.currentSource, 'yaw', msg[0]]);
Traj.OSC.sendSpatMessage(['source', Traj.Manager.currentSource, 'pitch', msg[1]]);
}
rate = (rate +1)%3;
},
sendNewTraj : function(msg){
......
......@@ -83,7 +83,7 @@ Traj.Player = {
Traj.OSC.sendPlay("end");
Traj.View.traj_repaint();
if (Traj.Player.loopMode) {
Traj.Player.playCurrentCurve();//playCurve(curveIdx);
Traj.Player.playCurrentCurve();
return;
}
Traj.Player.stopCurrentCurve();
......@@ -98,10 +98,6 @@ Traj.Player = {
playCurves : function (indexes){
this.stopCurrentCurve();
// for (var i = 0; i < indexes.length; i++) {
// Traj.Player.playCurve(indexes[i]);
// }
Traj.Player.isPlaying = true;
var curvesIdx = indexes;
......@@ -214,7 +210,7 @@ Traj.Player = {
Traj.View.traj_repaint();
if (Traj.Player.loopMode) {
Traj.Player.isPlaying = false;
Traj.Player.playAllCurve();
Traj.Player.playCurves(indexes);
return;
//Traj.Player.loopID = setTimeout(function() {Traj.Player.playCurrentCurve();},500);
}
......@@ -225,12 +221,9 @@ Traj.Player = {
Traj.Player.requestId = requestAnimationFrame(loopMulti);
}())
},
playAllCurve : function() { // LAG WHEN LOOP MODE. TODO : SAVE ALL THE LOADED DATA AND KEEP IT FOR THE NEXT CALL OF playAllCurve() (add a function that calls playAllCurve())
playAllCurve : function() {
this.stopCurrentCurve();
Traj.Player.isPlaying = true;
......
......@@ -92,6 +92,9 @@ Traj.Session = {
this.currentSession = 0;
}
this.updateCurrentSessionLbl();
}else{
this.dict = [];
this.newSession();
}
},
......@@ -141,35 +144,3 @@ Traj.Session = {
}
};
/*
*STATE FOR UNDO MECHANISM
Needs to be redon with a better way
*/
Traj.State = {
historySessions : [],
// Save the state of the app
newAction : function() {
var newState = JSON.stringify(Traj.Manager.trajectories);
this.historySessions.unshift(newState);
var length = this.historySessions.length;
if (length>10) {
this.historySessions = this.historySessions.splice(10,length-10);
}
},
// load previous state saved.
//Problem : if you change the session and then press undo, you get all the curves from the last session...
undo : function() {
if (this.historySessions.length>0) {
var lastState = JSON.parse(this.historySessions[0]),
trajectories = Traj.Session.makeTrajectoriesArrayFromDict(lastState);
Traj.Manager.setTrajectories(trajectories);
this.historySessions.splice(0,1);
}
},
};
......@@ -25,8 +25,6 @@ Traj.Events = {
Traj.Events.hideLongTouchMenu();
Traj.Events.hideContextMenu();
Traj.State.newAction();
if (Traj.View.touchState === 'wait' && evt.changedTouches.length < 2) {
//console.log(evt.changedTouches.length)
lastFactor = 1; // IN GLOBAL FOR NOW (used for 3 fingers event, stretch)
......@@ -303,7 +301,7 @@ Traj.Events = {
},
processOrientationEvents : function(event) {
console.log(event);
// console.log(event);
var alpha = event.alpha;
// gamma: left to right
var gamma = event.gamma;
......@@ -316,7 +314,6 @@ Traj.Events = {
},
addOrientationEvents : function(){
console.log(window.DeviceOrientationEvent);
if (window.DeviceOrientationEvent) {
window.addEventListener("deviceorientation", Traj.Events.processOrientationEvents);
}
......
......@@ -18,6 +18,13 @@ var Traj = {
}
window.addEventListener("beforeunload", function (e) {
var confirmationMessage = '';
(e || window.event).returnValue = confirmationMessage; //Gecko + IE
return confirmationMessage; //Gecko + Webkit, Safari, Chrome etc.
});
//Initializations
Traj.View.initCanvas(); //Drawing
Traj.Session.initStorage(); //storage
......
......@@ -71,7 +71,6 @@ Traj.Manager = {
this.createMultiPlayIndexes();
this.selectCurve(0);
Traj.View.repaintAll();
},
processCreateNewCurve : function(x, y, z, t) {
......@@ -111,7 +110,6 @@ Traj.Manager = {
processEndCurve : function(x, y, z, t) {
Traj.State.newAction();
if (Traj.Manager.currentCurve !== null && Traj.Manager.currentCurve.X.length > 6) {
Traj.Manager.trajectories.push(Traj.Manager.currentCurve.clone());
......@@ -173,7 +171,6 @@ Traj.Manager = {
},
processModifyCurve : function() {
Traj.State.newAction();
var newCurve = Traj.Manager.currentCurve,
curve = Traj.Manager.trajectories[Traj.Manager.modifiedCurve].clone(),
rangeTime = Traj.Events.getSliderValue(),
......@@ -202,7 +199,6 @@ Traj.Manager = {
// paste dans une courbe la clipboardCurve en translatant le reste de la courbe.
pasteInCurve : function(curve,beginIdx,endIdx) {
Traj.State.newAction();
var clipboardCurve = this.clipboardCurve,
curve = curve.clone(),
rangeTime = [curve.t[beginIdx], curve.t[endIdx]],
......@@ -238,7 +234,6 @@ Traj.Manager = {
// paste dans une courbe la clipboardCurve en la déformant (spacialement et temporellement) pour qu'elle rentre entre les deux curseurs curve[beginIdx] et curve[endIdx]
pasteInCurveAndAdapt : function(curve,beginIdx,endIdx) {
Traj.State.newAction();
var clipboardCurve = this.clipboardCurve,
maxIdxClipboardCurve = clipboardCurve.X.length-1,
curve = curve.clone(),
......@@ -300,7 +295,6 @@ Traj.Manager = {
},
deleteCurve : function(index) {
Traj.State.newAction();
Traj.Manager.trajectories.splice(index, 1);
Traj.Manager.selectCurve((Traj.Manager.currentCurveIndex - 1 + Traj.Manager.trajectories.length) % Traj.Manager.trajectories.length);
Traj.View.traj_repaint();
......@@ -430,6 +424,11 @@ Traj.Manager = {
Traj.Events.hideLongTouchMenu();
},
deleteAllCurves : function() {
Traj.Manager.setTrajectories([]);
Traj.Events.hideLongTouchMenu();
},
mirror : function (type){
var curve = Traj.Manager.trajectories[Traj.Manager.currentCurveIndex];
if (curve != undefined) {
......
Markdown is supported
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