API Docs for:
Show:

LS.SceneNode Class

Defined in: ../src/sceneNode.js:3
Module: LS

The SceneNode class represents and object in the scene Is the base class for all objects in the scene as meshes, lights, cameras, and so

Constructor

LS.SceneNode

(
  • name
)

Parameters:

  • name String

    the name for this node (otherwise a random one is computed)

Methods

assign

(
  • resource
  • on_complete
)

Assign a resource/element inteligently to a node: if it is a mesh it creates a MeshRenderer, if it is a Material it assigns it, if it is an animation creates a PlayAnimation, if it is a prefab assigns the prefab. etc

Parameters:

  • resource

    the resource to assign (it also accepts a resource filename that has been previously loaded).

  • on_complete Function

clone

() Object

remember clones this node and returns the new copy (you need to add it to the scene to see it)

Returns:

Object:

returns a cloned version of this node

configure

(
  • info
)

Configure this node from an object containing the info

Parameters:

  • info Object

    the object with all the info (comes from the serialize method)

destroy

(
  • time
)

Destroys this node

Parameters:

  • time Number

    [optional] time in seconds to wait till destroying the node

getLocator

(
  • property_name
)
String

Returns the locator string of this node

Parameters:

  • property_name String

    [optional] you can pass the name of a property in this node to get the locator of that one

Returns:

String:

the locator string of this node

getPropertyInfo

(
  • locator
)
Object

Returns and object with info about a property given a locator

Parameters:

  • locator String

Returns:

Object:

object with { node, target, name, value and type }

getPropertyInfoFromPath

(
  • path
)
Object

Returns and object with info about a property given a locator in path format

Parameters:

  • path Array

    a locator in path format (split by /)

Returns:

Object:

object with { node, target, name, value and type }

getPropertyValue

(
  • locaator
)

Returns the value of a property given a locator in string format

Parameters:

  • locaator String

Returns:

:

the value of that property

getPropertyValueFromPath

(
  • locator
)

Returns the value of a property given a locator in path format

Parameters:

  • locator Array

    in path format (array)

Returns:

:

the value of that property

getResources

(
  • res
  • include_children
)
Object

Returns all the resources used by this node and its components (you can include the resources from the children too)

Parameters:

  • res Object

    object where to store the resources used (in "res_name":LS.TYPE format)

  • include_children Boolean

    if you want to add also the resources used by the children nodes

Returns:

Object:

the same object passed is returned

insidePrefab

() Object

Returns the root node of the prefab incase it is inside a prefab, otherwise null

Returns:

Object:

returns the node where the prefab starts

isInLayer

(
  • index
)
Boolean

checks if this node is in the given layer

Parameters:

  • index Number | String

    of layer or name according to scene.layer_names

Returns:

Boolean:

true if belongs to this layer

load

(
  • url
  • on_complete
)

Allows to load some kind of resource and associate it to this node. It can be for prefabs, meshes, scenes from daes, etc

Parameters:

  • url String
  • on_complete Function

reloadFromPrefab

()

Apply prefab info (skipping the root components) to node, so all children will be removed and components lost and overwritten It is called from prefab.applyToNodes when a prefab is loaded in memory

serialize

(
  • ignore_prefab
)
Object

Serializes this node by creating an object with all the info it contains info about the components too

Parameters:

  • ignore_prefab Bool

    serializing wont returns children if it is a prefab, if you set this to ignore_prefab it will return all the info

Returns:

Object:

returns the object with the info

setLayer

(
  • the
  • value
)

Assigns this node to one layer

Parameters:

  • the Number | String

    index of the layer or the name (according to scene.layer_names)

  • value Boolean

setMesh

(
  • mesh_name
  • submesh_id
)

Simple way to assign a mesh to a node, it created a MeshRenderer component or reuses and existing one and assigns the mesh

Parameters:

  • mesh_name String

    the name of the mesh (path to the file)

  • submesh_id Number

    if you want to assign a submesh

setName

(
  • new_name
)
Object

changes the node name

Parameters:

  • new_name String

    the new name

Returns:

Object:

returns true if the name changed

setPropertyValue

(
  • locator
  • value
)

assigns a value to a property given the locator for that property

Parameters:

  • locator String
  • value

setPropertyValueFromPath

(
  • path
  • value
  • [optional]
)

given a locator in path mode (array) and a value, it searches for the corresponding value and applies it

Parameters:

  • path Array
  • value
  • [optional] Number optional

    offset used to skip the firsst positions in the array

Properties

className

String

Events

name_changed

Node changed name

Event Payload:

  • new_name String

transformChanged