dot big bang

Developer API
Menu

Class UI

All
  • Public
  • Public/Protected
  • All

Hierarchy

  • UI

Index

Methods

canvasToUIPos

  • Returns a UI-position (i.e. position on screen in normalized coordinates) from a position expressed in canvas space, i.e. in CSS pixels from the top-left corner.

    Parameters

    • canvasPoint: Vector2

      The position in CSS pixels to convert to UI-position units.

    • Optional optionalTarget: Vector2

      When provided, return the UI-position in this Vector2 instead of allocating one.

    Returns Vector2

clear

  • clear(): void
  • Clears the UI, i.e. removes all the elements it contains.

    Returns void

createTextElement

  • Creates and adds a text element (i.e. UITextElement object) to the UI.

    Parameters

    • font: Font

      The Font to use for the text element

    • text: string

      The text to be displayed. This can be dynamically changed later with UITextElement.setText()

    Returns UITextElement

createVoxelObjectElement

  • Creates and adds a VoxelObject element (i.e. UIVoxelObjectElement object) to the UI.

    Parameters

    • voxelObject: VoxelObject

      The VoxelObject to be displayed.

    Returns UIVoxelObjectElement

getElements

  • getElements(optionalTarget?: UIElement[]): UIElement[]
  • Gets all the elements that exist in the UI, whatever their type.

    Parameters

    • Optional optionalTarget: UIElement[]

      When provided, return the elements in this array instead of allocating one.

    Returns UIElement[]

getTextElements

  • getTextElements(optionalTarget?: UITextElement[]): UITextElement[]
  • Gets all the UITextElements that exist in the UI.

    Parameters

    • Optional optionalTarget: UITextElement[]

      When provided, return the elements in this array instead of allocating one.

    Returns UITextElement[]

getVoxelObjectElements

  • getVoxelObjectElements(optionalTarget?: UIVoxelObjectElement[]): UIVoxelObjectElement[]
  • Gets all the UIVoxelObjectElement that exist in the UI.

    Parameters

    • Optional optionalTarget: UIVoxelObjectElement[]

      When provided, return the elements in this array instead of allocating one.

    Returns UIVoxelObjectElement[]

removeElement

  • Remove a given element from the UI.

    Parameters

    • element: UIElement

      The element to remove from the UI.

    Returns void

worldToUIPos

  • Returns a UI-position (i.e. position on screen in normalized coordinates) from a position expressed in world units. The return value is a Vector3, and not a Vector2 as one might expect. This is because the z component indicates whether the point is visible or not. If it's less than 1, it is in front of the camera and therefore potentially visible (it might still be outside the camera frustum). If it's more than 1, it is behind the camera and thus necessarily invisible.

    Parameters

    • worldPosition: Vector3

      The world-unit position to convert to UI-position units.

    • Optional optionalTarget: Vector3

      When provided, return the UI-position in this Vector3 instead of allocating one.

    Returns Vector3