Jump to content

A GUI using meshes


skalibran
 Share

Recommended Posts

Hey there,

after digging out several topics about GUIs in Babylon.js it seems like adding another framework for that task is the best solution. However, I want to use pure Babylon.js. I made a panel that does something when I click on it and attached it as a child to the camera. Unfortunetaly, when I resize the window, the panel that should be in the bottom left corner is not where it belongs, because the camera proportion has changed and the panel is (partly) out of view.

 

http://spielwiese.vllg.at/bgame/

 

I could ask for the current width and height of the window onchange, but resetting the panel for every width / height pixel seems a bit weird.

What is the best solution to always have the panel on the bottom left corner, on mobile, on PC and on TV as well?

Thanks for your ideas!

Link to comment
Share on other sites

I don't have a good solution for that, I just made a playground to show the problem and people can start changing things. Maybe somebody has a good idea and can show it right here: http://www.babylonjs-playground.com/#ZZY18

 

 

Damn, I could have already done that. Sorry for making extra work :-/

 

 

You should try bGUI.

 

https://github.com/Temechon/bGUI

 

I've heard good things about it on this forum and the source looks really clean and simple.

 

Hey, did you test bGUI ? https://github.com/Temechon/bGUI

 

I'll have a look at it when I'm home, thanks for the link! However, is there a way to set the position of meshes relative to the camera and width/height?

Link to comment
Share on other sites

@Temechon: can we use bGUI on the playground? Do you have something like a CDN to link to? I want to create a GUI, too (maybe tonight) and haven't decided what to use yet. Can I use normal Babylon meshs in the GUI layer? lets say I want a box as a button and I want to rotate it so that the user can see that it is a box and not just a square. Is that possible and does it work the usual way?

Link to comment
Share on other sites

I think bGUI does use the 2nd cam:

 

bGUI adds automatically to your game an orthographic camera correctly configured (according to the canvas size and the device pixel ratio), and gives you several classes to create your game GUI.

source: https://github.com/Temechon/bGUI

 

My question is just if I have to watch out for anything special or if I can jsut use it like I would if I created the orthographic cam myself :P Well, I could just try it out I guess. I'll try to find a way to use it in the playground when I have time tonight.

Link to comment
Share on other sites

" is there a way to set the position of meshes relative to the camera and width/height?" 

-> Yes ! I created bGUI for that actually :)

 

"can we use bGUI on the playground?"

-> I don't have any CDN, but if you copy/paste the bgui.min.js in the playground, you should be able to use it (never tested it)

 

"Can I use normal Babylon meshs in the GUI layer? lets say I want a box as a button and I want to rotate it so that the user can see that it is a box and not just a square. Is that possible and does it work the usual way?"

-> Yes, yo ucan create a GUIObject from any BABYLON mesh, and use any animation you want afterwards.

Link to comment
Share on other sites

Just copying the code to the playground basically seems to work... http://www.babylonjs-playground.com/#1GJBXI#1 (took me a while to figure out that I have to sue the loader for the textures...maybe that sohuld be mentioned in the documentation ;) )

 

Got a question though: If i try to scale the panel (line 65) it disappears... how would I make that panel smaller?

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...