This commit is contained in:
Thomas FORGIONE
2015-07-09 15:38:56 +02:00
parent 2e97b14160
commit cd10d76d89
9 changed files with 119 additions and 12 deletions

View File

@@ -32,6 +32,11 @@ var ButtonManager = function(camera, cameras, previewer) {
self.pointerLockElement.onchange = function() {
self.camera.shouldLock = self.pointerLockElement.checked;
self.camera.onPointerLockChange();
// Log
var event = new L3D.BD.Event.SwitchedLockOption();
event.locked = self.pointerLockElement.checked;
event.send();
};
self.showarrowsElement.onchange = function() {self.showArrows = self.showarrowsElement.checked;};

View File

@@ -223,6 +223,7 @@ L3D.PointerCamera.prototype.isLocked = function() {
* Update the camera when the pointer lock changes state
*/
L3D.PointerCamera.prototype.onPointerLockChange = function() {
var event = new L3D.BD.Event.PointerLocked();
if (this.isLocked()) {
@@ -236,6 +237,14 @@ L3D.PointerCamera.prototype.onPointerLockChange = function() {
// Remove start canvas
this.startCanvas.clear();
// Send event
event.locked = true;
if (this.wasLocked !== event.locked)
event.send();
this.wasLocked = true;
} else {
this.pointerLocked = false;
@@ -250,8 +259,15 @@ L3D.PointerCamera.prototype.onPointerLockChange = function() {
else
this.startCanvas.clear();
event.locked = false;
if (this.wasLocked !== event.locked)
event.send();
this.wasLocked = false;
}
};
/**

View File

@@ -114,3 +114,24 @@ L3D.BD.Event.Fps.prototype.send = function() {
L3D.BD.Private.sendData(url, data);
};
L3D.BD.Event.PointerLocked = function() {};
L3D.BD.Event.PointerLocked.prototype.send = function() {
var url = "/pointer-locked";
var data = {
locked: this.locked
};
L3D.BD.Private.sendData(url, data);
};
L3D.BD.Event.SwitchedLockOption = function() {};
L3D.BD.Event.SwitchedLockOption.prototype.send = function() {
var url = "/switched-lock-option";
var data = {
locked: this.locked
};
L3D.BD.Private.sendData(url, data);
}