PROTO SharedObject [ exposedField SFBool isPilot TRUE exposedField SFString name "" exposedField MFNode children [] exposedField SFVec3f position 0 0 0 exposedField SFRotation orientation 0 0 1 0 eventIn SFBool set_isVisible eventOut SFBool isVisible_changed exposedField MFString url [] exposedField SFBool isAvatar FALSE exposedField MFNode states [] ] { Transform { translation IS position rotation IS orientation children [ DEF Visible Switch { whichChoice 0 choice [ Transform { rotation 0 1 0 3.141592 # to compensate for Camera direction children IS children } ] } Group { children IS states } DEF Control Script { eventIn SFBool set_isVisible IS set_isVisible eventOut SFBool isVisible_changed IS isVisible_changed eventOut SFInt32 choice mustEvaluate TRUE url "javascript: function set_isVisible( value ){ isVisible_changed = value; if( value == true ){ choice = 0; } else { choice = -1; } }" } ] } ROUTE Control.choice TO Visible.set_whichChoice }