#VRML V2.0 utf8 #EXTERNPROTO ROD [field SFInt32 onoff # field SFVec3f translation # field MFRotation rotations ] "rod.wrl" #Prototype of a on/off switch PROTO ONESHOT [ field SFInt32 onoff 0 field SFVec3f translation 0 0 0 field MFString text "Press to start" eventOut SFTime switchOn ] { Transform { translation IS translation children [ Shape { geometry Box { size .95 .95 0.1 } appearance Appearance { material Material { ambientIntensity 0.5 diffuseColor .8 .8 .8 } } }, Transform { translation -.3 -.4 .1 children DEF TXTSW Switch { choice [ Shape { geometry Text{ string IS text fontStyle FontStyle { family "SANS" size 0.1} #length .6 } appearance Appearance { material Material { diffuseColor 0 0 0 } } } ] whichChoice 0 } } DEF BUTTON Transform { translation 0 0 .1 children [ Shape { geometry Box { size .2 0.2 0.1 } appearance Appearance { material DEF BUTMAT Material { ambientIntensity 0.8 diffuseColor .8 .0 .8 emissiveColor .0 .0 .0 } } }, DEF TOUCH TouchSensor {}, DEF TON TimeSensor { cycleInterval .25 startTime -1 loop FALSE }, DEF SON PositionInterpolator { key [ 0 .8 1 ] keyValue [ 0 0 .1, 0 0 0, 0 0 0.1 ] } DEF OnSound AudioClip { url "bassoon.wav" } Sound { source USE OnSound } ] } ] } DEF SCR Script { eventIn SFTime switchIn eventOut SFTime switchOn IS switchOn url "javascript:function switchIn(value) { switchOn = value; }" } ROUTE TOUCH.touchTime TO TON.startTime ROUTE TON.fraction_changed TO SON.set_fraction ROUTE TOUCH.touchTime TO OnSound.startTime ROUTE TOUCH.touchTime TO SCR.switchIn ROUTE SON.value_changed TO BUTTON.set_translation } Transform { children [ ONESHOT { translation 0 0 0 } ] }