#VRML V2.0 utf8 ## ##:@+ discrete interpolator ##@ shape Shape { geometry Sphere { radius 2 } appearance Appearance { material DEF MATERIAL Material { diffuseColor 1 0 0 } } } ##@ sensor + script DEF TIME TimeSensor { loop TRUE cycleInterval 5 } # ## # We replace the ColorInterpolator by a Script DEF COLORS Script { eventIn SFFloat set_fraction eventOut SFColor value_changed url "javascript: function set_fraction(value) { if (value < 0.5) value_changed = '0 1 1'; else value_changed = '1 0 0'; } " }# ## # Note, there is no change in the routing ROUTE TIME.fraction_changed TO COLORS.set_fraction ROUTE COLORS.value_changed TO MATERIAL.diffuseColor ##