Skip to content

Commit

Permalink
js/playerFpsControl.js update to get fullscreen+mouselock on chrome
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromeetienne committed Jan 29, 2012
1 parent 20d7152 commit dad2164
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
11 changes: 6 additions & 5 deletions js/playerFpsControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ Marble.PlayerFpsControl = function()
}
console.log("mouse lock supported!!");

document.addEventListener('mozfullscreenchange', this._$onFullscreenChange, false);
document.addEventListener('webkitfullscreenchange', this._$onFullscreenChange, false);
document.addEventListener('mozfullscreenchange' , this._$onFullscreenChange, false);
document.addEventListener('webkitfullscreenchange' , this._$onFullscreenChange, false);
}

Marble.PlayerFpsControl.prototype.destroy = function()
Expand All @@ -40,13 +40,11 @@ Marble.PlayerFpsControl.prototype._onFullscreenChange = function()

navigator.pointer.lock(document.body, function(){
console.log("navigator.pointer.lock() succeed", navigator.pointer.islocked())

},function(){
console.log("navigator.pointer.lock() failled")
});

//console.log("after pointer lock, isLocked is", navigator.pointer.islocked());
//console.assert(navigator.pointer.islocked());

document.addEventListener('mousemove', this._$onMouseMove, false);

// accelerator for keyboard control
Expand All @@ -58,6 +56,9 @@ Marble.PlayerFpsControl.prototype._onFullscreenChange = function()
});
microphysics.world().add(this._fpsAcc);

//console.log("after pointer lock, isLocked is", navigator.pointer.islocked());
//console.assert(navigator.pointer.islocked());

}else{
navigator.pointer.unlock();
document.removeEventListener('mousemove', this._$onMousemove);
Expand Down
2 changes: 1 addition & 1 deletion js/threex.fullScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ THREEx.FullScreen.request = function(element)
{
element = element || document.body;
if( this._hasWebkitFullScreen ){
element.webkitRequestFullScreen();
element.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT);
}else if( this._hasMozFullScreen ){
element.mozRequestFullScreen();
}else{
Expand Down

0 comments on commit dad2164

Please sign in to comment.