Modos Posted April 28, 2018 Share Posted April 28, 2018 Hello guys, I'm new to this forum and to BabylonJS. The question about multiple scenes isn't new, I know. I already read some threads, but the answers didn't work for me. I need two scenes that act simultaneously. Only one scene should be visible at a time, the other should run in the background. I also want a button in each scene to switch to the other scene. For some reason I can't run my scenes with playground, so i just send you my html-files as an example. I'm sorry for the effort. 2engines.html is a modification of a version someone posted in one of the threads about two canvas and engines. It's nearly what I want, but the button to switch the scene is shown for just one scene (you can switch the scene without button by pressing '1'). I don't know if I have to use multiple canvas for my request. Multiview.html is an example how it could look like (also an experiment with multiviews). I call the createScene-function everytime to switch, so the scene will always start from the beginning. I want to switch to the other scene without restarting it, so you can see the progress of whatever happens there, while running in background. The main goal is to create a platform with a couple of minigames (solve a puzzle, realtime strategy, first-person-shooter etc.) via browser. Students can program their own agents and let them fight against pre-programmed agents. People or students that don't play should be able to watch one of those games and switch the camera (or scene) to watch another game. I'm trying to find out if it's possible to realize this concept (or rather the representation with scenes and cameras) with BabylonJS. I'm not the one creating this platform. It is part of my study project to find out, if BabylonJS is the right framework for this. Wow, that was a huge spam. I hope there wasn't too much unnecessary information and that I've made myself clear. Best regards. 2engines.html multiview.html Quote Link to comment Share on other sites More sharing options...
Guest Posted April 28, 2018 Share Posted April 28, 2018 Hey and welcome! so you want multiple canvas? This means multiple engines. If only one canvas, then it is easier as you can create as many scenes as you want and just switch the one you call .render() on in your runRenderLoop function Quote Link to comment Share on other sites More sharing options...
JohnK Posted April 29, 2018 Share Posted April 29, 2018 Hi @Modos and welcome. From your question this is what I understand; Person X (a teacher?) has set a project. X has given you a number of requirements for the project and has asked you to write a report showing whether Babylon.js meets some or all of the requirements. The requirements are possibly A multi-user games center with single user games A, B, C .......... A user can either play one of the games or watch another user playing a game. In some games a user can either program (and store?) an agent that will fight other agents that are pre-programmed (by the game designer or other users?) or can (select a user agent to fight and then?) watch a fight in progress. Is the above anywhere close to what you want? I am a little confused about: whether the games are mini puzzles or programmed agent games or both; the need for multiple scenes, since if a user can watch a game being played by another user then there must be multi users. There would be a need for a screen showing player and their games, to view a particular game being played the game states would have to be stored on the server and it would be downloading these states that would enable the viewer to watch the game so so no need for multiple scenes. As always I have probably totally misunderstood what you want and its me that needs more explanation. It is always very difficult to explain your own needs, to explain the needs of others is more than doubly difficult. Are you clear on what person X needs? Can you more clearly explain what X needs? Quote Link to comment Share on other sites More sharing options...
Modos Posted April 29, 2018 Author Share Posted April 29, 2018 Hey thank you for your responses. @Deltakosh 16 hours ago, Deltakosh said: so you want multiple canvas? This means multiple engines. I don't think I need multiple canvas. Just multiple scenes that I can switch (but until now I didn't find out how to do that correctly). @JohnK 3 hours ago, JohnK said: Is the above anywhere close to what you want? You are almost right about everything. The purpose of this platform is to give the students a better understanding of the topic "AI" or "agents" in a playful way. Therefor they shall build their own agents and compete against the pre-programmed (by the game designer) agents in an optional category. Every category contains a game with agents. The mini puzzle was just an example of a "problem solving game" with agents. Sorry for being unclear. 3 hours ago, JohnK said: In some games a user can either program (and store?) an agent that will fight other agents that are pre-programmed (by the game designer or other users?) or can (select a user agent to fight and then?) watch a fight in progress. And now that I think about it: I think the agents will be built outside of the game and the game designer have to implement them into the game. The user won't store it directly. So there is no activ gaming with users, the scenes are just to watch a competition between agents. 3 hours ago, JohnK said: It is always very difficult to explain your own needs, to explain the needs of others is more than doubly difficult. Are you clear on what person X needs? Can you more clearly explain what X needs? You're probably right, I should clarify that before annoying a forum ? So far, I thought like this: A User has to login into a website. There he can choose between games A,B,C to watch agents fighting each other. For every game one scene is needed. Therefor I thought you need multiple scenes. In this game you can switch the camera (e.g. from the ArcRotateCam to the FreeCam) and switch to another game. Maybe you don't have to switch from ingame, you could just go back to the game selection. Hm. Well, asking this made me realize: I also lack information. BUT I'm still curious how to switch the scenes with a button in each scene. Is it possible to let multiple scenes run at the same time and switch them without losing any progress (for example a time counter that runs in the scene in the background and if you switch to can see the counted time)? I created this: https://playground.babylonjs.com/#MEW6RE The button is there but only visible in the background scene. You can still click it (above the upper left corner), the scene will switch but you can't switch back. I think I write too much.... Quote Link to comment Share on other sites More sharing options...
JohnK Posted April 29, 2018 Share Posted April 29, 2018 I thought I would put together an example of scene switching in the PG using the GUI. However it turns out I am having problems. Will not be able to try again until later this week. Quote Link to comment Share on other sites More sharing options...
Guest Posted April 29, 2018 Share Posted April 29, 2018 Here is a quick example in the PG: https://www.babylonjs-playground.com/#1AP18W#8 Quote Link to comment Share on other sites More sharing options...
JohnK Posted April 30, 2018 Share Posted April 30, 2018 20 hours ago, Deltakosh said: Here is a quick example in the PG: https://www.babylonjs-playground.com/#1AP18W#8 Thanks and actually you solved this for me already. In the case for @Modos I am trying to use the GUI to switch between scenes and am failing. It seems to come down creating the advancedTexture for a second time. I have disposed of the original before re-creating but it fails on a call to line 39 in the following PG. SO what am I doing wrong this time? https://www.babylonjs-playground.com/#1AP18W#9 EDIT - MY STUPID MISTAKE Completely forgot to put the scene.render(), scene2.render() in the engine render loop.? https://www.babylonjs-playground.com/#1AP18W#10 Note - when you have clicked the button you must move the pointer away from the button before clicking it again else nothing happens. A sudden inspiration when writing the previous sentence, changing from onPointerClickObservable to onPointerUpObservable fixes that problem https://www.babylonjs-playground.com/#1AP18W#11 GameMonetize 1 Quote Link to comment Share on other sites More sharing options...
JohnK Posted April 30, 2018 Share Posted April 30, 2018 22 hours ago, Modos said: BUT I'm still curious how to switch the scenes with a button in each scene. Hope the final PG in my previous post now answers this question. Sorry it took so long to get there. GameMonetize 1 Quote Link to comment Share on other sites More sharing options...
Modos Posted May 2, 2018 Author Share Posted May 2, 2018 Hey there, sorry for my late respond. I was busy last days and in the evening too tired. I'm very grateful to you for your efforts. @Deltakosh & @JohnK On 4/30/2018 at 10:23 AM, JohnK said: A sudden inspiration when writing the previous sentence, changing from onPointerClickObservable to onPointerUpObservable fixes that problem https://www.babylonjs-playground.com/#1AP18W#11 On 4/30/2018 at 3:37 PM, JohnK said: Hope the final PG in my previous post now answers this question. Sorry it took so long to get there. There is no reason for an excuse, since this is "open source framework" and "we are all working on it on our spare time" as it is written in one of the pinned topics ? The playground sample looks like what I imagined when I asked for it. While writing this, I still didn't look at the code, I will do that later. I'll mark this thread as "solved", but maybe I'll come up with some questions to that code (for example what the exact difference between "onPointerClickObservable" and "onPointerUpObservable", but first I want to look that up by myself). In addition to that, maybe I want to come back later to the upper questions of my project without open a new thread. I hope that is okay with you guys. Thanks a lot so far. Quote Link to comment Share on other sites More sharing options...
JohnK Posted May 2, 2018 Share Posted May 2, 2018 Suggest that when you have a new question you start a new topic, you can always refer back to this topic (or post within it - copy date link in post) if necessary. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.