#VRML V2.0 utf8 # #
#[return] #

#ex-visibilitysensor.wrl
# example of VisibilitySensor node
 
# Leo - 11-Sept-97

# in this example when the white cube can be seen (that means the defined
#  visibility region can be seen by the viewer) the Sensor will send the
#  isActive=TRUE and the interpolate will work. Otherwise isActive=FALSE
#  will inhibit the interpolator operation
#  
#  REMEMBER : use the cursor to change the viewer position and achieve
#             the desired effect
#########

# viewer initial position
Viewpoint {position 0 0 15} 

DEF VISensor VisibilitySensor {
                         center 0 0 0
                         size  1 1 1
                         enabled TRUE
                              }
# rest / move cube
DEF XBox Transform {
             translation -5 -5  0
             rotation 1 1 0 -.7
             children [
                  Shape { 
                    geometry Box {
                               size 1 1 1
                                  }
                    appearance Appearance {
                               material Material { diffuseColor 0 1 0
#                                                   specularColor 0 1 0
                                                  }
                                           }
                         }
                       ]
                     }

# "image" of the sensitive region
Shape { 
       geometry Box {
                     size 1 1 1
                     }
       }
# Timer
#  parameter loop = TRUE will be set by the VisibilitySensor
DEF TIMER TimeSensor {
	cycleInterval 7
	     	      }

# Trajectory for the green box
DEF INTERP PositionInterpolator {
    key [0, 0.0833, 0.167, 0.25, 0.333, 0.417, 0.5, 0.583, 
         0.667, 0.75, 0.833, 0.917, 1]
    keyValue[-5 -5 0, -5 -4 0, -5 -3 0, -5 -2 0, -5 -1 0, -5 0 0, 
	      -5 1 0, -5 2 0, -5 3 0,  -5 4 0,  -5 3 0, -5 2 0,
	     -5 -5 0]		         }
            
# initialize green box translation movement
ROUTE VISensor.isActive TO TIMER.set_loop
ROUTE TIMER.fraction_changed TO INTERP.set_fraction
ROUTE INTERP.value_changed TO XBox.set_translation

#