KevinG Posted October 7, 2016 Share Posted October 7, 2016 I'm working on a 3D interface which will leverage WebVR which means that everything needs to be done inside of a single canvas element. The interface uses a FreeCamera to move around, but I'd like to also draw a HUD on top of the content. My current thoughts were that I could draw elements to a second scene, and layer that on top of the 3D scene. Is the second scene even necessary? Is there some way to lock a HUD element in place so it doesn't move when the camera moves? Thanks! Quote Link to comment Share on other sites More sharing options...
KevinG Posted October 7, 2016 Author Share Posted October 7, 2016 I did just see BABYLON.ScreenSpaceCanvas2D, would you be able to effectively use that on top of a 3D world to create a game HUD? Quote Link to comment Share on other sites More sharing options...
gryff Posted October 7, 2016 Share Posted October 7, 2016 @KevinG : welcome to the forum Simplest way that I know of creating an HUD interface is like this example: DNA Example It just parents the "buttons" to the camera. Here is a Playground example of parenting a simple pair of buttons cheers, gryff KevinG and Wingnut 2 Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted October 7, 2016 Share Posted October 7, 2016 yes Canvas2D is meant to be used as a HUD on top of 3D: http://doc.babylonjs.com/overviews/Canvas2D_Home KevinG 1 Quote Link to comment Share on other sites More sharing options...
dbawel Posted October 7, 2016 Share Posted October 7, 2016 I personally use a seperate canvas for GUI elements, as I find problems in parenting elements to the camera such as gimble lock and "flipping" if your camera is animated. Creating a seperate "game" canvas has been the best solution for me personally. DB Quote Link to comment Share on other sites More sharing options...
KevinG Posted October 8, 2016 Author Share Posted October 8, 2016 Two canvases can be easier to manage, unfortunately for VR games you can only send a single canvas to the HMD. Thanks for the tips all, for now ScreenSpaceCanvas2D seems like it might be the best bet. The problem I'm running into now is figuring out how to draw 3d game objects inside of ScreenSpaceCanvas2D so I can re-use game objects inside of menus. 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.