LS.Player Class
Player class allows to handle the app context easily without having to glue manually all events There is a list of options ========================== - canvas: the canvas where the scene should be rendered, if not specified one will be created - container_id: string with container id where to create the canvas, width and height will be those from the container - width: the width for the canvas in case it is created without a container_id - height: the height for the canvas in case it is created without a container_id - resources: string with the path to the resources folder - shaders: string with the url to the shaders.xml file - proxy: string with the url where the proxy is located (useful to avoid CORS) - filesystems: object that contains the virtual file systems info { "VFS":"http://litefileserver.com/" } ... - redraw: boolean to force to render the scene constantly (useful for animated scenes) - autoresize: boolean to automatically resize the canvas when the window is resized - autoplay: boolean to automatically start playing the scene once the load is completed - loadingbar: boolean to show a loading bar - debug: boolean allows to render debug info like nodes and skeletons
Optional callbacks to attach
============================
- onPreDraw: executed before drawing a frame
- onDraw: executed after drawing a frame
- onPreUpdate(dt): executed before updating the scene (delta_time as parameter)
- onUpdate(dt): executed after updating the scene (delta_time as parameter)
- onMouse(e): when a mouse event is triggered
- onKey(e): when a key event is triggered
Constructor
LS.Player
-
options
Parameters:
-
options
Objectsettings for the webgl context creation
Methods
loadScene
-
url
-
on_complete
Loads an scene and triggers start
Parameters:
-
url
Stringurl to the JSON file containing all the scene info
-
on_complete
Functioncallback trigged when the scene and the resources are loaded
setScene
-
scene
-
on_complete
loads Scene from object or JSON taking into account external and global scripts
Parameters:
-
scene
Object -
on_complete
Functioncallback trigged when the scene and the resources are loaded