Class: HUD

HUD(camera)

HUD stands for head-up display - a UI container mounted on users head. Typically we have some buttons around 50 cm front, 10-20 cm below line of sight. This is common UI supposed to be usefull on VR devices, PC and mobiles, but likely to be suboptimal - UI specifically designed for a device should be more ergonomic. By default it tracks active camera, and binds to new camera whenever active camera changes, e.g. upon entering/exiting VR. Constructed with a camera parameter, it does not rebound to a new one, e.g. switching from first-person view to god mode activates a different HUD.

Constructor

new HUD(camera)

Parameters:
Name Type Description
camera to track, by default tracks active camera
Source:

Classes

HUD

Methods

addButton(text, imageUrl, onPointerDown)

Create a button with given text and image and add it to the HUD
Parameters:
Name Type Description
text description to display
imageUrl image to display
onPointerDown callback function activated when pressed
Source:
Returns:
a BabylonJS HolographicButton

addColorPicker()

Adds color picker to the HUD.
Source:
Returns:
babylon ColorPicker object

addSlider()

Adds a slider to the HUD.
Source:
Returns:
babylon Slider object

rescaleHUD()

Window.resize event handler, rescales the HUD if aspect ratio is too small for all buttons to fit.
Source:

showButtons(show, …except)

Show or hide all HUD elements (buttons)
Parameters:
Name Type Attributes Description
show show or hide
except <repeatable>
optional element(s) to skip
Source:

trackCamera()

Handles camera change events, typically while entering/exiting VR.
Source: