Some commits
This commit is contained in:
+2
-1
@@ -100,12 +100,13 @@ function objectClickerOnClick(camera1, buttonManager, recommendations, coins) {
|
||||
} else if (obj instanceof L3D.BaseRecommendation) {
|
||||
|
||||
obj.check();
|
||||
camera1.moveHermite(obj);
|
||||
|
||||
// Send event to DB
|
||||
event = new L3D.DB.Event.ArrowClicked();
|
||||
event.arrowId = recommendations.indexOf(obj);
|
||||
event.send();
|
||||
|
||||
camera1.moveHermite(obj, undefined, event.arrowId);
|
||||
}
|
||||
|
||||
// Update the button manager
|
||||
|
||||
+36
-10
@@ -38,15 +38,15 @@ var pointer;
|
||||
var startCanvas;
|
||||
var loadingCanvas;
|
||||
|
||||
window.onbeforeunload = function() {
|
||||
|
||||
if (initMainScene !== L3D.initPeach && initMainScene !== L3D.initSponza && !($('#next').is(":visible"))) {
|
||||
|
||||
return 'Warning : you are going to leave the page and abort the current test !';
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
// window.onbeforeunload = function() {
|
||||
//
|
||||
// if (initMainScene !== L3D.initPeach && initMainScene !== L3D.initSponza && !($('#next').is(":visible"))) {
|
||||
//
|
||||
// return 'Warning : you are going to leave the page and abort the current test !';
|
||||
//
|
||||
// }
|
||||
//
|
||||
// };
|
||||
|
||||
var nextPage = '/prototype/play';
|
||||
|
||||
@@ -69,7 +69,7 @@ function main() {
|
||||
initModels();
|
||||
initListeners();
|
||||
|
||||
appendTo(container)(stats, Coin, startCanvas, pointer, previewer, loadingCanvas, renderer);
|
||||
appendTo(container)(stats, Coin, startCanvas, pointer, previewer, /*loadingCanvas,*/ renderer);
|
||||
// appendTo(container)(startCanvas, pointer, previewer, renderer);
|
||||
|
||||
// Set the good size of cameras
|
||||
@@ -117,6 +117,32 @@ function initThreeElements() {
|
||||
renderer = new THREE.WebGLRenderer({alpha:true, antialias:true});
|
||||
renderer.setClearColor(0x87ceeb);
|
||||
|
||||
var loader = new THREE.OBJLoader();
|
||||
|
||||
loader.load(
|
||||
'/static/data/coin/Coin.obj',
|
||||
function(object) {
|
||||
object.traverse(function (mesh) {
|
||||
if (mesh instanceof THREE.Mesh) {
|
||||
mesh.scale.set(0.01,0.01,0.01);
|
||||
mesh.material.color.setHex(0xffff00);
|
||||
mesh.geometry.computeVertexNormals();
|
||||
mesh.raycastable = true;
|
||||
mesh.position.copy(new THREE.Vector3(-23.85237224023958,12.30017484578007,2.883526209796364));
|
||||
scene.add(mesh);
|
||||
|
||||
newMesh = mesh.clone();
|
||||
newMesh.position.copy(new THREE.Vector3(-8.225753727064939,11.932703941399415,8.637544772060489));
|
||||
scene.add(newMesh);
|
||||
|
||||
newMesh.position.copy(new THREE.Vector3(18.198980821370327,2.5219742652442885,10.741621475827422));
|
||||
scene.add(newMesh);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
// Initialize pointer camera
|
||||
camera1 = new L3D.PointerCamera(
|
||||
50,
|
||||
|
||||
@@ -167,7 +167,7 @@ L3D.PointerCamera = function() {
|
||||
* Option to enable or disable the collisions
|
||||
* @type {Boolean}
|
||||
*/
|
||||
this.collisions = true;
|
||||
this.collisions = false;
|
||||
|
||||
/**
|
||||
* Is true when we should log the camera angles. It will be set to false
|
||||
@@ -457,7 +457,7 @@ L3D.PointerCamera.prototype.anglesFromVectors = function() {
|
||||
* @param {Camera} camera Camera to move to
|
||||
* @param {Boolean} [toSave=true] true if you want to save the current state of the camera
|
||||
*/
|
||||
L3D.PointerCamera.prototype.move = function(recommendation, toSave) {
|
||||
L3D.PointerCamera.prototype.move = function(recommendation, toSave, recommendationId) {
|
||||
if (toSave === undefined)
|
||||
toSave = true;
|
||||
|
||||
@@ -488,13 +488,13 @@ L3D.PointerCamera.prototype.move = function(recommendation, toSave) {
|
||||
* @param {Camera} camera Camera to move to
|
||||
* @param {Boolean} [toSave=true] true if you want to save the current state of the camera
|
||||
*/
|
||||
L3D.PointerCamera.prototype.moveHermite = function(recommendation, toSave) {
|
||||
L3D.PointerCamera.prototype.moveHermite = function(recommendation, toSave, recommendationId) {
|
||||
if (toSave === undefined)
|
||||
toSave = true;
|
||||
|
||||
var otherCamera = recommendation.camera || recommendation;
|
||||
this.recommendationClicked = recommendationId;
|
||||
|
||||
this.recommendationClicked = otherCamera;
|
||||
var otherCamera = recommendation.camera || recommendation;
|
||||
|
||||
this.moving = false;
|
||||
this.movingHermite = true;
|
||||
@@ -756,19 +756,22 @@ L3D.PointerCamera.prototype.redoable = function() {
|
||||
* </ol>
|
||||
*/
|
||||
L3D.PointerCamera.prototype.toList = function() {
|
||||
this.updateMatrix();
|
||||
this.updateMatrixWorld();
|
||||
|
||||
var camera = this; // (this.recommendationClicked === null ? this : this.cameras[this.recommendationClicked].camera);
|
||||
|
||||
camera.updateMatrix();
|
||||
camera.updateMatrixWorld();
|
||||
|
||||
camera.matrixWorldInverse.getInverse(camera.matrixWorld);
|
||||
|
||||
var frustum = new THREE.Frustum();
|
||||
var projScreenMatrix = new THREE.Matrix4();
|
||||
projScreenMatrix.multiplyMatrices(this.projectionMatrix, this.matrixWorldInverse);
|
||||
|
||||
frustum.setFromMatrix(new THREE.Matrix4().multiplyMatrices(this.projectionMatrix, this.matrixWorldInverse));
|
||||
frustum.setFromMatrix(new THREE.Matrix4().multiplyMatrices(camera.projectionMatrix, camera.matrixWorldInverse));
|
||||
|
||||
var ret =
|
||||
[[this.position.x, this.position.y, this.position.z],
|
||||
[this.target.x, this.target.y, this.target.z],
|
||||
this.recommendationClicked !== null
|
||||
[[camera.position.x, camera.position.y, camera.position.z],
|
||||
[camera.target.x, camera.target.y, camera.target.z],
|
||||
this.recommendationClicked
|
||||
];
|
||||
|
||||
for (var i = 0; i < frustum.planes.length; i++) {
|
||||
@@ -782,5 +785,6 @@ L3D.PointerCamera.prototype.toList = function() {
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -121,7 +121,7 @@ L3D.ReplayCamera.prototype.nextEvent = function() {
|
||||
self.isArrow = false;
|
||||
if (typeof self.logReco === 'function') {
|
||||
var info = self.logReco(false, self.totalTime);
|
||||
require('fs').appendFileSync(info.path, info.value);
|
||||
// require('fs').appendFileSync(info.path, info.value);
|
||||
}
|
||||
process.stderr.write('\033[31mArrowclicked finished !\033[0m\n');
|
||||
}
|
||||
@@ -161,7 +161,7 @@ L3D.ReplayCamera.prototype.nextEvent = function() {
|
||||
self.isArrow = true;
|
||||
if (typeof self.logReco === 'function') {
|
||||
var info = self.logReco(true, self.totalTime);
|
||||
require('fs').appendFileSync(info.path, info.value);
|
||||
// require('fs').appendFileSync(info.path, info.value);
|
||||
}
|
||||
process.stderr.write('\033[33mArrowclicked ! ' + JSON.stringify(self.cameras[self.event.id].camera.position) + '\033[0m\n');
|
||||
if (self.quittingTime === Infinity)
|
||||
|
||||
@@ -207,9 +207,9 @@ var ProgressiveLoader = function(path, scene, camera, callback, log, laggy, pref
|
||||
// Only good for sponza model
|
||||
this.camera._moveHermite = this.camera.moveHermite;
|
||||
|
||||
this.camera.moveHermite = function(param) {
|
||||
var toSend = param.position.x > 0 ? 0 : 1;
|
||||
self.socket.emit('reco', toSend);
|
||||
this.camera.moveHermite = function() {
|
||||
console.log(arguments);
|
||||
self.socket.emit('reco', arguments[2]);
|
||||
self.camera._moveHermite.apply(self.camera, arguments);
|
||||
};
|
||||
|
||||
@@ -242,7 +242,7 @@ var ProgressiveLoader = function(path, scene, camera, callback, log, laggy, pref
|
||||
|
||||
this.mapFace = {};
|
||||
|
||||
this.prefetch = prefetch === undefined ? true : (!!prefetch);
|
||||
this.prefetch = prefetch;
|
||||
|
||||
};
|
||||
|
||||
@@ -434,11 +434,8 @@ ProgressiveLoader.prototype.initIOCallbacks = function() {
|
||||
var param;
|
||||
if (typeof self.onBeforeEmit === 'function') {
|
||||
|
||||
for (var m of self.meshes) {
|
||||
m.geometry.computeBoundingSphere();
|
||||
}
|
||||
param = self.onBeforeEmit();
|
||||
setTimeout(function() { self.socket.emit('next', self.getCamera(), param);}, 100);
|
||||
self.socket.emit('next', self.getCamera(), param);
|
||||
|
||||
} else {
|
||||
|
||||
@@ -467,6 +464,13 @@ ProgressiveLoader.prototype.initIOCallbacks = function() {
|
||||
});
|
||||
};
|
||||
|
||||
ProgressiveLoader.prototype.computeBoundingSphere = function() {
|
||||
for (var m of this.meshes) {
|
||||
m.geometry.computeBoundingSphere();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Starts the communication with the server
|
||||
*/
|
||||
|
||||
@@ -40,7 +40,7 @@ L3D.ViewportRecommendation = function(arg1, arg2, arg3, arg4, position, target)
|
||||
);
|
||||
|
||||
(function(self, direction, left, other) {
|
||||
var material = new THREE.LineBasicMaterial({ color: '0x000000'});
|
||||
var material = new THREE.LineBasicMaterial({ color: '0x000000', linewidth: 3});
|
||||
var geometry = new THREE.Geometry();
|
||||
var tmpDirection = L3D.Tools.mul(direction, -2);
|
||||
var target = L3D.Tools.sum(self.camera.position, tmpDirection);
|
||||
|
||||
@@ -11,12 +11,12 @@ L3D.LogFunction = function(a,b) {
|
||||
};
|
||||
|
||||
L3D.addLight = function(scene) {
|
||||
var directionalLight = new THREE.DirectionalLight(0xdddddd);
|
||||
directionalLight.position.set(1, 2.5, 1).normalize();
|
||||
var directionalLight = new THREE.DirectionalLight(0x777777);
|
||||
directionalLight.position.set(1, 1, 0).normalize();
|
||||
directionalLight.castShadow = false;
|
||||
scene.add(directionalLight);
|
||||
|
||||
var ambientLight = new THREE.AmbientLight(0x555555);
|
||||
var ambientLight = new THREE.AmbientLight(0xbbbbbb);
|
||||
scene.add(ambientLight);
|
||||
};
|
||||
|
||||
@@ -167,7 +167,7 @@ L3D.createPeachRecommendations = function(width, height, rec) {
|
||||
L3D.initBobombScene = function(scene, collidableObjects, recommendation, clickable) {
|
||||
|
||||
var loader = new L3D.ProgressiveLoader(
|
||||
'/static/data/bobomb/bobomb battlefeild.obj',
|
||||
'/static/data/bobomb/bobomb battlefeild_sub.obj',
|
||||
scene,
|
||||
recommendation,
|
||||
function(object) {
|
||||
@@ -179,7 +179,9 @@ L3D.initBobombScene = function(scene, collidableObjects, recommendation, clickab
|
||||
THREEx.Transparency.push(object);
|
||||
}
|
||||
},
|
||||
L3D.LogFunction
|
||||
L3D.LogFunction,
|
||||
false,
|
||||
prefetch
|
||||
);
|
||||
|
||||
loader.load();
|
||||
@@ -200,6 +202,8 @@ L3D.resetBobombElements = function() {
|
||||
|
||||
L3D.generateCoins = function(totalCoins, coinIds) {
|
||||
|
||||
return [];
|
||||
|
||||
var i = 0;
|
||||
var tmp = [];
|
||||
|
||||
@@ -354,7 +358,7 @@ L3D.initBobomb = function(camera, scene, coins, clickable, coinIds) {
|
||||
L3D.initWhompScene = function(scene, collidableObjects, recommendation, clickable) {
|
||||
|
||||
var loader = new L3D.ProgressiveLoader(
|
||||
'/static/data/whomp/Whomps Fortress.obj',
|
||||
'/static/data/whomp/Whomps Fortress_sub.obj',
|
||||
scene,
|
||||
recommendation,
|
||||
function(object) {
|
||||
@@ -375,7 +379,10 @@ L3D.initWhompScene = function(scene, collidableObjects, recommendation, clickabl
|
||||
}
|
||||
|
||||
},
|
||||
L3D.LogFunction
|
||||
L3D.LogFunction,
|
||||
false,
|
||||
prefetch
|
||||
|
||||
);
|
||||
|
||||
loader.load();
|
||||
@@ -510,7 +517,7 @@ L3D.initWhomp = function(recommendation, scene, coins, clickable, coinIds) {
|
||||
L3D.initMountainScene = function(scene, collidableObjects, recommendation, clickable) {
|
||||
|
||||
var loader = new L3D.ProgressiveLoader(
|
||||
'/static/data/mountain/coocoolmountain.obj',
|
||||
'/static/data/mountain/coocoolmountain_sub.obj',
|
||||
scene,
|
||||
recommendation,
|
||||
function(object) {
|
||||
@@ -535,7 +542,10 @@ L3D.initMountainScene = function(scene, collidableObjects, recommendation, click
|
||||
object.material.opacity = 0.5;
|
||||
}
|
||||
},
|
||||
L3D.LogFunction
|
||||
L3D.LogFunction,
|
||||
false,
|
||||
prefetch
|
||||
|
||||
);
|
||||
|
||||
loader.load();
|
||||
@@ -670,26 +680,26 @@ L3D.initSponzaScene = function(scene, collidableObjects, recommendation, clickab
|
||||
loader.load();
|
||||
|
||||
|
||||
loader.getCamera = function() {
|
||||
var ret = loader.camera.toList();
|
||||
ret[0][0] *= 10;
|
||||
ret[0][1] *= 10;
|
||||
ret[0][2] *= 10;
|
||||
// loader.getCamera = function() {
|
||||
// var ret = loader.camera.toList();
|
||||
// ret[0][0] *= 10;
|
||||
// ret[0][1] *= 10;
|
||||
// ret[0][2] *= 10;
|
||||
|
||||
ret[1][0] *= 10;
|
||||
ret[1][1] *= 10;
|
||||
ret[1][2] *= 10;
|
||||
// ret[1][0] *= 10;
|
||||
// ret[1][1] *= 10;
|
||||
// ret[1][2] *= 10;
|
||||
|
||||
// Planes
|
||||
for (var i = 2; i < ret.length; i++) {
|
||||
// // Planes
|
||||
// for (var i = 3; i < ret.length; i++) {
|
||||
|
||||
ret[i][3] *= 10;
|
||||
// ret[i][3] *= 10;
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
return ret;
|
||||
};
|
||||
loader.obj.scale.set(0.1,0.1,0.1);
|
||||
// return ret;
|
||||
// };
|
||||
// loader.obj.scale.set(0.1,0.1,0.1);
|
||||
|
||||
collidableObjects.push(loader.obj);
|
||||
loader.obj.raycastable = true;
|
||||
@@ -724,6 +734,38 @@ L3D.createSponzaRecommendations = function(width, height) {
|
||||
);
|
||||
};
|
||||
|
||||
return [
|
||||
// createRecommendation(
|
||||
// new THREE.Vector3(-2.591997650227227,4.652225309342689,-2.815524195264902),
|
||||
// new THREE.Vector3(-40.87987891143996,10.202406707437795,7.344871219063935)
|
||||
// )
|
||||
// ,createRecommendation(
|
||||
// new THREE.Vector3(-20.507451191489245,1.7638914167988349,1.9557104822169127),
|
||||
// new THREE.Vector3(-58.90750279083062,7.314072814893941,-7.772163058087716)
|
||||
// )
|
||||
// ,
|
||||
// createRecommendation(
|
||||
// new THREE.Vector3(-23.383482289183434,14.264152490508069,-1.2119079930928534),
|
||||
// new THREE.Vector3(-1.7847952083517313,1.9364343472313017,30.117376738037517)
|
||||
// ),
|
||||
// createRecommendation(
|
||||
// new THREE.Vector3(2.327317420088316,0.3629147522258326,-0.3325792884643282),
|
||||
// new THREE.Vector3(1.3934131694970663,-0.8288981685786133,3.369771966148228)
|
||||
// ),
|
||||
// createRecommendation(
|
||||
// new THREE.Vector3(22.983553977938616,3.829033470023654,0.7135547783419287),
|
||||
// new THREE.Vector3(1.9041126108599506,-8.375131998286331,32.4423350397072)
|
||||
// )
|
||||
// createRecommendation(
|
||||
// new THREE.Vector3(-12.939581055355553,3.796374966524073,-2.463006239142574),
|
||||
// new THREE.Vector3(-51.61901925503118,-1.1193807374029414,6.466518183623911)
|
||||
// )
|
||||
createRecommendation(
|
||||
new THREE.Vector3(1.3571661176961554,4.934280286310308,-4.294700794239404),
|
||||
new THREE.Vector3(-31.49512083496389,15.286798072464663,16.04129235749628)
|
||||
)
|
||||
];
|
||||
|
||||
return [
|
||||
createRecommendation(
|
||||
new THREE.Vector3(97.36225946503932,10.925697484337014,12.852363038244272),
|
||||
@@ -742,8 +784,8 @@ L3D.createSponzaCoins = function() {
|
||||
|
||||
L3D.resetSponzaElements = function() {
|
||||
return {
|
||||
position: new THREE.Vector3(92.98373669520107,60.8877777990862,11.130138641670737),
|
||||
target: new THREE.Vector3(53.76696417668598,56.09739213575453,4.877382575136091)
|
||||
position: new THREE.Vector3(9.298373669520107,6.08877777990862,1.1130138641670737),
|
||||
target: new THREE.Vector3(5.376696417668598,5.609739213575453,0.4877382575136091)
|
||||
};
|
||||
};
|
||||
|
||||
@@ -757,7 +799,7 @@ L3D.initSponza = function(recommendation, scene, coins, clickable) {
|
||||
recommendation.resetElements = L3D.resetSponzaElements();
|
||||
recommendation.collidableObjects = collidableObjects;
|
||||
|
||||
recommendation.speed = 0.05;
|
||||
recommendation.speed = 0.005;
|
||||
recommendation.reset();
|
||||
recommendation.save();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user