From 5e0a6c312117844a6fca4cd05cb306b2743e542a Mon Sep 17 00:00:00 2001 From: Thomas FORGIONE Date: Fri, 13 Nov 2015 10:36:54 +0100 Subject: [PATCH] Some cleaning :cry: --- js/l3d/src/cameras/PointerCamera.js | 2 + {403 => server/403}/index.html | 0 {403 => server/403}/working.gif | Bin .../controllers}/before-begin/index.js | 0 .../controllers}/before-begin/urls.js | 0 .../before-begin/views/index.jade | 0 .../controllers}/bouncing/index.js | 0 .../controllers}/bouncing/urls.js | 0 .../controllers}/bouncing/views/index.jade | 0 .../controllers}/feedback/index.js | 0 .../controllers}/feedback/urls.js | 0 .../controllers}/feedback/views/index.jade | 0 .../controllers}/index/index.js | 0 .../controllers}/index/urls.js | 0 .../controllers}/index/views/index.jade | 0 .../controllers}/intro/index.js | 0 .../controllers}/intro/urls.js | 0 .../controllers}/intro/views/index.jade | 0 .../controllers}/list/index.js | 0 .../controllers}/list/urls.js | 0 .../controllers}/list/views/index.jade | 0 .../controllers}/logout/index.js | 0 .../controllers}/logout/urls.js | 0 .../controllers}/multisphere/index.js | 0 .../controllers}/multisphere/urls.js | 0 .../controllers}/multisphere/views/index.jade | 0 .../controllers}/prototype/dbrequests.js | 0 .../controllers}/prototype/index.js | 0 .../controllers}/prototype/urls.js | 0 .../controllers}/prototype/views/index.jade | 0 .../prototype/views/prototype.jade | 0 .../prototype/views/prototype_checker.jade | 0 .../prototype/views/prototype_clicker.jade | 0 .../views/prototype_interactive.jade | 0 .../views/prototype_recommendation.jade | 0 .../prototype/views/prototype_replays.jade | 0 .../prototype/views/prototype_reverse.jade | 0 .../prototype/views/prototype_viewer.jade | 0 .../prototype/views/replay_index.jade | 0 .../controllers}/prototype/views/sponza.jade | 0 .../prototype/views/tutorial.jade | 0 .../prototype/views/user_study.jade | 0 .../controllers}/stream/index.js | 0 .../controllers}/stream/urls.js | 0 .../controllers}/stream/views/index.jade | 0 .../controllers}/thankyou/index.js | 0 .../controllers}/thankyou/urls.js | 0 .../controllers}/thankyou/views/normal.jade | 0 .../controllers}/thankyou/views/vcode.jade | 0 .../controllers}/vcode/index.js | 0 .../controllers}/vcode/urls.js | 0 {geo => server/geo}/Geo.js | 0 {geo => server/geo}/Makefile | 4 +- {geo => server/geo}/Mesh.js | 0 {geo => server/geo}/MeshContainer.js | 87 ++++++++++- {geo => server/geo}/MeshStreamer.js | 142 +++++++++++------- server/geo/mat1.json | 1 + server/geo/mat1.json.bak | 1 + server/geo/mat2.json | 1 + server/geo/mat2.json.bak | 1 + server/geo/mat3.json | 1 + server/geo/mat3.json.bak | 1 + server/geo/matt1.json.bak | 1 + server/geo/matt2.json.bak | 1 + server/geo/matt3.json.bak | 1 + server/lib/Matrix.js | 141 +++++++++++++++++ {lib => server/lib}/NodeLog.js | 0 server/lib/Serial.js | 101 +++++++++++++ {lib => server/lib}/controllers.js | 0 {lib => server/lib}/filterInt.js | 0 server/lib/mat1.json | 1 + server/lib/mat2.json | 1 + server/lib/mat3.json | 1 + server/lib/matt1.json | 1 + server/lib/matt2.json | 1 + server/lib/matt3.json | 1 + {lib => server/lib}/posts.js | 0 server/lib/tests/myMatrix.json | 1 + {lib => server/lib}/vcode.js | 0 .../npm-shrinkwrap.json | 0 package.json => server/package.json | 0 .../posts}/arrow-clicked/index.js | 0 {posts => server/posts}/arrow-clicked/urls.js | 0 {posts => server/posts}/coin-clicked/index.js | 0 {posts => server/posts}/coin-clicked/urls.js | 0 {posts => server/posts}/coin-info/index.js | 0 {posts => server/posts}/coin-info/urls.js | 0 .../posts}/feedback-target/index.js | 0 .../posts}/feedback-target/urls.js | 0 {posts => server/posts}/fps/index.js | 0 {posts => server/posts}/fps/urls.js | 0 {posts => server/posts}/hovered/index.js | 0 {posts => server/posts}/hovered/urls.js | 0 .../posts}/identification/index.js | 0 .../posts}/identification/urls.js | 0 .../posts}/keyboard-event/index.js | 0 .../posts}/keyboard-event/urls.js | 0 .../posts}/pointer-locked/index.js | 0 .../posts}/pointer-locked/urls.js | 0 .../posts}/previous-next-clicked/index.js | 0 .../posts}/previous-next-clicked/urls.js | 0 .../posts}/reset-clicked/index.js | 0 {posts => server/posts}/reset-clicked/urls.js | 0 .../posts}/switched-lock-option/index.js | 0 .../posts}/switched-lock-option/urls.js | 0 server.js => server/server.js | 4 +- socket.js => server/socket.js | 0 urls.js => server/urls.js | 0 {views => server/views}/404.jade | 0 {views => server/views}/base.jade | 0 {views => server/views}/main.jade | 0 {views => server/views}/withjs.jade | 0 utils/demon.sh | 3 +- 113 files changed, 433 insertions(+), 67 deletions(-) rename {403 => server/403}/index.html (100%) rename {403 => server/403}/working.gif (100%) rename {controllers => server/controllers}/before-begin/index.js (100%) rename {controllers => server/controllers}/before-begin/urls.js (100%) rename {controllers => server/controllers}/before-begin/views/index.jade (100%) rename {controllers => server/controllers}/bouncing/index.js (100%) rename {controllers => server/controllers}/bouncing/urls.js (100%) rename {controllers => server/controllers}/bouncing/views/index.jade (100%) rename {controllers => server/controllers}/feedback/index.js (100%) rename {controllers => server/controllers}/feedback/urls.js (100%) rename {controllers => server/controllers}/feedback/views/index.jade (100%) rename {controllers => server/controllers}/index/index.js (100%) rename {controllers => server/controllers}/index/urls.js (100%) rename {controllers => server/controllers}/index/views/index.jade (100%) rename {controllers => server/controllers}/intro/index.js (100%) rename {controllers => server/controllers}/intro/urls.js (100%) rename {controllers => server/controllers}/intro/views/index.jade (100%) rename {controllers => server/controllers}/list/index.js (100%) rename {controllers => server/controllers}/list/urls.js (100%) rename {controllers => server/controllers}/list/views/index.jade (100%) rename {controllers => server/controllers}/logout/index.js (100%) rename {controllers => server/controllers}/logout/urls.js (100%) rename {controllers => server/controllers}/multisphere/index.js (100%) rename {controllers => server/controllers}/multisphere/urls.js (100%) rename {controllers => server/controllers}/multisphere/views/index.jade (100%) rename {controllers => server/controllers}/prototype/dbrequests.js (100%) rename {controllers => server/controllers}/prototype/index.js (100%) rename {controllers => server/controllers}/prototype/urls.js (100%) rename {controllers => server/controllers}/prototype/views/index.jade (100%) rename {controllers => server/controllers}/prototype/views/prototype.jade (100%) rename {controllers => server/controllers}/prototype/views/prototype_checker.jade (100%) rename {controllers => server/controllers}/prototype/views/prototype_clicker.jade (100%) rename {controllers => server/controllers}/prototype/views/prototype_interactive.jade (100%) rename {controllers => server/controllers}/prototype/views/prototype_recommendation.jade (100%) rename {controllers => server/controllers}/prototype/views/prototype_replays.jade (100%) rename {controllers => server/controllers}/prototype/views/prototype_reverse.jade (100%) rename {controllers => server/controllers}/prototype/views/prototype_viewer.jade (100%) rename {controllers => server/controllers}/prototype/views/replay_index.jade (100%) rename {controllers => server/controllers}/prototype/views/sponza.jade (100%) rename {controllers => server/controllers}/prototype/views/tutorial.jade (100%) rename {controllers => server/controllers}/prototype/views/user_study.jade (100%) rename {controllers => server/controllers}/stream/index.js (100%) rename {controllers => server/controllers}/stream/urls.js (100%) rename {controllers => server/controllers}/stream/views/index.jade (100%) rename {controllers => server/controllers}/thankyou/index.js (100%) rename {controllers => server/controllers}/thankyou/urls.js (100%) rename {controllers => server/controllers}/thankyou/views/normal.jade (100%) rename {controllers => server/controllers}/thankyou/views/vcode.jade (100%) rename {controllers => server/controllers}/vcode/index.js (100%) rename {controllers => server/controllers}/vcode/urls.js (100%) rename {geo => server/geo}/Geo.js (100%) rename {geo => server/geo}/Makefile (66%) rename {geo => server/geo}/Mesh.js (100%) rename {geo => server/geo}/MeshContainer.js (72%) rename {geo => server/geo}/MeshStreamer.js (82%) create mode 100644 server/geo/mat1.json create mode 100644 server/geo/mat1.json.bak create mode 100644 server/geo/mat2.json create mode 100644 server/geo/mat2.json.bak create mode 100644 server/geo/mat3.json create mode 100644 server/geo/mat3.json.bak create mode 100644 server/geo/matt1.json.bak create mode 100644 server/geo/matt2.json.bak create mode 100644 server/geo/matt3.json.bak create mode 100644 server/lib/Matrix.js rename {lib => server/lib}/NodeLog.js (100%) create mode 100644 server/lib/Serial.js rename {lib => server/lib}/controllers.js (100%) rename {lib => server/lib}/filterInt.js (100%) create mode 100644 server/lib/mat1.json create mode 100644 server/lib/mat2.json create mode 100644 server/lib/mat3.json create mode 100644 server/lib/matt1.json create mode 100644 server/lib/matt2.json create mode 100644 server/lib/matt3.json rename {lib => server/lib}/posts.js (100%) create mode 100644 server/lib/tests/myMatrix.json rename {lib => server/lib}/vcode.js (100%) rename npm-shrinkwrap.json => server/npm-shrinkwrap.json (100%) rename package.json => server/package.json (100%) rename {posts => server/posts}/arrow-clicked/index.js (100%) rename {posts => server/posts}/arrow-clicked/urls.js (100%) rename {posts => server/posts}/coin-clicked/index.js (100%) rename {posts => server/posts}/coin-clicked/urls.js (100%) rename {posts => server/posts}/coin-info/index.js (100%) rename {posts => server/posts}/coin-info/urls.js (100%) rename {posts => server/posts}/feedback-target/index.js (100%) rename {posts => server/posts}/feedback-target/urls.js (100%) rename {posts => server/posts}/fps/index.js (100%) rename {posts => server/posts}/fps/urls.js (100%) rename {posts => server/posts}/hovered/index.js (100%) rename {posts => server/posts}/hovered/urls.js (100%) rename {posts => server/posts}/identification/index.js (100%) rename {posts => server/posts}/identification/urls.js (100%) rename {posts => server/posts}/keyboard-event/index.js (100%) rename {posts => server/posts}/keyboard-event/urls.js (100%) rename {posts => server/posts}/pointer-locked/index.js (100%) rename {posts => server/posts}/pointer-locked/urls.js (100%) rename {posts => server/posts}/previous-next-clicked/index.js (100%) rename {posts => server/posts}/previous-next-clicked/urls.js (100%) rename {posts => server/posts}/reset-clicked/index.js (100%) rename {posts => server/posts}/reset-clicked/urls.js (100%) rename {posts => server/posts}/switched-lock-option/index.js (100%) rename {posts => server/posts}/switched-lock-option/urls.js (100%) rename server.js => server/server.js (96%) rename socket.js => server/socket.js (100%) rename urls.js => server/urls.js (100%) rename {views => server/views}/404.jade (100%) rename {views => server/views}/base.jade (100%) rename {views => server/views}/main.jade (100%) rename {views => server/views}/withjs.jade (100%) diff --git a/js/l3d/src/cameras/PointerCamera.js b/js/l3d/src/cameras/PointerCamera.js index 8abb8f7..feecace 100644 --- a/js/l3d/src/cameras/PointerCamera.js +++ b/js/l3d/src/cameras/PointerCamera.js @@ -138,6 +138,8 @@ L3D.PointerCamera = function() { */ this.listenerTarget = listenerTarget; + this.movingToRecommendation = null; + // Set events from the document var self = this; var onKeyDown = function(event) {self.onKeyDown(event);}; diff --git a/403/index.html b/server/403/index.html similarity index 100% rename from 403/index.html rename to server/403/index.html diff --git a/403/working.gif b/server/403/working.gif similarity index 100% rename from 403/working.gif rename to server/403/working.gif diff --git a/controllers/before-begin/index.js b/server/controllers/before-begin/index.js similarity index 100% rename from controllers/before-begin/index.js rename to server/controllers/before-begin/index.js diff --git a/controllers/before-begin/urls.js b/server/controllers/before-begin/urls.js similarity index 100% rename from controllers/before-begin/urls.js rename to server/controllers/before-begin/urls.js diff --git a/controllers/before-begin/views/index.jade b/server/controllers/before-begin/views/index.jade similarity index 100% rename from controllers/before-begin/views/index.jade rename to server/controllers/before-begin/views/index.jade diff --git a/controllers/bouncing/index.js b/server/controllers/bouncing/index.js similarity index 100% rename from controllers/bouncing/index.js rename to server/controllers/bouncing/index.js diff --git a/controllers/bouncing/urls.js b/server/controllers/bouncing/urls.js similarity index 100% rename from controllers/bouncing/urls.js rename to server/controllers/bouncing/urls.js diff --git a/controllers/bouncing/views/index.jade b/server/controllers/bouncing/views/index.jade similarity index 100% rename from controllers/bouncing/views/index.jade rename to server/controllers/bouncing/views/index.jade diff --git a/controllers/feedback/index.js b/server/controllers/feedback/index.js similarity index 100% rename from controllers/feedback/index.js rename to server/controllers/feedback/index.js diff --git a/controllers/feedback/urls.js b/server/controllers/feedback/urls.js similarity index 100% rename from controllers/feedback/urls.js rename to server/controllers/feedback/urls.js diff --git a/controllers/feedback/views/index.jade b/server/controllers/feedback/views/index.jade similarity index 100% rename from controllers/feedback/views/index.jade rename to server/controllers/feedback/views/index.jade diff --git a/controllers/index/index.js b/server/controllers/index/index.js similarity index 100% rename from controllers/index/index.js rename to server/controllers/index/index.js diff --git a/controllers/index/urls.js b/server/controllers/index/urls.js similarity index 100% rename from controllers/index/urls.js rename to server/controllers/index/urls.js diff --git a/controllers/index/views/index.jade b/server/controllers/index/views/index.jade similarity index 100% rename from controllers/index/views/index.jade rename to server/controllers/index/views/index.jade diff --git a/controllers/intro/index.js b/server/controllers/intro/index.js similarity index 100% rename from controllers/intro/index.js rename to server/controllers/intro/index.js diff --git a/controllers/intro/urls.js b/server/controllers/intro/urls.js similarity index 100% rename from controllers/intro/urls.js rename to server/controllers/intro/urls.js diff --git a/controllers/intro/views/index.jade b/server/controllers/intro/views/index.jade similarity index 100% rename from controllers/intro/views/index.jade rename to server/controllers/intro/views/index.jade diff --git a/controllers/list/index.js b/server/controllers/list/index.js similarity index 100% rename from controllers/list/index.js rename to server/controllers/list/index.js diff --git a/controllers/list/urls.js b/server/controllers/list/urls.js similarity index 100% rename from controllers/list/urls.js rename to server/controllers/list/urls.js diff --git a/controllers/list/views/index.jade b/server/controllers/list/views/index.jade similarity index 100% rename from controllers/list/views/index.jade rename to server/controllers/list/views/index.jade diff --git a/controllers/logout/index.js b/server/controllers/logout/index.js similarity index 100% rename from controllers/logout/index.js rename to server/controllers/logout/index.js diff --git a/controllers/logout/urls.js b/server/controllers/logout/urls.js similarity index 100% rename from controllers/logout/urls.js rename to server/controllers/logout/urls.js diff --git a/controllers/multisphere/index.js b/server/controllers/multisphere/index.js similarity index 100% rename from controllers/multisphere/index.js rename to server/controllers/multisphere/index.js diff --git a/controllers/multisphere/urls.js b/server/controllers/multisphere/urls.js similarity index 100% rename from controllers/multisphere/urls.js rename to server/controllers/multisphere/urls.js diff --git a/controllers/multisphere/views/index.jade b/server/controllers/multisphere/views/index.jade similarity index 100% rename from controllers/multisphere/views/index.jade rename to server/controllers/multisphere/views/index.jade diff --git a/controllers/prototype/dbrequests.js b/server/controllers/prototype/dbrequests.js similarity index 100% rename from controllers/prototype/dbrequests.js rename to server/controllers/prototype/dbrequests.js diff --git a/controllers/prototype/index.js b/server/controllers/prototype/index.js similarity index 100% rename from controllers/prototype/index.js rename to server/controllers/prototype/index.js diff --git a/controllers/prototype/urls.js b/server/controllers/prototype/urls.js similarity index 100% rename from controllers/prototype/urls.js rename to server/controllers/prototype/urls.js diff --git a/controllers/prototype/views/index.jade b/server/controllers/prototype/views/index.jade similarity index 100% rename from controllers/prototype/views/index.jade rename to server/controllers/prototype/views/index.jade diff --git a/controllers/prototype/views/prototype.jade b/server/controllers/prototype/views/prototype.jade similarity index 100% rename from controllers/prototype/views/prototype.jade rename to server/controllers/prototype/views/prototype.jade diff --git a/controllers/prototype/views/prototype_checker.jade b/server/controllers/prototype/views/prototype_checker.jade similarity index 100% rename from controllers/prototype/views/prototype_checker.jade rename to server/controllers/prototype/views/prototype_checker.jade diff --git a/controllers/prototype/views/prototype_clicker.jade b/server/controllers/prototype/views/prototype_clicker.jade similarity index 100% rename from controllers/prototype/views/prototype_clicker.jade rename to server/controllers/prototype/views/prototype_clicker.jade diff --git a/controllers/prototype/views/prototype_interactive.jade b/server/controllers/prototype/views/prototype_interactive.jade similarity index 100% rename from controllers/prototype/views/prototype_interactive.jade rename to server/controllers/prototype/views/prototype_interactive.jade diff --git a/controllers/prototype/views/prototype_recommendation.jade b/server/controllers/prototype/views/prototype_recommendation.jade similarity index 100% rename from controllers/prototype/views/prototype_recommendation.jade rename to server/controllers/prototype/views/prototype_recommendation.jade diff --git a/controllers/prototype/views/prototype_replays.jade b/server/controllers/prototype/views/prototype_replays.jade similarity index 100% rename from controllers/prototype/views/prototype_replays.jade rename to server/controllers/prototype/views/prototype_replays.jade diff --git a/controllers/prototype/views/prototype_reverse.jade b/server/controllers/prototype/views/prototype_reverse.jade similarity index 100% rename from controllers/prototype/views/prototype_reverse.jade rename to server/controllers/prototype/views/prototype_reverse.jade diff --git a/controllers/prototype/views/prototype_viewer.jade b/server/controllers/prototype/views/prototype_viewer.jade similarity index 100% rename from controllers/prototype/views/prototype_viewer.jade rename to server/controllers/prototype/views/prototype_viewer.jade diff --git a/controllers/prototype/views/replay_index.jade b/server/controllers/prototype/views/replay_index.jade similarity index 100% rename from controllers/prototype/views/replay_index.jade rename to server/controllers/prototype/views/replay_index.jade diff --git a/controllers/prototype/views/sponza.jade b/server/controllers/prototype/views/sponza.jade similarity index 100% rename from controllers/prototype/views/sponza.jade rename to server/controllers/prototype/views/sponza.jade diff --git a/controllers/prototype/views/tutorial.jade b/server/controllers/prototype/views/tutorial.jade similarity index 100% rename from controllers/prototype/views/tutorial.jade rename to server/controllers/prototype/views/tutorial.jade diff --git a/controllers/prototype/views/user_study.jade b/server/controllers/prototype/views/user_study.jade similarity index 100% rename from controllers/prototype/views/user_study.jade rename to server/controllers/prototype/views/user_study.jade diff --git a/controllers/stream/index.js b/server/controllers/stream/index.js similarity index 100% rename from controllers/stream/index.js rename to server/controllers/stream/index.js diff --git a/controllers/stream/urls.js b/server/controllers/stream/urls.js similarity index 100% rename from controllers/stream/urls.js rename to server/controllers/stream/urls.js diff --git a/controllers/stream/views/index.jade b/server/controllers/stream/views/index.jade similarity index 100% rename from controllers/stream/views/index.jade rename to server/controllers/stream/views/index.jade diff --git a/controllers/thankyou/index.js b/server/controllers/thankyou/index.js similarity index 100% rename from controllers/thankyou/index.js rename to server/controllers/thankyou/index.js diff --git a/controllers/thankyou/urls.js b/server/controllers/thankyou/urls.js similarity index 100% rename from controllers/thankyou/urls.js rename to server/controllers/thankyou/urls.js diff --git a/controllers/thankyou/views/normal.jade b/server/controllers/thankyou/views/normal.jade similarity index 100% rename from controllers/thankyou/views/normal.jade rename to server/controllers/thankyou/views/normal.jade diff --git a/controllers/thankyou/views/vcode.jade b/server/controllers/thankyou/views/vcode.jade similarity index 100% rename from controllers/thankyou/views/vcode.jade rename to server/controllers/thankyou/views/vcode.jade diff --git a/controllers/vcode/index.js b/server/controllers/vcode/index.js similarity index 100% rename from controllers/vcode/index.js rename to server/controllers/vcode/index.js diff --git a/controllers/vcode/urls.js b/server/controllers/vcode/urls.js similarity index 100% rename from controllers/vcode/urls.js rename to server/controllers/vcode/urls.js diff --git a/geo/Geo.js b/server/geo/Geo.js similarity index 100% rename from geo/Geo.js rename to server/geo/Geo.js diff --git a/geo/Makefile b/server/geo/Makefile similarity index 66% rename from geo/Makefile rename to server/geo/Makefile index 58a2a31..4322f3e 100644 --- a/geo/Makefile +++ b/server/geo/Makefile @@ -1,9 +1,9 @@ OPT=--compilation_level SIMPLE_OPTIMIZATIONS ifeq ($(TYPE),RELEASE) - CLOSURE=java -jar ../utils/closure-compiler/closure-compiler.jar + CLOSURE=java -jar ../../utils/closure-compiler/closure-compiler.jar else - CLOSURE=../utils/simple-compiler/compiler.sh + CLOSURE=../../utils/simple-compiler/compiler.sh endif all: Geo diff --git a/geo/Mesh.js b/server/geo/Mesh.js similarity index 100% rename from geo/Mesh.js rename to server/geo/Mesh.js diff --git a/geo/MeshContainer.js b/server/geo/MeshContainer.js similarity index 72% rename from geo/MeshContainer.js rename to server/geo/MeshContainer.js index 7cec9bc..0cb1a9d 100644 --- a/geo/MeshContainer.js +++ b/server/geo/MeshContainer.js @@ -1,4 +1,6 @@ var Log = require('../lib/NodeLog.js'); +var L3D = require('../../static/js/l3d.min.js'); +var THREE = require('three'); function clone(vec) { return {x : vec.x, y : vec.y, z : vec.z}; @@ -110,7 +112,7 @@ geo.MeshContainer = function(path, transfo, callback) { if (path !== undefined) { - this.loadFromFile(path); + this.loadFromFile('../' + path); } @@ -233,12 +235,18 @@ function trySetLoaded() { var availableMeshNames = { '/static/data/castle/princess peaches castle (outside).obj': { - done: false + done: false, + recommendations : L3D.createPeachRecommendations(1134, 768) + }, '/static/data/mountain/coocoolmountain.obj': { - done: false + done: false, + recommendations : L3D.createMountainRecommendations(1134, 768) + }, + '/static/data/mountain/coocoolmountain_sub.obj': { + done: false, + recommendations : L3D.createMountainRecommendations(1134, 768) }, - '/static/data/whomp/Whomps Fortress.obj': { done: false, transfo: { @@ -253,9 +261,26 @@ var availableMeshNames = { z: 0 }, scale: 0.1 - } + }, + recommendations : L3D.createWhompRecommendations(1134, 768) + }, + '/static/data/whomp/Whomps Fortress_sub.obj': { + done: false, + transfo: { + rotation: { + x: -Math.PI / 2, + y: 0, + z: Math.PI / 2 + }, + translation: { + x: 0, + y: 0, + z: 0 + }, + scale: 0.1 + }, + recommendations : L3D.createWhompRecommendations(1134, 768) }, - '/static/data/bobomb/bobomb battlefeild.obj': { done: false, transfo: { @@ -269,7 +294,25 @@ var availableMeshNames = { y: 0, z: 0 } - } + }, + recommendations : L3D.createBobombRecommendations(1134, 768) + }, + + '/static/data/bobomb/bobomb battlefeild_sub.obj': { + done: false, + transfo: { + rotation: { + x: 0, + y: Math.PI - 0.27, + z: 0 + }, + translation: { + x: 0, + y: 0, + z: 0 + } + }, + recommendations : L3D.createBobombRecommendations(1134, 768) }, '/static/data/sponza/sponza.obj': { @@ -294,6 +337,36 @@ function pushMesh(name) { name.substring(1, name.length), availableMeshNames[name].transfo, function() { + geo.availableMeshes[name].recommendations = []; + + if (availableMeshNames[name].recommendations !== undefined) { + + for (var i = 0; i < availableMeshNames[name].recommendations.length; i++) { + + var reco = availableMeshNames[name].recommendations[i].camera; + + reco.lookAt(reco.target); + + reco.updateMatrix(); + reco.updateProjectionMatrix(); + reco.updateMatrixWorld(); + + reco.matrixWorldInverse.getInverse( reco.matrixWorld ); + + var frustum = new THREE.Frustum(); + var projScreenMatrix = new THREE.Matrix4(); + projScreenMatrix.multiplyMatrices(reco.projectionMatrix, reco.matrixWorldInverse); + + frustum.setFromMatrix(new THREE.Matrix4().multiplyMatrices(reco.projectionMatrix, reco.matrixWorldInverse)); + + geo.availableMeshes[name].recommendations.push({ + position: reco.position, + frustum: frustum.planes + }); + + } + } + availableMeshNames[name].done = true; trySetLoaded(); } diff --git a/geo/MeshStreamer.js b/server/geo/MeshStreamer.js similarity index 82% rename from geo/MeshStreamer.js rename to server/geo/MeshStreamer.js index 2a76bb4..2ffe8f4 100644 --- a/geo/MeshStreamer.js +++ b/server/geo/MeshStreamer.js @@ -1,3 +1,59 @@ +var THREE = require('three'); +var L3D = require('../../static/js/l3d.min.js'); + +function isInFrustum(element, planes) { + + if (element instanceof Array) { + + var outcodes = []; + + for (var i = 0; i < element.length; i++) { + + var vertex = element[i]; + var currentOutcode = ""; + + for (var j = 0; j < planes.length; j++) { + + var plane = planes[j]; + + distance = + plane.normal.x * vertex.x + + plane.normal.y * vertex.y + + plane.normal.z * vertex.z + + plane.constant; + + // if (distance < 0) { + // exitToContinue = true; + // break; + // } + + currentOutcode += distance > 0 ? '0' : '1'; + + } + + outcodes.push(parseInt(currentOutcode,2)); + + } + + // http://vterrain.org/LOD/culling.html + // I have no idea what i'm doing + // http://i.kinja-img.com/gawker-media/image/upload/japbcvpavbzau9dbuaxf.jpg + // But it seems to work + // EDIT : Not, this should be ok http://www.cs.unc.edu/~blloyd/comp770/Lecture07.pdf + + if ((outcodes[0] | outcodes[1] | outcodes[2]) === 0) { + return true; + } else if ((outcodes[0] & outcodes[1] & outcodes[2]) !== 0) { + return false; + } else { + // part of the triangle is inside the viewing volume + return true; + } + + } + +} + /** * @private */ @@ -97,6 +153,18 @@ geo.MeshStreamer = function(path) { }; +geo.MeshStreamer.prototype.isBackFace = function(camera, face) { + + var directionCamera = L3D.Tools.diff(camera.target, camera.position); + + var v1 = L3D.Tools.diff(this.mesh.vertices[face.b], this.mesh.vertices[face.a]); + var v2 = L3D.Tools.diff(this.mesh.vertices[face.c], this.mesh.vertices[face.a]); + + var normal = L3D.Tools.cross(v1, v2); + + return L3D.Tools.dot(directionCamera, normal) > 0; +}; + /** * Compute a function that can compare two faces * @param {Camera} camera a camera seeing or not face @@ -192,6 +260,13 @@ geo.MeshStreamer.prototype.start = function(socket) { self.mesh = geo.availableMeshes[path]; + if (self.mesh === undefined) { + process.stderr.write('Wrong path for model : ' + path); + socket.emit('refused'); + socket.disconnect(); + return; + } + self.meshFaces = new Array(self.mesh.meshes.length); for (var i = 0; i < self.meshFaces.length; i++) { @@ -203,15 +278,6 @@ geo.MeshStreamer.prototype.start = function(socket) { } - var regex = /.*\.\..*/; - var filePath = path.substring(1, path.length); - - if (regex.test(filePath)) { - socket.emit('refused'); - socket.disconnect(); - return; - } - socket.emit('ok'); }); @@ -344,8 +410,8 @@ geo.MeshStreamer.prototype.nextElements = function(_camera, force) { var mightBeCompletetlyFinished = true; // BOOM - if (camera != null) - this.mesh.faces.sort(this.faceComparator(camera)); + // if (camera != null) + // this.mesh.faces.sort(this.faceComparator(camera)); for (var faceIndex = 0; faceIndex < this.mesh.faces.length; faceIndex++) { @@ -355,64 +421,30 @@ geo.MeshStreamer.prototype.nextElements = function(_camera, force) { continue; - } else { - - mightBeCompletetlyFinished = false; - } + mightBeCompletetlyFinished = false; + var vertex1 = this.mesh.vertices[currentFace.a]; var vertex2 = this.mesh.vertices[currentFace.b]; var vertex3 = this.mesh.vertices[currentFace.c]; - if (!force) { + if (!force && camera !== null) { var display = false; - var outcodes = []; var exitToContinue = false; threeVertices = [vertex1, vertex2, vertex3]; - for (i = 0; i < threeVertices.length; i++) { - - var vertex = threeVertices[i]; - var currentOutcode = ""; - - for (var j = 0; j < planes.length; j++) { - - var plane = planes[j]; - - distance = - plane.normal.x * vertex.x + - plane.normal.y * vertex.y + - plane.normal.z * vertex.z + - plane.constant; - - // if (distance < 0) { - // exitToContinue = true; - // break; - // } - - currentOutcode += distance > 0 ? '0' : '1'; - - } - - outcodes.push(parseInt(currentOutcode,2)); - - } - - // http://vterrain.org/LOD/culling.html - // I have no idea what i'm doing - // http://i.kinja-img.com/gawker-media/image/upload/japbcvpavbzau9dbuaxf.jpg - // But it seems to work - if ( (outcodes[0] | outcodes[1]) === 0 && (outcodes[1] | outcodes[2]) === 0 ) { - // all points in - } else if ( (outcodes[0] === outcodes[1]) && (outcodes[0] === outcodes[2]) ) { - // all points out + // Frustum culling + if (!isInFrustum(threeVertices, planes)) { continue; } - else { - // part of the triangle is inside the viewing volume + + // Backface culling + if (this.isBackFace(camera, currentFace)) { + continue; } + } if (!this.vertices[currentFace.a]) { diff --git a/server/geo/mat1.json b/server/geo/mat1.json new file mode 100644 index 0000000..c532e85 --- /dev/null +++ b/server/geo/mat1.json @@ -0,0 +1 @@ +[[0,0.07894736842105263,0.18421052631578946,0,0.02631578947368421,0.02631578947368421,0,0.02631578947368421,0,0.13157894736842105,0.2894736842105263,0.2631578947368421],[0,0,0.10526315789473684,0.15789473684210525,0.18421052631578946,0.02631578947368421,0,0.07894736842105263,0.02631578947368421,0.05263157894736842,0.05263157894736842,0.05263157894736842],[0,0.02631578947368421,0,0.5,0.02631578947368421,0.02631578947368421,0.02631578947368421,0.07894736842105263,0.02631578947368421,0.07894736842105263,0.07894736842105263,0.05263157894736842],[0,0.05263157894736842,0.07894736842105263,0,0.4473684210526316,0.02631578947368421,0.13157894736842105,0.02631578947368421,0,0.07894736842105263,0,0.13157894736842105],[0,0,0.02631578947368421,0.15789473684210525,0,0.3157894736842105,0.21052631578947367,0.05263157894736842,0,0.07894736842105263,0,0.10526315789473684],[0,0.10526315789473684,0,0.05263157894736842,0.13157894736842105,0,0.13157894736842105,0.05263157894736842,0.15789473684210525,0.02631578947368421,0.02631578947368421,0.02631578947368421],[0,0.15789473684210525,0.10526315789473684,0,0,0.10526315789473684,0,0.05263157894736842,0.21052631578947367,0.13157894736842105,0,0],[0,0.07894736842105263,0.05263157894736842,0.02631578947368421,0.07894736842105263,0.07894736842105263,0.10526315789473684,0,0.07894736842105263,0.02631578947368421,0.02631578947368421,0.05263157894736842],[0,0,0.10526315789473684,0.02631578947368421,0.02631578947368421,0.18421052631578946,0.15789473684210525,0,0,0.21052631578947367,0.07894736842105263,0.07894736842105263],[0,0.07894736842105263,0.10526315789473684,0.02631578947368421,0,0,0.07894736842105263,0.15789473684210525,0.13157894736842105,0,0.21052631578947367,0.07894736842105263],[0,0.02631578947368421,0.10526315789473684,0.07894736842105263,0.05263157894736842,0.02631578947368421,0,0.02631578947368421,0.23684210526315788,0.07894736842105263,0,0.10526315789473684],[0,0.18421052631578946,0.13157894736842105,0.13157894736842105,0.10526315789473684,0.02631578947368421,0,0.13157894736842105,0.02631578947368421,0.05263157894736842,0.07894736842105263,0]] \ No newline at end of file diff --git a/server/geo/mat1.json.bak b/server/geo/mat1.json.bak new file mode 100644 index 0000000..92b0746 --- /dev/null +++ b/server/geo/mat1.json.bak @@ -0,0 +1 @@ +[[0,0,602,0,0,0,0,0,0,151,191,0],[0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,1116,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0],[0,87,0,0,0,0,0,0,0,0,0,82],[0,0,0,0,0,0,0,0,195,0,0,0],[0,86,41,0,0,0,0,0,0,563,74,72],[0,0,59,0,0,0,0,0,0,0,0,49],[0,147,151,0,0,0,0,0,0,0,0,110],[0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0]] \ No newline at end of file diff --git a/server/geo/mat2.json b/server/geo/mat2.json new file mode 100644 index 0000000..2801915 --- /dev/null +++ b/server/geo/mat2.json @@ -0,0 +1 @@ +[[0,0.03125,0.09375,0.5,0.21875,0.03125,0.09375,0.1875,0,0.125,0.15625,0],[0,0,0.15625,0.0625,0.21875,0.0625,0.15625,0.09375,0,0.0625,0.03125,0],[0,0.21875,0,0.0625,0.0625,0,0,0,0,0,0.03125,0.0625],[0,0.09375,0.0625,0,0.25,0.03125,0.1875,0.1875,0.03125,0.25,0,0.03125],[0,0.125,0.0625,0.125,0,0.03125,0,0,0.1875,0.09375,0.15625,0.0625],[0,0.03125,0,0,0,0,0.21875,0,0.25,0,0,0.1875],[0,0.03125,0.0625,0.0625,0.03125,0.34375,0,0.125,0.34375,0,0.40625,0.0625],[0,0.125,0,0.15625,0,0.0625,0.25,0,0.03125,0.09375,0,0],[0,0.125,0.03125,0.0625,0,0.1875,0.15625,0.03125,0,0.0625,0,0.25],[0,0.1875,0,0.125,0.125,0,0.0625,0.03125,0,0,0.03125,0.125],[0,0.0625,0.0625,0.03125,0.09375,0,0.46875,0.09375,0.03125,0.09375,0,0.1875],[0,0,0.0625,0.0625,0,0,0,0.03125,0.1875,0.125,0.46875,0]] \ No newline at end of file diff --git a/server/geo/mat2.json.bak b/server/geo/mat2.json.bak new file mode 100644 index 0000000..f106f63 --- /dev/null +++ b/server/geo/mat2.json.bak @@ -0,0 +1 @@ +[[0,0,0,218,0,0,0,0,0,0,0,0],[0,0,0,106,36,0,0,182,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,3,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,72],[0,0,0,0,0,0,0,0,0,0,0,0]] \ No newline at end of file diff --git a/server/geo/mat3.json b/server/geo/mat3.json new file mode 100644 index 0000000..172e079 --- /dev/null +++ b/server/geo/mat3.json @@ -0,0 +1 @@ +[[0,0.05555555555555555,0.08333333333333333,0,0.16666666666666666,0.027777777777777776,0.5,0,0.05555555555555555,0.027777777777777776,0],[0,0,0.05555555555555555,0.08333333333333333,0.08333333333333333,0,0.08333333333333333,0,0.027777777777777776,0.027777777777777776,0],[0,0.05555555555555555,0,0.1111111111111111,0.027777777777777776,0,0.027777777777777776,0,0.027777777777777776,0.027777777777777776,0],[0,0.05555555555555555,0.027777777777777776,0,0.1111111111111111,0,0.027777777777777776,0.027777777777777776,0.08333333333333333,0.027777777777777776,0],[0,0.08333333333333333,0,0.1111111111111111,0,0.3888888888888889,0,0.16666666666666666,0.05555555555555555,0.027777777777777776,0.05555555555555555],[0,0,0,0.027777777777777776,0.25,0,0.1111111111111111,0.1388888888888889,0,0,0.2222222222222222],[0,0.05555555555555555,0.08333333333333333,0.1388888888888889,0,0.027777777777777776,0,0.027777777777777776,0.08333333333333333,0.16666666666666666,0.3055555555555556],[0,0.027777777777777776,0.027777777777777776,0,0.027777777777777776,0.1388888888888889,0.05555555555555555,0,0.08333333333333333,0.05555555555555555,0.027777777777777776],[0,0,0,0,0.08333333333333333,0.05555555555555555,0.1111111111111111,0.05555555555555555,0,0.1111111111111111,0.1111111111111111],[0,0.027777777777777776,0.027777777777777776,0.027777777777777776,0.16666666666666666,0,0.05555555555555555,0.027777777777777776,0.1388888888888889,0,0],[0,0,0.027777777777777776,0,0.1388888888888889,0.16666666666666666,0.1111111111111111,0.08333333333333333,0.1111111111111111,0,0]] \ No newline at end of file diff --git a/server/geo/mat3.json.bak b/server/geo/mat3.json.bak new file mode 100644 index 0000000..d6f5dac --- /dev/null +++ b/server/geo/mat3.json.bak @@ -0,0 +1 @@ +[[0,0,0,0,0,0,70,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,12,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0],[0,0,0,10,0,0,0,0,0,0,0],[0,0,0,0,0,83,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,64],[0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,36,0,0,0,16,0,0]] \ No newline at end of file diff --git a/server/geo/matt1.json.bak b/server/geo/matt1.json.bak new file mode 100644 index 0000000..0326e8c --- /dev/null +++ b/server/geo/matt1.json.bak @@ -0,0 +1 @@ +[[0,0.1,0.3,0,0,0,0,0,0,0.1,0.4,0.5],[0,0,0.1,0.2,0.2,0,0,0.2,0,0.1,0.1,0],[0,0.1,0,0.4,0,0,0.1,0.3,0.1,0.1,0.1,0],[0,0.1,0,0,0.4,0.1,0.2,0,0,0.1,0,0.2],[0,0,0,0.2,0,0.5,0.1,0,0,0.1,0,0],[0,0,0,0,0.3,0,0.1,0,0.3,0.1,0.1,0.1],[0,0.3,0.1,0,0,0,0,0.1,0.4,0.1,0,0],[0,0.1,0.1,0,0.1,0,0.4,0,0,0,0.1,0.2],[0,0,0.3,0,0,0.3,0.1,0,0,0.3,0.1,0],[0,0.1,0.1,0,0,0,0.1,0.4,0,0,0.2,0.1],[0,0,0.2,0.2,0.1,0.1,0,0.1,0.3,0,0,0],[0,0.2,0.2,0.3,0,0,0,0.1,0,0.1,0.1,0]] \ No newline at end of file diff --git a/server/geo/matt2.json.bak b/server/geo/matt2.json.bak new file mode 100644 index 0000000..6f445c8 --- /dev/null +++ b/server/geo/matt2.json.bak @@ -0,0 +1 @@ +[[0,0,0.1,0.5,0.3,0,0.1,0.1,0,0.2,0,0],[0,0,0.2,0.1,0.1,0,0.3,0.2,0,0.2,0,0],[0,0.2,0,0.1,0.2,0,0,0,0,0,0,0.1],[0,0.1,0.1,0,0.4,0,0,0.2,0,0.3,0,0],[0,0.2,0,0,0,0.1,0,0,0.4,0.1,0.2,0.1],[0,0.1,0,0,0,0,0.1,0,0.4,0,0,0.2],[0,0.1,0,0,0.1,0.4,0,0.1,0.1,0,0.3,0.1],[0,0,0,0.3,0,0.1,0.2,0,0,0,0,0],[0,0.2,0.1,0.1,0,0.2,0.2,0,0,0,0,0.2],[0,0.3,0,0.1,0.1,0,0.1,0,0,0,0.1,0],[0,0.1,0.1,0,0,0,0.3,0.1,0,0.1,0,0.2],[0,0,0.1,0.1,0,0,0,0,0.1,0,0.5,0]] \ No newline at end of file diff --git a/server/geo/matt3.json.bak b/server/geo/matt3.json.bak new file mode 100644 index 0000000..9e45fe0 --- /dev/null +++ b/server/geo/matt3.json.bak @@ -0,0 +1 @@ +[[0,0.16666666666666666,0.16666666666666666,0,0.16666666666666666,0,0.5,0,0,0,0],[0,0,0.16666666666666666,0.16666666666666666,0,0,0,0,0.16666666666666666,0.16666666666666666,0],[0,0.16666666666666666,0,0.16666666666666666,0.16666666666666666,0,0.16666666666666666,0,0,0,0],[0,0.16666666666666666,0.16666666666666666,0,0,0,0,0.16666666666666666,0.16666666666666666,0.16666666666666666,0],[0,0,0,0.3333333333333333,0,0.16666666666666666,0,0.16666666666666666,0.16666666666666666,0,0],[0,0,0,0.16666666666666666,0.5,0,0,0,0,0,0.3333333333333333],[0,0,0.16666666666666666,0.16666666666666666,0,0,0,0,0,0,0.5],[0,0,0,0,0,0.3333333333333333,0.16666666666666666,0,0.16666666666666666,0,0],[0,0,0,0,0,0.16666666666666666,0.16666666666666666,0,0,0.5,0.16666666666666666],[0,0.16666666666666666,0,0.16666666666666666,0.16666666666666666,0,0,0,0.3333333333333333,0,0],[0,0,0,0,0,0.3333333333333333,0.16666666666666666,0.3333333333333333,0.16666666666666666,0,0]] \ No newline at end of file diff --git a/server/lib/Matrix.js b/server/lib/Matrix.js new file mode 100644 index 0000000..2911a80 --- /dev/null +++ b/server/lib/Matrix.js @@ -0,0 +1,141 @@ +"use strict"; + +let fs = require('fs'); + +class OutOfBoundError extends Error { + constructor(matrix, i, j) { + super(`Index array out of bound (${i},${j}) exceeds (${matrix.lines}, ${matrix.columns}).`); + this.name = 'OutOfBoundError'; + } +} + +class Matrix { + constructor(lines, columns) { + // this.lines = lines; + // this.columns = columns; + + this.data = []; + + for (let i = 0; i < lines; i++) { + let line = []; + for (let j = 0; j < columns; j++) { + line.push(0); + } + this.data.push(line); + } + } + + get(i, j) { + // if (i >= this.lines || j >= this.columns || i < 0 || j < 0 ) { + // this._throwOutOfBoundError(i,j); + // } + return this.data[i][j]; + } + + set(i, j, value) { + // if (i >= this.lines || j >= this.columns || i < 0 || j < 0 ) { + // this._throwOutOfBoundError(i,j); + // } + return this.data[i][j] = value; + } + + print(type) { + if (type === 'matlab') { + + let maxColumns = 0; + + for (let i = 0; i < this.data.length; i++) { + if (this.data[i].length > maxColumns) + maxColumns = this.data[i].length; + } + + let str = '['; + + for (let i = 0; i < this.data.length; i++) { + str += '['; + for (let j = 0; j < maxColumns; j++) { + str += + (this.data[i][j] !== undefined ? this.data[i][j] : 0) + + (j === maxColumns - 1 ? ']' : ','); + } + str += (i === this.data.length - 1 ? ']' : ';'); + } + + console.log(str + ';'); + + return; + } + // for (let i = 0; i < this.lines; i++) { + // for (let j = 0; j < this.columns; j++) { + // process.stdout.write(this.get(i,j) + ' '); + // } + // process.stdout.write('\n'); + // } + } + + toArray() { + return this.data; + } + + fromArray(array) { + + // if (! array instanceof Array) + // throw new TypeError('Parameter is not an array'); + + // let columns = null; + // for (let line of array) { + // if (! line instanceof Array) + // throw new TypeError('Parameter is not an array of array'); + + // if (columns === null) { + // columns = line.length; + // } else if (columns !== line.length) { + // throw new Typerror('The lines have not the same size'); + // } + + // } + + this.data = array; + + // this.columns = columns; + // this.lines = array.length; + + } + + saveToFile(path, type) { + if (type === 'matlab') { + fs.writeFileSync(path, JSON.stringify(this.data).replace('],', '];')); + return; + } + fs.writeFileSync(path, JSON.stringify(this.data)); + } + + loadFromFile(path) { + this.fromArray(JSON.parse(fs.readFileSync(path, 'utf-8'))); + } + + _throwOutOfBoundError(i,j) { + throw new OutOfBoundError(this, i, j); + } +}; + +module.exports = Matrix; + +function main() { + + var m = new Matrix(2,3); + m.set(1,2,3); + m.print(); + m.saveToFile('tests/myMatrix.json'); + + console.log('----'); + + var m2 = new Matrix(); + m2.loadFromFile('tests/myMatrix.json'); + m2.print(); + +} + +if (require.main === module) { + main(); +} diff --git a/lib/NodeLog.js b/server/lib/NodeLog.js similarity index 100% rename from lib/NodeLog.js rename to server/lib/NodeLog.js diff --git a/server/lib/Serial.js b/server/lib/Serial.js new file mode 100644 index 0000000..5d642d7 --- /dev/null +++ b/server/lib/Serial.js @@ -0,0 +1,101 @@ +"use strict"; + +let fs = require('fs'); +let THREE = require('three'); +let L3D = require('../static/js/l3d.min.js'); + +function serialize(object) { + + let data = {}; + + data.vertices = object.children[0].geometry.vertices; + + data.children = []; + + for (let objChild of object.children) { + + let newChild = {}; + + // newChild.faceVertexUvs = objChild.geometry.faceVertexUvs; + newChild.faces = objChild.geometry.faces; + + data.children.push(newChild); + + } + + return JSON.stringify(data); + +} + +function deserialize(str) { + + let parse = JSON.parse(str); + let vertices = []; + let material = new THREE.MeshBasicMaterial(); + + let ret = new THREE.Object3D(); + + for (let vertex of parse.vertices) { + + vertices.push(new THREE.Vector3(vertex.x, vertex.y, vertex.z)); + + } + + + for (let parseChild of parse.children) { + + let geometry = new THREE.Geometry(); + geometry.vertices = vertices; + + for (let face of parseChild.faces) { + + geometry.faces.push(new THREE.Face3(face.a, face.b, face.c)); + + } + + geometry.computeBoundingSphere(); + let newChild = new THREE.Mesh(geometry, material); + + ret.children.push(newChild); + } + + return ret; + +} + +function serializeToFile(path, obj) { + + fs.writeFileSync(path, serialize(obj)); + +} + +function loadFromFile(path) { + + return deserialize(fs.readFileSync(path, 'utf-8')); + +} + +module.exports.serialize = serialize; +module.exports.deserialize = deserialize; +module.exports.serializeToFile = serializeToFile; +module.exports.loadFromFile = loadFromFile; + +function main() { + + let loader = new L3D.ProgressiveLoader( + '/static/data/castle/princess peaches castle (outside).obj', + new THREE.Object3D(), + null + ); + + loader.load(function() { + console.log("Loaded"); + // console.log(loader.obj.children[0].geometry); + deserialize(serialize(loader.obj)); + }); + +} + +if (require.main === module) { + main(); +} diff --git a/lib/controllers.js b/server/lib/controllers.js similarity index 100% rename from lib/controllers.js rename to server/lib/controllers.js diff --git a/lib/filterInt.js b/server/lib/filterInt.js similarity index 100% rename from lib/filterInt.js rename to server/lib/filterInt.js diff --git a/server/lib/mat1.json b/server/lib/mat1.json new file mode 100644 index 0000000..5dea28d --- /dev/null +++ b/server/lib/mat1.json @@ -0,0 +1 @@ +[[0,0.07894736842105263,0.18421052631578946,0,0.02631578947368421,0.02631578947368421,0,0.02631578947368421,0,0.13157894736842105,0.2894736842105263,0.2631578947368421],[0,0,0.10526315789473684,0.15789473684210525,0.18421052631578946,0.02631578947368421,0,0.07894736842105263,0.02631578947368421,0.05263157894736842,0.05263157894736842,0.05263157894736842],[0,0.02631578947368421,0,0.5,0.02631578947368421,0.02631578947368421,0.02631578947368421,0.07894736842105263,0.02631578947368421,0.07894736842105263,0.07894736842105263,0.05263157894736842],[0,0.05263157894736842,0.07894736842105263,0,0.4473684210526316,0.02631578947368421,0.13157894736842105,0.02631578947368421,0,0.07894736842105263,0,0.13157894736842105],[0,0,0.02631578947368421,0.15789473684210525,0,0.3157894736842105,0.21052631578947367,0.05263157894736842,0,0.07894736842105263,0,0.10526315789473684],[0,0.10526315789473684,0,0.05263157894736842,0.13157894736842105,0,0.13157894736842105,0.05263157894736842,0.15789473684210525,0.02631578947368421,0.02631578947368421,0.02631578947368421],[0,0.15789473684210525,0.10526315789473684,0,0,0.10526315789473684,0,0.05263157894736842,0.21052631578947367,0.13157894736842105,0,0],[0,0.07894736842105263,0.05263157894736842,0.02631578947368421,0.07894736842105263,0.07894736842105263,0.10526315789473684,0,0.07894736842105263,0.02631578947368421,0.02631578947368421,0.05263157894736842],[0,0,0.10526315789473684,0.02631578947368421,0.02631578947368421,0.18421052631578946,0.15789473684210525,0,0,0.21052631578947367,0.07894736842105263,0.07894736842105263],[0,0.07894736842105263,0.10526315789473684,0.02631578947368421,0,0,0.07894736842105263,0.15789473684210525,0.13157894736842105,0,0.21052631578947367,0.07894736842105263],[0,0.02631578947368421,0.10526315789473684,0.07894736842105263,0.05263157894736842,0.02631578947368421,0,0.02631578947368421,0.23684210526315788,0.07894736842105263,0,0.10526315789473684],[0,0.18421052631578946,0.13157894736842105,0.13157894736842105,0.10526315789473684,0.02631578947368421,0,0.13157894736842105,0.02631578947368421,0.05263157894736842,0.07894736842105263,0],] \ No newline at end of file diff --git a/server/lib/mat2.json b/server/lib/mat2.json new file mode 100644 index 0000000..ac39b91 --- /dev/null +++ b/server/lib/mat2.json @@ -0,0 +1 @@ +[[0,0.03125,0.09375,0.5,0.21875,0.03125,0.09375,0.1875,0,0.125,0.15625,0],[0,0,0.15625,0.0625,0.21875,0.0625,0.15625,0.09375,0,0.0625,0.03125,0],[0,0.21875,0,0.0625,0.0625,0,0,0,0,0,0.03125,0.0625],[0,0.09375,0.0625,0,0.25,0.03125,0.1875,0.1875,0.03125,0.25,0,0.03125],[0,0.125,0.0625,0.125,0,0.03125,0,0,0.1875,0.09375,0.15625,0.0625],[0,0.03125,0,0,0,0,0.21875,0,0.25,0,0,0.1875],[0,0.03125,0.0625,0.0625,0.03125,0.34375,0,0.125,0.34375,0,0.40625,0.0625],[0,0.125,0,0.15625,0,0.0625,0.25,0,0.03125,0.09375,0,0],[0,0.125,0.03125,0.0625,0,0.1875,0.15625,0.03125,0,0.0625,0,0.25],[0,0.1875,0,0.125,0.125,0,0.0625,0.03125,0,0,0.03125,0.125],[0,0.0625,0.0625,0.03125,0.09375,0,0.46875,0.09375,0.03125,0.09375,0,0.1875],[0,0,0.0625,0.0625,0,0,0,0.03125,0.1875,0.125,0.46875,0],] \ No newline at end of file diff --git a/server/lib/mat3.json b/server/lib/mat3.json new file mode 100644 index 0000000..dd49386 --- /dev/null +++ b/server/lib/mat3.json @@ -0,0 +1 @@ +[[0,0.05555555555555555,0.08333333333333333,0,0.16666666666666666,0.027777777777777776,0.5,0,0.05555555555555555,0.027777777777777776,0],[0,0,0.05555555555555555,0.08333333333333333,0.08333333333333333,0,0.08333333333333333,0,0.027777777777777776,0.027777777777777776,0],[0,0.05555555555555555,0,0.1111111111111111,0.027777777777777776,0,0.027777777777777776,0,0.027777777777777776,0.027777777777777776,0],[0,0.05555555555555555,0.027777777777777776,0,0.1111111111111111,0,0.027777777777777776,0.027777777777777776,0.08333333333333333,0.027777777777777776,0],[0,0.08333333333333333,0,0.1111111111111111,0,0.3888888888888889,0,0.16666666666666666,0.05555555555555555,0.027777777777777776,0.05555555555555555],[0,0,0,0.027777777777777776,0.25,0,0.1111111111111111,0.1388888888888889,0,0,0.2222222222222222],[0,0.05555555555555555,0.08333333333333333,0.1388888888888889,0,0.027777777777777776,0,0.027777777777777776,0.08333333333333333,0.16666666666666666,0.3055555555555556],[0,0.027777777777777776,0.027777777777777776,0,0.027777777777777776,0.1388888888888889,0.05555555555555555,0,0.08333333333333333,0.05555555555555555,0.027777777777777776],[0,0,0,0,0.08333333333333333,0.05555555555555555,0.1111111111111111,0.05555555555555555,0,0.1111111111111111,0.1111111111111111],[0,0.027777777777777776,0.027777777777777776,0.027777777777777776,0.16666666666666666,0,0.05555555555555555,0.027777777777777776,0.1388888888888889,0,0],[0,0,0.027777777777777776,0,0.1388888888888889,0.16666666666666666,0.1111111111111111,0.08333333333333333,0.1111111111111111,0,0],] \ No newline at end of file diff --git a/server/lib/matt1.json b/server/lib/matt1.json new file mode 100644 index 0000000..4238f03 --- /dev/null +++ b/server/lib/matt1.json @@ -0,0 +1 @@ +[[0,0.1,0.3,0,0,0,0,0,0,0.1,0.4,0.5],[0,0,0.1,0.2,0.2,0,0,0.2,0,0.1,0.1,0],[0,0.1,0,0.4,0,0,0.1,0.3,0.1,0.1,0.1,0],[0,0.1,0,0,0.4,0.1,0.2,0,0,0.1,0,0.2],[0,0,0,0.2,0,0.5,0.1,0,0,0.1,0,0],[0,0,0,0,0.3,0,0.1,0,0.3,0.1,0.1,0.1],[0,0.3,0.1,0,0,0,0,0.1,0.4,0.1,0,0],[0,0.1,0.1,0,0.1,0,0.4,0,0,0,0.1,0.2],[0,0,0.3,0,0,0.3,0.1,0,0,0.3,0.1,0],[0,0.1,0.1,0,0,0,0.1,0.4,0,0,0.2,0.1],[0,0,0.2,0.2,0.1,0.1,0,0.1,0.3,0,0,0],[0,0.2,0.2,0.3,0,0,0,0.1,0,0.1,0.1,0],] \ No newline at end of file diff --git a/server/lib/matt2.json b/server/lib/matt2.json new file mode 100644 index 0000000..0e34f73 --- /dev/null +++ b/server/lib/matt2.json @@ -0,0 +1 @@ +[[0,0,0.1,0.5,0.3,0,0.1,0.1,0,0.2,0,0],[0,0,0.2,0.1,0.1,0,0.3,0.2,0,0.2,0,0],[0,0.2,0,0.1,0.2,0,0,0,0,0,0,0.1],[0,0.1,0.1,0,0.4,0,0,0.2,0,0.3,0,0],[0,0.2,0,0,0,0.1,0,0,0.4,0.1,0.2,0.1],[0,0.1,0,0,0,0,0.1,0,0.4,0,0,0.2],[0,0.1,0,0,0.1,0.4,0,0.1,0.1,0,0.3,0.1],[0,0,0,0.3,0,0.1,0.2,0,0,0,0,0],[0,0.2,0.1,0.1,0,0.2,0.2,0,0,0,0,0.2],[0,0.3,0,0.1,0.1,0,0.1,0,0,0,0.1,0],[0,0.1,0.1,0,0,0,0.3,0.1,0,0.1,0,0.2],[0,0,0.1,0.1,0,0,0,0,0.1,0,0.5,0],] \ No newline at end of file diff --git a/server/lib/matt3.json b/server/lib/matt3.json new file mode 100644 index 0000000..abcd8da --- /dev/null +++ b/server/lib/matt3.json @@ -0,0 +1 @@ +[[0,0.16666666666666666,0.16666666666666666,0,0.16666666666666666,0,0.5,0,0,0,0],[0,0,0.16666666666666666,0.16666666666666666,0,0,0,0,0.16666666666666666,0.16666666666666666,0],[0,0.16666666666666666,0,0.16666666666666666,0.16666666666666666,0,0.16666666666666666,0,0,0,0],[0,0.16666666666666666,0.16666666666666666,0,0,0,0,0.16666666666666666,0.16666666666666666,0.16666666666666666,0],[0,0,0,0.3333333333333333,0,0.16666666666666666,0,0.16666666666666666,0.16666666666666666,0,0],[0,0,0,0.16666666666666666,0.5,0,0,0,0,0,0.3333333333333333],[0,0,0.16666666666666666,0.16666666666666666,0,0,0,0,0,0,0.5],[0,0,0,0,0,0.3333333333333333,0.16666666666666666,0,0.16666666666666666,0,0],[0,0,0,0,0,0.16666666666666666,0.16666666666666666,0,0,0.5,0.16666666666666666],[0,0.16666666666666666,0,0.16666666666666666,0.16666666666666666,0,0,0,0.3333333333333333,0,0],[0,0,0,0,0,0.3333333333333333,0.16666666666666666,0.3333333333333333,0.16666666666666666,0,0],] \ No newline at end of file diff --git a/lib/posts.js b/server/lib/posts.js similarity index 100% rename from lib/posts.js rename to server/lib/posts.js diff --git a/server/lib/tests/myMatrix.json b/server/lib/tests/myMatrix.json new file mode 100644 index 0000000..d75cc25 --- /dev/null +++ b/server/lib/tests/myMatrix.json @@ -0,0 +1 @@ +[[0,0,0],[0,0,3]] \ No newline at end of file diff --git a/lib/vcode.js b/server/lib/vcode.js similarity index 100% rename from lib/vcode.js rename to server/lib/vcode.js diff --git a/npm-shrinkwrap.json b/server/npm-shrinkwrap.json similarity index 100% rename from npm-shrinkwrap.json rename to server/npm-shrinkwrap.json diff --git a/package.json b/server/package.json similarity index 100% rename from package.json rename to server/package.json diff --git a/posts/arrow-clicked/index.js b/server/posts/arrow-clicked/index.js similarity index 100% rename from posts/arrow-clicked/index.js rename to server/posts/arrow-clicked/index.js diff --git a/posts/arrow-clicked/urls.js b/server/posts/arrow-clicked/urls.js similarity index 100% rename from posts/arrow-clicked/urls.js rename to server/posts/arrow-clicked/urls.js diff --git a/posts/coin-clicked/index.js b/server/posts/coin-clicked/index.js similarity index 100% rename from posts/coin-clicked/index.js rename to server/posts/coin-clicked/index.js diff --git a/posts/coin-clicked/urls.js b/server/posts/coin-clicked/urls.js similarity index 100% rename from posts/coin-clicked/urls.js rename to server/posts/coin-clicked/urls.js diff --git a/posts/coin-info/index.js b/server/posts/coin-info/index.js similarity index 100% rename from posts/coin-info/index.js rename to server/posts/coin-info/index.js diff --git a/posts/coin-info/urls.js b/server/posts/coin-info/urls.js similarity index 100% rename from posts/coin-info/urls.js rename to server/posts/coin-info/urls.js diff --git a/posts/feedback-target/index.js b/server/posts/feedback-target/index.js similarity index 100% rename from posts/feedback-target/index.js rename to server/posts/feedback-target/index.js diff --git a/posts/feedback-target/urls.js b/server/posts/feedback-target/urls.js similarity index 100% rename from posts/feedback-target/urls.js rename to server/posts/feedback-target/urls.js diff --git a/posts/fps/index.js b/server/posts/fps/index.js similarity index 100% rename from posts/fps/index.js rename to server/posts/fps/index.js diff --git a/posts/fps/urls.js b/server/posts/fps/urls.js similarity index 100% rename from posts/fps/urls.js rename to server/posts/fps/urls.js diff --git a/posts/hovered/index.js b/server/posts/hovered/index.js similarity index 100% rename from posts/hovered/index.js rename to server/posts/hovered/index.js diff --git a/posts/hovered/urls.js b/server/posts/hovered/urls.js similarity index 100% rename from posts/hovered/urls.js rename to server/posts/hovered/urls.js diff --git a/posts/identification/index.js b/server/posts/identification/index.js similarity index 100% rename from posts/identification/index.js rename to server/posts/identification/index.js diff --git a/posts/identification/urls.js b/server/posts/identification/urls.js similarity index 100% rename from posts/identification/urls.js rename to server/posts/identification/urls.js diff --git a/posts/keyboard-event/index.js b/server/posts/keyboard-event/index.js similarity index 100% rename from posts/keyboard-event/index.js rename to server/posts/keyboard-event/index.js diff --git a/posts/keyboard-event/urls.js b/server/posts/keyboard-event/urls.js similarity index 100% rename from posts/keyboard-event/urls.js rename to server/posts/keyboard-event/urls.js diff --git a/posts/pointer-locked/index.js b/server/posts/pointer-locked/index.js similarity index 100% rename from posts/pointer-locked/index.js rename to server/posts/pointer-locked/index.js diff --git a/posts/pointer-locked/urls.js b/server/posts/pointer-locked/urls.js similarity index 100% rename from posts/pointer-locked/urls.js rename to server/posts/pointer-locked/urls.js diff --git a/posts/previous-next-clicked/index.js b/server/posts/previous-next-clicked/index.js similarity index 100% rename from posts/previous-next-clicked/index.js rename to server/posts/previous-next-clicked/index.js diff --git a/posts/previous-next-clicked/urls.js b/server/posts/previous-next-clicked/urls.js similarity index 100% rename from posts/previous-next-clicked/urls.js rename to server/posts/previous-next-clicked/urls.js diff --git a/posts/reset-clicked/index.js b/server/posts/reset-clicked/index.js similarity index 100% rename from posts/reset-clicked/index.js rename to server/posts/reset-clicked/index.js diff --git a/posts/reset-clicked/urls.js b/server/posts/reset-clicked/urls.js similarity index 100% rename from posts/reset-clicked/urls.js rename to server/posts/reset-clicked/urls.js diff --git a/posts/switched-lock-option/index.js b/server/posts/switched-lock-option/index.js similarity index 100% rename from posts/switched-lock-option/index.js rename to server/posts/switched-lock-option/index.js diff --git a/posts/switched-lock-option/urls.js b/server/posts/switched-lock-option/urls.js similarity index 100% rename from posts/switched-lock-option/urls.js rename to server/posts/switched-lock-option/urls.js diff --git a/server.js b/server/server.js similarity index 96% rename from server.js rename to server/server.js index 05d0821..e1f66e3 100644 --- a/server.js +++ b/server/server.js @@ -75,10 +75,10 @@ require('./lib/controllers')(app); require('./lib/posts')(app); // Static files -app.use('/static', express.static('static')); +app.use('/static', express.static('../static')); // Favicon -app.use(favicon(__dirname + '/static/ico/favicon.ico')); +app.use(favicon(__dirname + '/../static/ico/favicon.ico')); // When error raised app.use(function(err, req, res, next) { diff --git a/socket.js b/server/socket.js similarity index 100% rename from socket.js rename to server/socket.js diff --git a/urls.js b/server/urls.js similarity index 100% rename from urls.js rename to server/urls.js diff --git a/views/404.jade b/server/views/404.jade similarity index 100% rename from views/404.jade rename to server/views/404.jade diff --git a/views/base.jade b/server/views/base.jade similarity index 100% rename from views/base.jade rename to server/views/base.jade diff --git a/views/main.jade b/server/views/main.jade similarity index 100% rename from views/main.jade rename to server/views/main.jade diff --git a/views/withjs.jade b/server/views/withjs.jade similarity index 100% rename from views/withjs.jade rename to server/views/withjs.jade diff --git a/utils/demon.sh b/utils/demon.sh index 938a212..cd698af 100755 --- a/utils/demon.sh +++ b/utils/demon.sh @@ -24,7 +24,8 @@ inotifywait -r -e close_write -m . | fi done & -cd ../geo +cd ../server/geo +# cd server/geo inotifywait -r -e close_write -m . | while read path action file; do if [ `find . -name $file | wc -l` -ne 0 ]; then