This commit is contained in:
Thomas FORGIONE 2015-07-09 15:38:56 +02:00
parent 2e97b14160
commit cd10d76d89
9 changed files with 119 additions and 12 deletions

View File

@ -32,6 +32,11 @@ var ButtonManager = function(camera, cameras, previewer) {
self.pointerLockElement.onchange = function() { self.pointerLockElement.onchange = function() {
self.camera.shouldLock = self.pointerLockElement.checked; self.camera.shouldLock = self.pointerLockElement.checked;
self.camera.onPointerLockChange(); self.camera.onPointerLockChange();
// Log
var event = new L3D.BD.Event.SwitchedLockOption();
event.locked = self.pointerLockElement.checked;
event.send();
}; };
self.showarrowsElement.onchange = function() {self.showArrows = self.showarrowsElement.checked;}; self.showarrowsElement.onchange = function() {self.showArrows = self.showarrowsElement.checked;};

View File

@ -223,6 +223,7 @@ L3D.PointerCamera.prototype.isLocked = function() {
* Update the camera when the pointer lock changes state * Update the camera when the pointer lock changes state
*/ */
L3D.PointerCamera.prototype.onPointerLockChange = function() { L3D.PointerCamera.prototype.onPointerLockChange = function() {
var event = new L3D.BD.Event.PointerLocked();
if (this.isLocked()) { if (this.isLocked()) {
@ -236,6 +237,14 @@ L3D.PointerCamera.prototype.onPointerLockChange = function() {
// Remove start canvas // Remove start canvas
this.startCanvas.clear(); this.startCanvas.clear();
// Send event
event.locked = true;
if (this.wasLocked !== event.locked)
event.send();
this.wasLocked = true;
} else { } else {
this.pointerLocked = false; this.pointerLocked = false;
@ -250,8 +259,15 @@ L3D.PointerCamera.prototype.onPointerLockChange = function() {
else else
this.startCanvas.clear(); this.startCanvas.clear();
event.locked = false;
if (this.wasLocked !== event.locked)
event.send();
this.wasLocked = false;
} }
}; };
/** /**

View File

@ -114,3 +114,24 @@ L3D.BD.Event.Fps.prototype.send = function() {
L3D.BD.Private.sendData(url, data); L3D.BD.Private.sendData(url, data);
}; };
L3D.BD.Event.PointerLocked = function() {};
L3D.BD.Event.PointerLocked.prototype.send = function() {
var url = "/pointer-locked";
var data = {
locked: this.locked
};
L3D.BD.Private.sendData(url, data);
};
L3D.BD.Event.SwitchedLockOption = function() {};
L3D.BD.Event.SwitchedLockOption.prototype.send = function() {
var url = "/switched-lock-option";
var data = {
locked: this.locked
};
L3D.BD.Private.sendData(url, data);
}

View File

@ -6,8 +6,8 @@ module.exports.index = function(req, res) {
pg.connect(secret.url, function(err, client, release) { pg.connect(secret.url, function(err, client, release) {
client.query( client.query(
"INSERT INTO fpscounter(exp_id, fps) VALUES($1,$2);", "INSERT INTO fpscounter(exp_id, fps, time) VALUES($1,$2,to_timestamp($3));",
[req.session.exp_id, req.body.fps], [req.session.exp_id, req.body.fps, req.body.time],
function(err, result) { function(err, result) {
if (err !== null) if (err !== null)
Log.dberror(err + ' in fps'); Log.dberror(err + ' in fps');

View File

@ -0,0 +1,21 @@
var pg = require('pg');
var secret = require('../../private');
var Log = require('../../lib/NodeLog.js');
module.exports.index = function(req, res) {
pg.connect(secret.url, function(err, client, release) {
client.query(
"INSERT INTO pointerlocked(exp_id, locked, time) VALUES($1,$2,to_timestamp($3));",
[req.session.exp_id, req.body.locked, req.body.time],
function(err, result) {
if (err !== null)
Log.dberror(err + ' in fps');
release();
}
);
});
res.setHeader('Content-Type', 'text/html');
res.send("");
};

View File

@ -0,0 +1,3 @@
module.exports = {
'/pointer-locked': 'index'
};

View File

@ -0,0 +1,21 @@
var pg = require('pg');
var secret = require('../../private');
var Log = require('../../lib/NodeLog.js');
module.exports.index = function(req, res) {
pg.connect(secret.url, function(err, client, release) {
client.query(
"INSERT INTO switchedlockoption(exp_id, locked, time) VALUES($1,$2,to_timestamp($3));",
[req.session.exp_id, req.body.locked, req.body.time],
function(err, result) {
if (err !== null)
Log.dberror(err + ' in fps');
release();
}
);
});
res.setHeader('Content-Type', 'text/html');
res.send("");
};

View File

@ -0,0 +1,3 @@
module.exports = {
'/switched-lock-option': 'index'
};

View File

@ -1,14 +1,16 @@
-- Clear database from previous tables (just in case...) -- Clear database from previous tables (just in case...)
DROP TABLE IF EXISTS users CASCADE; DROP TABLE IF EXISTS Users CASCADE;
DROP TABLE IF EXISTS arrowclicked CASCADE; DROP TABLE IF EXISTS Arrowclicked CASCADE;
DROP TABLE IF EXISTS coinclicked CASCADE; DROP TABLE IF EXISTS CoinClicked CASCADE;
DROP TABLE IF EXISTS keyboardevent CASCADE; DROP TABLE IF EXISTS KeyboardEvent CASCADE;
DROP TABLE IF EXISTS resetclicked CASCADE; DROP TABLE IF EXISTS ResetClicked CASCADE;
DROP TABLE IF EXISTS previousnextclicked CASCADE; DROP TABLE IF EXISTS PreviousNextClicked CASCADE;
DROP TABLE IF EXISTS hovered CASCADE; DROP TABLE IF EXISTS Hovered CASCADE;
DROP TABLE IF EXISTS scene CASCADE; DROP TABLE IF EXISTS Scene CASCADE;
DROP TABLE IF EXISTS experiment CASCADE; DROP TABLE IF EXISTS Experiment CASCADE;
DROP TABLE IF EXISTS fpscounter CASCADE; DROP TABLE IF EXISTS FpsCounter CASCADE;
DROP TABLE IF EXISTS PointerLocked CASCADE;
DROP TABLE IF EXISTS SwitchedLockOption CASCADE;
DROP TYPE IF EXISTS VECTOR3 CASCADE; DROP TYPE IF EXISTS VECTOR3 CASCADE;
DROP TYPE IF EXISTS CAMERA CASCADE; DROP TYPE IF EXISTS CAMERA CASCADE;
@ -100,5 +102,20 @@ CREATE TABLE hovered(
CREATE TABLE fpscounter( CREATE TABLE fpscounter(
id SERIAL PRIMARY KEY, id SERIAL PRIMARY KEY,
exp_id SERIAL REFERENCES experiment (id), exp_id SERIAL REFERENCES experiment (id),
time TIMESTAMP DEFAULT NOW(),
fps REAL fps REAL
); );
CREATE TABLE pointerlocked(
id SERIAL PRIMARY KEY,
exp_id SERIAL REFERENCES experiment (id),
time TIMESTAMP DEFAULT NOW(),
locked BOOLEAN
);
CREATE TABLE switchedlockoption(
id SERIAL PRIMARY KEY,
exp_id SERIAL REFERENCES experiment (id),
time TIMESTAMP DEFAULT NOW(),
locked BOOLEAN
);