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