Coins appear after scene loaded, and button is now blinking

This commit is contained in:
Thomas FORGIONE 2015-10-02 14:44:38 +02:00
parent 2982b9804b
commit 0e3eae5ff1
5 changed files with 56 additions and 4 deletions

View File

@ -1,6 +1,6 @@
function main() {
function main(path) {
var db = JSON.parse(require('fs').readFileSync('./data.json', 'utf8'));
var db = JSON.parse(require('fs').readFileSync(path, 'utf8'));
console.log('There were ' + db.users.length + ' users for ' + db.experiments.length + ' experiments');
@ -8,6 +8,8 @@ function main() {
var meanTimeArrow = 0;
var meanTimeViewport = 0;
console.log();
for (var i = 0; i < db.experiments.length; i++) {
var exp = db.experiments[i];
@ -19,7 +21,31 @@ function main() {
}
console.log(exp.user.worker_id + ' : ' + exp.user.rating + ' -> ' + timeToString(timeDifference(events[0].time, events[events.length-1].time)));
// console.log(exp.user.worker_id + ' : ' + exp.user.rating + ' -> ' + timeToString(timeDifference(events[0].time, events[events.length-1].time)));
var coins = [];
for (var j = 0; j < exp.elements.events.length; j++) {
if (exp.elements.events[j].type === 'coin') {
if (coins.find(function(elt) { return elt.id === exp.elements.events[j].id; }) === undefined) {
coins.push(exp.elements.events[j]);
}
}
}
console.log(exp.id + ' -> ' + coins.length + ' (on ' + exp.coinCombination.scene_id + ')');
}
console.log();
for (var i = 0; i < db.users.length; i++) {
var user = db.users[i];
console.log(user.worker_id + ' has done ' + user.experiments.length + ' experiments with rating ' + user.rating);
}
@ -39,4 +65,9 @@ function timeToString(_time) {
}
main();
if (process.argv.length !== 3) {
process.stderr.write('Error : please give me a JSON file to work on\n');
process.exit(-1);
}
main(process.argv[2])

View File

@ -91,6 +91,8 @@ Coin.update = function() {
}
document.getElementById('next').style.background = instantToColor(Coin.colorInstant);
// Coin.domElement.width = Coin.domElement.width;
// Coin.ctx.drawImage(Coin.image, x + 75,25,30,30);
@ -289,6 +291,7 @@ Coin.init = function(scale) {
function(object) {
object.traverse(function (mesh) {
if (mesh instanceof THREE.Mesh) {
mesh.visible = false;
mesh.scale.set(scale,scale,scale);
mesh.material.color.setHex(0xff0000);
mesh.geometry.computeVertexNormals();

View File

@ -1,6 +1,18 @@
// Let's be sure we avoid using global variables
var onWindowResize = (function() {
L3D.ProgressiveLoader.onFinished = function() {
if (coins.length === 0 || coins[0].mesh == undefined) {
setTimeout(L3D.ProgressiveLoader.onFinished, 500);
return;
}
for (var i = 0; i < coins.length; i++) {
coins[i].mesh.visible = true;
}
}
// Disable scrolling
window.onscroll = function () { window.scrollTo(0, 0); };

View File

@ -130,6 +130,7 @@ TutorialSteps.prototype.setCameras = function(cameras) {
TutorialSteps.prototype.addCoin = function(coin) {
this.coins.push(coin);
coin.mesh.visible = true;
coin.addToScene(this.scene);
this.clickableObjects.push(coin);
};

View File

@ -382,6 +382,11 @@ ProgressiveLoader.prototype.initIOCallbacks = function() {
if (typeof self.log === 'function')
self.log(self.numberOfFacesReceived, self.numberOfFaces);
self.finished = true;
if (typeof L3D.ProgressiveLoader.onFinished === 'function') {
L3D.ProgressiveLoader.onFinished();
}
});
};