2015-07-08 18:28:45 +02:00
|
|
|
// Auto-resize case
|
2015-08-28 21:34:29 +02:00
|
|
|
// var mainSection = document.getElementById('main-section');
|
2015-07-08 18:28:45 +02:00
|
|
|
//
|
2015-08-28 21:34:29 +02:00
|
|
|
// var containerSize = {
|
|
|
|
// width: function() { if (!isFullscreen) return mainSection.clientWidth; else return screen.width;},
|
2015-07-08 18:28:45 +02:00
|
|
|
// height: function() {
|
|
|
|
// if (!isFullscreen)
|
2015-08-28 21:34:29 +02:00
|
|
|
// return mainSection.clientHeight
|
2015-07-08 18:28:45 +02:00
|
|
|
// - document.getElementById('nav').offsetHeight
|
|
|
|
// - document.getElementById('main-div').offsetHeight;
|
|
|
|
// else
|
|
|
|
// return screen.height;
|
|
|
|
// }
|
|
|
|
// };
|
|
|
|
|
2015-08-28 21:34:29 +02:00
|
|
|
var containerSize = {
|
2015-07-08 18:28:45 +02:00
|
|
|
|
|
|
|
width: function() { return 1134; },
|
|
|
|
height: function() { return 768; }
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
function logfps(fps) {
|
2015-07-17 16:28:55 +02:00
|
|
|
var event = new L3D.DB.Event.Fps();
|
2015-07-08 18:28:45 +02:00
|
|
|
event.fps = fps;
|
|
|
|
event.send();
|
|
|
|
}
|
|
|
|
|
|
|
|
function objectClickerOnHover(camera1, previewer, recommendations, container) {
|
|
|
|
|
|
|
|
var hoveredCamera = null;
|
|
|
|
|
2015-07-17 11:32:57 +02:00
|
|
|
return function(c, x, y) {
|
|
|
|
|
|
|
|
var obj = c !== undefined ? c.object : undefined;
|
2015-07-08 18:28:45 +02:00
|
|
|
|
|
|
|
// Check if the object is clickable
|
|
|
|
var ok = obj instanceof Coin || obj instanceof L3D.BaseRecommendation;
|
|
|
|
|
|
|
|
// Little graphic stuff so the user knows that it's clickable
|
|
|
|
container.style.cursor = ok ? "pointer" : "auto";
|
|
|
|
if (camera1.pointerLocked)
|
|
|
|
camera1.mousePointer.render(ok ? L3D.MousePointer.RED : L3D.MousePointer.BLACK);
|
|
|
|
|
|
|
|
// Set previewer for preview
|
|
|
|
previewer.setCamera(obj instanceof L3D.BaseRecommendation ? obj.camera : null);
|
|
|
|
previewer.setPosition(x,y);
|
|
|
|
|
|
|
|
// Manage the hover camera event
|
|
|
|
if (hoveredCamera !== obj) {
|
|
|
|
|
2015-07-17 16:28:55 +02:00
|
|
|
var event = new L3D.DB.Event.Hovered();
|
2015-07-08 18:28:45 +02:00
|
|
|
|
|
|
|
if (obj instanceof L3D.BaseRecommendation) {
|
|
|
|
// The newly hovered object is different and is a recommendation
|
|
|
|
|
2015-08-28 21:34:29 +02:00
|
|
|
event.arrowId = recommendations.indexOf(obj);
|
2015-07-08 18:28:45 +02:00
|
|
|
event.start = true;
|
|
|
|
event.send();
|
|
|
|
|
|
|
|
hoveredCamera = obj;
|
|
|
|
|
|
|
|
} else if (hoveredCamera instanceof L3D.BaseRecommendation) {
|
|
|
|
|
|
|
|
// The newly hovered object is not a recommendation,
|
|
|
|
// but the previous one is : we must log
|
|
|
|
|
|
|
|
// Unhovered
|
2015-08-28 21:34:29 +02:00
|
|
|
event.arrowId = 0;
|
2015-07-08 18:28:45 +02:00
|
|
|
event.start = false;
|
|
|
|
event.send();
|
|
|
|
|
|
|
|
hoveredCamera = null;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function objectClickerOnClick(camera1, buttonManager, recommendations, coins) {
|
|
|
|
|
2015-07-17 11:32:57 +02:00
|
|
|
return function(c, x, y) {
|
2015-07-08 18:28:45 +02:00
|
|
|
|
|
|
|
var event;
|
2015-07-17 11:32:57 +02:00
|
|
|
var obj = c !== undefined ? c.object : undefined;
|
2015-07-08 18:28:45 +02:00
|
|
|
|
|
|
|
// Do stuff for click
|
|
|
|
if (obj instanceof Coin) {
|
|
|
|
|
|
|
|
obj.get();
|
|
|
|
|
|
|
|
// Send event to DB
|
2015-07-17 16:28:55 +02:00
|
|
|
event = new L3D.DB.Event.CoinClicked();
|
2015-08-28 21:34:29 +02:00
|
|
|
event.coinId = obj.id;
|
2015-07-08 18:28:45 +02:00
|
|
|
event.send();
|
|
|
|
|
|
|
|
} else if (obj instanceof L3D.BaseRecommendation) {
|
|
|
|
|
2015-07-09 09:50:11 +02:00
|
|
|
obj.check();
|
2015-07-08 18:28:45 +02:00
|
|
|
camera1.moveHermite(obj);
|
|
|
|
|
|
|
|
// Send event to DB
|
2015-07-17 16:28:55 +02:00
|
|
|
event = new L3D.DB.Event.ArrowClicked();
|
2015-08-28 21:34:29 +02:00
|
|
|
event.arrowId = recommendations.indexOf(obj);
|
2015-07-08 18:28:45 +02:00
|
|
|
event.send();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Update the button manager
|
|
|
|
buttonManager.updateElements();
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function createVisibilityFunction(value) {
|
|
|
|
return function(object) {
|
|
|
|
object.traverse(function(object) {
|
|
|
|
object.visible = value;
|
|
|
|
});
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
function resetCameraAspect(camera, width, height) {
|
|
|
|
camera.aspect = width / height;
|
|
|
|
camera.updateProjectionMatrix();
|
|
|
|
}
|
|
|
|
|
|
|
|
var show = createVisibilityFunction(true);
|
|
|
|
var hide = createVisibilityFunction(false);
|
|
|
|
|
|
|
|
function resizeElements() {
|
|
|
|
|
2015-08-28 21:34:29 +02:00
|
|
|
var width = containerSize.width(), height = containerSize.height();
|
2015-07-08 18:28:45 +02:00
|
|
|
|
|
|
|
for (var i = 0; i < arguments.length; i++) {
|
|
|
|
|
|
|
|
var obj = arguments[i];
|
|
|
|
|
|
|
|
if (obj instanceof Element) {
|
|
|
|
|
|
|
|
obj.style.width = width + 'px';
|
|
|
|
obj.style.height = height + 'px';
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (obj.domElement) {
|
|
|
|
|
2015-07-09 11:44:54 +02:00
|
|
|
obj.setSize(width, height);
|
2015-07-08 18:28:45 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function appendTo(container) {
|
|
|
|
|
|
|
|
return function() {
|
|
|
|
|
|
|
|
for (var i = 0; i < arguments.length; i++) {
|
|
|
|
|
|
|
|
container.appendChild(arguments[i].domElement);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
2015-09-01 09:51:57 +02:00
|
|
|
|
|
|
|
function setNextButton(target) {
|
2015-10-01 15:24:32 +02:00
|
|
|
Coin.blink();
|
2015-09-01 09:51:57 +02:00
|
|
|
$('#next').show();
|
|
|
|
$('#next').click(function() {
|
|
|
|
window.location = target;
|
|
|
|
$('#next').prop('disabled', true);
|
|
|
|
});
|
|
|
|
}
|