423

Writing program scripts with JavaScript
JavaScript script example code

DEF Bouncer Script {
    field    SFFloat bounceHeight 3.0
    eventIn  SFFloat set_fraction
    eventOut SFVec3f value_changed
    url "vrmlscript:
        function set_fraction( frac, tm ) {
            y = 4.0 * bounceHeight * frac * (1.0 - frac);
            value_changed[0] = 0.0;  // X
            value_changed[1] = y;    // Y
            value_changed[2] = 0.0;  // Z
        }"
}