Lua Observers

New Lua observers and additional callbacks for existing observers.

Transform Node Observer

There is a new type of observer that can be registered from Lua, which observes changes in internal scenegraph nodes dealing with world and local transforms, as well as world and local enabled states.

Difference from property observer

A transform observer differs from a normal property observer because it only observes the Enabled and Transform properties, and is also notified in response to changes of state on any ancestor of the node being observed.

When an assembly node is disabled, all of its descendants are also considered to be disabled in terms of application systems traversing the tree to process child nodes. However, a normal property observer on an Enabled property of one of these descendants would not be notified of this change because the property of that node hasn't actually changed.

Equally when an assembly node is moved, all of its descendants world transform change due to the nature of the transform hierarchy. A property observer on a Transform property of one of these descendants would not be notified of this change because the local transforms on these assemblies does not actually change when an ancestor transform changes.

This is the problem solved by the transform node observer.


A transform observer is added using the vrAddTransformNodeObserver function.

Consider this hierarchy of assembly nodes in the Scenes tree:

 - A
   - B
     - C

The following code snippet, executed in the console, will add a transform observer to the C assembly node, providing callback functions for transform and enabled state changes that print out a message that show the state notification was successful.

  function(node, matrix) print("transform changed") end,
  function(node, enabled) print("enabled state changed") end,
After running this example code, changing the transform or enabled property of any of A, B, or C will trigger the print messages.

The observer can also be removed using the vrRemoveObserver function, by providing the name (in this case "myObserver").

Changes to Node and MetaNode Observers

vrAddNodeObserver and vrAddMetaNodeObserver have been extended to support additional callbacks.

Node Observer

You can now specify a callback for when the observed node is destroyed.

  function(node) print("node property changed") end,
  function(node) print("node destroying") end

MetaNode Observer

You can now specify callbacks for parent change, renaming, and destroying.

  function(meta, node) print("node instance created") end,
  function(meta, node, old, new) print("node parent changed from old to new") end,
  function(meta, node) print("node instance renamed") end,
  function(meta, node) print("node instance destroying") end

No Results.

Getting StartedArchitectureBest PracticesHow ToAdvanced TopicsChangelogvrtree_cppCoreForeign Function InterfaceMetanodesMigrationsObserversPropertiesTreeUtilitiesAPI DefinitionsVR ExchangePluginsLua API