media @ VU
[] readme course preface I 1 2 II 3 4 III 5 6 7 IV 8 9 10 V 11 12 afterthoughts appendix references examples resources _

talk show tell print

web3d-x-ball-0.vr

web3d-x-ball-0.vr (wrl ) [ flux / bitmanagement / cortona / octaga ]

Web3D/VR

bouncing ball (0)

bounce


  
  DEF PLACE Transform {
  scale 0.5 0.5 0.5
  children [ 
  Shape  {
          geometry Sphere { radius 2 }
          appearance Appearance {
                  material DEF MATERIAL Material {
                          diffuseColor 1 0 0
                          }
                  }
  }
  ] }
  
  

sensor + script


  DEF TIME TimeSensor { loop TRUE cycleInterval 5 } #<l++>
  
  DEF SCRIPT Script {   
          directOutput TRUE
          field SFNode place USE PLACE
          field SFFloat position 0
          eventIn SFFloat set_fraction    
          eventOut SFColor value_changed  
          url "javascript:
          function set_fraction(value) {  
                  if (value < 0.5) {
                          position += 0.1;
                          value_changed = '0 1 1';
                  } else {
                          position -= 0.1;
                           value_changed = '1 0 0';
                          }
                  place.translation.y = position;
                  }
                  "
          }#<l++>
  

routing


  ROUTE TIME.fraction_changed TO SCRIPT.set_fraction
  ROUTE SCRIPT.value_changed TO MATERIAL.diffuseColor
  
  
  
  Viewpoint { position 0 0 20 }
  Background { skyColor 1 0.2 0.2 }
  
  


(C) A. Eliëns 21/5/2007

You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.