GithubHelp home page GithubHelp logo

ekakit / bgui Goto Github PK

View Code? Open in Web Editor NEW

This project forked from temechon/bgui

0.0 0.0 0.0 2.05 MB

A Babylon.js extension to create a game GUI

Home Page: http://temechon.github.io/bGUI/

License: Do What The F*ck You Want To Public License

JavaScript 99.92% CSS 0.04% HTML 0.05%

bgui's Introduction

bGUI is now obsolete due to the implementation of Canvas2D in Babylon.js 2.4. This library is then no longer maintenaned and/or developped.

v1.2

A Babylon.js extension to create a GUI

What ?

bGUI is an extension for the 3D engine Babylon.js providing a set of tools and class to display a game GUI directly into your Babylon 3D game, without any HTML/CSS.

Why ? I can use HTML/CSS to do that !

The only solution (for now) to deploy a babylon.js game on mobile platforms (Android/iOS - Windows Phone supports Webgl application natively) is to use Cocoon.js provided by Ludei, with the technology Canvas+ (Webview+ is not so great in term of performance for 3D scenes). However, Canvas+ does not support DOM elements, such as div, img, ... The only solution is to create the GUI directly in the HTML canvas. That's what bGUI do !

This library can also fit to some people who want to control the game GUI in javascript without the need of jQuery or manipulating DOM objects.

How does it work ?

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. A GUIObject is the root class of bGUI, and represents a 3D object (sphere, plane, cube, custom object, ...) translated into the GUI world, and removed from your game world.

bGUI gives you 2 specific classes in order to create HUD easily :

  • GUIPanel : extends GUIObject => it's a plane composed of an image texture.
  • GUIText : extends GUIPanel => its image texture is actually a dynamic texture where the specified text is written.

Is it easy to use ?

Of course ! First, you have to create a GUISystem, which represents your GUI world. It takes 3 parameters: the Babylon scene where the GUI will be created, and the width and the height of your GUI (in pixels).

var gui = new bGUI.GUISystem(scene, 1200, 780);

Now your GUI is created, you can create a new panel like this:

var headTexture = new BABYLON.Texture("assets/head.png", scene);
var head = new bGUI.GUIPanel("head", headTexture, null, gui);

A GUIPanel takes 4 parameters :

  • The name of this panel
  • The texture
  • The texture displayed when the user click/touch on this panel (to create a button for example)
  • The gui system where this panel should be displayed

bGUI provides a set of methods to update the position of the panel, 3 actually :

  • guiposition(BABYLON.Vector3) : to update the mesh in the GUI world (takes a position in pixels)
  • relativePosition(BABYLON.Vector3) : to update the mesh relatively to the origin of the GUI system (takes a position in percentages)
  • position(BABYLON.Vector3) :to update the mesh in the BABYLON world (takes a position in babylon units)

You can also use a direct reference to the BABYLON mesh used for any GUIObject. This way, you can use Babylon animations to update your panel for example.

You can read all the documentation here.

Any dependencies ?

bGUI depends on babylon.js (from v2.1-beta), and hand.js for touch events.

Is a demo available somewhere ?

Yes : http://temechon.github.io/bGUI/ Try to click on the images :)

Is there any documentation ?

Yes : bGUI documentation on official babylon website

Copyright ?

WTFPL

Build from source

Create the debug version of bgui

npm debug

Create the full minified version of bgui

npm build

bgui's People

Contributors

temechon avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.