API Docs for:
Show:

LS.BaseComponent Class

Module: LS

This is an example class for a component, should never be instantiated by itself, instead components get all the methods from this class attached when the component is registered. Components can overwrite this methods if they want.

Methods

bind

(
  • object
  • event
  • callback
  • type
  • setter
  • getter
)

Bind one object event to a method in this component

Parameters:

  • object

    the dispatcher of the event you want to react to

  • event String

    the name of the event to bind to

  • callback Function

    the callback to call

  • type String | Object

    [optional] an string identifying the type of the variable, could be "number","string","Texture","vec3","mat4", or an object with all the info

  • setter Function

    [optional] setter function, otherwise one will be created

  • getter Function

    [optional] getter function, otherwise one will be created

broadcastMessage

(
  • method_name
  • data
)

calls a method in all components in this node and all the children nodes

Parameters:

  • method_name String
  • data

clone

()

Create a clone of this node (the UID is removed to avoid collisions)

Returns:

:

component clone

configure

(
  • o
)

Configures the components based on an object that contains the serialized info

Parameters:

  • o Object

    object with the serialized info

createProperty

(
  • name
  • value
  • type
  • setter
  • getter
)

To create a new property for this component adding some extra useful info to help the editor

Parameters:

  • name String

    the name of the property as it will be accessed

  • value

    the value to assign by default to this property

  • type String | Object

    [optional] an string identifying the type of the variable, could be "number","string","Texture","vec3","mat4", or an object with all the info

  • setter Function

    [optional] setter function, otherwise one will be created

  • getter Function

    [optional] getter function, otherwise one will be created

getComponent

(
  • class_name
)

returns the first component of type class_name of the SceneNode where this component belongs

Parameters:

  • class_name String | Component

    the name of the class in string format or the component class itself

Returns:

:

Component or null

getLocator

(
  • property_name
)
String

Returns the locator string of this component

Parameters:

  • property_name String

    [optional] you can pass the name of a property in this component

Returns:

String:

the locator string of this component

getRootNode

()

Returns the node where this components is attached

serialize

() Object

Returns an object with all the info about this component in an object form

Returns:

Object:

object with the serialized info