Motivation
Many actions are too complex for animation nodes:
- Computed animation paths (eg. gravity)
- Algorithmic shapes (eg. fractals)
- Collaborative environments (eg. games)
You can create new sensors, interpolators, etc., using program scripts written in:
- JavaScript - easy-to-learn language
- ECMAScript - same as JavaScript
Syntax: Script
A Script node selects a program script to run:
- url - choice of program script
1 2 3 4 5 6 7 |
DEF Bouncer Script { url "ecmascript: ..." #or... url "javascript: ..." #or... url "bouncer.js" } |
Defining the program script interface
A Script node also declares the program script interface:
- initializeOnly, inputOnly, outputOnly, inputOutput - inputs and outputs
- Each has a name and data type
- Fields have an initial value
1 2 3 4 5 6 |
DEF Bouncer Script { initializeOnly SFFloat bounceHeight 3.0 inputOnly SFFloat set_fraction outputOnly SFVec3f value_changed inputOutput SFBool enabled TRUE } |
A sample using a program script
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
DEF Clock TimeSensor { ... } DEF Ball Transform { ... } DEF Bouncer Script { initializeOnly SFFloat bounceHeight 3.0 inputOnly SFFloat set_fraction outputOnly SFVec3f value_changed inputOutput SFBool enabled url "ecmascript: ..." } ROUTE Clock.fraction_changed TO Bouncer.set_fraction ROUTE Bouncer.value_changed TO Ball.set_translation |
Summary
The Script node selects a program script, specified by a URL.
Program scripts have field and event interface declarations, each with:
- A data type
- A name
- An initial value (fields only)