Jump to content

CASTORGUI don't scale to fullscreen while i use engine.switchFullscreen(true);


swat0284
 Share

Recommended Posts

Hi,

 

 This is because engine.switchFullscreen is using the Fullscreen API on the rendering canvas element. You have to put the rendering canvas and the HTML elements that will embed the CastorGUI into a unique element (a DIV for instance) and call the Fullscreen API on this container. For instance, here's a sample code:

 

var renderingZone = document.getElementById("renderingZone");
var isFullScreen = false;
 
document.addEventListener("fullscreenchange", onFullScreenChange, false);
document.addEventListener("mozfullscreenchange", onFullScreenChange, false);
document.addEventListener("webkitfullscreenchange", onFullScreenChange, false);
document.addEventListener("msfullscreenchange", onFullScreenChange, false);
 
function onFullScreenChange() {
    if (document.fullscreen !== undefined) {
        isFullScreen = document.fullscreen;
    } else if (document.mozFullScreen !== undefined) {
        isFullScreen = document.mozFullScreen;
    } else if (document.webkitIsFullScreen !== undefined) {
        isFullScreen = document.webkitIsFullScreen;
    } else if (document.msIsFullScreen !== undefined) {
        isFullScreen = document.msIsFullScreen;
    }
}
 
switchFullscreen = function () {
    if (!isFullScreen) {
        BABYLON.Tools.RequestFullscreen(renderingZone);
    }
    else {
        BABYLON.Tools.ExitFullscreen();
    }
};

 

Bye,

 

David

Link to comment
Share on other sites

I've added the detection of fullscreen change to a reload of the page to place all the elements correctly.
 
It was the simplest solution to achieve but I'm not sure this is the most adequate solution.  :(
document.addEventListener('webkitfullscreenchange', function() {location.reload();}, false);document.addEventListener('mozfullscreenchange',  function() {location.reload();}, false);document.addEventListener('fullscreenchange',  function() {location.reload();}, false);document.addEventListener('MSFullscreenChange',  function() {location.reload();}, false);

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...