home *** CD-ROM | disk | FTP | other *** search
/ Late Night VRML 2.0 with Java CD-ROM / code.zip / Ch11 / tests / soundTest.wrl < prev   
Text File  |  1997-03-30  |  917b  |  49 lines

  1. #VRML V2.0 utf8
  2.  
  3. Group {
  4.     children [
  5.     DEF xform Transform {
  6.         translation -1 0 0
  7.         children [
  8.         Sound {
  9.             source DEF soundclip AudioClip {
  10.             stopTime 0
  11.             startTime 1
  12.             url "didjOver13.wav"
  13.             loop TRUE
  14.             }
  15.             minFront 10
  16.             maxFront 1000
  17.             minBack 10
  18.             maxBack 1000
  19.         }
  20.         DEF mybox Shape {
  21.             geometry Box { size 0.5 0.5 0.5 }
  22.         }
  23.         DEF touch TouchSensor{}
  24.         DEF toggle Script {
  25.             eventIn SFTime touchTime
  26.             eventOut SFTime startTime
  27.             eventOut SFTime stopTime
  28.             field SFBool isPlaying TRUE
  29.             url "vrmlscript:
  30.             function touchTime(value, time) {
  31.                 if (isPlaying) {
  32.                 isPlaying = FALSE;
  33.                 stopTime = value;
  34.                 }
  35.                 else {
  36.                 isPlaying = TRUE;
  37.                 startTime = value;
  38.                 }
  39.             }
  40.             "
  41.         }
  42.         ]
  43.     }
  44.     ]
  45. }
  46. ROUTE touch.touchTime TO toggle.touchTime
  47. ROUTE toggle.startTime TO soundclip.startTime
  48. ROUTE toggle.stopTime TO soundclip.stopTime
  49.