home *** CD-ROM | disk | FTP | other *** search
Java Source | 1996-09-12 | 649 b | 31 lines |
- //
- // toggle the light state.
- //
-
- import vrml.*;
- import vrml.node.*;
- import vrml.field.*;
-
- public class LightOnOff extends Script{
- SFBool turnOnLight;
- // light state.
- boolean onOff = false;
-
- public void initialize(){
- // get the reference of the event out 'turnOnLight'.
- turnOnLight = (SFBool)getEventOut("turnOnLight");
- }
-
- public void processEvent(Event e){
- if(e.getName().equals("touchTime") == true){
-
- // toggle the light state.
- onOff = !onOff;
-
- // send the event.
- turnOnLight.setValue(onOff);
- }
- }
- }
-
-