From mixed convetion (_, and camel case) to all camel case

This commit is contained in:
Thomas FORGIONE 2015-08-28 21:34:29 +02:00
parent f136ce833f
commit 74cad3824b
40 changed files with 323 additions and 312 deletions

View File

@ -206,7 +206,7 @@ DBReq.Info.prototype.loadCameras = function() {
DBReq.Info.prototype.loadCoins = function() {
var self = this;
this.client.query(
"SELECT coin_id, time FROM coinclicked WHERE exp_id = $1 ORDER BY time;",
"SELECT coin_id AS \"coinId\", time FROM coinclicked WHERE exp_id = $1 ORDER BY time;",
[self.id],
function(err,result) {
if (err !== null) {
@ -218,7 +218,7 @@ DBReq.Info.prototype.loadCoins = function() {
{
type: 'coin',
time: result.rows[i].time,
id: result.rows[i].coin_id
id: result.rows[i].coinId
}
);
}
@ -236,7 +236,7 @@ DBReq.Info.prototype.loadCoins = function() {
DBReq.Info.prototype.loadArrows = function() {
var self = this;
this.client.query(
"SELECT arrow_id, time FROM arrowclicked WHERE exp_id = $1 ORDER BY time;",
"SELECT arrow_id AS \"arrowId\", time FROM arrowclicked WHERE exp_id = $1 ORDER BY time;",
[self.id],
function(err, result) {
if (err !== null) {
@ -248,7 +248,7 @@ DBReq.Info.prototype.loadArrows = function() {
{
type: 'arrow',
time: result.rows[i].time,
id: result.rows[i].arrow_id
id: result.rows[i].arrowId
}
);
}
@ -342,7 +342,7 @@ DBReq.Info.prototype.loadPreviousNext = function () {
DBReq.Info.prototype.loadHovered = function() {
var self = this;
this.client.query(
"SELECT start, time, arrow_id FROM hovered WHERE exp_id = $1 ORDER BY time;",
"SELECT start, time, arrow_id AS \"arrowId\" FROM hovered WHERE exp_id = $1 ORDER BY time;",
[self.id],
function(err, result) {
if (err !== null) {
@ -355,7 +355,7 @@ DBReq.Info.prototype.loadHovered = function() {
type: "hovered",
time: result.rows[i].time,
start: result.rows[i].start,
id: result.rows[i].arrow_id
id: result.rows[i].arrowId
}
);
}
@ -433,14 +433,14 @@ DBReq.Info.prototype.loadSwitchedLockOption = function() {
DBReq.Info.prototype.loadRedCoins = function() {
var self = this;
this.client.query(
"SELECT coin_1, \n" +
" coin_2, \n" +
" coin_3, \n" +
" coin_4, \n" +
" coin_5, \n" +
" coin_6, \n" +
" coin_7, \n" +
" coin_8 \n" +
"SELECT coin_1 AS coin1, \n" +
" coin_2 AS coin2, \n" +
" coin_3 AS coin3, \n" +
" coin_4 AS coin4, \n" +
" coin_5 AS coin5, \n" +
" coin_6 AS coin6, \n" +
" coin_7 AS coin7, \n" +
" coin_8 AS coin8 \n" +
"FROM CoinCombination, Experiment \n" +
"WHERE CoinCombination.id = Experiment.coin_combination_id AND \n" +
" Experiment.id = $1;",
@ -449,14 +449,14 @@ DBReq.Info.prototype.loadRedCoins = function() {
if (err !== null) {
Log.dberror(err + ' in loadRedCoins');
} else {
self.redCoins.push(result.rows[0].coin_1);
self.redCoins.push(result.rows[0].coin_2);
self.redCoins.push(result.rows[0].coin_3);
self.redCoins.push(result.rows[0].coin_4);
self.redCoins.push(result.rows[0].coin_5);
self.redCoins.push(result.rows[0].coin_6);
self.redCoins.push(result.rows[0].coin_7);
self.redCoins.push(result.rows[0].coin_8);
self.redCoins.push(result.rows[0].coin1);
self.redCoins.push(result.rows[0].coin2);
self.redCoins.push(result.rows[0].coin3);
self.redCoins.push(result.rows[0].coin4);
self.redCoins.push(result.rows[0].coin5);
self.redCoins.push(result.rows[0].coin6);
self.redCoins.push(result.rows[0].coin7);
self.redCoins.push(result.rows[0].coin8);
}
self.ready.redCoins = true;
self.tryMerge();
@ -515,16 +515,16 @@ DBReq.UserCreator.prototype.finish = function() {
/**
* Class that creates an experiment
* @param user_id {Number} id of the user that does the experiment
* @param scene_id {Number} id of the scene the experiment is based on
* @param userId {Number} id of the user that does the experiment
* @param sceneId {Number} id of the scene the experiment is based on
* @param finishAction {function} callback that has as a parameter the id of
* the new experiment
* @memberof DBReq
* @constructor
*/
DBReq.ExpCreator = function(user_id, finishAction) {
DBReq.ExpCreator = function(userId, finishAction) {
this.finishAction = finishAction;
this.user_id = user_id;
this.userId = userId;
this.finalResult = {};
// Connect to db
@ -547,7 +547,18 @@ DBReq.ExpCreator = function(user_id, finishAction) {
DBReq.ExpCreator.prototype.execute = function() {
var self = this;
this.client.query(
"SELECT DISTINCT RecommendationStyle.name, CoinCombination.scene_id, CoinCombination.id, coin_1, coin_2, coin_3, coin_4, coin_5, coin_6, coin_7, coin_8\n" +
"SELECT DISTINCT \n" +
" RecommendationStyle.name, \n" +
" CoinCombination.scene_id AS \"sceneId\", \n" +
" CoinCombination.id, \n" +
" coin_1 AS coin1, \n" +
" coin_2 AS coin2, \n" +
" coin_3 AS coin3, \n" +
" coin_4 AS coin4, \n" +
" coin_5 AS coin5, \n" +
" coin_6 AS coin6, \n" +
" coin_7 AS coin7, \n" +
" coin_8 AS coin8\n" +
"FROM CoinCombination, Experiment, Users U, Users Other, RecommendationStyle, Scene\n" +
"WHERE\n" +
" Scene.id = CoinCombination.scene_id AND\n" +
@ -578,22 +589,22 @@ DBReq.ExpCreator.prototype.execute = function() {
" WHERE Experiment.coin_combination_id = CoinCombination.id AND Experiment.user_id = $1\n" +
" )\n" +
"LIMIT 1;",
[self.user_id],
[self.userId],
function(err, result) {
if (result.rows.length > 0) {
// Set the result
self.finalResult.coin_combination_id = result.rows[0].id;
self.finalResult.scene_id = result.rows[0].scene_id;
self.finalResult.recommendation_style = result.rows[0].name;
self.finalResult.coinCombinationId = result.rows[0].id;
self.finalResult.sceneId = result.rows[0].sceneId;
self.finalResult.recommendationStyle = result.rows[0].name;
self.finalResult.coins = [
result.rows[0].coin_1,
result.rows[0].coin_2,
result.rows[0].coin_3,
result.rows[0].coin_4,
result.rows[0].coin_5,
result.rows[0].coin_6,
result.rows[0].coin_7,
result.rows[0].coin_8
result.rows[0].coin1,
result.rows[0].coin2,
result.rows[0].coin3,
result.rows[0].coin4,
result.rows[0].coin5,
result.rows[0].coin6,
result.rows[0].coin7,
result.rows[0].coin8
];
// There is a suggested experiment : create it
@ -601,9 +612,9 @@ DBReq.ExpCreator.prototype.execute = function() {
"INSERT INTO Experiment(user_id, coin_combination_id, recommendation_style)\n" +
"VALUES($1,$2,$3)\n" +
"RETURNING id",
[self.user_id, result.rows[0].id, result.rows[0].name],
[self.userId, result.rows[0].id, result.rows[0].name],
function(err, result) {
self.finalResult.exp_id = result.rows[0].id;
self.finalResult.expId = result.rows[0].id;
self.finish();
}
);
@ -612,7 +623,7 @@ DBReq.ExpCreator.prototype.execute = function() {
} else {
// Find the scene / recommendation style for the new experiment
self.client.query(
"SELECT RecommendationStyle.name, Scene.id as scene_id\n" +
"SELECT RecommendationStyle.name, Scene.id AS \"sceneId\"\n" +
"FROM RecommendationStyle, Scene\n" +
"WHERE\n" +
" RecommendationStyle.name NOT IN(\n" +
@ -632,11 +643,11 @@ DBReq.ExpCreator.prototype.execute = function() {
"\n" +
"ORDER BY RANDOM()\n" +
"LIMIT 1;",
[self.user_id],
[self.userId],
function(err, result) {
if (result.rows.length > 0) {
self.finalResult.scene_id = result.rows[0].scene_id;
self.finalResult.recommendation_style = result.rows[0].name;
self.finalResult.sceneId = result.rows[0].sceneId;
self.finalResult.recommendationStyle = result.rows[0].name;
// Generate random coins
self.client.query(
@ -645,7 +656,7 @@ DBReq.ExpCreator.prototype.execute = function() {
"WHERE Scene.id = $1\n" +
"ORDER BY RANDOM()\n" +
"LIMIT 8;",
[self.finalResult.scene_id],
[self.finalResult.sceneId],
function(err, result) {
self.finalResult.coins = [];
for (var i = 0; i < 8; i++) {
@ -658,7 +669,7 @@ DBReq.ExpCreator.prototype.execute = function() {
"VALUES($1,$2,$3,$4,$5,$6,$7,$8,$9)\n" +
"RETURNING id;",
[
self.finalResult.scene_id,
self.finalResult.sceneId,
self.finalResult.coins[0],
self.finalResult.coins[1],
self.finalResult.coins[2],
@ -669,16 +680,16 @@ DBReq.ExpCreator.prototype.execute = function() {
self.finalResult.coins[7],
],
function(err, result) {
self.finalResult.coin_combination_id = result.rows[0].id;
self.finalResult.coinCombinationId = result.rows[0].id;
// And create the experiment
self.client.query(
"INSERT INTO Experiment(user_id, coin_combination_id, recommendation_style)\n" +
"VALUES($1,$2,$3)\n" +
"RETURNING id;",
[self.user_id, self.finalResult.coin_combination_id, self.finalResult.recommendation_style],
[self.userId, self.finalResult.coinCombinationId, self.finalResult.recommendationStyle],
function(err, result) {
self.finalResult.exp_id = result.rows[0].id;
self.finalResult.expId = result.rows[0].id;
self.finish();
}
);
@ -710,10 +721,10 @@ DBReq.ExpCreator.prototype.finish = function() {
self.release = null;
self.finishAction(
self.finalResult.exp_id,
self.finalResult.coin_combination_id,
self.finalResult.scene_id,
self.finalResult.recommendation_style,
self.finalResult.expId,
self.finalResult.coinCombinationId,
self.finalResult.sceneId,
self.finalResult.recommendationStyle,
self.finalResult.coins
);
});
@ -829,13 +840,13 @@ DBReq.ExpIdChecker = function(id, finishAction) {
DBReq.ExpIdChecker.prototype.execute = function() {
var self = this;
this.client.query(
"SELECT scene_id FROM experiment, CoinCombination WHERE CoinCombination.id = Experiment.coin_combination_id AND Experiment.id = $1;",
"SELECT scene_id AS \"sceneId\" FROM experiment, CoinCombination WHERE CoinCombination.id = Experiment.coin_combination_id AND Experiment.id = $1;",
[self.id],
function(err, result) {
if (result === undefined || result.rows.length === 0) {
self.finalResult = null;
} else {
self.finalResult = result.rows[0].scene_id;
self.finalResult = result.rows[0].sceneId;
}
self.finish();
}
@ -879,10 +890,10 @@ DBReq.ExpGetter.prototype.execute = function() {
var self = this;
this.client.query(
"SELECT " +
"experiment.id as exp_id, " +
"users.worker_id as username, " +
"scene.name as scenename, " +
"users.id as user_id " +
"experiment.id AS \"expId\", " +
"users.worker_id AS username, " +
"scene.name AS scenename, " +
"users.id AS \"userId\" " +
"FROM experiment, users, scene, CoinCombination " +
"WHERE experiment.user_id = users.id and scene.id = CoinCombination.scene_id AND " +
" Experiment.coin_combination_id = CoinCombination.id " +
@ -923,7 +934,7 @@ DBReq.TutorialCreator.prototype.execute = function() {
var self = this;
this.client.query(
// Generate random coins
"SELECT Scene.id AS scene_id, generate_series AS id\n" +
"SELECT Scene.id AS \"sceneId\", generate_series AS id\n" +
"FROM Scene, generate_series(0,Scene.coin_number-1)\n" +
"WHERE Scene.name = 'peachcastle'\n" +
"ORDER BY RANDOM()\n" +
@ -934,13 +945,14 @@ DBReq.TutorialCreator.prototype.execute = function() {
for (var i = 0; i < 8; i++) {
self.finalResult.coins.push(result.rows[i].id);
}
console.log(result.rows[0]);
// Create CoinCombination
self.client.query(
"INSERT INTO CoinCombination(scene_id, coin_1, coin_2, coin_3, coin_4, coin_5, coin_6, coin_7, coin_8)\n" +
"VALUES($1,$2,$3,$4,$5,$6,$7,$8,$9)\n" +
"RETURNING id;",
[
result.rows[0].scene_id,
result.rows[0].sceneId,
result.rows[0].id,
result.rows[1].id,
result.rows[2].id,
@ -951,6 +963,7 @@ DBReq.TutorialCreator.prototype.execute = function() {
result.rows[7].id
],
function(err, result) {
console.log(err);
// Create experiment
self.client.query(
"INSERT INTO Experiment(user_id, coin_combination_id)\n" +
@ -1019,7 +1032,7 @@ DBReq.createUser = function(callback) {
* Creates an experiment
* @memberof DBReq
* @param id {Number} id of the user doing the experiment
* @param scene_id {Number} id of the scene on which the experiment is
* @param sceneId {Number} id of the scene on which the experiment is
* @param callback {function} callback called on the new experiment id
*/
DBReq.createExp = function(id, callback) {
@ -1050,8 +1063,8 @@ DBReq.checkUserName = function(name, callback) {
* @memberof DBReq
* @param id {Number} id of the experiment to check
* @param callback {function} callback called on an object (null if the
* experiment doesn't exist, an object containing username, scene_id,
* scenename, and exp_id if it exists
* experiment doesn't exist, an object containing username, sceneId,
* scenename, and expId if it exists
*/
DBReq.checkExpId = function(id, callback) {
new DBReq.ExpIdChecker(id, callback);

View File

@ -26,9 +26,9 @@ var sceneToFunction = function(scene) {
module.exports.game = function(req, res) {
db.tryUser(req.session.user_id, function(id) {
db.tryUser(req.session.userId, function(id) {
req.session.user_id = id;
req.session.userId = id;
db.createExp(id, function(expId, coinCombinationId, sceneId, recommendationStyle, coins) {
@ -39,7 +39,7 @@ module.exports.game = function(req, res) {
}
req.session.exp_id = expId;
req.session.expId = expId;
req.session.save();
res.locals.scene = sceneToFunction(sceneId);
@ -62,7 +62,7 @@ module.exports.sponza = function(req, res) {
});
};
module.exports.replay_info = function(req, res) {
module.exports.replayInfo = function(req, res) {
res.setHeader('Content-Type', 'text/plain');
// Parse id
@ -77,13 +77,13 @@ module.exports.replay = function(req, res, next) {
// Get id parameter
res.locals.id = tools.filterInt(req.params.id);
db.checkExpId(res.locals.id, function(scene_id) {
if (scene_id === null) {
db.checkExpId(res.locals.id, function(sceneId) {
if (sceneId === null) {
var err = new Error("This replay does not exist");
err.status = 404;
next(err);
} else {
res.locals.initjs = sceneToFunction(scene_id);
res.locals.initjs = sceneToFunction(sceneId);
res.setHeader('Content-Type', 'text/html');
res.render('prototype_replays.jade', res.locals, function(err, result) {
res.send(result);
@ -92,7 +92,7 @@ module.exports.replay = function(req, res, next) {
});
};
module.exports.replay_index = function(req, res, next) {
module.exports.replayIndex = function(req, res, next) {
db.getAllExps(function(result) {
res.locals.users = result;
@ -105,12 +105,12 @@ module.exports.replay_index = function(req, res, next) {
module.exports.tutorial = function(req, res) {
db.tryUser(req.session.user_id, function(id) {
req.session.user_id = id;
db.tryUser(req.session.userId, function(id) {
req.session.userId = id;
// 1 is the ID of peach scene
db.createTutorial(id, function(id, coins) {
req.session.exp_id = id;
req.session.expId = id;
res.locals.coins = coins;
req.session.save();

View File

@ -1,9 +1,9 @@
module.exports = {
'/prototype': 'index',
'/prototype/game': 'game',
'/prototype/replay': 'replay_index',
'/prototype/replay': 'replayIndex',
'/prototype/replay/:id': 'replay',
'/prototype/replay_info/:id': 'replay_info',
'/prototype/replay-info/:id': 'replayInfo',
'/prototype/tutorial': 'tutorial',
'/prototype/sponza': 'sponza',
'/prototype/coin-creator/:scene': 'clicker',

View File

@ -14,4 +14,4 @@ block content
a(href="reverse/") Reversed arrows looking like funnel
li
a(href="viewports/") Viewports
p You can also watch replays of previous experiences <a href="#{urls.replay_index}">here</a>.
p You can also watch replays of previous experiences <a href="#{urls.replayIndex}">here</a>.

View File

@ -10,4 +10,4 @@ block content
else
ol
each elt in users
li <a href="/prototype/replay/#{elt.exp_id}">User <em>#{elt.username} (#{elt.user_id})</em> for scene <em>#{elt.scenename}</em></a>
li <a href="/prototype/replay/#{elt.expId}">User <em>#{elt.username} (#{elt.userId})</em> for scene <em>#{elt.scenename}</em></a>

View File

@ -1,7 +1,7 @@
var BouncingCube = function(size, style) {
L3D.Cube.call(this, size, style);
this.fixed_center = new THREE.Vector3();
this.fixedCenter = new THREE.Vector3();
this.center = new THREE.Vector3();
this.speed = new THREE.Vector3(0,0,300);
@ -11,13 +11,13 @@ BouncingCube.prototype.constructor = BouncingCube;
BouncingCube.prototype.update = function() {
// Compute new center
var speed_clone = this.speed.clone();
speed_clone.multiply(BouncingCube.DT);
var speedClone = this.speed.clone();
speedClone.multiply(BouncingCube.DT);
this.speed.add(BouncingCube.G);
if (this.speed.dot(this.speed) > 100) {
this.center.add(speed_clone);
this.center.add(speedClone);
}
if (this.center.z < 0) {

View File

@ -1,10 +1,10 @@
var renderer, scene, camera, controls, cube, container, plane, mouse= {x:0, y:0};
var raycaster;
var objects = [];
var container_size = {};
var containerSize = {};
var previousTime;
container_size.width = 1067;
container_size.height = 600;
containerSize.width = 1067;
containerSize.height = 600;
init();
animate();
@ -12,10 +12,10 @@ animate();
function init() {
// on initialise le moteur de rendu
container = document.getElementById('container');
container.style.height = container_size.height + 'px';
container.style.width = container_size.width + 'px';
container.style.height = containerSize.height + 'px';
container.style.width = containerSize.width + 'px';
renderer = new THREE.WebGLRenderer({alpha:"true"});
renderer.setSize(container_size.width, container_size.height);
renderer.setSize(containerSize.width, containerSize.height);
renderer.shadowMapEnabled = true;
document.getElementById('container').appendChild(renderer.domElement);
@ -24,16 +24,16 @@ function init() {
raycaster = new THREE.Raycaster();
// init light
var directional_light = new THREE.DirectionalLight(0xffffff);
directional_light.position.set(1, 0.5, 1).normalize();
directional_light.castShadow = true;
scene.add(directional_light);
var directionalLight = new THREE.DirectionalLight(0xffffff);
directionalLight.position.set(1, 0.5, 1).normalize();
directionalLight.castShadow = true;
scene.add(directionalLight);
var ambient_light = new THREE.AmbientLight(0x444444);
scene.add(ambient_light);
var ambientLight = new THREE.AmbientLight(0x444444);
scene.add(ambientLight);
// on initialise la camera que lon place ensuite sur la scène
camera = new L3D.Camera(50, container_size.width / container_size.height, 1, 10000);
camera = new L3D.Camera(50, containerSize.width / containerSize.height, 1, 10000);
scene.add(camera);
window.addEventListener('resize', onWindowResize, false);

View File

@ -1,15 +1,15 @@
var mesh_number = 25;
var meshNumber = 25;
var renderer, scene, camera, controls, cube, container, plane, mouse= {x:0, y:0};
var raycaster;
var objects = [];
var spheres = new Array(mesh_number);
var spheres = new Array(meshNumber);
var visible = 0;
var loader, previousTime;
var container_size = {};
container_size.width = 1067;
container_size.height = 600;
var containerSize = {};
containerSize.width = 1067;
containerSize.height = 600;
init();
animate();
@ -34,10 +34,10 @@ function loadSphere(i) {
function init() {
// on initialise le moteur de rendu
container = document.getElementById('container');
container.style.height = container_size.height + 'px';
container.style.width = container_size.width + 'px';
container.style.height = containerSize.height + 'px';
container.style.width = containerSize.width + 'px';
renderer = new THREE.WebGLRenderer({alpha:"true"});
renderer.setSize(container_size.width, container_size.height);
renderer.setSize(containerSize.width, containerSize.height);
renderer.shadowMapEnabled = true;
document.getElementById('container').appendChild(renderer.domElement);
@ -46,16 +46,16 @@ function init() {
raycaster = new THREE.Raycaster();
// init light
var directional_light = new THREE.DirectionalLight(0xffffff);
directional_light.position.set(1, 0.5, 1).normalize();
directional_light.castShadow = true;
scene.add(directional_light);
var directionalLight = new THREE.DirectionalLight(0xffffff);
directionalLight.position.set(1, 0.5, 1).normalize();
directionalLight.castShadow = true;
scene.add(directionalLight);
var ambient_light = new THREE.AmbientLight(0x444444);
scene.add(ambient_light);
var ambientLight = new THREE.AmbientLight(0x444444);
scene.add(ambientLight);
// on initialise la camera que lon place ensuite sur la scène
camera = new L3D.Camera(50, container_size.width / container_size.height, 1, 10000);
camera = new L3D.Camera(50, containerSize.width / containerSize.height, 1, 10000);
scene.add(camera);
window.addEventListener('resize', onWindowResize, false);
@ -65,7 +65,7 @@ function init() {
// Création d'un objloader
loader = new THREE.OBJLoader();
for (var i = 0; i < mesh_number; i++) {
for (var i = 0; i < meshNumber; i++) {
loadSphere(i);

View File

@ -39,8 +39,8 @@ Coin.setSize = function(width,height) {
Coin.initSize = function() {
try {
Coin.domElement.width = container_size.width();
Coin.domElement.height = container_size.height();
Coin.domElement.width = containerSize.width();
Coin.domElement.height = containerSize.height();
} catch (e) {
setTimeout(100, Coin.initSize);
return;
@ -51,9 +51,9 @@ Coin.update = function() {
var x;
try {
x = container_size.width() * 4.75 / 5;
Coin.domElement.width = container_size.width();
Coin.domElement.height = container_size.height();
x = containerSize.width() * 4.75 / 5;
Coin.domElement.width = containerSize.width();
Coin.domElement.height = containerSize.height();
} catch (e) {
return;
}
@ -108,7 +108,7 @@ Coin.set = function() {
Coin.set(newLvl);
},50);
}
}
};
// Coin.image.onload = Coin.update;

View File

@ -1,11 +1,11 @@
// Auto-resize case
// var main_section = document.getElementById('main-section');
// var mainSection = document.getElementById('main-section');
//
// var container_size = {
// width: function() { if (!isFullscreen) return main_section.clientWidth; else return screen.width;},
// var containerSize = {
// width: function() { if (!isFullscreen) return mainSection.clientWidth; else return screen.width;},
// height: function() {
// if (!isFullscreen)
// return main_section.clientHeight
// return mainSection.clientHeight
// - document.getElementById('nav').offsetHeight
// - document.getElementById('main-div').offsetHeight;
// else
@ -13,7 +13,7 @@
// }
// };
var container_size = {
var containerSize = {
width: function() { return 1134; },
height: function() { return 768; }
@ -54,7 +54,7 @@ function objectClickerOnHover(camera1, previewer, recommendations, container) {
if (obj instanceof L3D.BaseRecommendation) {
// The newly hovered object is different and is a recommendation
event.arrow_id = recommendations.indexOf(obj);
event.arrowId = recommendations.indexOf(obj);
event.start = true;
event.send();
@ -66,7 +66,7 @@ function objectClickerOnHover(camera1, previewer, recommendations, container) {
// but the previous one is : we must log
// Unhovered
event.arrow_id = 0;
event.arrowId = 0;
event.start = false;
event.send();
@ -94,7 +94,7 @@ function objectClickerOnClick(camera1, buttonManager, recommendations, coins) {
// Send event to DB
event = new L3D.DB.Event.CoinClicked();
event.coin_id = obj.id;
event.coinId = obj.id;
event.send();
} else if (obj instanceof L3D.BaseRecommendation) {
@ -104,7 +104,7 @@ function objectClickerOnClick(camera1, buttonManager, recommendations, coins) {
// Send event to DB
event = new L3D.DB.Event.ArrowClicked();
event.arrow_id = recommendations.indexOf(obj);
event.arrowId = recommendations.indexOf(obj);
event.send();
}
@ -133,7 +133,7 @@ var hide = createVisibilityFunction(false);
function resizeElements() {
var width = container_size.width(), height = container_size.height();
var width = containerSize.width(), height = containerSize.height();
for (var i = 0; i < arguments.length; i++) {

View File

@ -97,7 +97,7 @@ function initThreeElements() {
// Initialize pointer camera
camera1 = new L3D.PointerCamera(
50,
container_size.width() / container_size.height(),
containerSize.width() / containerSize.height(),
0.01, 100000, renderer, container
);
@ -236,7 +236,7 @@ function render() {
// Set current position of camera
camera1.look();
var left = 0, bottom = 0, width = container_size.width(), height = container_size.height();
var left = 0, bottom = 0, width = containerSize.width(), height = containerSize.height();
renderer.setScissor(left, bottom, width, height);
renderer.enableScissorTest(true);
renderer.setViewport(left, bottom, width, height);
@ -252,7 +252,7 @@ function render() {
THREEx.Transparency.update(camera1);
// Render preview
previewer.render(container_size.width(), container_size.height());
previewer.render(containerSize.width(), containerSize.height());
// Finish stats
stats.end();
@ -264,7 +264,7 @@ function onWindowResize() {
resizeElements(renderer, container, previewer, pointer, startCanvas);
recommendations.forEach(function(reco) {
resetCameraAspect(reco.camera, container_size.width(), container_size.height());
resetCameraAspect(reco.camera, containerSize.width(), containerSize.height());
});
render();

View File

@ -103,7 +103,7 @@ function initThreeElements() {
// Initialize pointer camera
camera1 = new L3D.PointerCamera(
50,
container_size.width() / container_size.height(),
containerSize.width() / containerSize.height(),
0.01, 100000, renderer, container
);
@ -233,7 +233,7 @@ function render() {
// Set current position of camera
camera1.look();
var left = 0, bottom = 0, width = container_size.width(), height = container_size.height();
var left = 0, bottom = 0, width = containerSize.width(), height = containerSize.height();
renderer.setScissor(left, bottom, width, height);
renderer.enableScissorTest(true);
renderer.setViewport(left, bottom, width, height);
@ -249,7 +249,7 @@ function render() {
THREEx.Transparency.update(camera1);
// Render preview
previewer.render(container_size.width(), container_size.height());
previewer.render(containerSize.width(), containerSize.height());
// Finish stats
stats.end();
@ -261,7 +261,7 @@ function onWindowResize() {
resizeElements(renderer, container, previewer, pointer, startCanvas);
recommendations.forEach(function(reco) {
resetCameraAspect(reco.camera, container_size.width(), container_size.height());
resetCameraAspect(reco.camera, containerSize.width(), containerSize.height());
});
render();

View File

@ -103,7 +103,7 @@ function initThreeElements() {
// Initialize pointer camera
camera1 = new L3D.PointerCamera(
50,
container_size.width() / container_size.height(),
containerSize.width() / containerSize.height(),
0.01, 100000, renderer, container
);
@ -239,7 +239,7 @@ function render() {
// Set current position of camera
camera1.look();
var left = 0, bottom = 0, width = container_size.width(), height = container_size.height();
var left = 0, bottom = 0, width = containerSize.width(), height = containerSize.height();
renderer.setScissor(left, bottom, width, height);
renderer.enableScissorTest(true);
renderer.setViewport(left, bottom, width, height);
@ -255,7 +255,7 @@ function render() {
THREEx.Transparency.update(camera1);
// Render preview
previewer.render(container_size.width(), container_size.height());
previewer.render(containerSize.width(), containerSize.height());
// Finish stats
stats.end();
@ -267,7 +267,7 @@ function onWindowResize() {
resizeElements(renderer, container, previewer, pointer, startCanvas);
recommendations.forEach(function(reco) {
resetCameraAspect(reco.camera, container_size.width(), container_size.height());
resetCameraAspect(reco.camera, containerSize.width(), containerSize.height());
});
render();

View File

@ -92,7 +92,7 @@ function initThreeElements() {
// Initialize pointer camera
camera1 = new L3D.PointerCamera(
50,
container_size.width() / container_size.height(),
containerSize.width() / containerSize.height(),
0.01, 100000, renderer, container
);
@ -189,7 +189,7 @@ function render() {
// Set current position of camera
camera1.look();
var left = 0, bottom = 0, width = container_size.width(), height = container_size.height();
var left = 0, bottom = 0, width = containerSize.width(), height = containerSize.height();
renderer.setScissor(left, bottom, width, height);
renderer.enableScissorTest(true);
renderer.setViewport(left, bottom, width, height);
@ -205,7 +205,7 @@ function render() {
THREEx.Transparency.update(camera1);
// Render preview
previewer.render(container_size.width(), container_size.height());
previewer.render(containerSize.width(), containerSize.height());
// Finish stats
stats.end();
@ -217,7 +217,7 @@ function onWindowResize() {
resizeElements(renderer, container, previewer, Coin, pointer, startCanvas);
recommendations.forEach(function(reco) {
resetCameraAspect(reco.camera, container_size.width(), container_size.height());
resetCameraAspect(reco.camera, containerSize.width(), containerSize.height());
});
render();

View File

@ -20,7 +20,7 @@ function main() {
initThreeElements();
var xhr = new XMLHttpRequest();
xhr.open("GET", "/prototype/replay_info/" + params.get.id, true);
xhr.open("GET", "/prototype/replay-info/" + params.get.id, true);
xhr.onreadystatechange = function() {
if (xhr.readyState == 4 && xhr.status == 200) {
@ -60,7 +60,7 @@ function init(data) {
container.appendChild(renderer.domElement);
// Initialize replay camera
camera1 = new L3D.ReplayCamera(50, container_size.width()/container_size.height(), 0.01, 100000, coins, data);
camera1 = new L3D.ReplayCamera(50, containerSize.width()/containerSize.height(), 0.01, 100000, coins, data);
recommendations = initMainScene(camera1, scene, coins, undefined, data.redCoins);
camera1.cameras = recommendations;

View File

@ -5,7 +5,7 @@ var TutoCamera = function() {
this.renderer = arguments[4];
this.onWindowResize = arguments[6];
var scene = arguments[5];
var container_size = arguments[7];
var containerSize = arguments[7];
var coins = arguments[8];
if (arguments[9] === undefined)
@ -76,7 +76,7 @@ var TutoCamera = function() {
this.collisions = true;
// Create tutorial
this.tutorial = new TutorialSteps(this, scene, coins, this.onWindowResize, container_size, arguments[10]);
this.tutorial = new TutorialSteps(this, scene, coins, this.onWindowResize, containerSize, arguments[10]);
this.shouldLock = true;
@ -191,14 +191,14 @@ TutoCamera.prototype.update = function(time) {
};
TutoCamera.prototype.linearMotion = function(time) {
var position_direction = L3D.Tools.diff(this.new_position, this.position);
var target_direction = L3D.Tools.diff(this.new_target, this.target);
var positionDirection = L3D.Tools.diff(this.newPosition, this.position);
var targetDirection = L3D.Tools.diff(this.newTarget, this.target);
this.position.add(L3D.Tools.mul(position_direction, 0.05 * time / 20));
this.target.add(L3D.Tools.mul(target_direction, 0.05 * time / 20));
this.position.add(L3D.Tools.mul(positionDirection, 0.05 * time / 20));
this.target.add(L3D.Tools.mul(targetDirection, 0.05 * time / 20));
if (L3D.Tools.norm2(L3D.Tools.diff(this.position, this.new_position)) < 0.01 &&
L3D.Tools.norm2(L3D.Tools.diff(this.target, this.new_target)) < 0.01) {
if (L3D.Tools.norm2(L3D.Tools.diff(this.position, this.newPosition)) < 0.01 &&
L3D.Tools.norm2(L3D.Tools.diff(this.target, this.newTarget)) < 0.01) {
this.moving = false;
this.anglesFromVectors();
}
@ -352,11 +352,11 @@ TutoCamera.prototype.move = function(recommendation, toSave) {
this.moving = true;
this.movingHermite = false;
this.new_target = otherCamera.target.clone();
this.new_position = otherCamera.position.clone();
this.newTarget = otherCamera.target.clone();
this.newPosition = otherCamera.position.clone();
var t = [0,1];
var f = [this.position.clone(), this.new_position];
var fp = [L3D.Tools.diff(this.target, this.position), L3D.Tools.diff(this.new_target, this.new_position)];
var f = [this.position.clone(), this.newPosition];
var fp = [L3D.Tools.diff(this.target, this.position), L3D.Tools.diff(this.newTarget, this.newPosition)];
this.hermite = new L3D.Hermite.Polynom(t,f,fp);
this.t = 0;

View File

@ -1,11 +1,11 @@
var nextStep;
var TutorialSteps = function(tutoCamera, scene, coins, onWindowResize, container_size, clickableObjects) {
var TutorialSteps = function(tutoCamera, scene, coins, onWindowResize, containerSize, clickableObjects) {
this.camera = tutoCamera;
this.step = 0;
this.coinNumber = 0;
this.camera.allowed = {};
this.onWindowResize = onWindowResize;
this.container_size = container_size;
this.containerSize = containerSize;
this.coins = coins;
this.clickableObjects = clickableObjects;
@ -193,7 +193,7 @@ TutorialSteps.prototype.nextStep = function() {
});
break;
case 14:
this.firstReco = L3D.createPeachRecommendations(this.container_size.width(), this.container_size.height())[0];
this.firstReco = L3D.createPeachRecommendations(this.containerSize.width(), this.containerSize.height())[0];
this.addRecommendation(this.firstReco);
this.camera.move({
position: new THREE.Vector3(-9.157274598933608,3.6852142459329533,2.1820896816244444),
@ -201,7 +201,7 @@ TutorialSteps.prototype.nextStep = function() {
});
break;
case 16:
this.secondReco = L3D.createPeachRecommendations(this.container_size.width(), this.container_size.height(), L3D.ViewportRecommendation)[1];
this.secondReco = L3D.createPeachRecommendations(this.containerSize.width(), this.containerSize.height(), L3D.ViewportRecommendation)[1];
this.addRecommendation(this.secondReco);
this.secondReco.raycastable = true;
this.camera.move({
@ -217,7 +217,7 @@ TutorialSteps.prototype.nextStep = function() {
});
}, 3*60*1000);
var cams = L3D.createPeachRecommendations(this.container_size.width(), this.container_size.height());
var cams = L3D.createPeachRecommendations(this.containerSize.width(), this.containerSize.height());
for (var i = 2; i < cams.length; i++) {
this.addRecommendation(cams[i]);
}

View File

@ -92,8 +92,8 @@ function initThreeElements() {
// Initialize pointer camera
camera1 = new TutoCamera(
50,
container_size.width() / container_size.height(),
0.01, 100000, renderer, scene, onWindowResize, container_size, coins, container, clickableObjects
containerSize.width() / containerSize.height(),
0.01, 100000, renderer, scene, onWindowResize, containerSize, coins, container, clickableObjects
);
tutorial = camera1.tutorial;
@ -186,7 +186,7 @@ function render() {
// Set current position of camera
camera1.look();
var left = 0, bottom = 0, width = container_size.width(), height = container_size.height();
var left = 0, bottom = 0, width = containerSize.width(), height = containerSize.height();
renderer.setScissor(left, bottom, width, height);
renderer.enableScissorTest(true);
renderer.setViewport(left, bottom, width, height);
@ -202,7 +202,7 @@ function render() {
THREEx.Transparency.update(camera1);
// Render preview
previewer.render(container_size.width(), container_size.height());
previewer.render(containerSize.width(), containerSize.height());
// Finish stats
stats.end();
@ -214,7 +214,7 @@ function onWindowResize() {
resizeElements(renderer, container, previewer, Coin, pointer, startCanvas);
recommendations.forEach(function(reco) {
resetCameraAspect(reco.camera, container_size.width(), container_size.height());
resetCameraAspect(reco.camera, containerSize.width(), containerSize.height());
});
render();

View File

@ -1,14 +1,14 @@
var mesh_number = 25;
var meshNumber = 25;
var renderer, scene, controls, cube, container, plane, mouse= {x:0, y:0}, sphere, sphereLoader;
var bigmesh;
var raycaster;
var objects = [];
var spheres = new Array(mesh_number);
var spheres = new Array(meshNumber);
var visible = 0;
var previousTime;
var loader;
var container_size = {width: 1067, height: 600};
var containerSize = {width: 1067, height: 600};
init();
animate();
@ -16,10 +16,10 @@ animate();
function init() {
// on initialise le moteur de rendu
container = document.getElementById('container');
container.style.height = container_size.height + 'px';
container.style.width = container_size.width + 'px';
container.style.height = containerSize.height + 'px';
container.style.width = containerSize.width + 'px';
renderer = new THREE.WebGLRenderer({alpha:"true"});
renderer.setSize(container_size.width, container_size.height);
renderer.setSize(containerSize.width, containerSize.height);
renderer.shadowMapEnabled = true;
// renderer.setClearColor(0x000000);
document.getElementById('container').appendChild(renderer.domElement);
@ -29,16 +29,16 @@ function init() {
raycaster = new THREE.Raycaster();
// init light
var directional_light = new THREE.DirectionalLight(0x999999);
directional_light.position.set(1, 0.5, 1).normalize();
directional_light.castShadow = true;
scene.add(directional_light);
var directionalLight = new THREE.DirectionalLight(0x999999);
directionalLight.position.set(1, 0.5, 1).normalize();
directionalLight.castShadow = true;
scene.add(directionalLight);
var ambient_light = new THREE.AmbientLight(0x333333);
scene.add(ambient_light);
var ambientLight = new THREE.AmbientLight(0x333333);
scene.add(ambientLight);
// on initialise la camera que lon place ensuite sur la scène
camera = new L3D.Camera(50, container_size.width / container_size.height, 1, 100000);
camera = new L3D.Camera(50, containerSize.width / containerSize.height, 1, 100000);
scene.add(camera);
window.addEventListener('resize', onWindowResize, false);

View File

@ -294,14 +294,14 @@ L3D.PointerCamera.prototype.update = function(time) {
* @param {Number} time number of milliseconds between the previous and the next frame
*/
L3D.PointerCamera.prototype.linearMotion = function(time) {
var position_direction = L3D.Tools.diff(this.new_position, this.position);
var target_direction = L3D.Tools.diff(this.new_target, this.target);
var positionDirection = L3D.Tools.diff(this.newPosition, this.position);
var targetDirection = L3D.Tools.diff(this.newTarget, this.target);
this.position.add(L3D.Tools.mul(position_direction, 0.05 * time / 20));
this.target.add(L3D.Tools.mul(target_direction, 0.05 * time / 20));
this.position.add(L3D.Tools.mul(positionDirection, 0.05 * time / 20));
this.target.add(L3D.Tools.mul(targetDirection, 0.05 * time / 20));
if (L3D.Tools.norm2(L3D.Tools.diff(this.position, this.new_position)) < 0.01 &&
L3D.Tools.norm2(L3D.Tools.diff(this.target, this.new_target)) < 0.01) {
if (L3D.Tools.norm2(L3D.Tools.diff(this.position, this.newPosition)) < 0.01 &&
L3D.Tools.norm2(L3D.Tools.diff(this.target, this.newTarget)) < 0.01) {
this.moving = false;
this.anglesFromVectors();
}
@ -461,11 +461,11 @@ L3D.PointerCamera.prototype.move = function(recommendation, toSave) {
this.movingHermite = false;
this.moving = true;
this.new_target = otherCamera.target.clone();
this.new_position = otherCamera.position.clone();
this.newTarget = otherCamera.target.clone();
this.newPosition = otherCamera.position.clone();
var t = [0,1];
var f = [this.position.clone(), this.new_position];
var fp = [L3D.Tools.diff(this.target, this.position), L3D.Tools.diff(this.new_target, this.new_position)];
var f = [this.position.clone(), this.newPosition];
var fp = [L3D.Tools.diff(this.target, this.position), L3D.Tools.diff(this.newTarget, this.newPosition)];
this.hermite = new L3D.Hermite.Polynom(t,f,fp);
this.t = 0;

View File

@ -9,8 +9,8 @@ L3D.ReplayCamera = function() {
this.position = new THREE.Vector3();
this.target = new THREE.Vector3();
this.new_position = new THREE.Vector3();
this.new_target = new THREE.Vector3();
this.newPosition = new THREE.Vector3();
this.newTarget = new THREE.Vector3();
this.data = arguments[5];
@ -54,7 +54,7 @@ L3D.ReplayCamera.prototype.update = function(time) {
};
L3D.ReplayCamera.prototype.linearMotion = function(time) {
var tmp = L3D.Tools.sum(L3D.Tools.mul(this.old_position, 1-this.t), L3D.Tools.mul(this.new_position, this.t));
var tmp = L3D.Tools.sum(L3D.Tools.mul(this.oldPosition, 1-this.t), L3D.Tools.mul(this.newPosition, this.t));
this.position.copy(tmp);
this.t += 0.1 * time / 20;
@ -65,9 +65,9 @@ L3D.ReplayCamera.prototype.linearMotion = function(time) {
L3D.ReplayCamera.prototype.cameraMotion = function(time) {
var tmp = L3D.Tools.sum(L3D.Tools.mul(this.old_position, 1-this.t), L3D.Tools.mul(this.new_position, this.t));
var tmp = L3D.Tools.sum(L3D.Tools.mul(this.oldPosition, 1-this.t), L3D.Tools.mul(this.newPosition, this.t));
this.position.copy(tmp);
this.target = L3D.Tools.sum(L3D.Tools.mul(this.old_target, 1-this.t), L3D.Tools.mul(this.new_target, this.t));
this.target = L3D.Tools.sum(L3D.Tools.mul(this.oldTarget, 1-this.t), L3D.Tools.mul(this.newTarget, this.t));
this.t += 1 / (((new Date(this.path[this.counter].time)).getTime() - (new Date(this.path[this.counter-1].time)).getTime()) / 20);
if (this.t > 1) {
@ -171,10 +171,10 @@ L3D.ReplayCamera.prototype.move = function(recommendation) {
var otherCamera = recommendation.camera || recommendation;
this.moving = true;
this.old_target = this.target.clone();
this.old_position = this.position.clone();
this.new_target = new THREE.Vector3(otherCamera.target.x, otherCamera.target.y, otherCamera.target.z);
this.new_position = new THREE.Vector3(otherCamera.position.x, otherCamera.position.y, otherCamera.position.z);
this.oldTarget = this.target.clone();
this.oldPosition = this.position.clone();
this.newTarget = new THREE.Vector3(otherCamera.target.x, otherCamera.target.y, otherCamera.target.z);
this.newPosition = new THREE.Vector3(otherCamera.position.x, otherCamera.position.y, otherCamera.position.z);
this.t = 0;
};

View File

@ -132,11 +132,11 @@ L3D.MousePointer.prototype.render = function(style, force) {
this.domElement.width = this.domElement.width;
var i = container_size.width() / 2;
var i = containerSize.width() / 2;
var imin = i - this.size;
var imax = i + this.size;
var j = container_size.height() / 2;
var j = containerSize.height() / 2;
var jmin = j - this.size;
var jmax = j + this.size;

View File

@ -61,15 +61,15 @@ L3D.Previewer = function(renderer, scene) {
/**
* Renders the preview
* @param {Number} container_width width of the container
* @param {Number} container_height height of the container
* @param {Number} containerWidth width of the container
* @param {Number} containerHeight height of the container
*/
L3D.Previewer.prototype.render = function(container_width, container_height) {
L3D.Previewer.prototype.render = function(containerWidth, containerHeight) {
var width, height, left, bottom;
if (this.camera) {
width = Math.floor(container_width / 5);
height = Math.floor(container_height / 5);
width = Math.floor(containerWidth / 5);
height = Math.floor(containerHeight / 5);
if (!this.fixed) {
left = Math.floor(this.mouse.x - width/2);
bottom = Math.floor(this.renderer.domElement.height - this.mouse.y + height/5);
@ -88,22 +88,22 @@ L3D.Previewer.prototype.render = function(container_width, container_height) {
}
// Draw border
var can_bottom = container_height - bottom - height ;
var canBottom = containerHeight - bottom - height ;
this.ctx.strokeStyle = "#ffffff";
this.ctx.beginPath();
this.ctx.moveTo(left-1, can_bottom);
this.ctx.lineTo(left-1, can_bottom + height);
this.ctx.lineTo(left + width-1, can_bottom + height);
this.ctx.lineTo(left + width-1, can_bottom);
this.ctx.moveTo(left-1, canBottom);
this.ctx.lineTo(left-1, canBottom + height);
this.ctx.lineTo(left + width-1, canBottom + height);
this.ctx.lineTo(left + width-1, canBottom);
this.ctx.closePath();
this.ctx.stroke();
this.ctx.strokeStyle = "#000000";
this.ctx.beginPath();
this.ctx.moveTo(left, can_bottom + 1);
this.ctx.lineTo(left, can_bottom + height - 1);
this.ctx.lineTo(left + width - 2 , can_bottom + height-1);
this.ctx.lineTo(left + width - 2, can_bottom+1);
this.ctx.moveTo(left, canBottom + 1);
this.ctx.lineTo(left, canBottom + height - 1);
this.ctx.lineTo(left + width - 2 , canBottom + height-1);
this.ctx.lineTo(left + width - 2, canBottom+1);
this.ctx.closePath();
this.ctx.stroke();

View File

@ -44,7 +44,7 @@ L3D.StartCanvas.prototype.render = function(force) {
this.ctx.font = '30px Verdana';
this.ctx.globalAlpha = 1;
this.ctx.fillStyle = 'black';
this.ctx.fillText('Click here to lock the pointer !', container_size.width()/3.25, container_size.height()/2-10);
this.ctx.fillText('Click here to lock the pointer !', containerSize.width()/3.25, containerSize.height()/2-10);
this.shown = true;

View File

@ -2,9 +2,9 @@ var container = document.getElementById('content');
function print(text) {
var content = document.createTextNode(text);
var new_line = document.createElement('br');
var newLine = document.createElement('br');
container.appendChild(content);
container.appendChild(new_line);
container.appendChild(newLine);
}
function toString(variable) {

View File

@ -190,26 +190,26 @@ L3D.BaseRecommendation.prototype.update = function(mainCamera) {
// Compute distance between center of camera and position
dist = L3D.Tools.norm2(L3D.Tools.diff(mainCamera.position, this.center));
var low_bound = 1;
var high_bound = 5;
var new_value;
var lowBound = 1;
var highBound = 5;
var newValue;
if (dist < low_bound) {
new_value = 0;
} else if (dist > high_bound) {
new_value = 1;
if (dist < lowBound) {
newValue = 0;
} else if (dist > highBound) {
newValue = 1;
} else {
new_value = (dist - low_bound)/(high_bound - low_bound);
newValue = (dist - lowBound)/(highBound - lowBound);
}
// Update opacity
var self = this;
this.object3D.traverse(function(elt) {
if (elt instanceof THREE.Mesh) {
elt.material.transparent = new_value < 0.9;
elt.material.opacity = new_value;
elt.material.transparent = newValue < 0.9;
elt.material.opacity = newValue;
if (new_value < 0.1)
if (newValue < 0.1)
self.raycastable = elt.raycastable = elt.material.transparent = elt.visible = false;
}
});

View File

@ -42,8 +42,8 @@ L3D.ViewportRecommendation = function(arg1, arg2, arg3, arg4, position, target)
(function(self, direction, left, other) {
var material = new THREE.LineBasicMaterial({ color: '0x000000'});
var geometry = new THREE.Geometry();
var tmp_direction = L3D.Tools.mul(direction, -2);
var target = L3D.Tools.sum(self.camera.position, tmp_direction);
var tmpDirection = L3D.Tools.mul(direction, -2);
var target = L3D.Tools.sum(self.camera.position, tmpDirection);
// geometry.vertices.push(self.camera.position, target);
geometry.vertices.push(
L3D.Tools.sum(L3D.Tools.sum(self.camera.position, left), other),
@ -53,16 +53,16 @@ L3D.ViewportRecommendation = function(arg1, arg2, arg3, arg4, position, target)
L3D.Tools.sum(L3D.Tools.sum(self.camera.position, left), other),
L3D.Tools.sum(L3D.Tools.diff(self.camera.position, other), left),
L3D.Tools.sum(self.camera.position, tmp_direction),
L3D.Tools.sum(self.camera.position, tmpDirection),
L3D.Tools.sum(L3D.Tools.sum(self.camera.position, left), other),
L3D.Tools.sum(self.camera.position, tmp_direction),
L3D.Tools.sum(self.camera.position, tmpDirection),
L3D.Tools.diff(L3D.Tools.sum(self.camera.position, other),left),
L3D.Tools.sum(self.camera.position, tmp_direction),
L3D.Tools.sum(self.camera.position, tmpDirection),
L3D.Tools.diff(L3D.Tools.diff(self.camera.position, left),other),
L3D.Tools.sum(self.camera.position, tmp_direction),
L3D.Tools.sum(self.camera.position, tmpDirection),
L3D.Tools.sum(L3D.Tools.diff(self.camera.position, other), left)
);
@ -73,14 +73,14 @@ L3D.ViewportRecommendation = function(arg1, arg2, arg3, arg4, position, target)
var material = new THREE.MeshBasicMaterial();
var geometry = new THREE.Geometry();
var tmp_direction = L3D.Tools.mul(direction, -2);
var tmpDirection = L3D.Tools.mul(direction, -2);
geometry.vertices = [
L3D.Tools.sum(L3D.Tools.sum(self.camera.position, left), other),
L3D.Tools.diff(L3D.Tools.sum(self.camera.position, other),left),
L3D.Tools.diff(L3D.Tools.diff(self.camera.position, left),other),
L3D.Tools.sum(L3D.Tools.diff(self.camera.position, other), left),
L3D.Tools.sum(self.camera.position, tmp_direction)
L3D.Tools.sum(self.camera.position, tmpDirection)
];
geometry.faces = [
@ -145,22 +145,22 @@ L3D.ViewportRecommendation.prototype.update = function(position) {
// Compute distance between center of camera and position
dist = L3D.Tools.norm2(L3D.Tools.diff(position.position, this.camera.position));
var low_bound = 0.5;
var high_bound = 5;
var new_value;
var max_value = 0.5;
var lowBound = 0.5;
var highBound = 5;
var newValue;
var maxValue = 0.5;
if (dist < low_bound)
new_value = 0;
else if (dist > high_bound)
new_value = max_value;
if (dist < lowBound)
newValue = 0;
else if (dist > highBound)
newValue = maxValue;
else
new_value = max_value * (dist - low_bound)/(high_bound - low_bound);
newValue = maxValue * (dist - lowBound)/(highBound - lowBound);
this.mesh.material.transparent = new_value < 0.9;
this.mesh.material.opacity = new_value;
this.mesh.material.transparent = newValue < 0.9;
this.mesh.material.opacity = newValue;
this.raycastable = this.line.visible = this.mesh.material.transparent = this.mesh.visible = new_value > 0.1;
this.raycastable = this.line.visible = this.mesh.material.transparent = this.mesh.visible = newValue > 0.1;
};
L3D.ViewportRecommendation.prototype.setSize = function(size) {
@ -187,8 +187,8 @@ L3D.ViewportRecommendation.prototype.setSize = function(size) {
(function(self, direction, left, other, size) {
var tmp_direction = L3D.Tools.mul(direction, -2 * size);
var target = L3D.Tools.sum(self.camera.position, tmp_direction);
var tmpDirection = L3D.Tools.mul(direction, -2 * size);
var target = L3D.Tools.sum(self.camera.position, tmpDirection);
var vertices = [
L3D.Tools.sum(L3D.Tools.sum(self.camera.position, left), other),
@ -198,16 +198,16 @@ L3D.ViewportRecommendation.prototype.setSize = function(size) {
L3D.Tools.sum(L3D.Tools.sum(self.camera.position, left), other),
L3D.Tools.sum(L3D.Tools.diff(self.camera.position, other), left),
L3D.Tools.sum(self.camera.position, tmp_direction),
L3D.Tools.sum(self.camera.position, tmpDirection),
L3D.Tools.sum(L3D.Tools.sum(self.camera.position, left), other),
L3D.Tools.sum(self.camera.position, tmp_direction),
L3D.Tools.sum(self.camera.position, tmpDirection),
L3D.Tools.diff(L3D.Tools.sum(self.camera.position, other),left),
L3D.Tools.sum(self.camera.position, tmp_direction),
L3D.Tools.sum(self.camera.position, tmpDirection),
L3D.Tools.diff(L3D.Tools.diff(self.camera.position, left),other),
L3D.Tools.sum(self.camera.position, tmp_direction),
L3D.Tools.sum(self.camera.position, tmpDirection),
L3D.Tools.sum(L3D.Tools.diff(self.camera.position, other), left)
];
@ -218,14 +218,14 @@ L3D.ViewportRecommendation.prototype.setSize = function(size) {
(function(self, direction, left, other) {
var tmp_direction = L3D.Tools.mul(direction, -2 * size);
var tmpDirection = L3D.Tools.mul(direction, -2 * size);
self.collidingObject.geometry.vertices = [
L3D.Tools.sum(L3D.Tools.sum(self.camera.position, left), other),
L3D.Tools.diff(L3D.Tools.sum(self.camera.position, other),left),
L3D.Tools.diff(L3D.Tools.diff(self.camera.position, left),other),
L3D.Tools.sum(L3D.Tools.diff(self.camera.position, other), left),
L3D.Tools.sum(self.camera.position, tmp_direction)
L3D.Tools.sum(self.camera.position, tmpDirection)
];
})(this, direction, left, other, size);

View File

@ -8,13 +8,13 @@ L3D.LogFunction = function(a,b) {
};
L3D.addLight = function(scene) {
var directional_light = new THREE.DirectionalLight(0xdddddd);
directional_light.position.set(1, 2.5, 1).normalize();
directional_light.castShadow = false;
scene.add(directional_light);
var directionalLight = new THREE.DirectionalLight(0xdddddd);
directionalLight.position.set(1, 2.5, 1).normalize();
directionalLight.castShadow = false;
scene.add(directionalLight);
var ambient_light = new THREE.AmbientLight(0x555555);
scene.add(ambient_light);
var ambientLight = new THREE.AmbientLight(0x555555);
scene.add(ambientLight);
};
L3D.initPeachCastle = function(scene, collidableObjects, recommendation, clickable) {
@ -52,7 +52,7 @@ L3D.resetPeachElements = function() {
};
};
L3D.initPeach = function(camera, scene, coins, clickable, coin_ids) {
L3D.initPeach = function(camera, scene, coins, clickable, coinIds) {
L3D.addLight(scene);
var collidableObjects = [];
@ -67,7 +67,7 @@ L3D.initPeach = function(camera, scene, coins, clickable, coin_ids) {
scene.add(camera);
var tmp = L3D.generateCoins(L3D.createPeachCoins(), coin_ids);
var tmp = L3D.generateCoins(L3D.createPeachCoins(), coinIds);
for (var i in tmp) {
coins.push(tmp[i]);
@ -195,12 +195,12 @@ L3D.resetBobombElements = function() {
};
};
L3D.generateCoins = function(totalCoins, coin_ids) {
L3D.generateCoins = function(totalCoins, coinIds) {
var i = 0;
var tmp = [];
if (coin_ids === undefined) {
if (coinIds === undefined) {
tmp = [];
@ -215,17 +215,17 @@ L3D.generateCoins = function(totalCoins, coin_ids) {
totalCoins.push(tmp[coinsId[i]]);
}
} else if (coin_ids === null) {
} else if (coinIds === null) {
return [];
} else {
for (i = 0; i < coin_ids.length; i++) {
for (i = 0; i < coinIds.length; i++) {
for (var j = 0; j < totalCoins.length; j++) {
if (coin_ids[i] === totalCoins[j].id) {
if (coinIds[i] === totalCoins[j].id) {
// Swap i and j
tmp = totalCoins[i];
@ -241,7 +241,7 @@ L3D.generateCoins = function(totalCoins, coin_ids) {
var indices = [];
var coins = [];
var bound = (coin_ids instanceof Array && coin_ids.length === 0) ? totalCoins.length : 8;
var bound = (coinIds instanceof Array && coinIds.length === 0) ? totalCoins.length : 8;
for (i = 0; i < bound; i++) {
coins.push(totalCoins[i].coin);
@ -317,7 +317,7 @@ L3D.createBobombRecommendations = function(width, height) {
};
L3D.initBobomb = function(camera, scene, coins, clickable, coin_ids) {
L3D.initBobomb = function(camera, scene, coins, clickable, coinIds) {
L3D.addLight(scene);
var collidableObjects = [];
@ -333,13 +333,13 @@ L3D.initBobomb = function(camera, scene, coins, clickable, coin_ids) {
scene.add(camera);
Coin.init();
var tmp = L3D.generateCoins(L3D.createBobombCoins(), coin_ids);
var tmp = L3D.generateCoins(L3D.createBobombCoins(), coinIds);
for (var i in tmp) {
coins.push(tmp[i]);
}
var recommendations = L3D.createBobombRecommendations(container_size.width(), container_size.height());
var recommendations = L3D.createBobombRecommendations(containerSize.width(), containerSize.height());
recommendations.forEach(function(reco) {reco.addToScene(scene);});
@ -473,7 +473,7 @@ L3D.resetWhompElements = function() {
};
};
L3D.initWhomp = function(recommendation, scene, coins, clickable, coin_ids) {
L3D.initWhomp = function(recommendation, scene, coins, clickable, coinIds) {
L3D.addLight(scene);
var collidableObjects = [];
@ -489,13 +489,13 @@ L3D.initWhomp = function(recommendation, scene, coins, clickable, coin_ids) {
scene.add(recommendation);
Coin.init(0.002);
var tmp = L3D.generateCoins(L3D.createWhompCoins(), coin_ids);
var tmp = L3D.generateCoins(L3D.createWhompCoins(), coinIds);
for (var i in tmp) {
coins.push(tmp[i]);
}
var recommendations = L3D.createWhompRecommendations(container_size.width(), container_size.height());
var recommendations = L3D.createWhompRecommendations(containerSize.width(), containerSize.height());
recommendations.forEach(function(reco) {reco.addToScene(scene);});
@ -610,7 +610,7 @@ L3D.resetMountainElements = function() {
};
};
L3D.initMountain = function(recommendation, scene, coins, clickable, coin_ids) {
L3D.initMountain = function(recommendation, scene, coins, clickable, coinIds) {
L3D.addLight(scene);
var collidableObjects = [];
@ -626,13 +626,13 @@ L3D.initMountain = function(recommendation, scene, coins, clickable, coin_ids) {
scene.add(recommendation);
Coin.init();
var tmp = L3D.generateCoins(L3D.createMountainCoins(), coin_ids);
var tmp = L3D.generateCoins(L3D.createMountainCoins(), coinIds);
for (var i in tmp) {
coins.push(tmp[i]);
}
var recommendations = L3D.createMountainRecommendations(container_size.width(), container_size.height());
var recommendations = L3D.createMountainRecommendations(containerSize.width(), containerSize.height());
recommendations.forEach(function(reco) {reco.addToScene(scene);});
@ -691,8 +691,6 @@ L3D.initSponzaScene = function(scene, collidableObjects, recommendation, clickab
collidableObjects.push(loader.obj);
loader.obj.raycastable = true;
// ProgressiveLoader('/static/data/sponza/sponza.obj', scene,
// function(obj) {
// obj.scale.set(0.1,0.1,0.1);
@ -749,7 +747,7 @@ L3D.initSponza = function(recommendation, scene, coins, clickable) {
coins.push(tmp[i]);
}
var recommendations = L3D.createSponzaRecommendations(container_size.width(), container_size.height());
var recommendations = L3D.createSponzaRecommendations(containerSize.width(), containerSize.height());
recommendations.forEach(function(reco) {reco.addToScene(scene);});

View File

@ -100,7 +100,7 @@ L3D.DB.Event.ArrowClicked = function() {
* Id of the arrow
* @type {Number}
*/
this.arrow_id = null;
this.arrowId = null;
};
@ -109,7 +109,7 @@ L3D.DB.Event.ArrowClicked = function() {
*/
L3D.DB.Event.ArrowClicked.prototype.send = function() {
var url = "/posts/arrow-clicked";
var data = {arrow_id: this.arrow_id};
var data = {arrowId: this.arrowId};
L3D.DB.Private.sendData(url, data);
};
@ -124,7 +124,7 @@ L3D.DB.Event.CoinClicked = function() {
* Id of the coin taken
* @type {Number}
*/
this.coin_id = null;
this.coinId = null;
};
/**
@ -132,7 +132,7 @@ L3D.DB.Event.CoinClicked = function() {
*/
L3D.DB.Event.CoinClicked.prototype.send = function() {
var url = "/posts/coin-clicked";
var data = {coin_id: this.coin_id};
var data = {coinId: this.coinId};
L3D.DB.Private.sendData(url, data);
};
@ -222,7 +222,7 @@ L3D.DB.Event.Hovered = function() {
* The id of the arrow hovered
* @type {Number}
*/
this.arrow_id = null;
this.arrowId = null;
/**
* true if the hover starts, false if finishes
@ -239,7 +239,7 @@ L3D.DB.Event.Hovered.prototype.send = function() {
var url = "/posts/hovered";
var data = {
start: this.start,
arrow_id: this.arrow_id
arrowId: this.arrowId
};
L3D.DB.Private.sendData(url, data);

View File

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

View File

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

View File

@ -9,10 +9,10 @@ module.exports.index = function(req, res) {
"INSERT INTO hovered(exp_id, time, start, arrow_id)" +
"VALUES($1, to_timestamp($2), $3, $4);" ,
[
req.session.exp_id,
req.session.expId,
req.body.time,
req.body.start ? true : false,
req.body.arrow_id
req.body.arrowId
],
function(err, result) {
if (err !== null)

View File

@ -7,8 +7,8 @@ module.exports.index = function(req, res) {
db.checkUserName(req.body.inputId, function(ok) {
if (!ok) {
db.tryUser(req.session.user_id, function(id) {
req.session.user_id = id;
db.tryUser(req.session.userId, function(id) {
req.session.userId = id;
req.session.save();
pg.connect(secret.url, function(err, client, release) {
@ -18,7 +18,7 @@ module.exports.index = function(req, res) {
req.body.inputId,
req.body.inputAge,
req.body.inputGender === 'male',
req.session.user_id,
req.session.userId,
req.body.input3dskills,
req.body.inputLastTime
],

View File

@ -9,7 +9,7 @@ module.exports.index = function(req, res) {
"INSERT INTO keyboardevent(exp_id, camera, time, keycode, keypressed)" +
"VALUES($1, ROW(ROW($2,$3,$4),ROW($5,$6,$7)), to_timestamp($8), $9, $10);" ,
[
req.session.exp_id,
req.session.expId,
req.body.camera.position.x,
req.body.camera.position.y,
req.body.camera.position.z,

View File

@ -7,10 +7,10 @@ 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],
[req.session.expId, req.body.locked, req.body.time],
function(err, result) {
if (err !== null)
Log.dberror(err + ' in fps');
Log.dberror(err + ' in pointer-lock');
release();
}
);

View File

@ -9,7 +9,7 @@ module.exports.index = function(req, res) {
"INSERT INTO previousnextclicked(exp_id, previousnext, time, camera)" +
"VALUES($1, $2, to_timestamp($3), ROW(ROW($4,$5,$6), ROW($7,$8,$9)));" ,
[
req.session.exp_id,
req.session.expId,
req.body.previous ? 'p' : 'n',
req.body.time,
req.body.camera.position.x,

View File

@ -9,7 +9,7 @@ module.exports.index = function(req, res) {
"INSERT INTO resetclicked(exp_id, time)" +
"VALUES($1, to_timestamp($2));" ,
[
req.session.exp_id,
req.session.expId,
req.body.time
],
function(err, result) {

View File

@ -10,7 +10,7 @@ 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],
[req.session.expId, req.body.locked, req.body.time],
function(err, result) {
if (err !== null)
Log.dberror(err + ' in swithched lock option');

View File

@ -91,17 +91,17 @@ app.use(function(req, res) {
});
// Set ports and ip address
var server_port, server_ip_address;
var serverPort, serverIpAddress;
if ( isDev ) {
server_port = 4000;
server_ip_address = 'localhost';
serverPort = 4000;
serverIpAddress = 'localhost';
} else {
// Openhift conf
server_port = process.env.OPENSHIFT_NODEJS_PORT || 8080;
server_ip_address = process.env.OPENSHIFT_NODEJS_IP || '127.0.0.1';
serverPort = process.env.OPENSHIFT_NODEJS_PORT || 8080;
serverIpAddress = process.env.OPENSHIFT_NODEJS_IP || '127.0.0.1';
}
// Start server
http.listen(server_port, server_ip_address, function() {
Log.ready("Now listening " + server_ip_address + ":" + server_port);
http.listen(serverPort, serverIpAddress, function() {
Log.ready("Now listening " + serverIpAddress + ":" + serverPort);
});

View File

@ -7,6 +7,6 @@ module.exports.viewports = '/prototype/viewports/';
module.exports.stream = '/stream/';
module.exports.reverse = '/prototype/reverse/';
module.exports.sponza = '/prototype/sponza/';
module.exports.replay_index = '/prototype/replay/';
module.exports.replayIndex = '/prototype/replay/';
module.exports.tutorial = '/prototype/tutorial';
module.exports.logout = '/logout';