#VRML V2.0 utf8 PROTO ButtonBar [ eventIn SFFloat endTransparency ]{ DEF buttonBarSw Switch { whichChoice 0 choice [ Group { children [ Transform { translation -26 7.1 -0.5 rotation 0 1 0 1.57 children [ Shape { geometry Box { size 4 18.8 0 } appearance Appearance { texture ImageTexture { url "models/buttonBar/music_poster_menu.jpg" } material DEF abrMat Material { specularColor 1 1 1 ambientIntensity 1 emissiveColor 1 1 1 diffuseColor 1 1 1 shininess 1 } } } ] } Transform { translation -24.5 7.1 -2.5 rotation 0 1 0 0 children [ Shape { geometry Box { size 3 18.8 0 } appearance Appearance { texture ImageTexture { url "models/buttonBar/menuback.jpg" } material DEF buttonBackMat Material { diffuseColor 0.1 0.1 0.1 specularColor .1 .1 .1 ambientIntensity 0.1 emissiveColor 0.1 0.1 0.1 shininess 0 } } } ] } ] } ] } DEF timeSensor TimeSensor { enabled TRUE loop TRUE } DEF homeModelScript Script { eventIn SFTime time eventIn SFFloat setTransparency IS endTransparency field SFFloat beginTransparency 0 eventOut SFFloat transparency field SFTime beginTimeTransparency 0 field SFBool transparencyEffectEnabled FALSE field SFFloat totalTimeTransparency 2 eventOut SFInt32 whichchoice eventOut MFString rollOverText url "javascript: function initialize() { transparency = beginTransparency; } // simple interpolation: // if enabled: // compute factor: what fraction of total interpolation time has passed // = (currencttime - starttime)/ totalTime // if this factor < 1: compute the value of the interpolated variable // if this factor >= 1: stop the interpolation, set the interpolated variable to the end value function time(value) { if (transparencyEffectEnabled) { var factor = (value - beginTimeTransparency) / totalTimeTransparency; if (factor < 1) { transparency = factor * (setTransparency - beginTransparency) + beginTransparency; } else { transparency = setTransparency; transparencyEffectEnabled = false; if (setTransparency == 1) whichchoice = -1;//remove the buttonbar when completely transparent } } } //begin interpolation: starttime of interpolation is current time //sets start value of interpolated variable, enables interpolation function setTransparency (value,time) { //print('transparantie is: '); whichchoice = 0; beginTimeTransparency = time; beginTransparency = transparency; transparencyEffectEnabled = true; } " } ROUTE homeModelScript.transparency TO buttonBackMat.transparency ROUTE homeModelScript.transparency TO abrMat.transparency ROUTE homeModelScript.whichchoice TO buttonBarSw.whichChoice ROUTE timeSensor.time TO homeModelScript.time } ButtonBar {}