C
Behavior QML Type
Technology Preview Behavior Integration. More...
Import Statement: | import QtStudio3D 2.4 |
Signals
- void onActivate()
- void onDeactivate()
- void onInitialize()
- void onUpdate()
Methods
- matrix4x4 calculateGlobalTransform(string handle)
- void fireEvent(string event)
- var getAttribute(string attribute)
- var getAttribute(string handle, string attribute)
- float getDeltaTime()
- vector3d lookAt(vector3d target)
- void registerForEvent(string event, QJSValue function)
- void registerForEvent(string handle, string event, QJSValue function)
- void setAttribute(string attribute, var value)
- void setAttribute(string handle, string attribute, var value)
- void setDataInputValue(string name, variant value)
- void unregisterForEvent(string event)
- void unregisterForEvent(string handle, string event)
Detailed Description
This is a technology preview (API may change in upcoming version) of how Qt 3D Studio could support writing custom behavior scripts using QML and JavaScript. It enables interacting with the runtime using the Behavior QML class exposed to each behavior script.
Note: the Behavior type has its own import and is only available in behavior scripts
that are attached to scene objects during the design phase in Qt 3D Studio. It is not usable in ordinary QML application code.
In QML behavior script, the integration to Qt 3D Studio is established by using the metadata tag system similar to effect and material files.
[[ <Property name="somePropertyName" ... /> <Handler name="someHandlerName" ... /> <Event name="onSomeEvent" ... /> ... ]]
Secondly, the QML behavior script needs access to the QML module.
import QtStudio3D.Behavior 2.0
Finally, the Behavior type needs to be implemented in the qml script.
Behavior { id: mybehavior function onInitialize() { ... } function onActivate() { ... } function onUpdate() { ... } function onDeactivate() { ... } function someHandlerName() { ... fireEvent("onSomeEvent") } }
Signal Documentation
This signal is emitted when the script becomes active. Any behaviors which were not active last frame that are active this frame will have their onActivate
signaled. If multiple behaviors match this, the signal for parent elements will occur before their descendants.
This signal is emitted when the script becomes inactive. Any behaviors which were active last frame that are not active this frame will have their onDeactivate
signaled. If multiple behaviors match this, the signal for parent elements will occur before their descendants.
This signal is emitted when the script becomes active the first time. If multiple behaviors match this, the signal for parent elements will occur before their children/descendants.
Note: Each behavior will only have its onInitialize
signaled once, even if it is deactivated and later reactivated.
This signal is emitted on each frame when the script is active. Any behaviors that are active this frame will have their onUpdate
signaled. If multiple behaviors match this, the signal for parent elements will occur before their descendants.
Method Documentation
Returns the transformation matrix of the object identified with the handle.
void fireEvent(string event) |
Fires the given event.
Returns the value of the given attribute for a given handle.
void registerForEvent(string event, QJSValue function) |
Registers the script for an event with the handler function.
Registers the script for an event with the handler function for a given handle.
Sets the value of the given attribute for a given handle.
Sets the value of the data input identified with the name.
void unregisterForEvent(string event) |
Unregisters the script from an event.
Unregisters the script from an event for a given handle.
Available under certain Qt licenses.
Find out more.