proto product


  
  PROTO product [
  exposedField SFVec3f translation   0 0 0
  ]{
  
  
  DEF product Transform {
  translation IS translation
  children [
      DEF touch TouchSensor { }
      Transform { translation -3 0 0 
      children [
      Inline { url "@vr-web3d-box.wrl" }
      ] }
      DEF monitor monitor {  translation 3 3 0 }
      ]
  }
  
  
  
  
  DEF script Script {
  directOutput TRUE
  eventIn SFTime touch
  field SFNode text USE monitor
  field SFInt32 toggle 0
  field MFString string1 [ "message 1:" "this is a cube" ]
  field MFString string2 [ "message 2:" "it rotates" ]
  field MFString string3 [ "message 3:" "more" "information?" ]
  field SFInt32 damage 1
  field SFString temp "damage: "
  
  
  url "vrmlscript:
  function touch(value) {
  toggle += 1;
  if (toggle == 1) text.string = string1;
  else if (toggle == 2) text.set_string = string2;
  else if (toggle == 3) text.set_string = string3;
  else if (toggle == 4) {
  //temp += ' ';
  temp += damage.toString();
  //temp += ' ';
  text.set_string = new MFString(temp);
  }
  if (toggle == 4) toggle=0;
  }"
  
  } ## end script
  
  
  
  
  ROUTE touch.touchTime TO script.touch
  } ## end proto