vrnode

A node in the tree.

Public Member Functions


vrnode ancestor(string metaName)

(vrNodeGetAncestor) Gets the first ancestor of the specified type

Parameters
metaName

The type of ancestor to look for

Returns

Ancestor node of the specified type, or false if there isn't one


vrnode child(string metaType,
string name
)

(vrNodeGetChild) Gets the first child of a node.

Parameters
metaType

The type of child to get

name

The name of the child to get

Returns

The first child node, of the type in the metaType parameter, if specified, or false if there are no suitable child nodes


vrnode childbyindex(number idx)

(vrNodeGetChildByIndex) Gets a nodes child by its zero-based index. Note: this function may result in poor performance when iterating over lots of nodes - use vrNodeGetChild() and vrNodeGetSibling() instead (see the Best Practices section of the Programming Guide for more info).

Parameters
idx

The index of the child (zero based)

Returns

The specified child node, or false if out of range


number count()

(vrNodeGetChildCount) Counts the children of a node. Note: this function may result in poor performance when iterating over lots of nodes - use vrNodeGetChild() and vrNodeGetSibling() instead (see the Best Practices section of the Programming Guide for more info).

Returns

The number of direct child nodes


vrnode find(string path,
boolean caseSensitive
)

(vrNodeFindChild) Finds a descendant of a node by path

Parameters
path

The path or name of the node to search from

caseSensitive

Whether to match case in the path

Returns

The node at the specified path, or false if not found


void forEachChild(Any function)

(vrNodeForEachChild) Calls a function for each child of a node

Parameters
function

The function to call for each child node. This function should have a signature of function(node). This can be a string name of a global function, or a lua function object. If the function returns a value other than nil, the function will not be called for further children and the value will be returned to the caller


void forEachChildOfType(string metaType,
Any function
)

(vrNodeForEachChildOfType) Calls a function for each child of a node that matches a specified type

Parameters
metaType

The type of child nodes to find

function

The function to call for each child node. This function should have a signature of function(node). This can be a string name of a global function, or a lua function object. If the function returns a value other than nil, the function will not be called for further children and the value will be returned to the caller


void getLocal(string propName)

void getLocalMatrix(string propName)

(vrNodeGetLocalMatrix) DEPRECATED


(vrNodeGetLocal) DEPRECATED


string getName()

(vrNodeGetName) Gets the name of a node.

Returns

The name of the node


(vrNodeGetParent) Gets the parent of a node.

Returns

The parent node


MULTI< vrvec3, vrvec3, vrvec3 > getRelative(string propName,
vrnode otherNode
)

(vrNodeGetRelativeTransform) Gets the position, rotation and scale of the world transform of one node relative to another.

Returns

The relative world position

The relative world rotation

The relative world scale


void getWorld(string propName)

(vrNodeGetWorld) DEPRECATED


boolean hasTrait(string traitName)

(vrNodeHasTrait) Checks if the node is of a type with a specific trait. This is a lot faster than vrNodeGetTraits

Parameters
traitName

The name of the trait to check

Returns

true if the node has the specified trait


vrnode next(string metaType,
string name
)

(vrNodeGetSibling) Gets the sibling (adjacent) node to a node.

Parameters
metaType

The type of sibling to get

name

The name of the child to get

Returns

The next sibling node, of the type in the metaType parameter, if specified, or false if there are no suitable siblings


(vrNodeGetParent) Gets the parent of a node.

Returns

The parent node


string path()

(vrNodeGetPath) Gets the encoded path to a node relative to the tree root

Returns

The encoded path (special characters are encoded, e.g. space = %20


vrnode previous(string metaType,
string name
)

(vrNodeGetPreviousSibling) Gets the previous sibling (adjacent) node to a node.

Parameters
metaType

The type of sibling to get

name

The name of the child to get

Returns

The previous sibling node, of the type in the metaType parameter, if specified, or false if there are no suitable siblings


string relpath(vrnode relativeTo)

(vrNodeGetRelativePath) Gets the encoded path to a node, relative to another node.

Parameters
relativeTo

The node to get the path relative to

Returns

The encoded relative path (special characters are encoded, e.g. space = %20


void setLocal(string propName,
Any vpos,
Any vrot,
Any vscale
)

void setLocalMatrix(string propName,
vrmatrix4 matrix
)

(vrNodeSetLocalMatrix) DEPRECATED


(vrNodeSetLocal) DEPRECATED


void setName(string newName)

(vrNodeSetName) Sets the name of a node.

Parameters
newName

The new name for the node


void setParent(vrnode parent,
vrnode beforeSibling,
boolean preserveWorldTransform
)

(vrNodeSetParent) Sets the parent of a node.

Parameters
parent

New parent. If this is nil, the parent is cleared, effectively deleting the node from the tree.

beforeSibling

Specifies where to add the node in the parent's list of children, or nil to add it at the end of the list.

preserveWorldTransform

If true, the node's position, rotation and scale in the world will be maintained.


void setRelative(string propName,
vrnode otherNode,
Any vpos,
Any vrot,
Any vscale
)

(vrNodeSetRelativeTransform) Sets the position, rotation and scale of the world transform of a node relative to another.

Parameters
vpos

XYZ Position specified in a table {x, y, z}.

vrot

Euler Rotation specified in a table {x, y, z}.

vscale

XYZ Scale specified in a table {x, y, z}.


void setWorld(string propName,
Any vpos,
Any vrot,
Any vscale
)

(vrNodeSetWorld) DEPRECATED


vrnode sibling(string metaType,
string name
)

(vrNodeGetSibling) Gets the sibling (adjacent) node to a node.

Parameters
metaType

The type of sibling to get

name

The name of the child to get

Returns

The next sibling node, of the type in the metaType parameter, if specified, or false if there are no suitable siblings


vrnode tail(string metaType,
string name
)

(vrNodeGetTail) Gets the last child of a node.

Parameters
metaType

The type of child to get

name

The name of the child to get

Returns

The last child node, of the type in the metaType parameter, if specified, or false if there are no suitable child nodes


table traits()

(vrNodeGetTraits) Gets the list of traits that this node has. Can also be thought of as the base class of a node (e.g. Texture, Viewport, etc). This function is expensive and can affect performance. To check a specific trait use vrNodeHasTrait

Returns

Array of traits that this node has


string type(boolean versioned)

(vrNodeGetMetaNode) Gets the name of the MetaNode that a node is an instance of. This can also be referred to as the node type.

Parameters
versioned

Whether to get the full versioned metanode name rather than the unversioned name

Returns

The node type

No Results.

Getting StartedArchitectureBest PracticesHow ToAdvanced TopicsChangelogvrtreevrtree_cppvtCoreCoreForeign Function InterfaceMetanodesMigrationsObserversPropertiesSettingsTreeUtilitiesAPI DefinitionsVR ExchangePluginsLua API