Added lock option in session

This commit is contained in:
Thomas FORGIONE 2015-07-22 10:10:11 +02:00
parent 748656504b
commit 9b319f3c33
5 changed files with 52 additions and 46 deletions

View File

@ -5,7 +5,7 @@ block title
block mainjs block mainjs
script initMainScene = #{scene}; script initMainScene = #{scene};
script locked = #{session.locked};
script(src="/static/js/prototypeinteractive.min.js") script(src="/static/js/prototypeinteractive.min.js")
block description block description

View File

@ -1,6 +1,6 @@
var ButtonManager = function(camera, cameras, previewer) { var ButtonManager = function(camera, recommendations, previewer) {
this.camera = camera; this.camera = camera;
this.cameras = cameras; this.recommendations = recommendations;
this.previewer = previewer; this.previewer = previewer;
this.showArrows = true; this.showArrows = true;
@ -17,12 +17,17 @@ var ButtonManager = function(camera, cameras, previewer) {
// this.recommendationElement = document.getElementById('recommendation'); // this.recommendationElement = document.getElementById('recommendation');
// Default option
this.pointerLockElement.checked = window.locked;;
this.camera.shouldLock = window.locked;
this.camera.onPointerLockChange();
(function(self) { (function(self) {
self.undoElement.onclick = function() {self.camera.undo(); self.updateElements();}; self.undoElement.onclick = function() {self.camera.undo(); self.updateElements();};
self.redoElement.onclick = function() {self.camera.redo(); self.updateElements();}; self.redoElement.onclick = function() {self.camera.redo(); self.updateElements();};
// self.fullElement.onclick = function() { // self.fullElement.onclick = function() {
// self.cameras.map(function(camera) { // self.recommendations.map(function(camera) {
// if (!(camera instanceof PointerCamera)) { // if (!(camera instanceof PointerCamera)) {
// camera.fullArrow = self.fullElement.checked; // camera.fullArrow = self.fullElement.checked;
// } // }
@ -34,10 +39,17 @@ var ButtonManager = function(camera, cameras, previewer) {
self.camera.shouldLock = self.pointerLockElement.checked; self.camera.shouldLock = self.pointerLockElement.checked;
self.camera.onPointerLockChange(); self.camera.onPointerLockChange();
// Log // Log (this will change option in the session)
var bakup = L3D.DB.Private.enabled;
if (!bakup)
L3D.DB.enable();
var event = new L3D.DB.Event.SwitchedLockOption(); var event = new L3D.DB.Event.SwitchedLockOption();
event.locked = self.pointerLockElement.checked; event.locked = self.pointerLockElement.checked;
event.send(); event.send();
if (!bakup)
L3D.DB.disable();
}; };
self.showarrowsElement.onchange = function() {self.showArrows = self.showarrowsElement.checked;}; self.showarrowsElement.onchange = function() {self.showArrows = self.showarrowsElement.checked;};

View File

@ -50,7 +50,7 @@ function main() {
L3D.DB.disable(); L3D.DB.disable();
Coin.update(); Coin.update();
startCanvas.render(L3D.StartCanvas.Black); // startCanvas.render(L3D.StartCanvas.Black);
// Bind previewer to renderer (for fixed option) // Bind previewer to renderer (for fixed option)
function bind() { function bind() {

View File

@ -136,45 +136,36 @@ L3D.createPeachRecommendations = function(width, height) {
); );
}; };
recos.push(createRecommendation( recos.push(
new THREE.Vector3(-3.349895207953063, 5.148106346852601, 0.3365943929701533), createRecommendation(
new THREE.Vector3(13.114421714865292, -7.783476327687569, -33.74713248359852) new THREE.Vector3(-4.318087280217455,2.8007613084859253,1.5193437897009336),
)); new THREE.Vector3(19.04561491034525,-11.893857635144567,-27.432436709124897)
),
recos.push(createRecommendation( createRecommendation(
new THREE.Vector3(4.659399030971226, 1.018674883050052597, -2.578139604982815), new THREE.Vector3(-6.257935852456958,2.093463399444844,-7.017904350052701),
new THREE.Vector3(-16.08800293200113, -28.8795632312717, -19.165379404919797) new THREE.Vector3(25.88235261144178,-14.928107421416371,-23.669270187358173)
)); ),
createRecommendation(
recos.push(createRecommendation( new THREE.Vector3(9.807915641060413,1.599662719763407,1.3278972044453563),
new THREE.Vector3(2.625389073616235, 1.2252620948239699, -4.818718135555419), new THREE.Vector3(-16.404678696813406,-19.467671402046243,-20.330065097629618)
new THREE.Vector3(-19.756833131355208, -16.20027570329664, -33.02132017177813) ),
)); createRecommendation(
new THREE.Vector3(8.593027849546461,2.341563400341173,-10.381814971692629),
// recos.push(createRecommendation( new THREE.Vector3(-23.363783342561,-18.42997444113019,1.755130036517576)
// new THREE.Vector3(1.3304975149911331, 0.4836093721106701, -8.60618907952783), ),
// new THREE.Vector3(-1.7713635815431914, 6.271997833695163, -48.06341930106774) createRecommendation(
// )); new THREE.Vector3(6.422879729593868,3.06821771913114,-4.664407524854438),
new THREE.Vector3(-15.171947266786782,-24.05662912371069,-24.6119921091785)
// recos.push(createRecommendation( ),
// new THREE.Vector3(1.2976081760482443, 1.1520399813234647, -10.258148122402845), createRecommendation(
// new THREE.Vector3(-26.00651734173549, -9.19681009597505, -37.596510029925945) new THREE.Vector3(10.155340138717236,6.631665534350463,-5.574670324070963),
// )); new THREE.Vector3(-20.721131232754608,-9.966488352174423,-24.839789145555535)
),
recos.push(createRecommendation( createRecommendation(
new THREE.Vector3(0.15727187830660858, 2.7251137440572855, -5.84333603646124), new THREE.Vector3(-6.548087435820877,6.193523907010158,-3.627483164733988),
new THREE.Vector3(19.33738702531091, -13.614383891308975, -36.91010284556961) new THREE.Vector3(16.752484674681824,-11.466024392567634,-30.926268727065203)
)); )
);
recos.push(createRecommendation(
new THREE.Vector3(-3.912436457101955,1.4571795397310319,-7.361700012948173),
new THREE.Vector3(26.60153755572943,-12.280244389383581,-29.274722938506393)
));
recos.push(createRecommendation(
new THREE.Vector3(4.734058048040269,0.9171350442568073,0.12604632828978296),
new THREE.Vector3(25.163187055614348,-27.08137327531798,-19.842284094421995)
));
recos.forEach(function(reco) {reco.setSize(0.2);}); recos.forEach(function(reco) {reco.setSize(0.2);});

View File

@ -4,13 +4,16 @@ var Log = require('../../lib/NodeLog.js');
module.exports.index = function(req, res) { module.exports.index = function(req, res) {
req.session.locked = req.body.locked;
req.session.save();
pg.connect(secret.url, function(err, client, release) { pg.connect(secret.url, function(err, client, release) {
client.query( client.query(
"INSERT INTO switchedlockoption(exp_id, locked, time) VALUES($1,$2,to_timestamp($3));", "INSERT INTO switchedlockoption(exp_id, locked, time) VALUES($1,$2,to_timestamp($3));",
[req.session.exp_id, req.body.locked, req.body.time], [req.session.exp_id, req.body.locked, req.body.time],
function(err, result) { function(err, result) {
if (err !== null) if (err !== null)
Log.dberror(err + ' in fps'); Log.dberror(err + ' in swithched lock option');
release(); release();
} }
); );