tut37.wrl

#VRML V2.0 utf8

WorldInfo {
   title "Floppy's VRML97 Tutorial Example 3.7"
   info ["(C) Copyright 2000 Vapour Technology Ltd."
         "guide@web3dguide.org.uk"]
}

DEF CYCLE Script {
   eventIn SFTime touchTime
   field SFInt32 number 4
   eventOut SFInt32 output
   url "javascript:
      function initialize() {
         output = 0;
      }
      function touchTime(value, time) {
         if (output == number - 1) output = 0;
         else ++output;
      }
   "
}

Transform {
   translation 0 -.5 8
   children [
      DEF SENSOR TouchSensor {
      }
      Shape {
         appearance Appearance {
            material Material {
               emissiveColor 1 0 0
            }
         }
         geometry Sphere {
            radius 0.1
         }
      }
   ]
}

DEF SWITCH Switch {
   whichChoice 0
   choice [
      Shape {
         appearance DEF BLUE Appearance {
            material Material {
               diffuseColor 0 0 1
            }
         }
         geometry Box {}
      }
      Shape {
         appearance USE BLUE
         geometry Sphere {}
      }
      Shape {
         appearance USE BLUE
         geometry Cone {}
      }
      Shape {
         appearance USE BLUE
         geometry Cylinder {}
      }
   ]
}

ROUTE SENSOR.touchTime TO CYCLE.touchTime
ROUTE CYCLE.output TO SWITCH.whichChoice
Generated by GNU enscript 1.6.1.