#VRML V2.0 utf8 #Prototype of a dial PROTO DIAL [ field SFInt32 min 0 field SFInt32 max 100 field SFVec3f translation 0 0 0 field MFString text ["Dial"] eventOut SFInt32 ivalue eventOut SFFloat fvalue ] { 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 Shape { geometry Text { string IS text fontStyle FontStyle { family "SANS" size 0.1} } appearance Appearance { material Material { diffuseColor 0 0 0 } } } } Transform { translation -.3 .3 .1 children Shape { geometry DEF NUMVAL Text { string "0" fontStyle FontStyle { family "SANS" size 0.15 } } appearance Appearance { material Material { emissiveColor 0 1 0 } } } } DEF ROTCYL Transform { rotation 1 0 0 -1.57 children [ DEF CYL CylinderSensor { maxAngle 3.141 } DEF DIALCYL Transform { translation 0 -.2 0 rotation 0 1 0 0 children [ Shape { geometry Cylinder { radius .3 height 0.2 } appearance Appearance { material DEF BUTMAT Material { ambientIntensity 1 diffuseColor .4 .4 .7 emissiveColor .0 .0 .0 } } } Transform { translation 0 0 0.35 children Shape { geometry Box { size 0.05 0.05 0.1 } appearance Appearance { material Material { diffuseColor 0 0 0 } } }} ] }# end DIALCYL ]# end children }# end ROTCYL DEF ROTSCR Script { eventIn SFRotation offset eventOut MFString text eventOut SFInt32 ivalue IS ivalue eventOut SFFloat fvalue IS fvalue field SFFloat angle 0.1 field SFInt32 iangle 1 field SFInt32 max IS max url "javascript: function offset(value) { angle = value.angle; iangle = (max*value.angle) / 3.141; ivalue = iangle; fvalue = value.angle / 3.141; text = new MFString(iangle.toString()); } " } ] } ROUTE CYL.rotation_changed TO DIALCYL.set_rotation ROUTE CYL.rotation_changed TO ROTSCR.offset ROUTE ROTSCR.text TO NUMVAL.set_string } Transform { children [ DIAL { translation 0 0 0 } ] }