] } ] } Transform { translation -12.5 7 0 children [ Shape { appearance Appearance { material DEF toc-mat-@id Material { diffuseColor 1 0 0 transparency 1 } } geometry Box { size 3 3 0.5 } } DEF toc-touch-@id TouchSensor { } ] } DEF toc-script-@id Script { directOutput TRUE field SFNode me USE toc-script-@id field SFNode xswitch USE toc-switch-@id field SFNode transform USE toc-transform-@id field SFNode sensor USE toc-touch-@id field SFNode mat USE toc-mat-@id field SFInt32 state 0 eventIn SFBool touch eventIn SFBool over url "vrmlscript: function initialize() { Browser.addRoute(sensor,'isActive',me,'touch'); Browser.addRoute(sensor,'isOver',me,'over'); } function shutdown() { Browser.deleteRoute(sensor,'isActive',me,'touch'); Browser.deleteRoute(sensor,'isOver',me,'over'); } function touch(value,time) { if (value && state == 0) { xswitch.whichChoice = 0; transform.translation = new SFVec3f(1.5,1,0); transform.scale = new SFVec3f(0.8,0.8,1); state = 1; } else if (value && state == 1) { transform.translation = new SFVec3f(0,0,0); transform.scale = new SFVec3f(1,1,1); state = 2; } else if (value && state == 2) { xswitch.whichChoice = -1; state = 0; } } function over(value,time) { if (value) { mat.transparency = 0.5; } else { mat.transparency = 1; } } " }