LS.GUI Class
GUI is a static class used to create two kinds of GUIs: HTML GUIs on top of the 3D Canvas (in a safe way) or Immediate GUI using a Canvas2D (fast gui) For HTML GUIs check the getHTMLRoot function. For Immediate GUIs check the Box,Button,Toggle,Textfield,HorizontalSlider,VerticalSlider and Toolbar. To change colors of the immediate GUI check the LS.GUI.GUIStyle
Constructor
LS.GUI
()
Item Index
Methods
attach
-
element -
anchor
attach HTMLElement to HTML GUI Root in the anchor position specified
Parameters:
-
elementHTMLElement -
anchorString"top-left", "top-right", "bottom-left", "bottom-right" or "none"
Box
-
area -
color
Renders an immediate gui BOX, used as background
Parameters:
-
areaArray[x,y,width,height]
-
colorStringa color in string format "#AFAFAF"
Button
-
area -
content -
content_over
Renders a Button and returns if the button was pressed
Parameters:
-
areaArray[x,y,width,height]
-
contentString | GL.Texturecould be a string or a GL.Texture (if null the button will be invisible)
-
content_overString | GL.Texturesame as before but in case the mouse is over
Returns:
true if the button was pressed
createElement
-
tag_type -
anchor
Creates a HTMLElement of the tag_type and adds it to the DOM on top of the canvas
Parameters:
-
tag_typeStringthe tag type "div"
-
anchorString"top-left", "top-right", "bottom-left", "bottom-right" or "none"
Returns:
detach
-
element
Removes an element from the GUI (same as element.parentNode.removeChild( element ); )
Parameters:
-
elementHTMLElementHTML element to detach from the GUI
getHTMLRoot
()
HTMLElement
Returns the DOM element responsible for the HTML GUI of the app. This is helpful because this GUI will be automatically removed if the app finishes. Any HTML must be attached to this element, otherwise it may have problems with the editor.
Returns:
hideHTML
()
hides the HTML GUI (but it is still existing)
HorizontalSlider
-
area -
value -
left_value -
right_value -
show_value
Renders an horizontal slider widget, returns the current value Remember: you must pass as value the same value returned by this function in order to work propertly
Parameters:
-
areaArray[x,y,width,height]
-
valueNumberthe value to show in the slider
-
left_valueNumberthe minimum value for the slider
-
right_valueNumberthe maximum value for the slider
-
show_valueBooleanif you want to see a caption in text format with the value
Returns:
the current value of the slider (will be different from value if it was clicked)
Knob
-
area -
value -
bottom_value -
top_value -
steps -
content
Renders an knob slider widget, returns the current value Remember: you must pass as value the same value returned by this function in order to work propertly
Parameters:
-
areaArray[x,y,width,height]
-
valueNumberthe value to show in the slider
-
bottom_valueNumberthe minimum value for the slider
-
top_valueNumberthe maximum value for the slider
-
stepsNumber[optional] the numeber of steps (if 0 then infinite)
-
contentImage | GL.Texture[optional] a texture or image to use as the knob
Returns:
the current value of the slider (will be different from value if it was clicked)
Label
-
area -
content
Renders a text (or a texture)
Parameters:
-
areaArray[x,y,width,height]
-
contentString | GL.Texturecould be a string or a GL.Texture
loadHTML
-
url -
on_complete
Loads resource containing the HTML code for the GUI and attachs it inside a div to the hud
Parameters:
-
urlStringthe url of the resource containing all the HTML code
-
on_completeFunctioncallback that will be called once the HTML has been loaded and attached to the doom, it receives the HTMLElement containing all the HTML
reset
()
Removes all the GUI elements from the DOM
ResetImmediateGUI
()
Called by the LS.Renderer to clear intermediate stuff
showHTML
()
shows the HTML GUI
TextField
-
area -
text -
max_length -
is_password
Renders a textfield widget and returns the current text value Remember: you must pass as text the same text returned by this function in order to work propertly
Parameters:
-
areaArray[x,y,width,height]
-
textStringthe text to show in the textfield
-
max_lengthNumberto limit the text, otherwise leave blank
-
is_passwordBooleanset to true to show as password
Returns:
the current state of the checkbox (will be different from value if it was pressed)
Toggle
-
area -
value -
content -
content_off
Renders a checkbox widget, and returns the current state Remember: you must pass as value the same value returned by this function in order to work propertly
Parameters:
-
areaArray[x,y,width,height]
-
valueBooleanif the checkbox is on or off
-
contentString | GL.Texturean string or image in case the checkbox is on
-
content_offString | GL.Texturean string or image in case the checkbox is off
Returns:
the current state of the checkbox (will be different from value if it was pressed)
Toolbar
-
area -
selected -
options
Renders a Toolbar (list of buttons) and returns the active one
Parameters:
-
areaArray[x,y,width,height]
-
selectedNumberthe index of the selected option
-
optionsArrayString | GL.Texturean array containing either strings or GL.Texture
Returns:
the selected index
VerticalSlider
-
area -
value -
bottom_value -
top_value
Renders an vertical slider widget, returns the current value Remember: you must pass as value the same value returned by this function in order to work propertly
Parameters:
-
areaArray[x,y,width,height]
-
valueNumberthe value to show in the slider
-
bottom_valueNumberthe minimum value for the slider
-
top_valueNumberthe maximum value for the slider
Returns:
the current value of the slider (will be different from value if it was clicked)
