Script objects are used to control other objects present in the scene.
It can access and change every object in the program and supports some events
- Called on app initialization, its called after all children elements are initialized, its safe to apply operations on other objects inside this method.
- Called on every frame after rendering
- Called when disposing the program
- Called on every frame if mouse is on top of one of the script children
- Receives an intersections array as argument.
- onResize(x, y)
- Called every time the window is resized
- Receives width and height as parameters
- Called when receiving data sent by the host website
Code written inside scripts have access to the following attributes:
- Same as this reference but global in the script scope
Call onAppData if available.
Called automatically every time external data is passed to the runtime.
Disposes the script, can be used to clear resources when the program exits.
Calls the script dispose method if it exists.
Initialize script Automatically called by the runtime Calls the script initialize method if it exists
Call resize method if available.
The resize method receives width and height as arguments.
Set script code.
Can be used to dinamically change the script code. However it is not recommended can lead to undefined behavior.
Create JSON for script.
Update script state.
Calls the script update method if it exists.
Pointer to the parent program Used access program resources easier
Pointer to the parent scene