#VRML V2.0 utf8 Group { children [ DEF TOUCH TouchSensor {} DEF SWITCH Switch { whichChoice 0 choice [ Shape { appearance Appearance { material Material { diffuseColor 1 0 0 } } geometry Sphere {} } Shape { appearance Appearance { material Material { diffuseColor 0 1 0 } } geometry Box {} } Shape { appearance Appearance { material Material { diffuseColor 0 0 1 } } geometry Cone {} } ] } ] } DEF SCRIPT Script { eventIn SFBool clicked eventOut SFInt32 which field SFInt32 num 0 url "vrmlscript: function clicked(val) { if(val) { num = (num + 1) % 3; // same as num = num + 1; if(num==3) num=0; which = num; } }" } ROUTE TOUCH.isActive TO SCRIPT.clicked ROUTE SCRIPT.which TO SWITCH.whichChoice
mrl