From 0e3eae5ff1dc35b564602016dffd2154a7598e9b Mon Sep 17 00:00:00 2001 From: Thomas FORGIONE Date: Fri, 2 Oct 2015 14:44:38 +0200 Subject: [PATCH] Coins appear after scene loaded, and button is now blinking --- analysis/analyse.js | 39 +++++++++++++++++-- js/l3d/apps/prototype/Coin.js | 3 ++ js/l3d/apps/prototype/interactive/main.js | 12 ++++++ .../apps/prototype/tutorial/TutorialSteps.js | 1 + js/l3d/src/loaders/ProgressiveLoader.js | 5 +++ 5 files changed, 56 insertions(+), 4 deletions(-) diff --git a/analysis/analyse.js b/analysis/analyse.js index b015861..17d964c 100644 --- a/analysis/analyse.js +++ b/analysis/analyse.js @@ -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]) diff --git a/js/l3d/apps/prototype/Coin.js b/js/l3d/apps/prototype/Coin.js index 6296592..3d63287 100644 --- a/js/l3d/apps/prototype/Coin.js +++ b/js/l3d/apps/prototype/Coin.js @@ -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(); diff --git a/js/l3d/apps/prototype/interactive/main.js b/js/l3d/apps/prototype/interactive/main.js index 17a4cd8..627acce 100644 --- a/js/l3d/apps/prototype/interactive/main.js +++ b/js/l3d/apps/prototype/interactive/main.js @@ -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); }; diff --git a/js/l3d/apps/prototype/tutorial/TutorialSteps.js b/js/l3d/apps/prototype/tutorial/TutorialSteps.js index b6d1ad8..361d23e 100644 --- a/js/l3d/apps/prototype/tutorial/TutorialSteps.js +++ b/js/l3d/apps/prototype/tutorial/TutorialSteps.js @@ -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); }; diff --git a/js/l3d/src/loaders/ProgressiveLoader.js b/js/l3d/src/loaders/ProgressiveLoader.js index df2bfe8..8a4dedd 100644 --- a/js/l3d/src/loaders/ProgressiveLoader.js +++ b/js/l3d/src/loaders/ProgressiveLoader.js @@ -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(); + } + }); };