Jump to content

Clear viewport.


Recommended Posts

Hello community,


I'm in need of help with something on my project.


I need do draw a new scene in the same scene stuck in a while loop (while the option exit isn't pressed).


By that I mean, that i would like to clear the all screen when this function is started, then, when exit is pressed, the "state machine" would come back to the main scene.


I'm not beeing able to find any function to do this.


Any suggestions ?


Thanks in advance,


Link to comment
Share on other sites



Are you working on a menu or something like that ? Could you give us an example or a mockup (even in paint) to help us understand ?


Anyway, would set all meshes in your "all scene" to visible=false be enough ?

while(exitOptionNotSelected) {   allScene.meshes.forEach(function(mesh) {       mesh.isVisible = false;   }}allScene.meshes.forEach(function(mesh) {       mesh.isVisible = true;}
Link to comment
Share on other sites

Thanks Temechon.


Go to my project in http://www.andromedaquest.tk enter with username: xpto and password: xpto (I'll keep the user active for the next 24 hours at least).


When you hoover the planets, you can see the option "colonize planets".

And if a planet is already colonized, what will apear is base details.


So... When that option is pressed the screen has to change to the "base" screen, I have to draw a new floor, with new texture, the structures and anything else. Then when the player presses "exit" it will come back to the "space ambient".

Link to comment
Share on other sites

Nice work !


For your problem, I would save the player position in the space scene, and completely destroy it (scene.dispose()), and finally build your base scene.


On exit, retrieve the player position from indexDb (for example, or localStorage, or memory or whatever) and load your space scene as you do it in your init game.

Link to comment
Share on other sites

Hi gang.  Couldn't the space scene be in engine.scenes[0], and when a base needs to be assembled, do it in engine.scenes[1], and switch to it?  Then switch back to engine.scenes[0] upon base exit?  *shrug*


I have never tried scene switching... and know nothing about it, but maybe easier?  If you do tests on scene switching, Kilombo, report your discoveries to us, ok?  Cool.

Link to comment
Share on other sites

That's Deltakosh's idea.  :)


The babylon engine is already designed for multiple scenes.  How one goes about switching between engine.scenes[0] and engine.scenes[1]...  I have no idea.  But others might.  And you know Deltakosh and the other big dogs around here.  If its possible, they will install a function to help you do it.  :)




The playground makes the first scene FOR you... as the first alert indicates.  Then I make another scene, and the second alert tells us it worked.  :o

Link to comment
Share on other sites

you can just load all your scenes


I'm curious - in fact quite overwhelmed - about the code that allows loading "all your scenes" ?


Not something I have seen in any tuts - and how does it handle all the textures you might be loading?


cheers, gryff :)

Link to comment
Share on other sites

It's implemented. Quite easy actually. And works amazingly well.

I load the scenes in a "sta.rt" function by calling two diferent funtions (each calls his scenes[0] and scenes[1]).

Then, in the render loop i use some global booleans two trigger the rendering between them.

There's the example code.

function start() {    canvas = document.getElementById("renderCanvas");    var info1 = document.getElementById("info1");    var info2 = document.getElementById("info2");    var shipposition = document.getElementById("shipposition");            if (!BABYLON.Engine.isSupported()) {        window.alert('Browser not supported');    } else {        renderCanvas = document.getElementById("renderCanvas");        engine = new BABYLON.Engine(renderCanvas, true);        var systems = new Array();        systems = sceneSpace();                sceneBase();    };engine.runRenderLoop(function() {if (base === true){        space = false;        scenes[1].render();    }    if (space === true){        base = false;        scenes[0].render();    }        });

Thanks for the help guys.

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.

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.


  • Recently Browsing   0 members

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