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("