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-interpolator-proto.vr

web3d-interpolator-proto.vr (wrl ) [ flux / bitmanagement / cortona / octaga ]

Web3D/VR

interpolator prototype

proto (Bulb)


  PROTO Bulb [
  exposedField SFVec3f translation 0 0 0
  exposedField SFVec3f scale 1 1 1
  ]{
  

body (part 1)


  Transform {
  translation IS translation
  scale IS scale
  children [
  Shape  {
          geometry Sphere { radius 2 }
          appearance Appearance {
                  material DEF MATERIAL Material { #<l++>
                          diffuseColor 1 0 0
                          }
                  }
          } #<l++>
  
  DEF TOUCH TouchSensor { }
  DEF TIME TimeSensor { enabled FALSE loop TRUE } #<l++>
  
  

body (part 2) -- script


  DEF SCRIPT Script {   
          eventIn SFFloat set_fraction    
          eventOut SFColor value_changed  
          eventIn  SFTime touched
          eventOut SFBool enabled
          field SFBool on FALSE
  

script (continued)


          url "javascript:
          function touched(time) {
          if (!on) {
                  on = 'TRUE';
                  enabled = 'TRUE';
          } else {
                  on = 'FALSE';
                  enabled = 'FALSE';
                  }
          }
  

script (continued)


          function set_fraction(value) {  
                  if (value < 0.5) value_changed = '1 0 0';
                  else value_changed = '0 1 1';
                  }
                  "
          }#<l++>
  

routing


  
  ROUTE TOUCH.touchTime TO SCRIPT.touched
  ROUTE SCRIPT.enabled TO TIME.enabled
  ROUTE TIME.fraction_changed TO SCRIPT.set_fraction
  ROUTE SCRIPT.value_changed TO MATERIAL.diffuseColor
  ] }
  }
  
  

instances


  Bulb { translation -8 0 0 scale 0.5 0.5 0.5 }
  Bulb { translation -5 0 0 }
  Bulb { scale 1.5 1.5 1.5 }
  Bulb { translation 5 0 0 }
  Bulb { translation 8 0 0 scale 0.5 0.5 0.5 }
  


(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.