API Docs for:
Show:

LS.Player Class

Defined in: ../src/player.js:2
Module: LS

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 (in play mode)
- onDraw: executed after drawing a frame (in play mode)
- onPreUpdate(dt): executed before updating the scene (delta_time as parameter)
- onUpdate(dt): executed after updating the scene (delta_time as parameter)
- onDrawLoading: executed when loading
- onMouse(e): when a mouse event is triggered
- onKey(e): when a key event is triggered

Constructor

LS.Player

(
  • options
)

Defined in ../src/player.js:2

Parameters:

  • options Object

    settings for the webgl context creation

Methods

clear

()

Clears the current scene

loadConfig

(
  • url
  • on_complete
  • on_scene_loaded
)

Loads a config file for the player, it could also load an scene if the config specifies one

Parameters:

  • url String

    url to the JSON file containing the config

  • on_complete Function

    callback trigged when the config is loaded

  • on_scene_loaded Function

    callback trigged when the scene and the resources are loaded (in case the config contains a scene to load)

loadScene

(
  • url
  • on_complete
)

Loads an scene and triggers start

Parameters:

  • url String

    url to the JSON file containing all the scene info

  • on_complete Function

    callback trigged when the scene and the resources are loaded

pause

()

Pauses the execution. This will launch a "paused" event and stop calling the update method

play

()

Starts the scene. This will launch a "start" event and start calling the update for every frame

setDebugRender

(
  • v
)

Enable a debug renderer that shows gizmos for most of the things on the scene

Parameters:

  • v Boolean

    true if you want the debug render

setFileDrop

(
  • v
)

Enable the functionality to catch files droped in the canvas so script can catch the "fileDrop" event (onFileDrop in the Script components).

Parameters:

  • v Boolean

    true if you want to allow file drop (true by default)

setScene

(
  • scene
  • on_complete
)

loads Scene from object or JSON taking into account external and global scripts

Parameters:

  • scene Object
  • on_complete Function

    callback trigged when the scene and the resources are loaded

stop

()

Stops the scene. This will launch a "finish" event and stop calling the update