Skip to content
Häfner edited this page Apr 19, 2021 · 5 revisions

PolyVR has a script editor to create application logic, websites and shaders. The editor looks as follows:

image

Toolbar

  • Add new script.
  • Add new script from template library.
  • Add script section to help organize your code base. To move a script below such a section use the group option.
  • Import a script from another PolyVR project file.
  • Remove a script.
  • Save the current script, will actually also compile the python code and saves the whole project.
  • Execute the current script, this will also save and compile it as described above.
  • Search in your scripts.
  • Open the documentation with all available Python modules of PolyVR.
  • Enable profiling of the scripts execution, displays execution times.
  • Pause the script execution globally, click again to resume.

Options

The script type can either be Python, HTML or GLSL.

  • Python is the main scripting language, those script form the application logic.
  • HTML allows to write websites, also with CSS and Javascript. Those are hosted by PolyVR. Using the CEF module allows to put them as interactive UIs on any 3D mesh as a texture.
  • GLSL allows to create shaders, small programs that run on the graphics card, usually used for advanced rendering effects.

The group corresponds to the section the script is arranged under. Add sections using the toolbar as described above.

The server option is deprecated, but should not be changed!

Trigger

Scripts can be triggered by pressing the button with the gears. This is only meant for testing! The trigger types are:

  • on_scene_load
    • Triggers the script right after the scene loaded
  • on_timeout
    • Triggers the script each X ms (max once per frame), X must be passed as parameter
    • Set parameter to 0 to trigger each frame
  • on_device
    • Triggers the script when receiving a signal from a device
    • set the device to listen to
    • set the key and key state to listen to, setting the key to -1 makes the script trigger for any key.

Arguments

The first line of the script is dynamically generated. The name can be changed by renaming in the script list on the far left. To add parameters they have to be added to the list above. One can specify a type, but this is only useful when executing the script via the toolbar.

Clone this wiki locally