Table of Contents Chapter Index Previous Slide Next Slide 351
A sample JavaScript script use

Introducing program script writing with JavaScript
A sample JavaScript script use
  • Code needed:
  • Offset the fractional time
  • Compute an angle
  • Compute the total height
  • Compute X, Y, and Z positions
  • function set_fraction( f, tm ) {
        f += fractionOffset;
        while ( f > 1.0 )
            f -= 1.0;
        angle = f * 6.28 * cycles + phase;
        deltaHeight = endHeight - startHeight;
    
        position_changed[0] = radius * Math.sin( angle );
        position_changed[1] = f*deltaHeight + startHeight;
        position_changed[2] = radius * Math.sin( angle+1.571 );
    }