Constructor
new HUD(camera)
Parameters:
Name | Type | Description |
---|---|---|
camera |
to track, by default tracks active camera |
Classes
Members
vrHelper
set by World.InitXR()
Methods
activate()
Input delegate method, activates the current control (as if clicked on)
activateButton()
Activates given button, if it's visible
addAttachment()
Add an attachment mesh. It will be used for XR controller manipulation as other hud elements.
However, mesh parent isn't changed, it has to be set by caller to hud root.
addButton(text, imageUrl, onPointerDown, shareMaterial)
Create a button with given text and image and add it to the HUD
Parameters:
Name | Type | Default | Description |
---|---|---|---|
text |
description to display | ||
imageUrl |
image to display | ||
onPointerDown |
callback function activated when pressed | ||
shareMaterial |
true | optional, defaults to true, use shared material for all buttons or create a new one |
Returns:
a BabylonJS HolographicButton
addColorPicker()
Adds color picker to the HUD.
Returns:
babylon ColorPicker object
addForm(form, textureWidth, textureHeight)
Adds a Form to the hud. Creates and returns AdvancedDynamicTexture to render the form.
Parameters:
Name | Type | Description |
---|---|---|
form |
to add | |
textureWidth |
width in pixels | |
textureHeight |
height in pixels |
addSlider()
Adds a slider to the HUD.
Returns:
babylon Slider object
attachedController()
Returns VR controller this HUD is attached to, or null
attachToCamera()
Attach HUD to camera it was created with.
attachToLeftController()
Attach hud to left hand
attachToRightController()
Attach hud to right hand
clearControls()
Clears and disposes of all controls in the current row
clearRow()
Clears the current row. Previous row is scaled back to original size and brought back into position.
currentRow()
Returns the current row
distance()
Returns distance of the HUD from the camera
down()
Input delegate method, process a gamepad up button event: go back to previous row, or forward to the Form.
enableSpeech(enable)
Enable/disable speech input.
Parameters:
Name | Type | Description |
---|---|---|
enable |
true/false to enable/disable |
getActiveControl()
Input delegate method, returns active control current in row or form.
getControlIndex()
Input delegate method, returns index of control current in row or form.
getControls()
Input delegate method, returns controls available in the current row or form.
initXR(vrHelper)
Initialize XR - allows to grab hud in left or right hand
Parameters:
Name | Type | Description |
---|---|---|
vrHelper |
VRHelper |
intersects()
Returns true if mesh intersects any of hud elements. Allows to 'grab' the hud with a VR controller.
inXR()
Returns true if XR mode is active (current camera is WebXRCamera)
isActive()
Returns true if button color matches colorActive
isEnabled()
Returns true if button color matches colorEnabled
isSelectableMesh()
Used XR pointer selection predicate, returns true if selection is allowed and given mesh is one of HUD elements.
left()
Activates previous element (gamepad left button)
makeRoomForMore()
Called before adding a new button to reposition existing ones
markActive()
Helper method to set button color to green, note that button needs it's own material.
markButton()
Common code for markEnabled/Disabled/Active
markDisabled()
Helper method to set button color to red, note that button needs it's own material.
markEnabled()
Helper method to set button color, note that button needs it's own material.
newRow()
Creates a new empty row. Current row is scaled down and moved a bit down.
next(increment)
Input delegate method, internal state management. Activates next or previous element, ignoring invisible ones.
Parameters:
Name | Type | Description |
---|---|---|
increment |
1 or 1 for previous/next |
otherController()
If attached to a hand, returns the other hand, or null otherwise
removeAttachment()
Detach an attached mesh. Parent is not changed here.
rescaleHUD()
Window.resize event handler, rescales the HUD if aspect ratio is too small for all buttons to fit.
right()
Activates next element (gamepad right button)
scaling()
Returns scaling of the HUD
selectControl()
Input delegate method, selects the control at given index, keeps track of bounds and wraps around.
selectCurrent()
Input delegate method, selects current control (button or Form element) at given index.
setActiveControl()
Input delegate method, sets active control current in row or form.
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 |
trackCamera()
Handles camera change events, typically while entering/exiting VR.
unselectCurrent()
Input delegate method, deselects current control.
up()
Input delegate method, process a gamepad up button event: activate a button or delegate it to the Form.
vertical()
Returns vertical position of the HUD