From fab183eaa76ebd5f77e0cdda02b6d57d638c438c Mon Sep 17 00:00:00 2001 From: Thomas FORGIONE Date: Wed, 1 Jul 2015 10:14:15 +0200 Subject: [PATCH] A lot of cleaning... jshint likes me now ! --- controllers/bouncing/index.js | 2 +- controllers/bouncing/urls.js | 2 +- controllers/index/index.js | 2 +- controllers/index/urls.js | 2 +- controllers/list/index.js | 2 +- controllers/list/urls.js | 2 +- controllers/logout/index.js | 2 +- controllers/logout/urls.js | 2 +- controllers/multisphere/index.js | 2 +- controllers/multisphere/urls.js | 2 +- controllers/prototype/dbrequests.js | 52 ++++++++-------- controllers/prototype/index.js | 18 +++--- controllers/prototype/urls.js | 2 +- controllers/stream/index.js | 4 +- geo/Mesh.js | 57 +++++++++--------- geo/MeshContainer.js | 4 +- geo/MeshStreamer.js | 26 ++++---- js/BouncingCube.js | 4 +- js/BufferGeometryToGeometry.js | 7 ++- js/Camera.js | 6 +- js/CameraContainer.js | 26 ++++---- js/Cube.js | 12 ++-- js/Hermite.js | 20 +++---- js/History.js | 14 ++--- js/List.js | 52 ++++++++-------- js/Logger.js | 26 ++++---- js/MousePointer.js | 8 +-- js/PointerCamera.js | 86 +++++++++++++-------------- js/ProgressiveLoader.js | 10 ++-- js/ProgressiveLoaderGeometry.js | 12 ++-- js/ProgressiveSphere.js | 6 +- js/StartCanvas.js | 10 ++-- js/Tools.js | 16 ++--- js/ToolsTest.js | 2 + js/TutoCamera.js | 89 ++++++++++++++-------------- js/bouncing/BouncingMain.js | 2 +- js/multisphere/MultiSphere.js | 40 +++++++------ js/prototype/ArrowCamera.js | 33 ++++++----- js/prototype/ButtonManager.js | 16 ++--- js/prototype/Coin.js | 20 +++---- js/prototype/FixedCamera.js | 2 +- js/prototype/OldFixedCamera.js | 26 ++++---- js/prototype/Previewer.js | 12 ++-- js/prototype/ReplayCamera.js | 53 ++++++++--------- js/prototype/ReverseCamera.js | 21 +++---- js/prototype/TutorialSteps.js | 16 ++--- js/prototype/initScene.js | 73 +++++++++++------------ js/prototype/raycasterTools.js | 71 +++++++++++++--------- js/prototype/replay.js | 4 +- js/prototype/tutorial.js | 2 +- lib/controllers.js | 18 ++++-- lib/filterInt.js | 2 +- lib/posts.js | 17 ++++-- posts/arrow-clicked/index.js | 2 +- posts/arrow-clicked/urls.js | 2 +- posts/coin-clicked/index.js | 2 +- posts/coin-clicked/urls.js | 2 +- posts/fps/index.js | 2 +- posts/fps/urls.js | 2 +- posts/hovered/index.js | 2 +- posts/hovered/urls.js | 2 +- posts/keyboard-event/index.js | 4 +- posts/keyboard-event/urls.js | 2 +- posts/previous-next-clicked/index.js | 2 +- posts/previous-next-clicked/urls.js | 2 +- posts/reset-clicked/index.js | 2 +- posts/reset-clicked/urls.js | 2 +- socket.js | 2 +- 68 files changed, 544 insertions(+), 505 deletions(-) diff --git a/controllers/bouncing/index.js b/controllers/bouncing/index.js index 85d49d5..301ab88 100644 --- a/controllers/bouncing/index.js +++ b/controllers/bouncing/index.js @@ -4,4 +4,4 @@ module.exports.index = function(req, res) { res.render('index.jade', res.locals, function(err, result) { res.send(result); }); -} +}; diff --git a/controllers/bouncing/urls.js b/controllers/bouncing/urls.js index 1288727..c3ce63c 100644 --- a/controllers/bouncing/urls.js +++ b/controllers/bouncing/urls.js @@ -1,3 +1,3 @@ module.exports = { '/bouncing' : 'index' -} +}; diff --git a/controllers/index/index.js b/controllers/index/index.js index 6ce7d1b..a81430a 100644 --- a/controllers/index/index.js +++ b/controllers/index/index.js @@ -4,4 +4,4 @@ module.exports.index = function(req, res) { res.render('index.jade', res.locals, function(err, out) { res.send(out); }); -} +}; diff --git a/controllers/index/urls.js b/controllers/index/urls.js index 6ebdf66..93705f9 100644 --- a/controllers/index/urls.js +++ b/controllers/index/urls.js @@ -1,3 +1,3 @@ module.exports = { '/': 'index' -} +}; diff --git a/controllers/list/index.js b/controllers/list/index.js index 6ce7d1b..a81430a 100644 --- a/controllers/list/index.js +++ b/controllers/list/index.js @@ -4,4 +4,4 @@ module.exports.index = function(req, res) { res.render('index.jade', res.locals, function(err, out) { res.send(out); }); -} +}; diff --git a/controllers/list/urls.js b/controllers/list/urls.js index 7cbc258..6a7e782 100644 --- a/controllers/list/urls.js +++ b/controllers/list/urls.js @@ -1,3 +1,3 @@ module.exports = { '/list': 'index' -} +}; diff --git a/controllers/logout/index.js b/controllers/logout/index.js index 966fad7..930787d 100644 --- a/controllers/logout/index.js +++ b/controllers/logout/index.js @@ -6,4 +6,4 @@ module.exports.index = function(req, res) { res.render('index.jade', res.locals, function(err, out) { res.send(out); }); -} +}; diff --git a/controllers/logout/urls.js b/controllers/logout/urls.js index c3476e1..1243eed 100644 --- a/controllers/logout/urls.js +++ b/controllers/logout/urls.js @@ -1,3 +1,3 @@ module.exports = { '/logout': 'index' -} +}; diff --git a/controllers/multisphere/index.js b/controllers/multisphere/index.js index 85d49d5..301ab88 100644 --- a/controllers/multisphere/index.js +++ b/controllers/multisphere/index.js @@ -4,4 +4,4 @@ module.exports.index = function(req, res) { res.render('index.jade', res.locals, function(err, result) { res.send(result); }); -} +}; diff --git a/controllers/multisphere/urls.js b/controllers/multisphere/urls.js index e3206ed..a412ebd 100644 --- a/controllers/multisphere/urls.js +++ b/controllers/multisphere/urls.js @@ -1,3 +1,3 @@ module.exports = { '/multisphere': 'index' -} +}; diff --git a/controllers/prototype/dbrequests.js b/controllers/prototype/dbrequests.js index 4caf494..710d318 100644 --- a/controllers/prototype/dbrequests.js +++ b/controllers/prototype/dbrequests.js @@ -23,7 +23,7 @@ var Info = function(id, finishAction) { self.release = release; self.execute(); }); -} +}; Info.prototype.execute = function() { this.loadCameras(); @@ -32,7 +32,7 @@ Info.prototype.execute = function() { this.loadResets(); this.loadPreviousNext(); this.loadHovered(); -} +}; Info.prototype.tryMerge = function() { // If not ready, do nothing @@ -49,7 +49,7 @@ Info.prototype.tryMerge = function() { this.merge(); this.finishAction(this.finalResult); -} +}; // Merges the results of every SQL requests done by the load... methods Info.prototype.merge = function() { @@ -76,7 +76,7 @@ Info.prototype.merge = function() { // Add the next element in results and shift its table this.finalResult.push(this.results[nextIndex].shift()); } -} +}; Info.prototype.loadCameras = function() { var self = this; @@ -114,7 +114,7 @@ Info.prototype.loadCameras = function() { self.tryMerge(); } ); -} +}; Info.prototype.loadCoins = function() { var self = this; @@ -136,7 +136,7 @@ Info.prototype.loadCoins = function() { self.tryMerge(); } ); -} +}; Info.prototype.loadArrows = function() { var self = this; @@ -158,7 +158,7 @@ Info.prototype.loadArrows = function() { self.tryMerge(); } ); -} +}; Info.prototype.loadResets = function() { var self = this; @@ -179,7 +179,7 @@ Info.prototype.loadResets = function() { self.tryMerge(); } ); -} +}; Info.prototype.loadPreviousNext = function () { var self = this; @@ -218,7 +218,7 @@ Info.prototype.loadPreviousNext = function () { self.tryMerge(); } ); -} +}; Info.prototype.loadHovered = function() { var self = this; @@ -241,7 +241,7 @@ Info.prototype.loadHovered = function() { self.tryMerge(); } ); -} +}; var UserCreator = function(finishAction) { this.finishAction = finishAction; @@ -253,7 +253,7 @@ var UserCreator = function(finishAction) { self.release = release; self.execute(); }); -} +}; UserCreator.prototype.execute = function() { var self = this; @@ -265,7 +265,7 @@ UserCreator.prototype.execute = function() { self.finish(); } ); -} +}; UserCreator.prototype.finish = function() { this.release(); @@ -273,7 +273,7 @@ UserCreator.prototype.finish = function() { this.release = null; this.finishAction(this.finalResult); -} +}; var ExpCreator = function(user_id, scene_id, finishAction) { this.finishAction = finishAction; @@ -287,7 +287,7 @@ var ExpCreator = function(user_id, scene_id, finishAction) { self.release = release; self.execute(); }); -} +}; ExpCreator.prototype.execute = function() { var self = this; @@ -301,7 +301,7 @@ ExpCreator.prototype.execute = function() { }); } ); -} +}; ExpCreator.prototype.finish = function() { this.release(); @@ -309,7 +309,7 @@ ExpCreator.prototype.finish = function() { this.release = null; this.finishAction(this.finalResult); -} +}; var UserIdChecker = function(id, finishAction) { this.id = id; @@ -321,7 +321,7 @@ var UserIdChecker = function(id, finishAction) { self.release = release; self.execute(); }); -} +}; UserIdChecker.prototype.execute = function() { var self = this; @@ -333,7 +333,7 @@ UserIdChecker.prototype.execute = function() { self.finish(); } ); -} +}; UserIdChecker.prototype.finish = function() { this.release(); @@ -341,7 +341,7 @@ UserIdChecker.prototype.finish = function() { this.release = null; this.finishAction(this.finalResult); -} +}; var ExpIdChecker = function(id, finishAction) { this.id = id; @@ -353,7 +353,7 @@ var ExpIdChecker = function(id, finishAction) { self.release = release; self.execute(); }); -} +}; ExpIdChecker.prototype.execute = function() { var self = this; @@ -369,7 +369,7 @@ ExpIdChecker.prototype.execute = function() { self.finish(); } ); -} +}; ExpIdChecker.prototype.finish = function() { this.release(); @@ -377,7 +377,7 @@ ExpIdChecker.prototype.finish = function() { this.release = null; this.finishAction(this.finalResult); -} +}; var ExpGetter = function(finishAction) { this.finishAction = finishAction; @@ -388,7 +388,7 @@ var ExpGetter = function(finishAction) { self.release = release; self.execute(); }); -} +}; ExpGetter.prototype.execute = function() { var self = this; @@ -407,7 +407,7 @@ ExpGetter.prototype.execute = function() { self.finish(); } ); -} +}; ExpGetter.prototype.finish = function() { this.release(); @@ -415,7 +415,7 @@ ExpGetter.prototype.finish = function() { this.release = null; this.finishAction(this.finalResult); -} +}; var tryUser = function(id, callback) { if (id !== undefined && id !== null) { @@ -429,7 +429,7 @@ var tryUser = function(id, callback) { } else { new UserCreator(callback); } -} +}; module.exports.getInfo = function(id, callback) { new Info(id, callback); }; module.exports.createUser = function(callback) { new UserCreator(callback); }; diff --git a/controllers/prototype/index.js b/controllers/prototype/index.js index 2d5f4e4..dd4d4ab 100644 --- a/controllers/prototype/index.js +++ b/controllers/prototype/index.js @@ -38,7 +38,7 @@ module.exports.index = function(req, res) { res.render('index.jade', res.locals, function(err, result) { res.send(result); }); -} +}; var generateSceneNumber = function(req, res) { if (req.session.scenes !== undefined) { @@ -49,7 +49,7 @@ var generateSceneNumber = function(req, res) { } return req.session.scenes[req.session.currentSceneIndex]; -} +}; var sceneToFunction = function(scene) { switch (scene) { @@ -62,7 +62,7 @@ var sceneToFunction = function(scene) { default: return 'initPeach'; } -} +}; var protoHelper = function(template) { return function(req, res) { @@ -82,7 +82,7 @@ var protoHelper = function(template) { }); }); }; -} +}; module.exports.arrows = protoHelper('prototype_arrows.jade'); module.exports.viewports = protoHelper('prototype_viewports.jade'); @@ -94,7 +94,7 @@ module.exports.sponza = function(req, res) { res.render('sponza.jade', res.locals, function(err, result) { res.send(result); }); -} +}; module.exports.replay_info = function(req, res) { res.setHeader('Content-Type', 'text/plain'); @@ -105,7 +105,7 @@ module.exports.replay_info = function(req, res) { db.getInfo(id, function(results) { res.send(JSON.stringify(results)); }); -} +}; module.exports.replay = function(req, res, next) { // Get id parameter @@ -124,7 +124,7 @@ module.exports.replay = function(req, res, next) { }); } }); -} +}; module.exports.replay_index = function(req, res, next) { db.getAllExps(function(result) { @@ -135,7 +135,7 @@ module.exports.replay_index = function(req, res, next) { res.send(result); }); }); -} +}; module.exports.tutorial = function(req, res) { @@ -144,4 +144,4 @@ module.exports.tutorial = function(req, res) { res.render('tutorial.jade', res.lcals, function(err, result) { res.send(result); }); -} +}; diff --git a/controllers/prototype/urls.js b/controllers/prototype/urls.js index 6c7399a..17ad99b 100644 --- a/controllers/prototype/urls.js +++ b/controllers/prototype/urls.js @@ -8,4 +8,4 @@ module.exports = { '/prototype/replay_info/:id': 'replay_info', '/prototype/tutorial': 'tutorial', '/prototype/sponza': 'sponza' -} +}; diff --git a/controllers/stream/index.js b/controllers/stream/index.js index 17bdafd..326ea82 100644 --- a/controllers/stream/index.js +++ b/controllers/stream/index.js @@ -1,4 +1,4 @@ -var tools = require('../../lib/filterInt') +var tools = require('../../lib/filterInt'); module.exports.index = function(req, res, next) { @@ -22,4 +22,4 @@ module.exports.index = function(req, res, next) { res.render('index.jade', res.locals, function(err, result) { res.send(result); }); -} +}; diff --git a/geo/Mesh.js b/geo/Mesh.js index 091a339..a1c53cc 100644 --- a/geo/Mesh.js +++ b/geo/Mesh.js @@ -12,7 +12,7 @@ geo.Mesh = function() { this.material = null; this.started = false; this.finished = false; -} +}; /** * Checks if there are normals in the mesh @@ -20,7 +20,7 @@ geo.Mesh = function() { */ geo.Mesh.prototype.hasNormals = function() { return this.normals.length > 0; -} +}; /** * Checks if there are texture coordinates in the mesh @@ -28,7 +28,7 @@ geo.Mesh.prototype.hasNormals = function() { */ geo.Mesh.prototype.hasTexCoords = function() { return this.texCoords.length > 0; -} +}; /** * Adds a vertex to a mesh @@ -46,7 +46,7 @@ geo.Mesh.prototype.addVertex = function(vertex) { } return this.vertices[this.vertices.length - 1]; -} +}; /** * Adds a face to a mesh @@ -70,7 +70,7 @@ geo.Mesh.prototype.addFaces = function(face) { } else { return faces; } -} +}; /** * Adds a texture coordinate to a mesh @@ -87,7 +87,7 @@ geo.Mesh.prototype.addTexCoord = function(texCoord) { } return this.texCoords[this.texCoords.length - 1]; -} +}; /** * Adds a normal to a mesh @@ -104,11 +104,11 @@ geo.Mesh.prototype.addNormal = function(normal) { } return this.normals[this.normals.length - 1]; -} +}; geo.Mesh.prototype.isFinished = function() { return this.faceIndex === this.faces.length; -} +}; /** * Represent a 3D vertex @@ -143,7 +143,7 @@ geo.Vertex = function() { * @type {Boolean} */ this.sent = false; -} +}; /** * Gives a list representation of the vertex @@ -156,7 +156,7 @@ geo.Vertex = function() { */ geo.Vertex.prototype.toList = function() { return ['v', this.index, this.x, this.y, this.z]; -} +}; /** * Gives a string representation of the vertex @@ -168,7 +168,7 @@ geo.Vertex.prototype.toList = function() { */ geo.Vertex.prototype.toString = function() { return 'v ' + this.x + ' ' + this.y + ' ' + this.z; -} +}; /** * Represent a 3D normal @@ -178,7 +178,7 @@ geo.Vertex.prototype.toString = function() { */ geo.Normal = function() { geo.Vertex.apply(this, arguments); -} +}; geo.Normal.prototype = Object.create(geo.Vertex.prototype); geo.Normal.prototype.constructor = geo.Normal; @@ -196,7 +196,7 @@ geo.Normal.prototype.toList = function() { var superObject = geo.Vertex.prototype.toList.call(this); superObject[0] = 'vn'; return superObject; -} +}; /** * Gives a string representation of the normal @@ -210,7 +210,7 @@ geo.Normal.prototype.toString = function() { var superObject = geo.Vertex.prototype.toString.call(this); superObject.replace('v', 'vn'); return superObject; -} +}; /** * Represent a texture coordinate element @@ -239,7 +239,7 @@ geo.TexCoord = function() { * @type {Boolean} */ this.sent = false; -} +}; /** * Gives a list representation of the texture coordinate @@ -252,7 +252,7 @@ geo.TexCoord = function() { */ geo.TexCoord.prototype.toList = function() { return ['vt', this.index, this.x, this.y]; -} +}; /** * Gives a string representation of the texture coordinate @@ -264,7 +264,7 @@ geo.TexCoord.prototype.toList = function() { */ geo.TexCoord.prototype.toString = function() { return 'vt ' + this.x + ' ' + this.y; -} +}; /** @@ -273,17 +273,18 @@ geo.TexCoord.prototype.toString = function() { * @memberOf geo */ geo.Face = function() { + var split; if (typeof arguments[0] === 'string' || arguments[0] instanceof String) { if (arguments[0].indexOf('/') === -1) { // No / : easy win : "f 1 2 3" or "f 1 2 3 4" - var split = arguments[0].replace(/\s+/g, ' ').split(' '); + split = arguments[0].replace(/\s+/g, ' ').split(' '); this.a = parseInt(split[1]) - 1; this.b = parseInt(split[2]) - 1; this.c = parseInt(split[3]) - 1; } else { // There might be textures coords - var split = arguments[0].replace(/\s+/g, ' ').trim().split(' '); + split = arguments[0].replace(/\s+/g, ' ').trim().split(' '); // Split elements var split1 = split[1].split('/'); @@ -357,7 +358,7 @@ geo.Face = function() { */ this.sent = false; -} +}; /** * Parse a face line and returns an array of faces @@ -390,7 +391,7 @@ var parseFace = function(arg) { } return ret; -} +}; /** * Returns the max index of the vertices of the face @@ -402,7 +403,7 @@ geo.Face.prototype.max = function() { } else { return Math.max(this.a, this.b, this.c); } -} +}; /** * Returns the max index of the texture coordinates of the face @@ -414,7 +415,7 @@ geo.Face.prototype.maxTexture = function() { } else { return Math.max(this.aTexture, this.bTexture, this.cTexture); } -} +}; /** * Gives a list representation of the face @@ -452,7 +453,7 @@ geo.Face.prototype.toList = function() { // l.push(this.dTexture); return l; -} +}; /** * Gives a string representation of the face @@ -464,7 +465,7 @@ geo.Face.prototype.toList = function() { */ geo.Face.prototype.toString = function() { return 'f ' + this.a + ' ' + this.b + ' ' + this.c + (this.d !== undefined ? ' ' + this.d : ''); -} +}; /** * Represents a material name @@ -480,7 +481,7 @@ geo.Material = function() { * @type {string} */ this.name = split[1]; -} +}; /** * Gives a string representation of the material @@ -488,7 +489,7 @@ geo.Material = function() { */ geo.Material.prototype.toString = function() { return 'usemtl ' + this.name; -} +}; /** * Gives a list representation of the material @@ -499,5 +500,5 @@ geo.Material.prototype.toString = function() { */ geo.Material.prototype.toList = function() { return ['u', this.name]; -} +}; diff --git a/geo/MeshContainer.js b/geo/MeshContainer.js index 85edfb0..db36b3e 100644 --- a/geo/MeshContainer.js +++ b/geo/MeshContainer.js @@ -42,7 +42,7 @@ geo.MeshContainer = function(path) { } -} +}; /** * Loads a obj file @@ -133,7 +133,7 @@ geo.MeshContainer.prototype.loadFromFile = function(path) { } -} +}; var availableMeshNames = [ '/static/data/castle/princess peaches castle (outside).obj', diff --git a/geo/MeshStreamer.js b/geo/MeshStreamer.js index 81c8c7c..b70b6ea 100644 --- a/geo/MeshStreamer.js +++ b/geo/MeshStreamer.js @@ -95,7 +95,7 @@ geo.MeshStreamer = function(path) { } -} +}; /** * Compute a function that can compare two faces @@ -145,7 +145,7 @@ geo.MeshStreamer.prototype.faceComparator = function(camera) { x: (self.vertices[face2.a].x + self.vertices[face2.b].x + self.vertices[face2.b].x) / 3, y: (self.vertices[face2.a].y + self.vertices[face2.b].y + self.vertices[face2.b].y) / 3, z: (self.vertices[face2.a].z + self.vertices[face2.b].z + self.vertices[face2.b].z) / 3 - } + }; var dir2 = { x: center2.x - camera.position.x, @@ -170,8 +170,8 @@ geo.MeshStreamer.prototype.faceComparator = function(camera) { } return 0; - } -} + }; +}; /** * Initialize the socket.io callback @@ -243,7 +243,7 @@ geo.MeshStreamer.prototype.start = function(socket) { } }); -} +}; /** * Prepare the array of materials @@ -271,7 +271,7 @@ geo.MeshStreamer.prototype.nextMaterials = function() { return data; -} +}; /** * Prepare the next elements @@ -281,6 +281,8 @@ geo.MeshStreamer.prototype.nextMaterials = function() { */ geo.MeshStreamer.prototype.nextElements = function(_camera, force) { + var i; + if (force === undefined) { force = false; @@ -305,9 +307,9 @@ geo.MeshStreamer.prototype.nextElements = function(_camera, force) { y: _camera[1][1], z: _camera[1][2] } - } + }; - for (var i = 2; i < _camera.length; i++) { + for (i = 2; i < _camera.length; i++) { planes.push({ normal: { @@ -325,7 +327,7 @@ geo.MeshStreamer.prototype.nextElements = function(_camera, force) { x: camera.target.x - camera.position.x, y: camera.target.y - camera.position.y, z: camera.target.z - camera.position.z - } + }; } @@ -400,7 +402,7 @@ geo.MeshStreamer.prototype.nextElements = function(_camera, force) { var exitToContinue = false; threeVertices = [vertex1, vertex2, vertex3]; - for (var i = 0; i < threeVertices.length; i++) { + for (i = 0; i < threeVertices.length; i++) { var vertex = threeVertices[i]; @@ -530,10 +532,10 @@ geo.MeshStreamer.prototype.nextElements = function(_camera, force) { return {data: data, finished: mightBeCompletetlyFinished}; -} +}; geo.MeshStreamer.prototype.isFinished = function(i) { return this.meshFaces[i].counter === this.meshFaces[i].array.length; -} +}; diff --git a/js/BouncingCube.js b/js/BouncingCube.js index 3cb9809..ac51096 100644 --- a/js/BouncingCube.js +++ b/js/BouncingCube.js @@ -5,7 +5,7 @@ var BouncingCube = function(size, style) { this.center = new THREE.Vector3(); this.speed = new THREE.Vector3(0,0,300); -} +}; BouncingCube.prototype = Object.create(Cube.prototype); BouncingCube.prototype.constructor = BouncingCube; @@ -27,7 +27,7 @@ BouncingCube.prototype.update = function() { // Update the mesh this.mesh.position.set(this.center.x, this.center.y, this.center.z); -} +}; // Static variables BouncingCube.DT = new THREE.Vector3(0.1,0.1,0.1); diff --git a/js/BufferGeometryToGeometry.js b/js/BufferGeometryToGeometry.js index d7fcb42..2211880 100644 --- a/js/BufferGeometryToGeometry.js +++ b/js/BufferGeometryToGeometry.js @@ -11,7 +11,8 @@ Converter.toGeometry = function (bg) { var vertices = []; - for(var i = 0, n = positions.length; i < n; i += 3) { + var i; + for(i = 0, n = positions.length; i < n; i += 3) { var x = positions[i]; var y = positions[i + 1]; var z = positions[i + 2]; @@ -20,7 +21,7 @@ Converter.toGeometry = function (bg) { var faces = []; - for(var i = 0, n = vertices.length; i < n; i += 3) { + for(i = 0, n = vertices.length; i < n; i += 3) { faces.push(new THREE.Face3(i, i + 1, i + 2)); } @@ -29,4 +30,4 @@ Converter.toGeometry = function (bg) { geometry.faces = faces; geometry.computeFaceNormals(); return geometry; -} +}; diff --git a/js/Camera.js b/js/Camera.js index d1bf1ca..bc059bb 100644 --- a/js/Camera.js +++ b/js/Camera.js @@ -8,7 +8,7 @@ var Camera = function() { this.up = new THREE.Vector3(0,0,1); this.target = new THREE.Vector3(); -} +}; Camera.prototype = Object.create(THREE.PerspectiveCamera.prototype); // Update function @@ -19,12 +19,12 @@ Camera.prototype.update = function(time) { this.theta += 0.01 * time / 20; this.position.x = Camera.DISTANCE_X*Math.cos(this.theta); this.position.y = Camera.DISTANCE_X*Math.sin(this.theta); -} +}; // Look function Camera.prototype.look = function() { this.lookAt(this.target); -} +}; // Static members Camera.DISTANCE_X = 1000; diff --git a/js/CameraContainer.js b/js/CameraContainer.js index b4edb20..bd6e2cb 100644 --- a/js/CameraContainer.js +++ b/js/CameraContainer.js @@ -8,7 +8,7 @@ var CameraContainer = function (pointerCamera, cameras) { if (pointerCamera !== undefined) { this.push(pointerCamera); } -} +}; CameraContainer.prototype.mainCamera = function(id) { if (id === undefined) { @@ -20,35 +20,35 @@ CameraContainer.prototype.mainCamera = function(id) { } this.current_camera = id; -} +}; CameraContainer.prototype.forEach = function(callback) { callback(this.pointerCamera); this.cameras.forEach(callback); -} +}; CameraContainer.prototype.look = function() { this.mainCamera().look(); -} +}; CameraContainer.prototype.updateMainCamera = function(time) { this.pointerCamera.update(time); -} +}; CameraContainer.prototype.update = function(position) { this.cameras.map(function (elt) { elt.update(position); }); -} +}; CameraContainer.prototype.push = function(camera) { this.pointerCamera = camera; this.push = function(camera) { this.cameras.push(camera); }; -} +}; CameraContainer.prototype.get = function(i) { return this.cameras[i]; -} +}; CameraContainer.prototype.getByObject = function(object) { for (var i in this.cameras) { @@ -56,22 +56,22 @@ CameraContainer.prototype.getByObject = function(object) { return this.get(i); } } -} +}; CameraContainer.prototype.setById = function(id) { var i = this.getById(id); if (i !== -1) this.current_camera = i; -} +}; CameraContainer.prototype.nextCamera = function() { - if (this.cameras.length != 0) { + if (this.cameras.length !== 0) { this.current_camera++; this.current_camera%=this.cameras.length; } -} +}; CameraContainer.prototype.map = function(callback) { this.cameras.map(callback); -} +}; diff --git a/js/Cube.js b/js/Cube.js index 7323c9a..02eac45 100644 --- a/js/Cube.js +++ b/js/Cube.js @@ -1,14 +1,14 @@ var Displayable = function() { // Nothing to do here -} +}; Displayable.prototype.addToScene = function(scene) { scene.add(this.mesh); -} +}; Displayable.prototype.translate = function(x,y,z) { this.geometry.applyMatrix(new THREE.Matrix4().makeTranslation(x,y,z)); -} +}; // class Cube extends Displayable var Cube = function(size, style) { @@ -24,7 +24,7 @@ var Cube = function(size, style) { this.mesh = new THREE.Mesh(this.geometry, this.material); this.mesh.castShadow = false; -} +}; Cube.prototype = Object.create(Displayable.prototype); Cube.prototype.constructor = Cube; @@ -40,10 +40,10 @@ var Plane = function(size1, size2, style) { this.mesh = new THREE.Mesh(this.geometry, this.material); this.mesh.receiveShadow = true; -} +}; Plane.prototype = Object.create(Displayable.prototype); Plane.prototype.constructor = Plane; Plane.prototype.addToScene = function(scene) { scene.add(this.mesh); -} +}; diff --git a/js/Hermite.js b/js/Hermite.js index 990cfcf..0972e2b 100644 --- a/js/Hermite.js +++ b/js/Hermite.js @@ -5,7 +5,7 @@ Hermite.Polynom = function(t, f, fp) { this.evals = f; this.primes = fp; - this.baseFunctions = new Array(); + this.baseFunctions = []; for (var i in this.times) { this.baseFunctions.push(new Hermite.BaseFunction(i, this.times)); @@ -22,7 +22,7 @@ Hermite.Polynom = function(t, f, fp) { this.tools.sum = function(a, b) { return a + b; }; this.tools.prod = function(a, b) { return a * b; }; } -} +}; Hermite.Polynom.prototype.eval = function(t) { var ret; @@ -65,7 +65,7 @@ Hermite.Polynom.prototype.eval = function(t) { } return ret; -} +}; Hermite.Polynom.prototype.prime = function(t) { var ret; @@ -139,12 +139,12 @@ Hermite.Polynom.prototype.prime = function(t) { } return ret; -} +}; Hermite.BaseFunction = function(index, times) { this.index = index; this.times = times; -} +}; Hermite.BaseFunction.prototype.eval = function(t) { var ret = 1; @@ -156,7 +156,7 @@ Hermite.BaseFunction.prototype.eval = function(t) { } return ret * ret; -} +}; Hermite.BaseFunction.prototype.prime = function(t) { var ret = 0; @@ -168,7 +168,7 @@ Hermite.BaseFunction.prototype.prime = function(t) { } return this.eval(t) * ret; -} +}; Hermite.special = {}; @@ -190,12 +190,12 @@ Hermite.special.Polynom = function(P0, P1, PP1) { this.a = this.tools.sum(PP1, this.tools.diff(P0, P1)); this.b = this.tools.diff(this.tools.mul(this.tools.diff(P1,P0), 2), PP1); -} +}; Hermite.special.Polynom.prototype.eval = function(t) { return this.tools.sum(this.tools.mul(this.a, t*t), this.tools.sum(this.tools.mul(this.b, t), this.c)); -} +}; Hermite.special.Polynom.prototype.prime = function(t) { return this.tools.sum(this.tools.mul(this.a,2*t), this.b); -} +}; diff --git a/js/History.js b/js/History.js index fc755cc..06659e5 100644 --- a/js/History.js +++ b/js/History.js @@ -20,7 +20,7 @@ var History = function() { * @type {Number} */ this.size = 0; -} +}; /** * Appends a new state at the end of the history @@ -30,7 +30,7 @@ History.prototype.addState = function(state) { ++this.index; this.size = this.index + 1; this.states[this.size-1] = state; -} +}; /** * Returns the previous state and change the index to the previous state (so you can redo) @@ -40,7 +40,7 @@ History.prototype.undo = function() { this.index--; return this.currentState(); } -} +}; /** * Returns the next state and change the index to the next state (so you can re-undo) @@ -50,7 +50,7 @@ History.prototype.redo = function() { this.index++; return this.currentState(); } -} +}; /** * Checks if there is a undo possibility @@ -58,7 +58,7 @@ History.prototype.redo = function() { */ History.prototype.undoable = function() { return this.index > 0; -} +}; /** * Checks if there is a redo possibility @@ -66,7 +66,7 @@ History.prototype.undoable = function() { */ History.prototype.redoable = function() { return this.index < this.size - 1; -} +}; /** * Returns the current state in the history @@ -74,4 +74,4 @@ History.prototype.redoable = function() { */ History.prototype.currentState = function() { return this.states[this.index]; -} +}; diff --git a/js/List.js b/js/List.js index a78124d..a734dcc 100644 --- a/js/List.js +++ b/js/List.js @@ -7,12 +7,12 @@ utils.List = function() { this._size = 0; this._begin = null; this._end = null; -} +}; // Returns the number of element of a list utils.List.prototype.size = function() { return this._size; -} +}; // Pushes an element to the end of a class utils.List.prototype.push = function(element) { @@ -26,7 +26,7 @@ utils.List.prototype.push = function(element) { this._end = newObject; this._size++; } -} +}; // Sort the list utils.List.prototype.sort = function(comparator) { @@ -50,14 +50,14 @@ utils.List.prototype.sort = function(comparator) { for (var i = 0; i < size; i++) { this.push(array[i]); } -} +}; // Remove last element and returns it utils.List.prototype.pop = function() { var tmp = this._end; this._end = null; return tmp.data; -} +}; // Apply a function to each element of the list utils.List.prototype.forEach = function(callback) { @@ -67,7 +67,7 @@ utils.List.prototype.forEach = function(callback) { callback(chain.data); chain = chain.next; } -} +}; // Apply a function to each element of the list (starting from the end) utils.List.prototype.forEachInverse = function(callback) { @@ -77,7 +77,7 @@ utils.List.prototype.forEachInverse = function(callback) { callback(chain.data); chain = chain.prev; } -} +}; // Get ith element of the list utils.List.prototype.at = function(ith) { @@ -91,18 +91,20 @@ utils.List.prototype.at = function(ith) { } return chain.data; -} +}; // Clear the list utils.List.prototype.clear = function() { this._begin = null; this._end = null; this._size = 0; -} +}; // Insert an element at the right place in the list // Precondition : list must be sorted utils.List.prototype.insertSorted = function(elt, comparator) { + var newElement; + if (comparator === undefined) { comparator = priv.defaultComparator; } @@ -112,7 +114,7 @@ utils.List.prototype.insertSorted = function(elt, comparator) { this.push(elt); } else if (comparator(this._begin.data, elt) > 0) { // Inserted in front (smallest element) - var newElement = {prev: null, next: this._begin, data: elt}; + newElement = {prev: null, next: this._begin, data: elt}; this._begin.prev = newElement; @@ -129,7 +131,7 @@ utils.List.prototype.insertSorted = function(elt, comparator) { while (chain.next !== null) { // If chain < elt < chain.next if (comparator(chain.next.data, elt) > 0) { - var newElement = {data: elt, next: chain.next, prev: chain}; + newElement = {data: elt, next: chain.next, prev: chain}; if (chain.next) { chain.next.prev = newElement; } @@ -142,7 +144,7 @@ utils.List.prototype.insertSorted = function(elt, comparator) { chain = chain.next; } } -} +}; // Check if a list is sorted of not utils.List.prototype.isSorted = function(comparator) { @@ -160,65 +162,65 @@ utils.List.prototype.isSorted = function(comparator) { } return true; -} +}; // Gives an iterator to the begin of the list utils.List.prototype.begin = function() { return new utils.List.Iterator(this._begin, 0); -} +}; // Gives an iterator to the end of the list utils.List.prototype.end = function() { return new utils.List.Iterator(this._end, this.size() - 1); -} +}; // Class iterator utils.List.Iterator = function(chain, counter) { this._chain = chain; this._counter = counter; -} +}; // Go to the next element utils.List.Iterator.prototype.next = function() { this._chain = this._chain.next; this._counter ++; -} +}; // Go to the previous element utils.List.Iterator.prototype.prev = function() { this._chain = this._chain.prev; this._counter --; -} +}; // Return the current element utils.List.Iterator.prototype.get = function() { return this._chain.data; -} +}; // Check if there is another element next utils.List.Iterator.prototype.hasNext = function() { return this._chain.next !== null; -} +}; // Check if there is another element before utils.List.Iterator.prototype.hasPrev = function() { return this._chain.prev !== null; -} +}; // Compares to another iterator of the same list utils.List.Iterator.prototype.lowerThan = function(it2) { return utils.distance(this, it2) > 0; -} +}; // Compares to another iterator of the same list utils.List.Iterator.prototype.greaterThan = function(it2) { return utils.distance(this, it2) < 0; -} +}; // Returns the distance between two iterators of the same list utils.distance = function(it1, it2) { return it2._counter - it1._counter; -} +}; priv = {}; @@ -228,7 +230,7 @@ priv.defaultComparator = function(a,b) { if (a > b) return 1; return 0; -} +}; // Support for NodeJs if (typeof module !== 'undefined' && module.exports) { diff --git a/js/Logger.js b/js/Logger.js index 318e1ea..4467a80 100644 --- a/js/Logger.js +++ b/js/Logger.js @@ -19,17 +19,17 @@ BD.Private.sendData = function(url, data) { xhr.send(JSON.stringify(data)); } -} +}; BD.Private.enabled = true; BD.enable = function() { BD.Private.enabled = true; -} +}; BD.disable = function() { BD.Private.enabled = false; -} +}; BD.Private.compactCamera = function(camera) { return { @@ -44,7 +44,7 @@ BD.Private.compactCamera = function(camera) { z: camera.target.z } }; -} +}; BD.Event = {}; @@ -53,14 +53,14 @@ BD.Event.ArrowClicked.prototype.send = function() { var url = "/arrow-clicked"; var data = {arrow_id: this.arrow_id}; BD.Private.sendData(url, data); -} +}; BD.Event.CoinClicked = function() {}; BD.Event.CoinClicked.prototype.send = function() { var url = "/coin-clicked"; var data = {coin_id: this.coin_id}; BD.Private.sendData(url, data); -} +}; BD.Event.KeyboardEvent = function() {}; BD.Event.KeyboardEvent.prototype.send = function() { @@ -68,17 +68,17 @@ BD.Event.KeyboardEvent.prototype.send = function() { var data = { camera: BD.Private.compactCamera(this.camera) - } + }; BD.Private.sendData(url, data); -} +}; BD.Event.ResetClicked = function() {}; BD.Event.ResetClicked.prototype.send = function() { var url = "/reset-clicked"; var data = {}; BD.Private.sendData(url, data); -} +}; BD.Event.PreviousNextClicked = function() {}; BD.Event.PreviousNextClicked.prototype.send = function() { @@ -90,7 +90,7 @@ BD.Event.PreviousNextClicked.prototype.send = function() { }; BD.Private.sendData(url, data); -} +}; BD.Event.Hovered = function() {}; BD.Event.Hovered.prototype.send = function() { @@ -101,7 +101,7 @@ BD.Event.Hovered.prototype.send = function() { }; BD.Private.sendData(url, data); -} +}; BD.Event.Fps = function() {}; BD.Event.Fps.prototype.send = function() { @@ -109,8 +109,8 @@ BD.Event.Fps.prototype.send = function() { var url = "/fps"; var data = { fps: this.fps - } + }; BD.Private.sendData(url, data); -} +}; diff --git a/js/MousePointer.js b/js/MousePointer.js index d4c26db..b7f39b4 100644 --- a/js/MousePointer.js +++ b/js/MousePointer.js @@ -8,7 +8,7 @@ var MousePointer = function(camera) { this.drawn = false; camera.mousePointer = this; this.style = MousePointer.NONE; -} +}; MousePointer.NONE = 0; MousePointer.BLACK = 1; @@ -27,7 +27,7 @@ MousePointer.toColor = function(style) { } -} +}; MousePointer.prototype.render = function(style) { @@ -73,10 +73,10 @@ MousePointer.prototype.render = function(style) { } -} +}; MousePointer.prototype.clear = function() { this.render(MousePointer.NONE); -} +}; diff --git a/js/PointerCamera.js b/js/PointerCamera.js index 198ba51..49fa8da 100644 --- a/js/PointerCamera.js +++ b/js/PointerCamera.js @@ -177,7 +177,7 @@ var PointerCamera = function() { * @param {Object} */ this.resetElements = resetBobombElements(); -} +}; PointerCamera.prototype = Object.create(THREE.PerspectiveCamera.prototype); PointerCamera.prototype.constructor = PointerCamera; @@ -201,7 +201,7 @@ PointerCamera.prototype.lockPointer = function() { } -} +}; /** * Check that the pointer is locked or not, and updated locked attribute @@ -215,7 +215,7 @@ PointerCamera.prototype.isLocked = function() { return toto; -} +}; /** * Update the camera when the pointer lock changes state @@ -253,7 +253,7 @@ PointerCamera.prototype.onPointerLockChange = function() { } -} +}; /** * Update the position of the camera @@ -267,7 +267,7 @@ PointerCamera.prototype.update = function(time) { } else { this.normalMotion(time); } -} +}; /** * Update the camera according to its linear motion @@ -285,17 +285,17 @@ PointerCamera.prototype.linearMotion = function(time) { this.moving = false; this.anglesFromVectors(); } -} +}; /** * Update the camera according to its hermite motion * @param {Number} time number of milliseconds between the previous and the next frame */ PointerCamera.prototype.hermiteMotion = function(time) { - var eval = this.hermitePosition.eval(this.t); - this.position.x = eval.x; - this.position.y = eval.y; - this.position.z = eval.z; + var e = this.hermitePosition.eval(this.t); + this.position.x = e.x; + this.position.y = e.y; + this.position.z = e.z; this.target = Tools.sum(this.position, this.hermiteAngles.eval(this.t)); @@ -305,7 +305,7 @@ PointerCamera.prototype.hermiteMotion = function(time) { this.movingHermite = false; this.anglesFromVectors(); } -} +}; /** * Update the camera according to the user's input @@ -379,7 +379,7 @@ PointerCamera.prototype.normalMotion = function(time) { // Update angle this.target = this.position.clone(); this.target.add(forward); -} +}; /** * Reset the camera to its resetElements, and finishes any motion @@ -389,7 +389,7 @@ PointerCamera.prototype.reset = function() { this.moving = false; this.movingHermite = false; (new BD.Event.ResetClicked()).send(); -} +}; /** * Reset the position of th camera @@ -398,7 +398,7 @@ PointerCamera.prototype.resetPosition = function() { this.position.copy(this.resetElements.position); this.target.copy(this.resetElements.target); this.anglesFromVectors(); -} +}; /** * Computes the vectors (forward, left, ...) according to theta and phi @@ -412,7 +412,7 @@ PointerCamera.prototype.vectorsFromAngles = function() { this.forward.x = cos * Math.sin(this.theta); this.forward.normalize(); -} +}; /** * Computes theta and phi according to the vectors (forward, left, ...) @@ -426,7 +426,7 @@ PointerCamera.prototype.anglesFromVectors = function() { // Don't know why this line works... But thanks Thierry-san and // Bastien because it seems to work... this.theta = Math.atan2(forward.x, forward.z); -} +}; /** * Creates a linear motion to another camera @@ -453,7 +453,7 @@ PointerCamera.prototype.move = function(otherCamera, toSave) { } this.history.addState({position: otherCamera.position.clone(), target: otherCamera.target.clone()}); } -} +}; /** * Creates a hermite motion to another camera @@ -486,7 +486,7 @@ PointerCamera.prototype.moveHermite = function(otherCamera, toSave) { } this.history.addState({position: otherCamera.position.clone(), target: otherCamera.target.clone()}); } -} +}; /** * Checks the collisions between the collidables objects and the camera @@ -505,21 +505,21 @@ PointerCamera.prototype.isColliding = function(direction) { } return false; -} +}; /** * Look method. Equivalent to gluLookAt for the current camera */ PointerCamera.prototype.look = function() { this.lookAt(this.target); -} +}; /** * Adds the camera to the scene */ PointerCamera.prototype.addToScene = function(scene) { scene.add(this); -} +}; /** * Manages keyboard events @@ -553,11 +553,11 @@ PointerCamera.prototype.onKeyEvent = function(event, toSet) { } if (motionJsonCopy != JSON.stringify(this.motion)) { // Log any change - var event = new BD.Event.KeyboardEvent(); - event.camera = this; - event.send(); + var e = new BD.Event.KeyboardEvent(); + e.camera = this; + e.send(); } -} +}; /** * Manages the key pressed events @@ -565,7 +565,7 @@ PointerCamera.prototype.onKeyEvent = function(event, toSet) { */ PointerCamera.prototype.onKeyDown = function(event) { this.onKeyEvent(event, true); -} +}; /** * Manages the key released events @@ -573,7 +573,7 @@ PointerCamera.prototype.onKeyDown = function(event) { */ PointerCamera.prototype.onKeyUp = function(event) { this.onKeyEvent(event, false); -} +}; /** * Manages the mouse down events. Start drag'n'dropping if the options are set to drag'n'drop @@ -589,7 +589,7 @@ PointerCamera.prototype.onMouseDown = function(event) { this.dragging = true; this.mouseMoved = false; } -} +}; /** * Manages the mouse move events. Modifies the target of the camera according to the drag'n'drop motion @@ -607,7 +607,7 @@ PointerCamera.prototype.onMouseMove = function(event) { this.mouseMoved = true; } -} +}; /** * Manages the mouse move envent in case of pointer lock @@ -631,7 +631,7 @@ PointerCamera.prototype.onMouseMovePointer = function(e) { } -} +}; /** * Manages the mouse up event. Stops the dragging @@ -642,21 +642,21 @@ PointerCamera.prototype.onMouseUp = function(event) { // Send log to DB if (this.dragging && this.mouseMoved && !this.moving && !this.movingHermite) { - var event = new BD.Event.KeyboardEvent(); - event.camera = this; - event.send(); + var e = new BD.Event.KeyboardEvent(); + e.camera = this; + e.send(); } this.dragging = false; -} +}; /** * Logs the camera to the terminal (pratical to create recommended views) */ PointerCamera.prototype.log = function() { - console.log("createCamera(\nnew THREE.Vector3(" + this.position.x + "," + this.position.y + ',' + this.position.z + '),\n' - + "new THREE.Vector3(" + this.target.x + "," + this.target.y + ',' + this.target.z + ')\n)'); -} + console.log("createCamera(\nnew THREE.Vector3(" + this.position.x + "," + this.position.y + ',' + this.position.z + '),\n' + + "new THREE.Vector3(" + this.target.x + "," + this.target.y + ',' + this.target.z + ')\n)'); +}; /** * Save the current state of the camera in the history @@ -666,7 +666,7 @@ PointerCamera.prototype.save = function() { backup.position = this.position.clone(); backup.target = this.target.clone(); this.history.addState(backup); -} +}; /** * Undo last motion according to the history @@ -681,7 +681,7 @@ PointerCamera.prototype.undo = function() { this.move(move, false); } -} +}; /** * Redo last motion according to the history @@ -696,7 +696,7 @@ PointerCamera.prototype.redo = function() { this.move(move, false); } -} +}; /** * Checks if there is a undo possibility in the history @@ -704,7 +704,7 @@ PointerCamera.prototype.redo = function() { */ PointerCamera.prototype.undoable = function() { return this.history.undoable(); -} +}; /** * Checks if there is a redo possibility in the history @@ -712,7 +712,7 @@ PointerCamera.prototype.undoable = function() { */ PointerCamera.prototype.redoable = function() { return this.history.redoable(); -} +}; PointerCamera.prototype.toList = function() { this.updateMatrix(); @@ -739,5 +739,5 @@ PointerCamera.prototype.toList = function() { } return ret; -} +}; diff --git a/js/ProgressiveLoader.js b/js/ProgressiveLoader.js index e586d5d..93ba00d 100644 --- a/js/ProgressiveLoader.js +++ b/js/ProgressiveLoader.js @@ -61,7 +61,7 @@ var _parseList = function(arr) { } return ret; -} +}; var ProgressiveLoader = function(path, scene, camera, callback) { // Init attributes @@ -89,7 +89,7 @@ var ProgressiveLoader = function(path, scene, camera, callback) { this.camera = camera; -} +}; ProgressiveLoader.prototype.load = function() { @@ -104,7 +104,7 @@ ProgressiveLoader.prototype.load = function() { self.start(); }); -} +}; ProgressiveLoader.prototype.initIOCallbacks = function() { @@ -278,9 +278,9 @@ ProgressiveLoader.prototype.initIOCallbacks = function() { console.log('Finished !'); self.finished = true; }); -} +}; ProgressiveLoader.prototype.start = function() { this.socket.emit('request', this.objPath); -} +}; diff --git a/js/ProgressiveLoaderGeometry.js b/js/ProgressiveLoaderGeometry.js index 49557d2..aacbf85 100644 --- a/js/ProgressiveLoaderGeometry.js +++ b/js/ProgressiveLoaderGeometry.js @@ -66,7 +66,7 @@ var _parseList2 = function(arr) { } return ret; -} +}; /** * Loads a mesh from socket.io @@ -175,7 +175,7 @@ var ProgressiveLoaderGeometry = function(path, scene, camera, callback) { */ this.camera = camera; -} +}; /** * Starts the loading of the mesh @@ -193,7 +193,7 @@ ProgressiveLoaderGeometry.prototype.load = function() { self.start(); }); -} +}; /** * Will return a list representation of the camera (to be sent to the server) @@ -203,7 +203,7 @@ ProgressiveLoaderGeometry.prototype.getCamera = function() { return null; return this.toList(); -} +}; /** * Initializes the socket.io functions so that it can discuss with the server @@ -366,12 +366,12 @@ ProgressiveLoaderGeometry.prototype.initIOCallbacks = function() { console.log('Finished !'); self.finished = true; }); -} +}; /** * Starts the communication with the server */ ProgressiveLoaderGeometry.prototype.start = function() { this.socket.emit('request', this.objPath); -} +}; diff --git a/js/ProgressiveSphere.js b/js/ProgressiveSphere.js index ae4bbcf..1aeebb0 100644 --- a/js/ProgressiveSphere.js +++ b/js/ProgressiveSphere.js @@ -29,7 +29,7 @@ var ProgessiveSphere = function(loader, res) { }); })(this); -} +}; ProgessiveSphere.prototype = Object.create(Displayable.prototype); ProgessiveSphere.prototype.constructor = ProgessiveSphere; @@ -81,9 +81,9 @@ ProgessiveSphere.prototype.addFace = function() { this.wasFinished = true; console.log("Finished reconstructing the mesh !"); } -} +}; ProgessiveSphere.prototype.addToScene = function(scene) { Displayable.prototype.addToScene.call(this, scene); this.addedToScene = true; -} +}; diff --git a/js/StartCanvas.js b/js/StartCanvas.js index e194dba..5502cca 100644 --- a/js/StartCanvas.js +++ b/js/StartCanvas.js @@ -8,17 +8,17 @@ var StartCanvas = function(camera) { camera.startCanvas = this; -} +}; StartCanvas.prototype.render = function() { if (!this.shown) { - this.ctx.fillStyle = 'white' + this.ctx.fillStyle = 'white'; this.ctx.globalAlpha = 0.7; this.ctx.fillRect(0,0,this.domElement.width, this.domElement.height); - this.ctx.font = '30px Verdana' + 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); @@ -28,7 +28,7 @@ StartCanvas.prototype.render = function() { } -} +}; StartCanvas.prototype.clear = function() { @@ -41,4 +41,4 @@ StartCanvas.prototype.clear = function() { } -} +}; diff --git a/js/Tools.js b/js/Tools.js index 4190f7d..6664812 100644 --- a/js/Tools.js +++ b/js/Tools.js @@ -2,15 +2,15 @@ var Tools = {version : "1.0" }; Tools.sum = function(v1, v2) { return new THREE.Vector3(v1.x + v2.x, v1.y + v2.y, v1.z + v2.z); -} +}; Tools.diff = function(v1, v2) { return new THREE.Vector3(v1.x - v2.x, v1.y - v2.y, v1.z - v2.z); -} +}; Tools.dot = function(v1, v2) { return v1.x * v2.x + v1.y * v2.y + v1.z * v2.z; -} +}; Tools.cross = function(v1, v2) { return new THREE.Vector3( @@ -18,20 +18,20 @@ Tools.cross = function(v1, v2) { v1.z * v2.x - v1.x * v2.z, v1.x * v2.y - v1.y * v2.x ); -} +}; Tools.mul = function(v1, lambda) { return new THREE.Vector3(v1.x * lambda, v1.y * lambda, v1.z * lambda); -} +}; Tools.equals = function(v1, v2) { return v1.x == v2.x && v1.y == v2.y && v1.z == v2.z; -} +}; Tools.norm2 = function(v) { return v.x * v.x + v.y * v.y + v.z * v.z; -} +}; Tools.norm = function(v) { return Math.sqrt(Tools.norm2(v)); -} +}; diff --git a/js/ToolsTest.js b/js/ToolsTest.js index f2f2ec2..1160b02 100644 --- a/js/ToolsTest.js +++ b/js/ToolsTest.js @@ -1,3 +1,5 @@ +// We will be doing a lot of document.write, so let's remove jshint warnings +/* jshint evil:true */ function test(b) { if (b) document.write("
  • Success !
  • "); diff --git a/js/TutoCamera.js b/js/TutoCamera.js index 8eb4db2..fb706cb 100644 --- a/js/TutoCamera.js +++ b/js/TutoCamera.js @@ -82,7 +82,7 @@ var TutoCamera = function() { this.shouldLock = true; -} +}; TutoCamera.prototype = Object.create(THREE.PerspectiveCamera.prototype); TutoCamera.prototype.constructor = TutoCamera; @@ -102,7 +102,7 @@ TutoCamera.prototype.lockPointer = function() { } -} +}; TutoCamera.prototype.isLocked = function() { var toto = @@ -112,7 +112,7 @@ TutoCamera.prototype.isLocked = function() { return toto; -} +}; TutoCamera.prototype.onPointerLockChange = function() { @@ -155,7 +155,7 @@ TutoCamera.prototype.onPointerLockChange = function() { } -} +}; // Update function TutoCamera.prototype.update = function(time) { @@ -166,7 +166,7 @@ TutoCamera.prototype.update = function(time) { } else { this.normalMotion(time); } -} +}; TutoCamera.prototype.linearMotion = function(time) { var position_direction = Tools.diff(this.new_position, this.position); @@ -180,13 +180,13 @@ TutoCamera.prototype.linearMotion = function(time) { this.moving = false; this.anglesFromVectors(); } -} +}; TutoCamera.prototype.hermiteMotion = function(time) { - var eval = this.hermitePosition.eval(this.t); - this.position.x = eval.x; - this.position.y = eval.y; - this.position.z = eval.z; + var e = this.hermitePosition.eval(this.t); + this.position.x = e.x; + this.position.y = e.y; + this.position.z = e.z; this.target = Tools.sum(this.position, this.hermiteAngles.eval(this.t)); @@ -196,7 +196,7 @@ TutoCamera.prototype.hermiteMotion = function(time) { this.movingHermite = false; this.anglesFromVectors(); } -} +}; TutoCamera.prototype.normalMotion = function(time) { // Update angles @@ -262,7 +262,7 @@ TutoCamera.prototype.normalMotion = function(time) { // Update angle this.target = this.position.clone(); this.target.add(forward); -} +}; TutoCamera.prototype.reset = function() { if (this.tutorial.nextAction() === 'reset-camera') { @@ -276,13 +276,13 @@ TutoCamera.prototype.reset = function() { this.previousTheta = this.theta; this.previousPhi = this.phi; -} +}; TutoCamera.prototype.resetPosition = function() { this.position.copy(this.resetElements.position); this.target.copy(this.resetElements.target); this.anglesFromVectors(); -} +}; TutoCamera.prototype.vectorsFromAngles = function() { // Update direction @@ -293,7 +293,7 @@ TutoCamera.prototype.vectorsFromAngles = function() { this.forward.x = cos * Math.sin(this.theta); this.forward.normalize(); -} +}; TutoCamera.prototype.anglesFromVectors = function() { var forward = Tools.diff(this.target, this.position); @@ -304,7 +304,7 @@ TutoCamera.prototype.anglesFromVectors = function() { // Don't know why this line works... But thanks Thierry-san and // Bastien because it seems to work... this.theta = Math.atan2(forward.x, forward.z); -} +}; TutoCamera.prototype.move = function(otherCamera, toSave) { if (toSave === undefined) @@ -326,7 +326,7 @@ TutoCamera.prototype.move = function(otherCamera, toSave) { } this.history.addState({position: otherCamera.position.clone(), target: otherCamera.target.clone()}); } -} +}; TutoCamera.prototype.moveHermite = function(otherCamera, toSave) { if (this.tutorial.nextAction() === 'recommendation') { @@ -358,7 +358,7 @@ TutoCamera.prototype.moveHermite = function(otherCamera, toSave) { } this.history.addState({position: otherCamera.position.clone(), target: otherCamera.target.clone()}); } -} +}; TutoCamera.prototype.isColliding = function(direction) { this.raycaster.set(this.position, direction.clone().normalize()); @@ -370,23 +370,24 @@ TutoCamera.prototype.isColliding = function(direction) { return intersects[i]; } } -} +}; // Look function TutoCamera.prototype.look = function() { this.lookAt(this.target); -} +}; TutoCamera.prototype.addToScene = function(scene) { scene.add(this); -} +}; TutoCamera.prototype.onKeyEvent = function(event, toSet) { // Create copy of state var motionJsonCopy = JSON.stringify(this.motion); + var moved; if (this.allowed.keyboardTranslate) { - var moved = true; + moved = true; switch ( event.keyCode ) { // Azerty keyboards @@ -411,7 +412,7 @@ TutoCamera.prototype.onKeyEvent = function(event, toSet) { } if (this.allowed.keyboardRotate) { - var moved = true; + moved = true; switch ( event.keyCode ) { case 73: case 104: this.motion.increasePhi = toSet; break; // 8 Up for angle @@ -433,19 +434,19 @@ TutoCamera.prototype.onKeyEvent = function(event, toSet) { if (motionJsonCopy != JSON.stringify(this.motion)) { // Log any change - var event = new BD.Event.KeyboardEvent(); - event.camera = this; - event.send(); + var e = new BD.Event.KeyboardEvent(); + e.camera = this; + e.send(); } -} +}; TutoCamera.prototype.onKeyDown = function(event) { this.onKeyEvent(event, true); -} +}; TutoCamera.prototype.onKeyUp = function(event) { this.onKeyEvent(event, false); -} +}; TutoCamera.prototype.onMouseDown = function(event) { this.mouse.x = ( ( event.clientX - this.renderer.domElement.offsetLeft ) / this.renderer.domElement.width ) * 2 - 1; @@ -455,7 +456,7 @@ TutoCamera.prototype.onMouseDown = function(event) { this.dragging = true; this.mouseMoved = false; } -} +}; TutoCamera.prototype.onMouseMove = function(event) { if (!this.shouldLock && this.dragging) { @@ -474,7 +475,7 @@ TutoCamera.prototype.onMouseMove = function(event) { this.tutorial.nextStep(); } } -} +}; TutoCamera.prototype.onMouseMovePointer = function(e) { @@ -494,32 +495,32 @@ TutoCamera.prototype.onMouseMovePointer = function(e) { } -} +}; TutoCamera.prototype.onMouseUp = function(event) { this.onMouseMove(event); // Send log to DB if (this.dragging && this.mouseMoved && !this.moving && !this.movingHermite) { - var event = new BD.Event.KeyboardEvent(); - event.camera = this; - event.send(); + var e = new BD.Event.KeyboardEvent(); + e.camera = this; + e.send(); } this.dragging = false; -} +}; TutoCamera.prototype.log = function() { - console.log("createCamera(\nnew THREE.Vector3(" + this.position.x + "," + this.position.y + ',' + this.position.z + '),\n' - + "new THREE.Vector3(" + this.target.x + "," + this.target.y + ',' + this.target.z + ')\n)'); -} + console.log("createCamera(\nnew THREE.Vector3(" + this.position.x + "," + this.position.y + ',' + this.position.z + '),\n' + + "new THREE.Vector3(" + this.target.x + "," + this.target.y + ',' + this.target.z + ')\n)'); +}; TutoCamera.prototype.save = function() { var backup = {}; backup.position = this.position.clone(); backup.target = this.target.clone(); this.history.addState(backup); -} +}; TutoCamera.prototype.undo = function() { var move = this.history.undo(); @@ -531,7 +532,7 @@ TutoCamera.prototype.undo = function() { this.move(move, false); } -} +}; TutoCamera.prototype.redo = function() { var move = this.history.redo(); @@ -543,12 +544,12 @@ TutoCamera.prototype.redo = function() { this.move(move, false); } -} +}; TutoCamera.prototype.undoable = function() { return this.history.undoable(); -} +}; TutoCamera.prototype.redoable = function() { return this.history.redoable(); -} +}; diff --git a/js/bouncing/BouncingMain.js b/js/bouncing/BouncingMain.js index 6ec5a02..0dcac7d 100644 --- a/js/bouncing/BouncingMain.js +++ b/js/bouncing/BouncingMain.js @@ -1,7 +1,7 @@ var renderer, scene, camera, controls, cube, container, plane, mouse= {x:0, y:0}; var raycaster; var objects = []; -var container_size = new Object(); +var container_size = {}; var previousTime; container_size.width = 1067; container_size.height = 600; diff --git a/js/multisphere/MultiSphere.js b/js/multisphere/MultiSphere.js index 97165ce..b07b113 100644 --- a/js/multisphere/MultiSphere.js +++ b/js/multisphere/MultiSphere.js @@ -7,13 +7,30 @@ var visible = 0; var loader, previousTime; -var container_size = new Object(); +var container_size = {}; container_size.width = 1067; container_size.height = 600; init(); animate(); +function loadSphere(i) { + loader.load('/static/data/spheres/' + (i+1) + '.obj', function (object) { + object.traverse(function (child) { + if (child instanceof THREE.Mesh ) { + child.material.color.setHex(0xff0000); + child.up = new THREE.Vector3(0,0,1); + child.geometry.computeFaceNormals(); + child.geometry.computeVertexNormals(); + } + }); + spheres[i] = object; + scene.add(object); + if (i !== 0) + hide(object); + }); +} + function init() { // on initialise le moteur de rendu container = document.getElementById('container'); @@ -49,24 +66,9 @@ function init() { loader = new THREE.OBJLoader(); for (var i = 0; i < mesh_number; i++) { - // Capture of i - // I am pretty good - (function(i) { - loader.load('/static/data/spheres/' + (i+1) + '.obj', function (object) { - object.traverse(function (child) { - if (child instanceof THREE.Mesh ) { - child.material.color.setHex(0xff0000); - child.up = new THREE.Vector3(0,0,1); - child.geometry.computeFaceNormals(); - child.geometry.computeVertexNormals(); - } - }); - spheres[i] = object; - scene.add(object); - if (i != 0) - hide(object); - }); - })(i); + + loadSphere(i); + } diff --git a/js/prototype/ArrowCamera.js b/js/prototype/ArrowCamera.js index 6621b6a..475d974 100644 --- a/js/prototype/ArrowCamera.js +++ b/js/prototype/ArrowCamera.js @@ -37,7 +37,7 @@ var ArrowCamera = function(arg1, arg2, arg3, arg4, position, target) { this.fullArrow = false; -} +}; ArrowCamera.prototype = Object.create(THREE.PerspectiveCamera.prototype); ArrowCamera.prototype.constructor = ArrowCamera; @@ -46,7 +46,7 @@ ArrowCamera.prototype.check = function() { if (obj instanceof THREE.Mesh) obj.material.color.setHex(0x663366); }); -} +}; ArrowCamera.prototype.initExtremity = function() { var geometry = new THREE.Geometry(); @@ -90,7 +90,7 @@ ArrowCamera.prototype.initExtremity = function() { this.mesh = new THREE.Mesh(geometry, material); return this.mesh; -} +}; ArrowCamera.prototype.updateExtremity = function() { var direction = this.target.clone(); @@ -116,12 +116,12 @@ ArrowCamera.prototype.updateExtremity = function() { this.mesh.geometry.computeFaceNormals(); this.mesh.geometry.verticesNeedUpdate = true; -} +}; ArrowCamera.prototype.setSize = function(size) { this.size = size; this.updateExtremity(); -} +}; // Update function ArrowCamera.prototype.update = function(mainCamera) { @@ -154,10 +154,11 @@ ArrowCamera.prototype.update = function(mainCamera) { }); this.regenerateArrow(mainCamera); -} +}; ArrowCamera.prototype.regenerateArrow = function(mainCamera) { - var vertices = new Array(); + var i; + var vertices = []; // First point of curve var f0 = mainCamera.position.clone(); @@ -202,7 +203,7 @@ ArrowCamera.prototype.regenerateArrow = function(mainCamera) { var limit = this.fullArrow ? 0.1 : 0.3; // for (var i = this.fullArrow ? 0 : 0.5; i <= 1.001; i += 0.05) { - for (var i = 1; i > limit; i -= 0.1) { + for (i = 1; i > limit; i -= 0.1) { point = hermite.eval(i); deriv = hermite.prime(i); up.cross(deriv); @@ -224,10 +225,10 @@ ArrowCamera.prototype.regenerateArrow = function(mainCamera) { this.arrow.geometry.vertices = vertices; - if (this.arrow.geometry.faces.length == 0) { - var faces = new Array(); + if (this.arrow.geometry.faces.length === 0) { + var faces = []; - for (var i = 0; i < vertices.length - 4; i+= 4) { + for (i = 0; i < vertices.length - 4; i+= 4) { faces.push(new THREE.Face3(i,i+1,i+5),new THREE.Face3(i,i+5,i+4), new THREE.Face3(i+1,i+2,i+6),new THREE.Face3(i+1,i+6,i+5), new THREE.Face3(i+2,i+3,i+7),new THREE.Face3(i+2,i+7,i+6), @@ -262,22 +263,22 @@ ArrowCamera.prototype.regenerateArrow = function(mainCamera) { this.arrow.geometry.groupsNeedUpdate = true; this.arrow.geometry.normalsNeedUpdate = true; -} +}; // Look function ArrowCamera.prototype.look = function() { this.lookAt(this.target); -} +}; ArrowCamera.prototype.addToScene = function(scene) { scene.add(this); scene.add(this.object3D); -} +}; ArrowCamera.prototype.traverse = function(callback) { this.object3D.traverse(callback); -} +}; ArrowCamera.prototype.containsObject = function(object) { return object.parent === this.object3D; -} +}; diff --git a/js/prototype/ButtonManager.js b/js/prototype/ButtonManager.js index d2e3f95..cbdfe9c 100644 --- a/js/prototype/ButtonManager.js +++ b/js/prototype/ButtonManager.js @@ -19,8 +19,8 @@ var ButtonManager = function(cameras, previewer) { this.fullscreenElement.onclick = function() {fullscreen();}; (function(self) { - self.undoElement.onclick = function() {self.cameras.mainCamera().undo(); self.updateElements();} - self.redoElement.onclick = function() {self.cameras.mainCamera().redo(); self.updateElements();} + self.undoElement.onclick = function() {self.cameras.mainCamera().undo(); self.updateElements();}; + self.redoElement.onclick = function() {self.cameras.mainCamera().redo(); self.updateElements();}; self.fullElement.onclick = function() { self.cameras.map(function(camera) { @@ -34,21 +34,21 @@ var ButtonManager = function(cameras, previewer) { self.pointerLockElement.onchange = function() { self.cameras.mainCamera().shouldLock = self.pointerLockElement.checked; self.cameras.mainCamera().onPointerLockChange(); - } + }; - self.showarrowsElement.onchange = function() {self.showArrows = self.showarrowsElement.checked;} + self.showarrowsElement.onchange = function() {self.showArrows = self.showarrowsElement.checked;}; self.resetElement.onclick = function() { // Reinit camera self.cameras.mainCamera().reset(); - } + }; self.recommendationElement.onchange = function() { previewer.fixedRecommendation(self.recommendationElement.checked); - } + }; })(this); -} +}; ButtonManager.prototype.updateElements = function() { // Update icon @@ -63,5 +63,5 @@ ButtonManager.prototype.updateElements = function() { } else { this.redoElement.className = "btn btn-primary navbar-btn"; } -} +}; diff --git a/js/prototype/Coin.js b/js/prototype/Coin.js index 85b4118..af12250 100644 --- a/js/prototype/Coin.js +++ b/js/prototype/Coin.js @@ -6,7 +6,7 @@ var Coin = function(x,y,z, callback) { this.callback = callback; this.rotating = true; } -} +}; var _toto = new Audio(); Coin.extension = _toto.canPlayType("audio/x-vorbis") === "" ? ".ogg" : ".mp3"; @@ -28,7 +28,7 @@ Coin.initSize = function() { setTimeout(100, Coin.initSize); return; } -} +}; Coin.update = function() { @@ -56,7 +56,7 @@ Coin.update = function() { Coin.ctx.stroke(); Coin.ctx.fill(); -} +}; Coin.image.onload = Coin.update; @@ -79,17 +79,17 @@ Coin.prototype.init = function(x,y,z) { },1000); })(this,x,y,z); } -} +}; Coin.prototype.addToScene = function(scene) { scene.add(this.mesh); -} +}; Coin.prototype.update = function() { var self = this; if (this.ready && this.rotating) - this.mesh.rotation.y += 0.1 -} + this.mesh.rotation.y += 0.1; +}; Coin.prototype.get = function() { if (!this.got) { @@ -127,7 +127,7 @@ Coin.prototype.get = function() { Coin.update(); } -} +}; Coin.lastSound = new Audio('/static/data/music/starappears' + Coin.extension); Coin.lastSound.preload = "auto"; @@ -155,7 +155,7 @@ Coin.init = function(scale) { mesh.material.color.setHex(0xff0000); mesh.geometry.computeVertexNormals(); mesh.raycastable = true; - Coin.BASIC_MESH = mesh + Coin.BASIC_MESH = mesh; } }); } @@ -163,4 +163,4 @@ Coin.init = function(scale) { Coin.nextSound = new Audio('/static/data/music/redcoins/1' + Coin.extension); } -} +}; diff --git a/js/prototype/FixedCamera.js b/js/prototype/FixedCamera.js index c59f485..1bddb31 100644 --- a/js/prototype/FixedCamera.js +++ b/js/prototype/FixedCamera.js @@ -3,7 +3,7 @@ // class camera extends THREE.PerspectiveCamera var FixedCamera = function(arg1, arg2, arg3, arg4, position, target) { ArrowCamera.apply(this, arguments); -} +}; FixedCamera.prototype = Object.create(ArrowCamera.prototype); FixedCamera.prototype.constructor = FixedCamera; diff --git a/js/prototype/OldFixedCamera.js b/js/prototype/OldFixedCamera.js index b858a71..ae0967d 100644 --- a/js/prototype/OldFixedCamera.js +++ b/js/prototype/OldFixedCamera.js @@ -50,8 +50,8 @@ var OldFixedCamera = 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 direction = Tools.mul(direction, -2); - var target = Tools.sum(self.position, direction); + var tmp_direction = Tools.mul(direction, -2); + var target = Tools.sum(self.position, tmp_direction); // geometry.vertices.push(self.position, target); geometry.vertices.push( Tools.sum(Tools.sum(self.position, left), other), @@ -61,16 +61,16 @@ var OldFixedCamera = function(arg1, arg2, arg3, arg4, position, target) { Tools.sum(Tools.sum(self.position, left), other), Tools.sum(Tools.diff(self.position, other), left), - Tools.sum(self.position, direction), + Tools.sum(self.position, tmp_direction), Tools.sum(Tools.sum(self.position, left), other), - Tools.sum(self.position, direction), + Tools.sum(self.position, tmp_direction), Tools.diff(Tools.sum(self.position, other),left), - Tools.sum(self.position, direction), + Tools.sum(self.position, tmp_direction), Tools.diff(Tools.diff(self.position, left),other), - Tools.sum(self.position, direction), + Tools.sum(self.position, tmp_direction), Tools.sum(Tools.diff(self.position, other), left) ); @@ -87,13 +87,13 @@ var OldFixedCamera = function(arg1, arg2, arg3, arg4, position, target) { this.mesh = new THREE.Mesh(geometry, material); this.mesh.raycastable = true; -} +}; OldFixedCamera.prototype = Object.create(THREE.PerspectiveCamera.prototype); OldFixedCamera.prototype.constructor = OldFixedCamera; OldFixedCamera.prototype.check = function() { this.mesh.material.color.setHex(0x663366); -} +}; // Update function OldFixedCamera.prototype.update = function(position) { @@ -117,25 +117,25 @@ OldFixedCamera.prototype.update = function(position) { if (new_value < 0.1) this.mesh.material.transparent = this.mesh.visible = false; -} +}; // Look function OldFixedCamera.prototype.look = function() { this.lookAt(this.target); -} +}; OldFixedCamera.prototype.addToScene = function(scene) { scene.add(this); scene.add(this.mesh); scene.add(this.line); -} +}; OldFixedCamera.prototype.traverse = function(callback) { callback(this.mesh); callback(this.line); -} +}; OldFixedCamera.prototype.containsObject = function(object) { return object === this.mesh; -} +}; diff --git a/js/prototype/Previewer.js b/js/prototype/Previewer.js index 49363aa..c1f82c3 100644 --- a/js/prototype/Previewer.js +++ b/js/prototype/Previewer.js @@ -1,6 +1,6 @@ Math.clamp = Math.clamp || function(number, min, max) { return Math.max(Math.min(number, max), min); -} +}; var Previewer = function(renderer, scene) { this.domElement = document.createElement('canvas'); @@ -10,7 +10,7 @@ var Previewer = function(renderer, scene) { this.scene = scene; this.drawn = false; this.drawnBefore = false; -} +}; Previewer.prototype.render = function(prev, container_width, container_height) { var width, height, left, bottom; @@ -77,20 +77,20 @@ Previewer.prototype.render = function(prev, container_width, container_height) { this.clearNeeded = true; } -} +}; Previewer.prototype.clear = function() { if (this.clearNeeded) { this.domElement.width = this.domElement.width; this.clearNeeded = false; } -} +}; Previewer.prototype.fixedRecommendation = function(bool) { this.fixed = bool; -} +}; Previewer.prototype.update = function(arg) { this.drawnBefore = this.drawn; this.drawn = arg; -} +}; diff --git a/js/prototype/ReplayCamera.js b/js/prototype/ReplayCamera.js index 83d029c..cc530ee 100644 --- a/js/prototype/ReplayCamera.js +++ b/js/prototype/ReplayCamera.js @@ -2,7 +2,7 @@ var ReplayCamera = function() { THREE.PerspectiveCamera.apply(this, arguments); - this.coins = arguments[4] + this.coins = arguments[4]; this.started = false; this.counter = 0; @@ -17,15 +17,14 @@ var ReplayCamera = function() { var xhr = new XMLHttpRequest(); xhr.open("GET", "/prototype/replay_info/" + id, true); - (function(self) { - xhr.onreadystatechange = function() { - if (xhr.readyState == 4 && xhr.status == 200) { - self.path = JSON.parse(xhr.responseText); - self.started = true; - self.nextEvent(); - } + var self = this; + xhr.onreadystatechange = function() { + if (xhr.readyState == 4 && xhr.status == 200) { + self.path = JSON.parse(xhr.responseText); + self.started = true; + self.nextEvent(); } - })(this); + }; xhr.send(); // Set Position @@ -34,13 +33,13 @@ var ReplayCamera = function() { this.resetElements = resetBobombElements(); -} +}; ReplayCamera.prototype = Object.create(THREE.PerspectiveCamera.prototype); ReplayCamera.prototype.constructor = ReplayCamera; ReplayCamera.prototype.look = function() { this.lookAt(this.target); -} +}; // Update function ReplayCamera.prototype.update = function(time) { @@ -58,7 +57,7 @@ ReplayCamera.prototype.update = function(time) { // // Nothing to do // } } -} +}; ReplayCamera.prototype.linearMotion = function(time) { var tmp = Tools.sum(Tools.mul(this.old_position, 1-this.t), Tools.mul(this.new_position, this.t)); @@ -70,7 +69,7 @@ ReplayCamera.prototype.linearMotion = function(time) { if (this.t > 1) { this.nextEvent(); } -} +}; ReplayCamera.prototype.cameraMotion = function(time) { @@ -84,13 +83,13 @@ ReplayCamera.prototype.cameraMotion = function(time) { if (this.t > 1) { this.nextEvent(); } -} +}; ReplayCamera.prototype.hermiteMotion = function(time) { - var eval = this.hermitePosition.eval(this.t); - this.position.x = eval.x; - this.position.y = eval.y; - this.position.z = eval.z; + var e = this.hermitePosition.eval(this.t); + this.position.x = e.x; + this.position.y = e.y; + this.position.z = e.z; this.target = Tools.sum(this.position, this.hermiteAngles.eval(this.t)); @@ -99,7 +98,7 @@ ReplayCamera.prototype.hermiteMotion = function(time) { if (this.t > 1) { this.nextEvent(); } -} +}; ReplayCamera.prototype.nextEvent = function() { this.counter++; @@ -136,19 +135,19 @@ ReplayCamera.prototype.nextEvent = function() { } else if (this.event.type == 'hovered') { this.nextEvent(); } -} +}; ReplayCamera.prototype.reset = function() { this.resetPosition(); this.moving = false; this.movingHermite = false; -} +}; ReplayCamera.prototype.resetPosition = function() { this.position.copy(this.resetElements.position); this.target.copy(this.resetElements.target); this.anglesFromVectors(); -} +}; ReplayCamera.prototype.vectorsFromAngles = function() { // Update direction @@ -159,7 +158,7 @@ ReplayCamera.prototype.vectorsFromAngles = function() { this.forward.x = cos * Math.sin(this.theta); this.forward.normalize(); -} +}; ReplayCamera.prototype.anglesFromVectors = function() { // Update phi and theta so that return to reality does not hurt @@ -171,7 +170,7 @@ ReplayCamera.prototype.anglesFromVectors = function() { // Don't know why this line works... But thanks Thierry-san and // Bastien because it seems to work... this.theta = Math.atan2(forward.x, forward.z); -} +}; ReplayCamera.prototype.move = function(otherCamera) { this.moving = true; @@ -181,7 +180,7 @@ ReplayCamera.prototype.move = function(otherCamera) { this.new_position = new THREE.Vector3(otherCamera.position.x, otherCamera.position.y, otherCamera.position.z); this.t = 0; -} +}; ReplayCamera.prototype.moveHermite = function(otherCamera) { this.movingHermite = true; @@ -198,6 +197,6 @@ ReplayCamera.prototype.moveHermite = function(otherCamera) { Tools.diff(otherCamera.target, otherCamera.position), new THREE.Vector3() ); -} +}; -ReplayCamera.prototype.save = function() {} +ReplayCamera.prototype.save = function() {}; diff --git a/js/prototype/ReverseCamera.js b/js/prototype/ReverseCamera.js index a46f4db..63409dd 100644 --- a/js/prototype/ReverseCamera.js +++ b/js/prototype/ReverseCamera.js @@ -3,7 +3,7 @@ // class camera extends THREE.PerspectiveCamera var ReverseCamera = function(arg1, arg2, arg3, arg4, position, target) { ArrowCamera.apply(this, arguments); -} +}; ReverseCamera.prototype = Object.create(ArrowCamera.prototype); ReverseCamera.prototype.constructor = ReverseCamera; @@ -23,7 +23,7 @@ ReverseCamera.prototype.initExtremity = function() { left = Tools.mul(left, this.size / 2 ); other = Tools.mul(other, this.size / 2); - var pyramidCenter = Tools.diff(this.position, Tools.mul(direction,0.25)) + var pyramidCenter = Tools.diff(this.position, Tools.mul(direction,0.25)); geometry.vertices.push( Tools.sum( Tools.sum( this.position, left), other), Tools.diff(Tools.sum( this.position, other), left), @@ -71,10 +71,11 @@ ReverseCamera.prototype.initExtremity = function() { this.mesh = new THREE.Mesh(geometry, material); return this.mesh; -} +}; ReverseCamera.prototype.regenerateArrow = function(mainCamera) { - var vertices = new Array(); + var i; + var vertices = []; // First point of curve var f0 = mainCamera.position.clone(); @@ -119,7 +120,7 @@ ReverseCamera.prototype.regenerateArrow = function(mainCamera) { var limit = this.fullArrow ? 0.1 : 0.3; // for (var i = this.fullArrow ? 0 : 0.5; i <= 1.001; i += 0.05) { - for (var i = 1; i > limit; i -= 0.1) { + for (i = 1; i > limit; i -= 0.1) { point = hermite.eval(i); deriv = hermite.prime(i); up.cross(deriv); @@ -141,10 +142,10 @@ ReverseCamera.prototype.regenerateArrow = function(mainCamera) { this.arrow.geometry.vertices = vertices; - if (this.arrow.geometry.faces.length == 0) { - var faces = new Array(); + if (this.arrow.geometry.faces.length === 0) { + var faces = []; - for (var i = 0; i < vertices.length - 4; i+= 4) { + for (i = 0; i < vertices.length - 4; i+= 4) { faces.push(new THREE.Face3(i,i+1,i+5),new THREE.Face3(i,i+5,i+4), new THREE.Face3(i+1,i+2,i+6),new THREE.Face3(i+1,i+6,i+5), new THREE.Face3(i+2,i+3,i+7),new THREE.Face3(i+2,i+7,i+6), @@ -155,7 +156,7 @@ ReverseCamera.prototype.regenerateArrow = function(mainCamera) { faces.push(new THREE.Face3(len-4,len-3,len-2), new THREE.Face3(len-4,len-2,len-1)); var max = 0; - for (var i = 0; i < faces.length; i++) { + for (i = 0; i < faces.length; i++) { max = Math.max(max, faces[i].a, faces[i].b, faces[i].c); } console.log(max + '/' + len); @@ -179,4 +180,4 @@ ReverseCamera.prototype.regenerateArrow = function(mainCamera) { this.arrow.geometry.groupsNeedUpdate = true; this.arrow.geometry.normalsNeedUpdate = true; -} +}; diff --git a/js/prototype/TutorialSteps.js b/js/prototype/TutorialSteps.js index 72ead2d..6645363 100644 --- a/js/prototype/TutorialSteps.js +++ b/js/prototype/TutorialSteps.js @@ -97,11 +97,11 @@ var TutorialSteps = function(tutoCamera, scene, coins, onWindowResize, container this.scene = scene; Coin.domElement.style.display = "none"; -} +}; TutorialSteps.prototype.setCameras = function(cameras) { this.cameras = cameras; -} +}; TutorialSteps.prototype.nextStep = function() { console.log(this.step); @@ -175,7 +175,7 @@ TutorialSteps.prototype.nextStep = function() { } this.step++; } -} +}; TutorialSteps.prototype.nextAction = function() { switch (this.step) { @@ -188,18 +188,18 @@ TutorialSteps.prototype.nextAction = function() { case 13: return 'reset-camera'; case 15: return 'recommendation'; } -} +}; TutorialSteps.prototype.tryFinish = function() { if (this.coinNumber === 8) { console.log("Finished"); } -} +}; TutorialSteps.prototype.alert = function(myString, justclicked) { this.notify(myString, justclicked); this.onWindowResize(); -} +}; TutorialSteps.prototype.notify = function(myString, justclick) { $('#alert-placeholder').html( @@ -215,11 +215,11 @@ TutorialSteps.prototype.notify = function(myString, justclick) { ' (next)' : '' ) + '' + '' - ) + ); $('#toto').removeClass('alert-info').addClass('alert-danger'); setTimeout(function() { $('#toto').removeClass('alert-danger').addClass('alert-warning'); }, 500); -} +}; diff --git a/js/prototype/initScene.js b/js/prototype/initScene.js index cbed754..67143c1 100644 --- a/js/prototype/initScene.js +++ b/js/prototype/initScene.js @@ -11,7 +11,7 @@ function addLight(scene) { scene.add(ambient_light); } -function initPeachCastle(scene, collidableObjects, loader, camera) { +function initPeachCastle(scene, collidableObjects, camera) { var loader = new ProgressiveLoaderGeometry( '/static/data/castle/princess peaches castle (outside).obj', @@ -45,10 +45,9 @@ function resetPeachElements() { function initPeach(camera, scene, coins) { addLight(scene); - var loader = new THREE.OBJMTLLoader(); var collidableObjects = []; - initPeachCastle(scene, collidableObjects, loader, camera); + initPeachCastle(scene, collidableObjects, camera); camera.resetElements = resetPeachElements(); camera.collidableObjects = collidableObjects; @@ -107,7 +106,7 @@ function createPeachCameras(width, height) { position, target ); - } + }; cams.push(createCamera( new THREE.Vector3(-3.349895207953063, 5.148106346852601, 0.3365943929701533), @@ -155,7 +154,7 @@ function createPeachCameras(width, height) { return cams; } -function initBobombScene(scene, collidableObjects, loader, camera) { +function initBobombScene(scene, collidableObjects, camera) { var loader = new ProgressiveLoaderGeometry( '/static/data/bobomb/bobomb battlefeild.obj', @@ -215,7 +214,7 @@ function createBobombCameras(width, height) { position, target ); - } + }; cams.push( createCamera( @@ -270,10 +269,9 @@ function createBobombCameras(width, height) { function initBobomb(camera, scene, coins) { addLight(scene); - var loader = new THREE.OBJMTLLoader(); var collidableObjects = []; - initBobombScene(scene, collidableObjects, loader, camera); + initBobombScene(scene, collidableObjects, camera); camera.resetElements = resetBobombElements(); camera.collidableObjects = collidableObjects; @@ -296,12 +294,12 @@ function initBobomb(camera, scene, coins) { otherCams.forEach(function(cam) {cam.addToScene(scene);}); - setTimeout(function() { coins.forEach(function(coin) { coin.addToScene(scene); })}, 1000); + setTimeout(function() { coins.forEach(function(coin) { coin.addToScene(scene); });}, 1000); return cameras; } -function initWhompScene(scene, collidableObjects, loader, camera) { +function initWhompScene(scene, collidableObjects, camera) { var loader = new ProgressiveLoaderGeometry( '/static/data/whomp/Whomps Fortress.obj', @@ -331,25 +329,25 @@ function initWhompScene(scene, collidableObjects, loader, camera) { loader.obj.rotation.z = Math.PI/2; loader.obj.scale.set(0.1,0.1,0.1); - loader.getCamera = function() { - var ret = loader.camera.toList(); - ret[0][0] *= 10; - ret[0][1] *= 10; - ret[0][2] *= 10; + // loader.getCamera = function() { + // var ret = loader.camera.toList(); + // ret[0][0] *= 10; + // ret[0][1] *= 10; + // ret[0][2] *= 10; - ret[1][0] *= 10; - ret[1][1] *= 10; - ret[1][2] *= 10; + // ret[1][0] *= 10; + // ret[1][1] *= 10; + // ret[1][2] *= 10; - // Planes - for (var i = 2; i < ret.length; i++) { + // // Planes + // for (var i = 2; i < ret.length; i++) { - ret[i][3] *= 10; + // ret[i][3] *= 10; - } + // } - return ret; - } + // return ret; + // }; collidableObjects.push(loader.obj); loader.obj.raycastable = true; @@ -367,7 +365,7 @@ function createWhompCameras(width, height) { position, target ); - } + }; cams.push( createCamera( @@ -443,10 +441,9 @@ function resetWhompElements() { function initWhomp(camera, scene, coins) { addLight(scene); - var loader = new THREE.OBJMTLLoader(); var collidableObjects = []; - initWhompScene(scene, collidableObjects, loader, camera); + initWhompScene(scene, collidableObjects, camera); camera.resetElements = resetWhompElements(); camera.collidableObjects = collidableObjects; @@ -469,12 +466,12 @@ function initWhomp(camera, scene, coins) { otherCams.forEach(function(cam) {cam.addToScene(scene);}); - setTimeout(function() { coins.forEach(function(coin) { coin.addToScene(scene); })}, 1000); + setTimeout(function() { coins.forEach(function(coin) { coin.addToScene(scene); });}, 1000); return cameras; } -function initMountainScene(scene, collidableObjects, loader, camera) { +function initMountainScene(scene, collidableObjects, camera) { var loader = new ProgressiveLoaderGeometry( '/static/data/mountain/coocoolmountain.obj', @@ -531,7 +528,7 @@ function createMountainCameras(width, height) { position, target ); - } + }; cams.push( createCamera( @@ -591,15 +588,14 @@ function resetMountainElements() { return { position : new THREE.Vector3(-20.558328115300082,23.601312087942762,-10.220633604814038), target : new THREE.Vector3(11.025356711105232,11.969889531789319,11.393733425161644) - } + }; } function initMountain(camera, scene, coins) { addLight(scene); - var loader = new THREE.OBJMTLLoader(); var collidableObjects = []; - initMountainScene(scene, collidableObjects, loader, camera); + initMountainScene(scene, collidableObjects, camera); camera.resetElements = resetMountainElements(); camera.collidableObjects = collidableObjects; @@ -622,11 +618,11 @@ function initMountain(camera, scene, coins) { otherCams.forEach(function(cam) {cam.addToScene(scene);}); - setTimeout(function() { coins.forEach(function(coin) { coin.addToScene(scene); })}, 1000); + setTimeout(function() { coins.forEach(function(coin) { coin.addToScene(scene); });}, 1000); return cameras; } -function initSponzaScene(scene, collidableObjects, loader, camera) { +function initSponzaScene(scene, collidableObjects, camera) { var loader = new ProgressiveLoaderGeometry('/static/data/sponza/sponza.obj', scene, camera, function(obj) { if (obj.material.name === 'chain' || @@ -663,7 +659,7 @@ function initSponzaScene(scene, collidableObjects, loader, camera) { } return ret; - } + }; loader.obj.scale.set(0.1,0.1,0.1); collidableObjects.push(loader.obj); @@ -707,10 +703,9 @@ function resetSponzaElements() { function initSponza(camera, scene, coins) { addLight(scene); - var loader = new THREE.JSONLoader(); var collidableObjects = []; - initSponzaScene(scene, collidableObjects, loader, camera); + initSponzaScene(scene, collidableObjects, camera); camera.resetElements = resetSponzaElements(); camera.collidableObjects = collidableObjects; @@ -733,7 +728,7 @@ function initSponza(camera, scene, coins) { otherCams.forEach(function(cam) {cam.addToScene(scene);}); - setTimeout(function() { coins.forEach(function(coin) { coin.addToScene(scene); })}, 1000); + setTimeout(function() { coins.forEach(function(coin) { coin.addToScene(scene); });}, 1000); return cameras; diff --git a/js/prototype/raycasterTools.js b/js/prototype/raycasterTools.js index 6acd441..c08dce7 100644 --- a/js/prototype/raycasterTools.js +++ b/js/prototype/raycasterTools.js @@ -7,7 +7,7 @@ var CameraSelecter = function(renderer, scene, cameras, coins, buttonManager) { this.buttonManager = buttonManager; this.scene = scene; this.coins = coins; -} +}; CameraSelecter.prototype.pointedCamera = function() { var returnCamera; @@ -64,12 +64,14 @@ CameraSelecter.prototype.pointedCamera = function() { } } this.currentPointedCamera = null; -} +}; CameraSelecter.prototype.update = function(event, y) { + var e; + if (event !== undefined) { - this.mouse.x = event.offsetX == undefined ? event.layerX : event.offsetX; - this.mouse.y = event.offsetY == undefined ? event.layerY : event.offsetY; + this.mouse.x = event.offsetX === undefined ? event.layerX : event.offsetX; + this.mouse.y = event.offsetY === undefined ? event.layerY : event.offsetY; } if (y !== undefined) { @@ -83,10 +85,10 @@ CameraSelecter.prototype.update = function(event, y) { if (hovered !== undefined && !(hovered instanceof Coin)) { if (hovered !== previousCamera) { // log it - var event = new BD.Event.Hovered(); - event.start = true; - event.arrow_id = this.cameras.cameras.indexOf(this.currentPointedCamera); - event.send(); + e = new BD.Event.Hovered(); + e.start = true; + e.arrow_id = this.cameras.cameras.indexOf(this.currentPointedCamera); + e.send(); this.prev.x = this.mouse.x; this.prev.y = this.mouse.y; @@ -96,10 +98,10 @@ CameraSelecter.prototype.update = function(event, y) { } else { if (this.prev.go) { // Log if previous was not null - var event = new BD.Event.Hovered(); - event.start = false; - event.arrow_id = null; - event.send(); + e = new BD.Event.Hovered(); + e.start = false; + e.arrow_id = null; + e.send(); } this.prev.go = false; } @@ -109,44 +111,59 @@ CameraSelecter.prototype.update = function(event, y) { if (this.cameras.mainCamera().pointerLocked) this.cameras.mainCamera().mousePointer.render(hovered ? MousePointer.RED : MousePointer.BLACK); -} +}; CameraSelecter.prototype.click = function(event) { + var e; var newCamera = this.pointedCamera(); + if (newCamera !== undefined && !(newCamera instanceof Coin)) { - var event = new BD.Event.ArrowClicked(); - event.arrow_id = this.cameras.cameras.indexOf(newCamera); - event.send(); + + e = new BD.Event.ArrowClicked(); + e.arrow_id = this.cameras.cameras.indexOf(newCamera); + e.send(); newCamera.check(); this.cameras.mainCamera().moveHermite(newCamera); buttonManager.updateElements(); + } else if (newCamera instanceof Coin) { + // Coin found, notify server - var event = new BD.Event.CoinClicked(); - event.coin_id = this.coins.indexOf(newCamera); - event.send(); + e = new BD.Event.CoinClicked(); + e.coin_id = this.coins.indexOf(newCamera); + e.send(); newCamera.get(); + } -} + +}; CameraSelecter.prototype.clickPointer = function(event) { + var e; + if (this.cameras.mainCamera().pointerLocked) { + var newCamera = this.pointedCamera(); + if (newCamera !== undefined && !(newCamera instanceof Coin)) { - var event = new BD.Event.ArrowClicked(); - event.arrow_id = this.cameras.cameras.indexOf(newCamera); - event.send(); + + e = new BD.Event.ArrowClicked(); + e.arrow_id = this.cameras.cameras.indexOf(newCamera); + e.send(); newCamera.check(); this.cameras.mainCamera().moveHermite(newCamera); buttonManager.updateElements(); + } else if (newCamera instanceof Coin) { + // Coin found, notify server - var event = new BD.Event.CoinClicked(); - event.coin_id = this.coins.indexOf(newCamera); - event.send(); + e = new BD.Event.CoinClicked(); + e.coin_id = this.coins.indexOf(newCamera); + e.send(); newCamera.get(); + } } -} +}; diff --git a/js/prototype/replay.js b/js/prototype/replay.js index cc5299c..9fdb1fc 100644 --- a/js/prototype/replay.js +++ b/js/prototype/replay.js @@ -17,7 +17,7 @@ var main_section = document.getElementById('main-section'); var container_size = { width: function() { return 1024; }, height: function() { return 768; } -} +}; var onWindowResize = (function() { @@ -48,7 +48,7 @@ function init() { renderer = new THREE.WebGLRenderer({alpha:true, antialias:true}); // Collidable objects to prevent camera from traversing objects - var collidableObjects = new Array(); + var collidableObjects = []; // Initialize renderer container = document.getElementById('container'); diff --git a/js/prototype/tutorial.js b/js/prototype/tutorial.js index 756f81c..20a2530 100644 --- a/js/prototype/tutorial.js +++ b/js/prototype/tutorial.js @@ -39,7 +39,7 @@ function init() { BD.disable(); // Collidable objects to prevent camera from traversing objects - var collidableObjects = new Array(); + var collidableObjects = []; // Initialize renderer container = document.getElementById('container'); diff --git a/lib/controllers.js b/lib/controllers.js index 7345012..cb0bdf5 100644 --- a/lib/controllers.js +++ b/lib/controllers.js @@ -8,7 +8,8 @@ var fs = require('fs'); module.exports = function(parent, options){ var verbose = options.verbose; - verbose && console.log("Loading controllers :"); + if (verbose) + console.log("Loading controllers :"); fs.readdirSync(__dirname + '/../controllers').forEach(function(name){ @@ -17,7 +18,7 @@ module.exports = function(parent, options){ // urls.js, just like django urls.py var urls = require('./../controllers/' + name + '/urls'); - var name = obj.name || name; + name = obj.name || name; var app = express(); // allow specifying the view engine @@ -27,12 +28,19 @@ module.exports = function(parent, options){ // generate routes based // on the exported methods - verbose && console.log('\t' + name + ':'); + if (verbose) + console.log('\t' + name + ':'); + for (var key in urls) { app.get(key, obj[urls[key]]); - verbose && console.log('\t\t' + key + ' -> ' + name + '.' + urls[key]); + + if (verbose) + console.log('\t\t' + key + ' -> ' + name + '.' + urls[key]); + } - verbose && console.log(); + + if (verbose) + console.log(); // mount the app parent.use(app); diff --git a/lib/filterInt.js b/lib/filterInt.js index c966cbb..13bb537 100644 --- a/lib/filterInt.js +++ b/lib/filterInt.js @@ -3,4 +3,4 @@ module.exports.filterInt = function(value) { if(/^(\-|\+)?([0-9]+|Infinity)$/.test(value)) return Number(value); return NaN; -} +}; diff --git a/lib/posts.js b/lib/posts.js index d6a1825..c29c304 100644 --- a/lib/posts.js +++ b/lib/posts.js @@ -8,7 +8,8 @@ var fs = require('fs'); module.exports = function(parent, options){ var verbose = options.verbose; - verbose && console.log("Loading controllers :"); + if (verbose) + console.log("Loading controllers :"); fs.readdirSync(__dirname + '/../posts').forEach(function(name){ @@ -17,7 +18,7 @@ module.exports = function(parent, options){ // urls.js, just like django urls.py var urls = require('./../posts/' + name + '/urls'); - var name = obj.name || name; + name = obj.name || name; var app = express(); // allow specifying the view engine @@ -27,12 +28,18 @@ module.exports = function(parent, options){ // generate routes based // on the exported methods - verbose && console.log('\t' + name + ':'); + if (verbose) + console.log('\t' + name + ':'); + for (var key in urls) { app.post(key, obj[urls[key]]); - verbose && console.log('\t\t' + key + ' -> ' + name + '.' + urls[key]); + + if (verbose) + console.log('\t\t' + key + ' -> ' + name + '.' + urls[key]); } - verbose && console.log(); + + if (verbose) + console.log(); // mount the app parent.use(app); diff --git a/posts/arrow-clicked/index.js b/posts/arrow-clicked/index.js index 9358303..5ef4910 100644 --- a/posts/arrow-clicked/index.js +++ b/posts/arrow-clicked/index.js @@ -15,4 +15,4 @@ module.exports.index = function(req, res) { res.setHeader('Content-Type', 'text/html'); res.send(""); -} +}; diff --git a/posts/arrow-clicked/urls.js b/posts/arrow-clicked/urls.js index 9e26ab8..b0729d0 100644 --- a/posts/arrow-clicked/urls.js +++ b/posts/arrow-clicked/urls.js @@ -1,3 +1,3 @@ module.exports = { '/arrow-clicked': 'index' -} +}; diff --git a/posts/coin-clicked/index.js b/posts/coin-clicked/index.js index 3956b76..0c30bbd 100644 --- a/posts/coin-clicked/index.js +++ b/posts/coin-clicked/index.js @@ -15,4 +15,4 @@ module.exports.index = function(req, res) { res.setHeader('Content-Type', 'text/html'); res.send(""); -} +}; diff --git a/posts/coin-clicked/urls.js b/posts/coin-clicked/urls.js index 2b46584..b6546fc 100644 --- a/posts/coin-clicked/urls.js +++ b/posts/coin-clicked/urls.js @@ -1,3 +1,3 @@ module.exports = { '/coin-clicked': 'index' -} +}; diff --git a/posts/fps/index.js b/posts/fps/index.js index 2c06aa1..445e5b2 100644 --- a/posts/fps/index.js +++ b/posts/fps/index.js @@ -15,4 +15,4 @@ module.exports.index = function(req, res) { res.setHeader('Content-Type', 'text/html'); res.send(""); -} +}; diff --git a/posts/fps/urls.js b/posts/fps/urls.js index 9ddb40c..af9fc07 100644 --- a/posts/fps/urls.js +++ b/posts/fps/urls.js @@ -1,3 +1,3 @@ module.exports = { '/fps': 'index' -} +}; diff --git a/posts/hovered/index.js b/posts/hovered/index.js index 6cad008..37f3663 100644 --- a/posts/hovered/index.js +++ b/posts/hovered/index.js @@ -21,4 +21,4 @@ module.exports.index = function(req, res) { res.setHeader('Content-Type', 'text/html'); res.send(""); -} +}; diff --git a/posts/hovered/urls.js b/posts/hovered/urls.js index 378b256..e4b8eb9 100644 --- a/posts/hovered/urls.js +++ b/posts/hovered/urls.js @@ -1,3 +1,3 @@ module.exports = { '/hovered': 'index' -} +}; diff --git a/posts/keyboard-event/index.js b/posts/keyboard-event/index.js index 6812aef..e0e4f1b 100644 --- a/posts/keyboard-event/index.js +++ b/posts/keyboard-event/index.js @@ -26,5 +26,5 @@ module.exports.index = function(req, res) { }); res.setHeader('Content-Type', 'text/html'); - res.send("") -} + res.send(""); +}; diff --git a/posts/keyboard-event/urls.js b/posts/keyboard-event/urls.js index c9ede51..8abfea9 100644 --- a/posts/keyboard-event/urls.js +++ b/posts/keyboard-event/urls.js @@ -1,3 +1,3 @@ module.exports = { '/keyboard-event': 'index' -} +}; diff --git a/posts/previous-next-clicked/index.js b/posts/previous-next-clicked/index.js index fa6a684..c4afaa8 100644 --- a/posts/previous-next-clicked/index.js +++ b/posts/previous-next-clicked/index.js @@ -27,4 +27,4 @@ module.exports.index = function(req, res) { res.setHeader('Content-Type', 'text/html'); res.send(""); -} +}; diff --git a/posts/previous-next-clicked/urls.js b/posts/previous-next-clicked/urls.js index 8499640..f013a5f 100644 --- a/posts/previous-next-clicked/urls.js +++ b/posts/previous-next-clicked/urls.js @@ -1,3 +1,3 @@ module.exports = { '/previous-next-clicked': 'index' -} +}; diff --git a/posts/reset-clicked/index.js b/posts/reset-clicked/index.js index 3bef20b..31c8676 100644 --- a/posts/reset-clicked/index.js +++ b/posts/reset-clicked/index.js @@ -20,4 +20,4 @@ module.exports.index = function(req, res) { res.setHeader('Content-Type', 'text/html'); res.send(""); -} +}; diff --git a/posts/reset-clicked/urls.js b/posts/reset-clicked/urls.js index c5a6d2d..d6c1a22 100644 --- a/posts/reset-clicked/urls.js +++ b/posts/reset-clicked/urls.js @@ -1,3 +1,3 @@ module.exports = { '/reset-clicked': 'index' -} +}; diff --git a/socket.js b/socket.js index f33c952..7aea81c 100644 --- a/socket.js +++ b/socket.js @@ -9,4 +9,4 @@ module.exports = function(io) { streamer.start(socket); }); -} +};